-
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: AppBar 컴포넌트 #32
Merged
Changes from all commits
Commits
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { RecipeVariants, recipe } from '@vanilla-extract/recipes'; | ||
|
||
export const appBarElement = recipe({ | ||
base: { | ||
position: 'absolute', | ||
width: 44, | ||
height: '100%', | ||
display: 'flex', | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
}, | ||
variants: { | ||
direction: { | ||
left: { | ||
top: 0, | ||
left: 3, | ||
}, | ||
right: { | ||
top: 0, | ||
right: 10, | ||
}, | ||
}, | ||
}, | ||
}); | ||
|
||
export type AppBarElementVariant = Exclude< | ||
RecipeVariants<typeof appBarElement>, | ||
undefined | ||
>; |
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,19 @@ | ||
import { ComponentProps } from 'react'; | ||
import { cx } from '../util.ts'; | ||
import * as styles from './app-bar-element.styles.css.ts'; | ||
|
||
export type AppBarElementProps = ComponentProps<'div'> & | ||
styles.AppBarElementVariant; | ||
|
||
export const AppBarElement = (props: AppBarElementProps) => { | ||
const { children, className, direction, ...restProps } = props; | ||
|
||
return ( | ||
<div | ||
{...restProps} | ||
className={cx(styles.appBarElement({ direction }), className)} | ||
> | ||
{children} | ||
</div> | ||
); | ||
}; |
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,55 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import { ArrowLeft, Cart, Logo } from '../../assets/index.ts'; | ||
import { AppBar } from './app-bar.tsx'; | ||
|
||
const meta: Meta<typeof AppBar> = { | ||
title: 'ui/AppBar', | ||
component: AppBar, | ||
argTypes: { | ||
variant: { | ||
options: ['default', 'page'], | ||
control: 'radio', | ||
}, | ||
}, | ||
parameters: { | ||
layout: 'fullScreen', | ||
}, | ||
tags: ['autodocs'], | ||
} satisfies Meta<typeof AppBar>; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default: Story = { | ||
render: (args) => ( | ||
<AppBar {...args}> | ||
<Logo /> | ||
</AppBar> | ||
), | ||
}; | ||
|
||
export const DefaultWithRight: Story = { | ||
render: (args) => ( | ||
<AppBar {...args} right={<Cart />}> | ||
<Logo /> | ||
</AppBar> | ||
), | ||
}; | ||
|
||
export const Page: Story = { | ||
args: { | ||
variant: 'page', | ||
}, | ||
render: (args) => <AppBar {...args}>title</AppBar>, | ||
}; | ||
|
||
export const PageWithElement: Story = { | ||
args: { | ||
variant: 'page', | ||
}, | ||
render: (args) => ( | ||
<AppBar {...args} left={<ArrowLeft />} right={<Cart />}> | ||
title | ||
</AppBar> | ||
), | ||
}; |
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,34 @@ | ||
import { RecipeVariants, recipe } from '@vanilla-extract/recipes'; | ||
import { typography } from '../typography.css.ts'; | ||
|
||
export const appBar = recipe({ | ||
base: { | ||
position: 'relative', | ||
height: 44, | ||
display: 'flex', | ||
alignItems: 'center', | ||
maxWidth: 440, | ||
}, | ||
variants: { | ||
variant: { | ||
default: [ | ||
typography('title_1_22_b'), | ||
{ | ||
padding: '0 10px 0 20px', | ||
}, | ||
], | ||
page: [ | ||
typography('head_1_18_sb'), | ||
{ | ||
justifyContent: 'center', | ||
padding: '0 10px 0 3px', | ||
}, | ||
], | ||
}, | ||
}, | ||
defaultVariants: { | ||
variant: 'default', | ||
}, | ||
}); | ||
|
||
export type AppBarVariants = RecipeVariants<typeof appBar>; |
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,21 @@ | ||
import { ComponentProps, PropsWithChildren, ReactNode } from 'react'; | ||
import { cx } from '../util.ts'; | ||
import { AppBarElement } from './app-bar-element.tsx'; | ||
import * as styles from './app-bar.styles.css.ts'; | ||
|
||
export type AppBarProps = ComponentProps<'div'> & { | ||
left?: ReactNode; | ||
right?: ReactNode; | ||
} & styles.AppBarVariants; | ||
|
||
export const AppBar = (props: PropsWithChildren<AppBarProps>) => { | ||
const { left, right, children, variant, className, ...restProps } = props; | ||
|
||
return ( | ||
<div {...restProps} className={cx(styles.appBar({ variant }), className)}> | ||
{left && <AppBarElement direction="left">{left}</AppBarElement>} | ||
{children} | ||
{right && <AppBarElement direction="right">{right}</AppBarElement>} | ||
</div> | ||
Comment on lines
+15
to
+19
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. left center right 별로 다 달라서 외부에서 주입하는 거 잘하신거 같아요. AppBarElement를 통해 재사용성을 높인 부분도 좋네요👍 |
||
); | ||
}; |
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,2 @@ | ||
export { AppBar, type AppBarProps } from './app-bar.tsx'; | ||
export { AppBarElement, type AppBarElementProps } from './app-bar-element.tsx'; |
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.
리뷰 보고 css 코드 보니까 px을 안붙여도 가능하네요. 동환님 방식이 더 편한거 같습니다.
padding: '0 10px 0 20px',
padding 부분은 px을 붙여야지 작동하나요?