-
Notifications
You must be signed in to change notification settings - Fork 0
[FEAT] 프로그레스 바 구현 #130
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] 프로그레스 바 구현 #130
Changes from 4 commits
c55ad94
03f92ff
feefdd3
a5c8483
5694a7a
93d455a
7b3412b
83b1fc9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,6 +32,7 @@ export const colors = { | |
| purple: '#a855f7', | ||
| white: '#ffffff', | ||
| black: '#000000', | ||
| pink: '#FF507D', | ||
| }; | ||
|
|
||
| export const COLORS = { | ||
|
|
@@ -41,9 +42,11 @@ export const COLORS = { | |
| green: colors['green'][300], | ||
| black: colors['black'], | ||
| white: colors['white'], | ||
| pink: colors['pink'], | ||
| }; | ||
|
|
||
| export type Colors = keyof typeof colors; | ||
| export type IconColor = keyof typeof COLORS; | ||
| export type SwitchColor = keyof typeof COLORS; | ||
| export type ProgressBarColor = keyof typeof colors; | ||
|
||
| export const colorNames = Object.keys(colors) as Colors[]; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import type { Meta, StoryObj } from '@storybook/react'; | ||
|
|
||
| import { COLORS } from '@/shared/lib/colors'; | ||
|
|
||
| import { ProgressBar } from './ProgressBar'; | ||
|
|
||
| const meta = { | ||
| title: 'Components/ProgressBar', | ||
| component: ProgressBar, | ||
| tags: ['autodocs'], | ||
| parameters: { | ||
| docs: { | ||
| description: { | ||
| component: 'ProgressBar 컴포넌트는 진행 상황을 시각적으로 표시하는 컴포넌트입니다.', | ||
| }, | ||
| }, | ||
| }, | ||
| } satisfies Meta<typeof ProgressBar>; | ||
|
|
||
| export default meta; | ||
|
|
||
| export const Basic: StoryObj<typeof ProgressBar> = { | ||
| args: { | ||
| percent: 60, | ||
| color: 'pink', | ||
| }, | ||
| argTypes: { | ||
| percent: { control: { type: 'range', min: 0, max: 100, step: 1 } }, | ||
| color: { | ||
| control: { type: 'select' }, | ||
| table: { | ||
| type: { summary: 'Colors' }, | ||
| defaultValue: { summary: 'primary' }, | ||
| }, | ||
| options: Object.keys(COLORS), | ||
| }, | ||
| }, | ||
| render: (args) => <ProgressBar {...args} />, | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import { COLORS, colors } from '@/shared/lib/colors'; | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| import { cn } from '@/shared/lib/core'; | ||
| import { Flex } from '@/shared/ui/Flex'; | ||
|
|
||
| type Props = { | ||
| /** | ||
| * defined in percentage (0-100). | ||
| */ | ||
| percent: number; | ||
| /** | ||
| * color of the switch. | ||
| * @default 'primary' | ||
| */ | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| color?: keyof typeof COLORS; | ||
| className?: string; | ||
| }; | ||
|
|
||
| export function ProgressBar({ color = 'primary', percent, className }: Props) { | ||
| const clampedPercent = Math.min(100, Math.max(0, percent)); | ||
| const barColor = COLORS[color]; | ||
|
|
||
| return ( | ||
| <Flex> | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| <div | ||
| className={cn('h-[0.625rem] w-[16.5rem] overflow-hidden rounded-full', className)} | ||
| style={{ | ||
| backgroundColor: colors.gray[100], | ||
| }} | ||
| > | ||
| <div | ||
| className="h-full rounded-full transition-[width] duration-600 ease-in-out" | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| style={{ | ||
| width: `${clampedPercent}%`, | ||
| backgroundColor: barColor, | ||
| }} | ||
|
||
| /> | ||
| </div> | ||
| </Flex> | ||
| ); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export { ProgressBar } from './ProgressBar'; |
Uh oh!
There was an error while loading. Please reload this page.