Skip to content

Commit

Permalink
πŸ’„ design: Text μŠ€νƒ€μΌμ— λ””μžμΈ 토큰 별 정리 (#44)
Browse files Browse the repository at this point in the history
* πŸ’„ design: Text μŠ€νƒ€μΌμ— λ””μžμΈ 토큰별 정리

* πŸ’„ design: λ³€κ²½λœ Text μŠ€νƒ€μΌμ— 따라 μŠ€ν† λ¦¬λΆ μž¬μž‘μ„±

* πŸ’„ design: Button μŠ€νƒ€μΌμ— λ””μžμΈ 토큰 반영 (#46)

* πŸ“¦ chore: primary κ΄€λ ¨ 색상 μƒμˆ˜ 정리

* πŸ’„ design: Button μ»΄ν¬λ„ŒνŠΈμ— λ””μžμΈ 토큰 적용 및 size 속성 μΆ”κ°€

* πŸ’„ design: Button μŠ€ν† λ¦¬λΆμ— μƒˆλ‘œμš΄ variant 적용

* πŸ’„ design: Navbar μŠ€ν† λ¦¬λΆμ— λ²„νŠΌμ˜ μƒˆλ‘œμš΄ variant 적용

* πŸ’„ design: active νŠΈλžœμ§€μ…˜μ΄ disabled μ—μ„œλŠ” λ‚˜νƒ€λ‚˜μ§€ μ•Šλ„λ‘ μˆ˜μ •

* πŸ’„ design: Button μŠ€ν† λ¦¬λΆμ— size, disabled prop μΆ”κ°€

* πŸ“¦ chore: preview.yml λŒ€μƒ λΈŒλžœμΉ˜μ— feat/** μΆ”κ°€

* πŸ“ style: BottomSheet의 button에 semi-transparent 속성 적용
  • Loading branch information
bbearcookie authored Jan 30, 2024
1 parent 059b758 commit 7332886
Show file tree
Hide file tree
Showing 11 changed files with 349 additions and 143 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ env:

on:
pull_request:
branches: ['main']
branches: ['main', feat/**]

jobs:
build:
Expand Down
3 changes: 2 additions & 1 deletion .stylelintrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
}
],
"rules": {
"selector-max-type": null
"selector-max-type": null,
"no-descending-specificity": null
}
}
7 changes: 5 additions & 2 deletions src/components/BottomSheet/index.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,13 @@ export const λ°”ν…€μ‹œνŠΈ: StoryObj = {
<h2>λˆ„κ΅¬μ—κ²Œ λ³΄λ‚ΌκΉŒμš”?</h2>
</div>
<Navbar css={styles.navbar}>
<Button variant="primary-unaccent" onClick={toggleDrawer(false)}>
<Button
variant="semi-transparent-unaccent"
onClick={toggleDrawer(false)}
>
λ‹«κΈ°
</Button>
<Button variant="primary" onClick={toggleDrawer(false)}>
<Button variant="semi-transparent" onClick={toggleDrawer(false)}>
μ™„λ£Œ
</Button>
</Navbar>
Expand Down
90 changes: 87 additions & 3 deletions src/components/Button/index.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,104 @@
import type { Meta, StoryObj } from '@storybook/react';
import { css } from '@emotion/react';
import { PencilLine } from '@/assets/icons';
import Button from './';

const meta = {
title: 'Components/Button',
component: Button,
tags: ['autodocs'],
argTypes: {},
argTypes: {
disabled: {
control: 'boolean',
description: 'λ²„νŠΌμ˜ λΉ„ν™œμ„±ν™” μ—¬λΆ€μž…λ‹ˆλ‹€.',
},
},
} satisfies Meta<typeof Button>;

export default meta;

type Story = StoryObj<typeof meta>;

export const Primary: Story = {
export const Default: Story = {
args: {
variant: 'primary',
children: 'λ²„νŠΌμž…λ‹ˆλ‹€',
size: 'md',
children: 'button',
disabled: false,
},
};

const styles = {
container: css`
display: flex;
flex-direction: column;
gap: 1rem;
width: 21rem;
`,
semiTransparentContainer: css`
display: flex;
gap: 1rem;
padding: 1rem;
background-color: #fcecd0;
`,
};

export const Primary: Story = {
render: () => (
<div css={styles.container}>
<Button variant="primary">
<PencilLine />
<p>button</p>
</Button>
<Button disabled variant="primary">
<PencilLine />
<p>button</p>
</Button>
</div>
),
};

export const PrimaryOutline: Story = {
render: () => (
<div css={styles.container}>
<Button variant="primary-outline">
<PencilLine />
<p>button</p>
</Button>
<Button disabled variant="primary-outline">
<PencilLine />
<p>button</p>
</Button>
</div>
),
};

export const Secondary: Story = {
render: () => (
<div css={styles.container}>
<Button variant="secondary">
<PencilLine />
<p>button</p>
</Button>
<Button disabled variant="secondary">
<PencilLine />
<p>button</p>
</Button>
</div>
),
};

export const SemiTransparent: Story = {
render: () => (
<div css={styles.semiTransparentContainer}>
<Button variant="semi-transparent-unaccent">
<PencilLine />
<p>button</p>
</Button>
<Button variant="semi-transparent">
<PencilLine />
<p>button</p>
</Button>
</div>
),
};
8 changes: 5 additions & 3 deletions src/components/Button/index.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import React, { forwardRef } from 'react';
import styles, { type ButtonVariant } from './styles';
import styles, { type ButtonSize, type ButtonVariant } from './styles';

interface ButtonProps extends React.ComponentProps<'button'> {
/** λ²„νŠΌμ˜ λ°°κ²½ 색상과 폰트 색상을 μ§€μ •ν•©λ‹ˆλ‹€. */
variant?: ButtonVariant;
/** λ²„νŠΌμ— λ“€μ–΄κ°ˆ νŒ¨λ”©μ˜ 크기λ₯Ό μ§€μ •ν•©λ‹ˆλ‹€. */
size?: ButtonSize;
/** λ²„νŠΌμ˜ λ‚΄μš©μ„ μ§€μ •ν•©λ‹ˆλ‹€. */
children?: React.ReactNode;
}

const Button = forwardRef<HTMLButtonElement, ButtonProps>(
({ variant = 'primary', children, ...props }, ref) => {
({ variant = 'primary', size = 'md', children, ...props }, ref) => {
return (
<button css={styles.button(variant)} ref={ref} {...props}>
<button css={styles.button(variant, size)} ref={ref} {...props}>
{children}
</button>
);
Expand Down
89 changes: 78 additions & 11 deletions src/components/Button/styles.ts
Original file line number Diff line number Diff line change
@@ -1,46 +1,113 @@
import { css } from '@emotion/react';
import textStyles from '@/styles/textStyles';
import COLORS from '@/constants/colors';

export type ButtonVariant = 'primary' | 'primary-unaccent' | 'white';
export type ButtonVariant =
| 'primary'
| 'primary-outline'
| 'secondary'
| 'semi-transparent'
| 'semi-transparent-unaccent';

export type ButtonSize = 'md' | 'sm';

const styles = {
button: (variant: ButtonVariant) => css`
button: (variant: ButtonVariant, size: ButtonSize) => css`
display: flex;
flex: 1 0;
gap: 0.5rem;
justify-content: center;
align-items: center;
padding: 0.75rem 1.25rem;
border: none;
border-radius: 3.8rem;
font-weight: 500;
font-size: 0.875rem;
border-radius: 6.25rem;
cursor: pointer;
transition: all 0.2s ease;
&:not(:disabled):active {
box-shadow: 0 2px 10px rgb(0 0 0 / 0.2);
transform: scale(0.98);
}
&:disabled {
box-shadow: none;
cursor: not-allowed;
}
${textStyles.t3}
${sizeStyles[size]}
${variantStyles[variant]}
`,
};

const sizeStyles = {
sm: css`
padding: 0.75rem 1.25rem;
`,
md: css`
padding: 1rem 1.25rem;
`,
};

const variantStyles = {
primary: css`
background-color: ${COLORS.primary};
color: white;
box-shadow: 0 8px 16px 0 rgb(13 35 51 / 0.2);
&:hover {
background-color: ${COLORS.primaryHover};
}
&:disabled {
background-color: ${COLORS.primaryDisabled};
}
`,
'primary-outline': css`
background-color: white;
color: ${COLORS.primary};
box-shadow: 0 8px 16px 0 rgb(13 35 51 / 0.2);
outline: 1px solid ${COLORS.primary};
&:hover {
outline: 1px solid ${COLORS.primaryHover};
}
&:disabled {
background-color: ${COLORS.gray5};
color: ${COLORS.gray4};
}
`,
secondary: css`
background-color: white;
color: black;
box-shadow: 0 8px 16px 0 rgb(153 153 153 / 0.2);
&:hover {
background-color: ${COLORS.gray6};
}
&:disabled {
background-color: ${COLORS.gray5};
color: ${COLORS.gray4};
}
`,
'semi-transparent': css`
background: radial-gradient(
491.85% 132.88% at 0% 12.5%,
rgb(255 255 255 / 0.7) 0%,
rgb(255 255 255 / 0.28) 100%
);
color: black;
box-shadow: 0 8px 16px 0 rgb(153 153 153 / 0.2);
`,
'primary-unaccent': css`
'semi-transparent-unaccent': css`
background: radial-gradient(
491.85% 132.88% at 0% 12.5%,
rgb(255 255 255 / 0.7) 0%,
rgb(255 255 255 / 0.28) 100%
);
color: ${COLORS.gray3};
`,
white: css`
background-color: white;
color: black;
box-shadow: 0 8px 16px 0 rgb(153 153 153 / 0.2);
`,
};

Expand Down
Loading

0 comments on commit 7332886

Please sign in to comment.