Skip to content

Commit

Permalink
Create Progress component
Browse files Browse the repository at this point in the history
  • Loading branch information
lialila committed Feb 27, 2024
1 parent 0786483 commit 21f3a5e
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 0 deletions.
53 changes: 53 additions & 0 deletions src/components/Progress/Progress.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import React from 'react';
import { StoryFn, Meta } from '@storybook/react';

import { BoemlyProgress as Progress } from './Progress';

export default {
title: 'components/Progress',
component: Progress,
argTypes: {
ariaLAbel: {
type: { name: 'string', required: true },
control: { type: 'text' },
},
},
} as Meta<typeof Progress>;

const Template: StoryFn<typeof Progress> = (args) => <Progress {...args} />;
export const Default = Template.bind({});
Default.args = {};

export const Red = Template.bind({});
Red.args = {
min: 50,
max: 100,
value: 25,
color: 'red',
};

export const Gray = Template.bind({});
Gray.args = {
min: 50,
max: 200,
value: 50,
color: 'gray',
};

export const Green = Template.bind({});
Green.args = {
min: 50,
max: 300,
value: 100,
color: 'green',
isIndeterminate: true,
};

export const WithStripe = Template.bind({});
WithStripe.args = {
min: 50,
max: 400,
value: 100,
color: 'green',
hasStripe: true,
};
34 changes: 34 additions & 0 deletions src/components/Progress/Progress.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from 'react';
import { Progress } from '@chakra-ui/react';

interface BoemlyProgressProps {
min?: number;
max?: number;
value: number;
color: 'red' | 'green' | 'gray';
hasStripe?: boolean;
}

const VARIANTS = {
red: 'red',
green: 'primary',
gray: 'gray',
};

export const BoemlyProgress: React.FC<BoemlyProgressProps> = ({
min = 0,
max = 100,
value,
color,
hasStripe,
}: BoemlyProgressProps) => (
<Progress
role="progressbar"
value={value}
borderRadius="full"
colorScheme={VARIANTS[color]}
maxWidth={max}
minWidth={min}
hasStripe={hasStripe}
/>
);
1 change: 1 addition & 0 deletions src/components/Progress/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { BoemlyProgress } from './Progress';

0 comments on commit 21f3a5e

Please sign in to comment.