-
Notifications
You must be signed in to change notification settings - Fork 7
로고, 버튼, 아이콘버튼 마이그레이션, ThemeProvider 스토리북에 적용 #54
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
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
6cfd8f4
chore: Modify logo svg - Issue #26
hhhyyo 8a25d17
feat: Apply styled-components to Logo - Issue #26
hhhyyo ac488f6
feat: Create Logo component - Issue #26
hhhyyo ae39270
feat: Apply Storybook to Logo - Issue #26
hhhyyo cf33b1c
Merge branch 'feature/migration-logo' into develop
hhhyyo 02f4c7a
Merge branch 'develop' of https://github.com/TeamCooks/TwoSpoon into …
hhhyyo 44415c9
feat: Add Button.types.ts - Issue #29
hhhyyo 024e011
feat: Apply styled-components to Button - Issue #29
hhhyyo e5cd366
feat: Create Button component - Issue #29
hhhyyo d76e54a
conf: ApplyThemeProvider to Storybook - Issue #52
hhhyyo 7b40975
feat: Apply Storybook to Button - Issue #29
hhhyyo 0b46fa9
Merge branch 'feature/migration-button' into develop
hhhyyo 9768edc
feat: Add IconButtonProps type - Issue #51
hhhyyo 5b4509f
refactor: Modify IconButtonProps type - Issue #51
hhhyyo 1c63d9b
feat: Apply styled-components to IconButton - Issue #51
hhhyyo 6fa9a49
feat: Create IconButton component - Issue #51
hhhyyo 1ec657f
feat: Apply Storybook to IconButton - Issue #51
hhhyyo f90d5d3
Merge branch 'feature/migration-iconButton' into develop
hhhyyo af26b6b
Merge branch 'develop' of https://github.com/TeamCooks/TwoSpoon into …
hhhyyo c3f3647
feat: Change styled-components to emotion - Issue #29
hhhyyo 8250b6b
feat: Change styled-components to emotion - Issue #51
hhhyyo 407d5b1
fix: Add aria-label - Issue #51
hhhyyo a1c15a3
chore: Fix typo - Issue #26
hhhyyo e10a2f0
feat: Change styled-components to emotion and Apply Next.js - Issue #26
hhhyyo ba5fd8e
feat: Apply emotion to ThemeProvider - Issue #52
hhhyyo 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 hidden or 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 hidden or 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,48 @@ | ||
| import { ComponentMeta, ComponentStory } from '@storybook/react'; | ||
| import { GiPerspectiveDiceSixFacesRandom } from 'react-icons/gi'; | ||
| import { Button } from './Button'; | ||
|
|
||
| export default { | ||
| title: 'Button', | ||
| component: Button, | ||
| } as ComponentMeta<typeof Button>; | ||
|
|
||
| const Template: ComponentStory<typeof Button> = (args) => <Button {...args} />; | ||
|
|
||
| export const Default = Template.bind({}); | ||
|
|
||
| export const Outline = Template.bind({}); | ||
|
|
||
| Outline.args = { | ||
| variant: 'outlined', | ||
| color: 'primaryGreen', | ||
| children: ( | ||
| <> | ||
| <GiPerspectiveDiceSixFacesRandom style={{ fontSize: '25px' }} /> | ||
| REROLL | ||
| </> | ||
| ), | ||
| style: { | ||
| display: 'flex', | ||
| alignItems: 'center', | ||
| gap: '10px', | ||
| }, | ||
| round: true, | ||
| }; | ||
|
|
||
| export const Fill = Template.bind({}); | ||
|
|
||
| Fill.args = { | ||
| type: 'submit', | ||
| variant: 'filled', | ||
| color: 'primaryGreen', | ||
| children: 'Sign In', | ||
| round: true, | ||
| }; | ||
|
|
||
| export const Transparent = Template.bind({}); | ||
|
|
||
| Transparent.args = { | ||
| variant: 'transparent', | ||
| children: 'Not registered yet? Sign up here!', | ||
| }; |
This file contains hidden or 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 styled from '@emotion/styled'; | ||
| import { StyledButtonProps } from './Button.types'; | ||
|
|
||
| export const StyledButton = styled.button<StyledButtonProps>` | ||
| padding: 10px; | ||
| border: none; | ||
| background: none; | ||
| border-radius: ${({ round }) => round && '30px'}; | ||
| `; | ||
|
|
||
| export const StyledOutlineButton = styled(StyledButton)` | ||
| border: 1px solid currentColor; | ||
| color: ${({ color, theme }) => theme.color[color]}; | ||
| `; | ||
|
|
||
| export const StyledFillButton = styled(StyledButton)` | ||
| background-color: ${({ color, theme }) => theme.color[color]}; | ||
| color: ${({ theme }) => theme.color.white}; | ||
| `; |
This file contains hidden or 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,33 @@ | ||
| import { ButtonProps, StyledButtonProps } from './Button.types'; | ||
| import { StyledButton, StyledOutlineButton, StyledFillButton } from './Button.styled'; | ||
|
|
||
| const renderButton = ({ type, round = false, color, style, variant, children, ...restProps }: ButtonProps) => { | ||
| const props: StyledButtonProps = { type, round, color, style }; | ||
|
|
||
| switch (variant) { | ||
| case 'transparent': | ||
| return ( | ||
| <StyledButton {...props} {...restProps}> | ||
| {children} | ||
| </StyledButton> | ||
| ); | ||
| case 'outlined': | ||
| return ( | ||
| <StyledOutlineButton {...props} {...restProps}> | ||
| {children} | ||
| </StyledOutlineButton> | ||
| ); | ||
| case 'filled': | ||
| return ( | ||
| <StyledFillButton {...props} {...restProps}> | ||
| {children} | ||
| </StyledFillButton> | ||
| ); | ||
| default: | ||
| return null; | ||
| } | ||
| }; | ||
|
|
||
| export const Button = (props: ButtonProps) => { | ||
| return renderButton(props); | ||
| }; |
This file contains hidden or 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,31 @@ | ||
| type Type = 'button' | 'submit'; | ||
| type Variant = 'transparent' | 'outlined' | 'filled'; | ||
| type Color = 'primaryGreen' | 'primaryOrange' | 'white' | 'black'; | ||
| type IconType = 'search' | 'user' | 'heart' | 'close' | 'cart' | 'link' | 'bookmark' | 'bookmarkFill' | 'up'; | ||
| type Size = 'small' | 'large'; | ||
|
|
||
| export interface StyledButtonProps { | ||
| type: Type; | ||
| round?: boolean; | ||
| color: Color; | ||
| style?: React.CSSProperties; | ||
| className?: string; | ||
| } | ||
|
|
||
| export interface ButtonProps extends StyledButtonProps { | ||
| variant: Variant; | ||
| children: React.ReactNode; | ||
| } | ||
|
|
||
| export interface StyledIconButtonProps { | ||
| type: Type; | ||
| ariaLabel: string; | ||
| circle: boolean; | ||
| color: Color; | ||
| size: Size; | ||
| } | ||
|
|
||
| export interface IconButtonProps extends StyledIconButtonProps { | ||
| iconType: IconType; | ||
| variant: Variant; | ||
| } |
This file contains hidden or 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,71 @@ | ||
| import { ComponentMeta, ComponentStory } from '@storybook/react'; | ||
| import { IconButton } from './IconButton'; | ||
|
|
||
| export default { | ||
| title: 'IconButton', | ||
| component: IconButton, | ||
| } as ComponentMeta<typeof IconButton>; | ||
|
|
||
| const Template: ComponentStory<typeof IconButton> = (args) => <IconButton {...args} />; | ||
|
|
||
| export const Default = Template.bind({}); | ||
|
|
||
| export const Search = Template.bind({}); | ||
|
|
||
| Search.args = { | ||
| type: 'submit', | ||
| ariaLabel: 'search', | ||
| iconType: 'search', | ||
| variant: 'transparent', | ||
| color: 'black', | ||
| size: 'small', | ||
| }; | ||
|
|
||
| export const Link = Template.bind({}); | ||
| Link.decorators = [ | ||
| (Story) => ( | ||
| <div style={{ backgroundColor: 'rgba(0,0,0,0.5)' }}> | ||
| <Story /> | ||
| </div> | ||
| ), | ||
| ]; | ||
|
|
||
| Link.args = { | ||
| type: 'button', | ||
| ariaLabel: 'copy link', | ||
| iconType: 'link', | ||
| variant: 'transparent', | ||
| color: 'white', | ||
| size: 'large', | ||
| }; | ||
|
|
||
| export const Fill = Template.bind({}); | ||
|
|
||
| Fill.args = { | ||
| type: 'button', | ||
| ariaLabel: 'cart', | ||
| iconType: 'cart', | ||
| variant: 'filled', | ||
| color: 'primaryGreen', | ||
| size: 'large', | ||
| circle: true, | ||
| }; | ||
|
|
||
| export const Outline = Template.bind({}); | ||
| Outline.decorators = [ | ||
| (Story) => ( | ||
| <div style={{ backgroundColor: 'rgba(0,0,0,0.5)' }}> | ||
| <Story /> | ||
| </div> | ||
| ), | ||
| ]; | ||
|
|
||
| Outline.args = { | ||
| type: 'button', | ||
| ariaLabel: 'heart', | ||
| iconType: 'heart', | ||
| variant: 'outlined', | ||
| color: 'white', | ||
| size: 'large', | ||
| circle: true, | ||
| }; |
This file contains hidden or 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,42 @@ | ||
| import styled from '@emotion/styled'; | ||
| import { css } from '@emotion/react'; | ||
| import { StyledIconButtonProps } from './Button.types'; | ||
|
|
||
| const sizes = { | ||
| small: { | ||
| width: '24px', | ||
| height: '24px', | ||
| fontSize: '16px', | ||
| }, | ||
| large: { | ||
| width: '50px', | ||
| height: '50px', | ||
| fontSize: '32px', | ||
| }, | ||
| }; | ||
|
|
||
| export const StyledButton = styled.button<StyledIconButtonProps>` | ||
| display: flex; | ||
| justify-content: center; | ||
| align-items: center; | ||
| padding: 0; | ||
| border: none; | ||
| background: none; | ||
| border-radius: ${({ circle }) => circle && '50%'}; | ||
| color: ${({ color, theme }) => theme.color[color]}; | ||
|
|
||
| ${({ size }) => css` | ||
| width: ${sizes[size].width}; | ||
| height: ${sizes[size].height}; | ||
| font-size: ${sizes[size].fontSize}; | ||
| `} | ||
| `; | ||
|
|
||
| export const StyledOutlineButton = styled(StyledButton)` | ||
| border: 1px solid currentColor; | ||
| `; | ||
|
|
||
| export const StyledFillButton = styled(StyledButton)` | ||
| background-color: ${({ color, theme }) => theme.color[color]}; | ||
| color: ${({ theme }) => theme.color.white}; | ||
| `; |
This file contains hidden or 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,72 @@ | ||
| import { FiSearch } from 'react-icons/fi'; | ||
| import { FaArrowUp } from 'react-icons/fa'; | ||
| import { BsPersonCircle, BsCartCheckFill, BsLink45Deg, BsBookmark, BsFillBookmarkFill } from 'react-icons/bs'; | ||
| import { HiHeart } from 'react-icons/hi'; | ||
| import { MdClose } from 'react-icons/md'; | ||
| import { StyledButton, StyledOutlineButton, StyledFillButton } from './IconButton.styled'; | ||
| import { IconButtonProps, StyledIconButtonProps } from './Button.types'; | ||
|
|
||
| const renderIcon = (iconType: IconButtonProps['iconType']) => { | ||
| switch (iconType) { | ||
| case 'search': | ||
| return <FiSearch />; | ||
| case 'user': | ||
| return <BsPersonCircle />; | ||
| case 'heart': | ||
| return <HiHeart />; | ||
| case 'close': | ||
| return <MdClose />; | ||
| case 'cart': | ||
| return <BsCartCheckFill />; | ||
| case 'link': | ||
| return <BsLink45Deg />; | ||
| case 'bookmarkFill': | ||
| return <BsFillBookmarkFill />; | ||
| case 'bookmark': | ||
| return <BsBookmark />; | ||
| case 'up': | ||
| return <FaArrowUp />; | ||
| default: | ||
| return null; | ||
| } | ||
| }; | ||
|
|
||
| const renderButton = ({ | ||
| type, | ||
| ariaLabel, | ||
| iconType, | ||
| circle = false, | ||
| variant, | ||
| color, | ||
| size, | ||
| ...restProps | ||
| }: IconButtonProps) => { | ||
| const props: StyledIconButtonProps = { type, ariaLabel, circle, color, size }; | ||
|
|
||
| switch (variant) { | ||
| case 'transparent': | ||
| return ( | ||
| <StyledButton aria-label={ariaLabel} {...props} {...restProps}> | ||
| {renderIcon(iconType)} | ||
| </StyledButton> | ||
| ); | ||
| case 'outlined': | ||
| return ( | ||
| <StyledOutlineButton aria-label={ariaLabel} {...props} {...restProps}> | ||
| {renderIcon(iconType)} | ||
| </StyledOutlineButton> | ||
| ); | ||
| case 'filled': | ||
| return ( | ||
| <StyledFillButton aria-label={ariaLabel} {...props} {...restProps}> | ||
| {renderIcon(iconType)} | ||
| </StyledFillButton> | ||
| ); | ||
| default: | ||
| return null; | ||
| } | ||
| }; | ||
|
|
||
| export const IconButton = (props: IconButtonProps) => { | ||
| return renderButton(props); | ||
| }; |
This file contains hidden or 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,11 @@ | ||
| import { ComponentMeta, ComponentStory } from '@storybook/react'; | ||
| import { Logo } from './Logo'; | ||
|
|
||
| export default { | ||
| title: 'Logo', | ||
| component: Logo, | ||
| } as ComponentMeta<typeof Logo>; | ||
|
|
||
| const Template: ComponentStory<typeof Logo> = () => <Logo />; | ||
|
|
||
| export const Default = Template.bind({}); |
This file contains hidden or 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,23 @@ | ||
| import styled from '@emotion/styled'; | ||
| import { pxToRem, media } from 'utils'; | ||
| import { LogoIcon } from './LogoIcon'; | ||
|
|
||
| export const StyledA = styled.a` | ||
| display: flex; | ||
| font-size: ${pxToRem(24)}; | ||
| align-items: center; | ||
| `; | ||
|
|
||
| export const StyledIcon = styled(LogoIcon)` | ||
| margin: 10px; | ||
| `; | ||
|
|
||
| export const StyledSpan = styled.span` | ||
| width: 130px; | ||
| transition: 400ms width ease; | ||
|
|
||
| ${media.mobile} { | ||
| width: 0; | ||
| overflow: hidden; | ||
| } | ||
| `; | ||
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.
오오 utils에서 import 하는 media 이건 어디에서 배운 신기한 것인가요?
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.
구글링하다가 이렇게 분리하면 좋을 것 같아서 적용해보았습니다~