Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: init app-layout components #9

Merged
merged 7 commits into from
Dec 10, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const config: StorybookConfig = {
name: '@storybook/nextjs',
options: {},
},
staticDirs: ['../public'],
Copy link
Contributor Author

@altaywtf altaywtf Dec 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

required for storybook to load assets from the public folder

};

export default config;
5 changes: 4 additions & 1 deletion app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Metadata } from 'next';
import type { PropsWithChildren } from 'react';

import { AppLayout } from '@/components/layout/app-layout';
import { ThemeProvider } from '@/components/theme-provider';
import '@/components/theme-provider/styles.css';

Expand All @@ -13,7 +14,9 @@ export default function RootLayout({ children }: PropsWithChildren) {
return (
<html lang="en" suppressHydrationWarning>
<body>
<ThemeProvider>{children}</ThemeProvider>
<ThemeProvider>
<AppLayout>{children}</AppLayout>
</ThemeProvider>
</body>
</html>
);
Expand Down
17 changes: 17 additions & 0 deletions components/layout/app-content.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import type { PropsWithChildren } from 'react';

import { Container } from '@radix-ui/themes';

export function AppContent(props: PropsWithChildren) {
return (
<Container
px={{
initial: '6',
lg: '0',
}}
size="4"
>
{props.children}
</Container>
);
}
13 changes: 13 additions & 0 deletions components/layout/app-footer.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { Meta, StoryObj } from '@storybook/react';

import { AppFooter } from './app-footer';

export const Default: StoryObj<typeof AppFooter> = {
render: () => <AppFooter />,
};

const meta: Meta<typeof AppFooter> = {
component: AppFooter,
};

export default meta;
81 changes: 81 additions & 0 deletions components/layout/app-footer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import { GitHubLogoIcon, TwitterLogoIcon } from '@radix-ui/react-icons';
import { Flex, Link, Text } from '@radix-ui/themes';
import React from 'react';

import { AppContent } from './app-content';

const FOOTER_COMPANY_LINKS = [
{
href: 'https://experiment.st',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

label: 'Privacy policy',
},
{
href: 'https://experiment.st',
label: 'Terms of service',
},
] as const;

const FOOTER_SOCIAL_LINKS = [
{
href: 'https://github.com/okanisildar/beecast',
altaywtf marked this conversation as resolved.
Show resolved Hide resolved
icon: <GitHubLogoIcon />,
title: 'GitHub',
},
{
href: 'https://twitter.com/beecast_ai',
icon: <TwitterLogoIcon />,
title: 'Twitter',
},
] as const;

export function AppFooter() {
return (
<AppContent>
<Flex justify="between" py="4">
<Flex align="start" direction="column">
<Text size="2" weight="bold">
Built with ☕️ by your folks at the{' '}
<Link color="gray" href="https://experiment.st" target="_blank">
altaywtf marked this conversation as resolved.
Show resolved Hide resolved
Experiment Station
</Link>
</Text>

<Flex align="center" gap="1">
{FOOTER_COMPANY_LINKS.map((link) => (
<React.Fragment key={link.href}>
<Link color="gray" href={link.href} size="2" target="_blank">
{link.label}
</Link>

{link !==
FOOTER_COMPANY_LINKS[FOOTER_COMPANY_LINKS.length - 1] ? (
<Text size="2">·</Text>
) : null}
</React.Fragment>
))}
</Flex>
</Flex>

<Flex align="end" direction="column">
<Flex align="center" gap="2">
{FOOTER_SOCIAL_LINKS.map((link) => (
<Link
color="gray"
href={link.href}
key={link.href}
target="_blank"
title={link.title}
>
{link.icon}
</Link>
))}
</Flex>

<Text color="gray" size="2">
©2023 Experiment Station
</Text>
</Flex>
</Flex>
</AppContent>
);
}
26 changes: 26 additions & 0 deletions components/layout/app-header.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import type { Meta, StoryObj } from '@storybook/react';

import { AppHeader } from './app-header';

export const Guest: StoryObj<typeof AppHeader> = {
render: () => <AppHeader variant="guest" />,
};

export const Authenticated: StoryObj<typeof AppHeader> = {
render: () => (
<AppHeader
user={{
avatarURL: '/beecast.png',
credits: 10,
username: 'Mr. Bee',
}}
variant="authenticated"
/>
),
};

const meta: Meta<typeof AppHeader> = {
component: AppHeader,
};

export default meta;
117 changes: 117 additions & 0 deletions components/layout/app-header.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
import { ArrowRightIcon, PersonIcon } from '@radix-ui/react-icons';
import {
Avatar,
Button,
DropdownMenu,
Flex,
Heading,
Text,
} from '@radix-ui/themes';
import Image from 'next/image';
import Link from 'next/link';

import { AppContent } from './app-content';

type Props =
| {
user: {
avatarURL?: string;
credits: number;
username: string;
};
variant: 'authenticated';
}
| {
variant: 'guest';
};

function AppHeaderActionsAuthenticated(
props: Pick<Exclude<Props, { variant: 'guest' }>, 'user'>,
) {
return (
<Flex align="center" gap="2">
<Flex align="end" direction="column">
<Text size="2" weight="medium">
{props.user.username}
</Text>

<Text color="gray" size="2">
{props.user.credits === 0 ? 'No' : props.user.credits} credits
remaining
</Text>
</Flex>

<DropdownMenu.Root>
<DropdownMenu.Trigger>
<Avatar
fallback={<PersonIcon />}
radius="full"
src={props.user.avatarURL}
/>
</DropdownMenu.Trigger>

<DropdownMenu.Content>
<DropdownMenu.Item>Buy credits</DropdownMenu.Item>
<DropdownMenu.Item>Settings</DropdownMenu.Item>
<DropdownMenu.Separator />
<DropdownMenu.Item color="red">Sign out</DropdownMenu.Item>
</DropdownMenu.Content>
</DropdownMenu.Root>
</Flex>
);
}

function AppHeaderActionsGuest() {
return (
<Flex gap="2">
<Button asChild variant="soft">
<Link href="/sign-in">Sign in</Link>
</Button>

<Button asChild>
<Link href="/sign-up">
Get started
<ArrowRightIcon />
</Link>
</Button>
</Flex>
);
}

export function AppHeader(props: Props) {
return (
<Flex direction="column" gap="4" py="4">
<AppContent>
<Flex align="center" justify="between">
<Flex align="center" asChild gap="2">
<Link
href="/"
style={{
color: 'inherit',
textDecoration: 'none',
}}
>
<Image
alt="beecast.ai logo"
height="48"
src="/beecast.png"
style={{ display: 'block' }}
width="48"
/>

<Heading size="5" weight="medium">
Beecast
</Heading>
</Link>
</Flex>

{props.variant === 'authenticated' ? (
<AppHeaderActionsAuthenticated {...props} />
) : (
<AppHeaderActionsGuest />
)}
</Flex>
</AppContent>
</Flex>
);
}
32 changes: 32 additions & 0 deletions components/layout/app-layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import type { PropsWithChildren } from 'react';

import { Box, Flex } from '@radix-ui/themes';

import { AppContent } from './app-content';
import { AppFooter } from './app-footer';
import { AppHeader } from './app-header';

export function AppLayout({ children }: PropsWithChildren) {
return (
<Flex
direction="column"
style={{
minHeight: '100vh',
}}
>
<header className="sticky">
<AppHeader variant="guest" />
</header>

<main>
<AppContent>
<Box my="6">{children}</Box>
</AppContent>
</main>

<footer style={{ marginTop: 'auto' }}>
<AppFooter />
</footer>
</Flex>
);
}
5 changes: 2 additions & 3 deletions components/theme-provider/radix-themes.provider.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import type { PropsWithChildren } from 'react';

import { Theme, ThemePanel } from '@radix-ui/themes';
import { Theme } from '@radix-ui/themes';

export function RadixThemesProvider({ children }: PropsWithChildren) {
return (
<Theme>
<Theme accentColor="amber" appearance="dark" grayColor="sand">
{children}
<ThemePanel />
</Theme>
);
}
4 changes: 4 additions & 0 deletions components/theme-provider/styles.css
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
@import '@radix-ui/themes/styles.css';

body {
margin: 0;
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
},
"prettier": "@vercel/style-guide/prettier",
"dependencies": {
"@radix-ui/react-icons": "^1.3.0",
"@radix-ui/themes": "^2.0.2",
"next": "14.0.4",
"next-themes": "1.0.0-beta.0",
Expand Down
11 changes: 11 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added public/beecast.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion public/next.svg

This file was deleted.

1 change: 0 additions & 1 deletion public/vercel.svg

This file was deleted.