-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
192 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
--- | ||
title: Progress | ||
description: Displays an indicator showing the completion progress of a task, typically displayed as a progress bar. | ||
links: | ||
doc: https://www.radix-ng.com/primitives/components/progress | ||
api: https://www.radix-ng.com/primitives/components/progress#api-reference | ||
--- | ||
|
||
<ComponentPreview | ||
name="progress-demo" | ||
description="A progress bar component." | ||
/> | ||
|
||
## Installation | ||
|
||
<Tabs defaultValue="cli"> | ||
|
||
<TabsList> | ||
<TabsTrigger value="cli">CLI</TabsTrigger> | ||
<TabsTrigger value="manual">Manual</TabsTrigger> | ||
</TabsList> | ||
<TabsContent value="cli"> | ||
|
||
```bash | ||
npx shadcn-ng@latest add progress | ||
``` | ||
|
||
</TabsContent> | ||
|
||
<TabsContent value="manual"> | ||
|
||
<Steps> | ||
|
||
<Step>Install the following dependencies:</Step> | ||
|
||
```bash | ||
npm install @radix-ng/primitives | ||
``` | ||
|
||
<Step>Copy and paste the following code into your project.</Step> | ||
|
||
<ComponentSource name="progress" /> | ||
|
||
<Step>Update the import paths to match your project setup.</Step> | ||
|
||
</Steps> | ||
|
||
</TabsContent> | ||
|
||
</Tabs> | ||
|
||
## Usage | ||
|
||
```ts | ||
import { ProgressDirective } from '@/components/ui/progress' | ||
``` | ||
|
||
```html | ||
<div ubProgress [progress]="10"></div> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { ProgressDirective } from '@/registry/default/ui/progress' | ||
|
||
import { Component, type OnDestroy, type OnInit } from '@angular/core' | ||
|
||
@Component({ | ||
standalone: true, | ||
selector: '[progress-demo-default]', | ||
imports: [ProgressDirective], | ||
template: `<div ubProgress [progress]="progress" class="w-[60%]"></div>`, | ||
}) | ||
export default class ProgressDemoDefault implements OnInit, OnDestroy { | ||
progress = 10 | ||
intervalId!: NodeJS.Timeout | ||
|
||
ngOnInit(): void { | ||
this.intervalId = setTimeout(() => { | ||
this.progress = 66 | ||
}, 500) | ||
} | ||
|
||
ngOnDestroy(): void { | ||
if (this.intervalId) { | ||
clearInterval(this.intervalId) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { cn } from '@/lib/utils' | ||
import { Component, computed, input, numberAttribute } from '@angular/core' | ||
|
||
import { RdxProgressIndicatorDirective, RdxProgressRootDirective } from '@radix-ng/primitives/progress' | ||
|
||
@Component({ | ||
standalone: true, | ||
selector: '[ubProgress]', | ||
imports: [RdxProgressIndicatorDirective], | ||
host: { | ||
'[class]': 'computedClass()', | ||
}, | ||
hostDirectives: [ | ||
{ | ||
directive: RdxProgressRootDirective, | ||
inputs: ['rdxValue:progress', 'rdxMax:max', 'rdxValueLabel:valueLabel'], | ||
}, | ||
], | ||
template: ` | ||
<div rdxProgressIndicator class="h-full w-full flex-1 bg-primary transition-all" [style.transform]="'translateX(-' + (100 - (progress() || 0)) + '%)'"></div> | ||
`, | ||
}) | ||
export class ProgressDirective { | ||
progress = input(0, { | ||
transform: numberAttribute, | ||
}) | ||
|
||
class = input<string>() | ||
computedClass = computed(() => cn('relative h-4 w-full overflow-hidden rounded-full bg-secondary', this.class())) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { ProgressDirective } from '@/registry/new-york/ui/progress' | ||
|
||
import { Component, type OnDestroy, type OnInit } from '@angular/core' | ||
|
||
@Component({ | ||
standalone: true, | ||
selector: '[progress-demo-new-york]', | ||
imports: [ProgressDirective], | ||
template: `<div ubProgress [progress]="progress" class="w-[60%]"></div>`, | ||
}) | ||
export default class ProgressDemoNewYork implements OnInit, OnDestroy { | ||
progress = 10 | ||
intervalId!: NodeJS.Timeout | ||
|
||
ngOnInit(): void { | ||
this.intervalId = setTimeout(() => { | ||
this.progress = 66 | ||
}, 500) | ||
} | ||
|
||
ngOnDestroy(): void { | ||
if (this.intervalId) { | ||
clearInterval(this.intervalId) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { cn } from '@/lib/utils' | ||
import { Component, computed, input, numberAttribute } from '@angular/core' | ||
|
||
import { RdxProgressIndicatorDirective, RdxProgressRootDirective } from '@radix-ng/primitives/progress' | ||
|
||
@Component({ | ||
standalone: true, | ||
selector: '[ubProgress]', | ||
imports: [RdxProgressIndicatorDirective], | ||
host: { | ||
'[class]': 'computedClass()', | ||
}, | ||
hostDirectives: [ | ||
{ | ||
directive: RdxProgressRootDirective, | ||
inputs: ['rdxValue:progress', 'rdxMax:max', 'rdxValueLabel:valueLabel'], | ||
}, | ||
], | ||
template: ` | ||
<div rdxProgressIndicator class="h-full w-full flex-1 bg-primary transition-all" [style.transform]="'translateX(-' + (100 - (progress() || 0)) + '%)'"></div> | ||
`, | ||
}) | ||
export class ProgressDirective { | ||
progress = input(0, { | ||
transform: numberAttribute, | ||
}) | ||
|
||
class = input<string>() | ||
computedClass = computed(() => cn('relative h-2 w-full overflow-hidden rounded-full bg-primary/20', this.class())) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters