Skip to content

Commit

Permalink
feat: progress bar component
Browse files Browse the repository at this point in the history
  • Loading branch information
SySagar committed Aug 1, 2024
1 parent 2582a4e commit 404c769
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/three-houses-deny.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@groovy-box/ui': patch
---

Progress component added
26 changes: 26 additions & 0 deletions apps/ui/lib/components/Progress/Progress.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import * as React from 'react';
import * as ProgressPrimitive from '@radix-ui/react-progress';

import { cn } from '@utils/utils';

const Progress = React.forwardRef<
React.ElementRef<typeof ProgressPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof ProgressPrimitive.Root>
>(({ className, value, ...props }, ref) => (
<ProgressPrimitive.Root
ref={ref}
className={cn(
'relative h-4 w-full overflow-hidden rounded-full bg-primary-100 bg-opacity-50',
className
)}
{...props}
>
<ProgressPrimitive.Indicator
className="h-full w-full flex-1 bg-primary-500 transition-all"
style={{ transform: `translateX(-${100 - (value || 0)}%)` }}
/>
</ProgressPrimitive.Root>
));
Progress.displayName = ProgressPrimitive.Root.displayName;

export { Progress };
1 change: 1 addition & 0 deletions apps/ui/lib/components/Progress/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './Progress';
1 change: 1 addition & 0 deletions apps/ui/lib/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ export * from './components/Accordion';
export * from './components/Navigation-menu';
export * from './components/Switch';
export * from './components/Toast';
export * from './components/Progress';
30 changes: 30 additions & 0 deletions apps/ui/stories/Progress.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from 'react';
import { Meta, Story } from '@storybook/react';

import { Progress, Text } from '../lib';

const DefaultTemplate = ({ value = 40 }) => {
return (
<div
style={{
display: 'flex',
alignItems: 'start',
flexDirection: 'column',
justifyItems: 'start',
gap: '1rem',
}}
>
<Text variant="heading-4">{value}% complete</Text>
<Progress value={value} />
</div>
);
};

export default {
title: 'components/Progress',
component: DefaultTemplate,
} as Meta;

export const Default = () => {
return <DefaultTemplate />;
};

0 comments on commit 404c769

Please sign in to comment.