Skip to content

Commit 18c1308

Browse files
committed
added progress bar
1 parent a7b5616 commit 18c1308

File tree

13 files changed

+187
-11
lines changed

13 files changed

+187
-11
lines changed

components/ui/Progress.tsx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"use client";
2+
3+
import * as React from "react";
4+
import * as ProgressPrimitive from "@radix-ui/react-progress";
5+
6+
import { cn } from "@/lib/utils";
7+
8+
const Progress = React.forwardRef<
9+
React.ElementRef<typeof ProgressPrimitive.Root>,
10+
React.ComponentPropsWithoutRef<typeof ProgressPrimitive.Root>
11+
>(({ className, value, ...props }, ref) => (
12+
<ProgressPrimitive.Root
13+
ref={ref}
14+
className={cn(
15+
"relative h-4 w-full overflow-hidden bg-background border-2 border-black",
16+
className
17+
)}
18+
{...props}
19+
>
20+
<ProgressPrimitive.Indicator
21+
className="h-full w-full flex-1 bg-primary transition-all"
22+
style={{ transform: `translateX(-${100 - (value || 0)}%)` }}
23+
/>
24+
</ProgressPrimitive.Root>
25+
));
26+
Progress.displayName = ProgressPrimitive.Root.displayName;
27+
28+
export { Progress };

