-
Notifications
You must be signed in to change notification settings - Fork 0
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
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f35a6fc
feat: init app-layout components
altaywtf aa77dad
feat: create app-content component
altaywtf 6fb1330
feat: add footer
altaywtf 5b11b75
refactor: fine-tune app-layout
altaywtf 7381454
chore: add @TODO for company links
altaywtf 2e0f932
chore: remove var
altaywtf 31f4797
refactor: update github url
altaywtf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
@import '@radix-ui/themes/styles.css'; | ||
|
||
body { | ||
margin: 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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