-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from bankids/feature/storybook
feat: button component
- Loading branch information
Showing
18 changed files
with
12,444 additions
and
13,018 deletions.
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,34 @@ | ||
import { ComponentStory, ComponentMeta } from '@storybook/react'; | ||
import Button from './Button'; | ||
|
||
// More on default export: https://storybook.js.org/docs/react/writing-stories/introduction#default-export | ||
export default { | ||
title: 'Common/Button', | ||
component: Button, | ||
// More on argTypes: https://storybook.js.org/docs/react/api/argtypes | ||
argTypes: {}, | ||
} as ComponentMeta<typeof Button>; | ||
|
||
// More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args | ||
const Template: ComponentStory<typeof Button> = (args) => <Button {...args} />; | ||
|
||
export const 다음 = Template.bind({}); | ||
다음.args = { | ||
property: 'primary', | ||
label: '다음', | ||
state: true, | ||
}; | ||
|
||
export const 다음_disabled = Template.bind({}); | ||
다음_disabled.args = { | ||
property: 'primary', | ||
label: '다음', | ||
state: false, | ||
}; | ||
|
||
export const 카카오톡으로_시작하기 = Template.bind({}); | ||
카카오톡으로_시작하기.args = { | ||
label: '카카오톡으로 시작하기', | ||
property: 'etc', | ||
state: true, | ||
}; |
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,62 @@ | ||
import styled, { css } from 'styled-components'; | ||
|
||
interface ButtonProps { | ||
/** | ||
* etc : 카카오로그인 / primary-secondary : 한칸 두칸 | ||
*/ | ||
property: 'etc' | 'primary' | 'secondary'; | ||
/** | ||
* 버튼 내용 | ||
*/ | ||
label: string; | ||
/** | ||
* 버튼 활성화 상태 | ||
*/ | ||
state?: boolean; | ||
/** | ||
* Optional click handler | ||
*/ | ||
onClick?: () => void; | ||
} | ||
|
||
function Button({ property, label, state, onClick }: ButtonProps) { | ||
return ( | ||
<Wrapper | ||
property={property} | ||
state={true} | ||
onClick={onClick} | ||
disabled={!state} | ||
> | ||
{label} | ||
</Wrapper> | ||
); | ||
} | ||
|
||
export default Button; | ||
|
||
const Wrapper = styled.button<{ | ||
property: 'etc' | 'primary' | 'secondary'; | ||
state: boolean; | ||
}>` | ||
width: 100%; | ||
height: 50px; | ||
border-radius: 8px; | ||
border: none; | ||
font-size: 16px; | ||
font-weight: bold; | ||
${({ property }) => | ||
property == 'etc' | ||
? css` | ||
color: ${({ theme }) => theme.palette.black}; | ||
background-color: ${({ theme }) => theme.palette.yellow[3]}; | ||
` | ||
: css` | ||
color: ${({ theme }) => theme.palette.white}; | ||
background-color: ${({ theme }) => theme.palette.yellow[0]}; | ||
`}; | ||
:disabled { | ||
background-color: ${({ theme }) => theme.palette.gray[2]}; | ||
color: ${({ theme }) => theme.palette.gray[5]}; | ||
} | ||
`; |
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,12 @@ | ||
import { ReactNode } from 'react'; | ||
import styled from 'styled-components'; | ||
|
||
function Margin({ children }: { children: ReactNode }) { | ||
return <Wrapper>{children}</Wrapper>; | ||
} | ||
|
||
export default Margin; | ||
|
||
const Wrapper = styled.div` | ||
margin: 20px 0px; | ||
`; |
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
src/components/stories/Button.stories.tsx → src/components/stories/Example.stories.tsx
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
2 changes: 1 addition & 1 deletion
2
src/components/stories/Button.tsx → src/components/stories/Example.tsx
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.