components/ui/Switch.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const Switch = ({ className, ...props }: SwitchPrimitives.SwitchProps) => (
1515
>
1616
<SwitchPrimitives.Thumb
1717
className={cn(
18-
"pointer-events-none block h-4 w-4 bg-primary border-2 mx-0.5 border-foreground shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0 data-[state=checked]:bg-background"
18+
"pointer-events-none block h-4 w-4 bg-primary border-2 mx-0.5 border-foreground ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0 data-[state=checked]:bg-background"
1919
)}
2020
/>
2121
</SwitchPrimitives.Root>

components/ui/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ export * from "./Badge";
1616
export * from "./Tab";
1717
export * from "./Dialog";
1818
export * from "./Menu";
19+
export * from "./Progress";

config/components.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ export const componentConfig: {
5959
name: "menu",
6060
filePath: "components/ui/Menu.tsx",
6161
},
62+
progress: {
63+
name: "progress",
64+
filePath: "components/ui/Progress.tsx",
65+
},
6266
radio: {
6367
name: "radio",
6468
filePath: "components/ui/Radio.tsx",
@@ -237,6 +241,13 @@ export const componentConfig: {
237241
filePath: "preview/components/menu-style-default.tsx",
238242
preview: lazy(() => import("@/preview/components/menu-style-default")),
239243
},
244+
"progress-style-default": {
245+
name: "progress-style-default",
246+
filePath: "preview/components/progress-style-default.tsx",
247+
preview: lazy(
248+
() => import("@/preview/components/progress-style-default")
249+
),
250+
},
240251
"radio-style-default": {
241252
name: "radio-style-default",
242253
filePath: "preview/components/radio-style-default.tsx",

config/navigation.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,16 @@ export const navConfig: INavigationConfig = {
2828
{ title: "Alert", href: `${componentsRoute}/alert` },
2929
{ title: "Avatar", href: `${componentsRoute}/avatar` },
3030
{ title: "Badge", href: `${componentsRoute}/badge` },
31-
{ title: "Button", href: `${componentsRoute}/button` },
31+
{ title: "Button", href: `${componentsRoute}/button`, tag: "Updated" },
3232
{ title: "Card", href: `${componentsRoute}/card` },
3333
{ title: "Checkbox", href: `${componentsRoute}/checkbox` },
3434
{ title: "Dialog", href: `${componentsRoute}/dialog` },
3535
{ title: "Input", href: `${componentsRoute}/input`, tag: "Updated" },
3636
{ title: "Menu", href: `${componentsRoute}/menu` },
37+
{ title: "Progress", href: `${componentsRoute}/progress` },
3738
{ title: "Radio", href: `${componentsRoute}/radio` },
38-
{ title: "Select", href: `${componentsRoute}/select`, tag: "New" },
39-
{ title: "Switch", href: `${componentsRoute}/switch`, tag: "New" },
39+
{ title: "Select", href: `${componentsRoute}/select` },
40+
{ title: "Switch", href: `${componentsRoute}/switch` },
4041
{ title: "Tab", href: `${componentsRoute}/tab` },
4142
{ title: "Textarea", href: `${componentsRoute}/textarea` },
4243
{ title: "Text", href: `${componentsRoute}/text` },
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
---
2+
title: Progress
3+
description: Let's you users know how long to wait.
4+
lastUpdated: 05 Apr, 2025
5+
links:
6+
api_reference: https://www.radix-ui.com/docs/primitives/components/progress#api-reference
7+
source: https://github.com/Logging-Stuff/RetroUI/blob/main/components/ui/Progress.tsx
8+
---
9+
10+
<ComponentShowcase name="progress-style-default" />
11+
<br />
12+
<br />
13+
14+
## Installation
15+
16+
<ComponentInstall>
17+
<ComponentInstall.Cli>
18+
```sh
19+
npx shadcn@latest add "https://retroui.dev/r/progress.json"
20+
```
21+
</ComponentInstall.Cli>
22+
<ComponentInstall.Manual>
23+
#### 1. Install dependencies:
24+
25+
```sh
26+
npm install @radix-ui/react-progress lucide-react
27+
```
28+
29+
<br />
30+
31+
#### 2. Copy the code 👇 into your project:
32+
33+
<ComponentSource name="progress" />
34+
35+
</ComponentInstall.Manual>
36+
</ComponentInstall>
37+
38+
<br />
39+
<br />
40+
41+
## Examples
42+
43+
### Default
44+
45+
<ComponentShowcase name="progress-style-default" />
46+
{/* ## Installation
47+
48+
<CodeTabs>
49+
50+
<TabsList>
51+
<TabsTrigger value="cli">CLI</TabsTrigger>
52+
<TabsTrigger value="manual">Manual</TabsTrigger>
53+
</TabsList>
54+
<TabsContent value="cli">
55+
56+
```bash
57+
npx shadcn@latest add progress
58+
```
59+
60+
</TabsContent>
61+
62+
<TabsContent value="manual">
63+
64+
<Steps>
65+
66+
<Step>Install the following dependencies:</Step>
67+
68+
```bash
69+
npm install @radix-ui/react-progress
70+
```
71+
72+
<Step>Copy and paste the following code into your project.</Step>
73+
74+
<ComponentSource name="progress" />
75+
76+
<Step>Update the import paths to match your project setup.</Step>
77+
78+
</Steps>
79+
80+
</TabsContent>
81+
82+
</CodeTabs>
83+
84+
## Usage
85+
86+
```tsx
87+
import { Progress } from "@/components/ui/progress"
88+
```
89+
90+
```tsx
91+
<Progress value={33} />
92+
``` */}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"@radix-ui/react-dialog": "^1.1.2",
1818
"@radix-ui/react-dropdown-menu": "^2.1.2",
1919
"@radix-ui/react-label": "^2.1.2",
20+
"@radix-ui/react-progress": "^1.1.2",
2021
"@radix-ui/react-radio-group": "^1.2.3",
2122
"@radix-ui/react-select": "^2.1.6",
2223
"@radix-ui/react-switch": "^1.1.3",

pnpm-lock.yaml

Lines changed: 29 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"use client";
2+
3+
import * as React from "react";
4+
5+
import { Progress } from "@/components/ui";
6+
7+
export default function ProgressDemo() {
8+
const [progress, setProgress] = React.useState(13);
9+
10+
React.useEffect(() => {
11+
const timer = setTimeout(() => setProgress(66), 500);
12+
return () => clearTimeout(timer);
13+
}, []);
14+
15+
return <Progress value={progress} className="w-[60%]" />;
16+
}

preview/components/select-style-default.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default function SelectStyleDefault() {
55
return (
66
<Select>
77
<Select.Trigger className="w-60">
8-
<Select.Value placeholder="Pick your favorite Pokemon" />
8+
<Select.Value placeholder="Pick your Pokemon" />
99
</Select.Trigger>
1010
<Select.Content>
1111
<Select.Group>

0 commit comments

Comments
 (0)