Skip to content
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
1 change: 1 addition & 0 deletions src/shared/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
3 changes: 3 additions & 0 deletions src/shared/lib/colors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const colors = {
purple: '#a855f7',
white: '#ffffff',
black: '#000000',
pink: '#FF507D',
};

export const COLORS = {
Expand All @@ -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[];
39 changes: 39 additions & 0 deletions src/shared/ui/ProgressBar/ProgressBar.stories.tsx
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} />,
};
32 changes: 32 additions & 0 deletions src/shared/ui/ProgressBar/ProgressBar.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<div className={cn('h-2.5 w-[16.5rem] overflow-hidden rounded-full bg-gray-100', className)}>
<div
className="h-full rounded-full transition-[width] duration-500 ease-in-out"
style={{
width: `${clampedPercent}%`,
backgroundColor: barColor,
}}
/>
</div>
);
}
1 change: 1 addition & 0 deletions src/shared/ui/ProgressBar/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { ProgressBar } from './ProgressBar';
Loading