diff --git a/src/shared/index.ts b/src/shared/index.ts index ea5eac2d..27148b1e 100644 --- a/src/shared/index.ts +++ b/src/shared/index.ts @@ -18,6 +18,7 @@ export { MediaUpload } from './ui/MediaUpload'; export { NavBack } from './ui/NavBack'; export { Pagination } from './ui/Pagination'; export { Portal } from './ui/Portal'; +export { ProgressBar } from './ui/ProgressBar'; export { Select, GroupingSelect } from './ui/Select'; export { Skeleton } from './ui/Skeleton'; export { Radio, RadioItem } from './ui/Radio'; diff --git a/src/shared/lib/colors.ts b/src/shared/lib/colors.ts index 7df79a79..412bc200 100644 --- a/src/shared/lib/colors.ts +++ b/src/shared/lib/colors.ts @@ -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[]; diff --git a/src/shared/ui/ProgressBar/ProgressBar.stories.tsx b/src/shared/ui/ProgressBar/ProgressBar.stories.tsx new file mode 100644 index 00000000..15b7110f --- /dev/null +++ b/src/shared/ui/ProgressBar/ProgressBar.stories.tsx @@ -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; + +export default meta; + +export const Basic: StoryObj = { + 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) => , +}; diff --git a/src/shared/ui/ProgressBar/ProgressBar.tsx b/src/shared/ui/ProgressBar/ProgressBar.tsx new file mode 100644 index 00000000..e6af41f3 --- /dev/null +++ b/src/shared/ui/ProgressBar/ProgressBar.tsx @@ -0,0 +1,32 @@ +import { COLORS } from '@/shared/lib/colors'; +import { cn } from '@/shared/lib/core'; + +type Props = { + /** + * defined in percentage (0-100). + */ + percent: number; + /** + * color of the progressbar. + * @default 'primary' + */ + 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 ( +
+
+
+ ); +} diff --git a/src/shared/ui/ProgressBar/index.ts b/src/shared/ui/ProgressBar/index.ts new file mode 100644 index 00000000..d702dcfb --- /dev/null +++ b/src/shared/ui/ProgressBar/index.ts @@ -0,0 +1 @@ +export { ProgressBar } from './ProgressBar';