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/button #34

Merged
merged 3 commits into from
Jan 18, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
28 changes: 25 additions & 3 deletions ui-kit/src/components/Button/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
import React, { HTMLAttributes } from 'react';
import React, { Ref, forwardRef } from 'react';
import classnames from 'classnames';
import { CombineElementProps } from 'src/types/utils';
import { Text } from '..';

export default function Button(props: HTMLAttributes<HTMLButtonElement>): JSX.Element {
return <button className="button" {...props} />;
interface ButtonBaseProps {
size?: 'small' | 'medium' | 'large';
}
type ButtonProps = CombineElementProps<'button', ButtonBaseProps>;

const Button = (
{ size = 'small', disabled, style, ...props }: ButtonProps,
ref: Ref<HTMLButtonElement>
) => {
return (
<button
className={classnames('lubycon-button', `lubycon-button__${size}`)}
disabled={disabled}
style={style}
ref={ref}
>
<Text typography={size === 'large' ? 'p1' : 'p2'} fontWeight="bold" {...props}></Text>
</button>
);
};

export default forwardRef(Button) as typeof Button;
34 changes: 32 additions & 2 deletions ui-kit/src/sass/components/_Button.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
.button {
outline: 0;
.lubycon-button {
font: inherit;
text-align: inherit;
outline: none;
border: 0;
margin: 0;
background-color: get-color('blue50');
border-radius: 4px;
color: #ffffff;
cursor: pointer;

&__small {
height: 32px;
padding: 4px 16px;
}
&__medium {
height: 40px;
padding: 8px 16px;
}
&__large {
height: 56px;
padding: 12px 32px;
}

&:hover, &:active {
background-color: get-color('blue60');
}
&:disabled {
color: get-color('gray60');
background-color: get-color('gray40');
cursor: not-allowed;
}
}
41 changes: 39 additions & 2 deletions ui-kit/src/stories/Button.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,47 @@
import React from 'react';
import Button from 'components/Button';
import Text from 'components/Text';
import { Meta } from '@storybook/react/types-6-0';

export default {
title: 'Lubycon UI Kit/Button',
component: Button,
} as Meta;

export const Default = () => <Button>기본 버튼</Button>;
const sizeList = ['small', 'medium', 'large'] as const;
const btnText = '버튼 텍스트';

export const Default = () => {
return (
<div>
<Text as="div" typography="h5" style={{ marginBottom: '40px' }}>
Rounded Button
</Text>
<ul style={{ listStyle: 'none' }}>
{sizeList.map((size, index) => (
<li
key={index}
style={{
display: 'grid',
gridTemplateColumns: '100px 150px 150px',
gridGap: '50px',
marginBottom: '30px',
alignItems: 'center',
}}
>
<Text style={{ width: '100px' }}>{size.charAt(0).toUpperCase() + size.slice(1)}</Text>
<div>
<Button size={size} key={index}>
{btnText}
</Button>
</div>
<div>
<Button size={size} key={index + 'disabled'} disabled>
{btnText}
</Button>
</div>
</li>
))}
</ul>
</div>
);
};