Skip to content

Commit 1062017

Browse files
committed
feat: progress headless and styled
1 parent 1b26020 commit 1062017

File tree

15 files changed

+193
-11
lines changed

15 files changed

+193
-11
lines changed

apps/website/src/_state/component-statuses.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export const statusByComponent: ComponentKitsStatuses = {
2424
Modal: ComponentStatus.Draft,
2525
Pagination: ComponentStatus.Draft,
2626
Popover: ComponentStatus.Draft,
27+
Progress: ComponentStatus.Draft,
2728
RadioGroup: ComponentStatus.Draft,
2829
Separator: ComponentStatus.Beta,
2930
Skeleton: ComponentStatus.Beta,
@@ -38,6 +39,7 @@ export const statusByComponent: ComponentKitsStatuses = {
3839
Modal: ComponentStatus.Beta,
3940
Pagination: ComponentStatus.Draft,
4041
Popover: ComponentStatus.Beta,
42+
Progress: ComponentStatus.Draft,
4143
Select: ComponentStatus.Beta,
4244
Separator: ComponentStatus.Beta,
4345
Tabs: ComponentStatus.Beta,

apps/website/src/routes/docs/headless/menu.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
- [Modal](/docs/headless/modal)
2121
- [Pagination](/docs/headless/pagination)
2222
- [Popover](/docs/headless/popover)
23+
- [Progress](/docs/headless/progress)
2324
- [Select](/docs/headless/select)
2425
- [Separator](/docs/headless/separator)
2526
- [Tabs](/docs/headless/tabs)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { component$, useSignal, useVisibleTask$ } from '@builder.io/qwik';
2+
import * as Progress from '@qwik-ui/headless';
3+
4+
export default component$(() => {
5+
const progress = useSignal(30);
6+
7+
useVisibleTask$(() => {
8+
setTimeout(() => {
9+
progress.value = 50;
10+
}, 1000);
11+
});
12+
13+
return (
14+
<>
15+
<Progress.Root
16+
value={progress.value}
17+
class="h-7 w-full overflow-hidden rounded-full bg-gray-100"
18+
>
19+
<Progress.Indicator
20+
class="h-full w-full bg-slate-700"
21+
style={{
22+
transform: `translateX(-${100 - progress.value}%)`,
23+
transition: 'transform 0.3s',
24+
}}
25+
/>
26+
</Progress.Root>
27+
</>
28+
);
29+
});
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
title: Qwik UI | Progress
3+
---
4+
5+
import { statusByComponent } from '~/_state/component-statuses';
6+
import { FeatureList } from '~/components/feature-list/feature-list';
7+
import { Note } from '~/components/note/note';
8+
9+
<StatusBanner status={statusByComponent.headless.Progress} />
10+
11+
# Progress
12+
13+
Displays a progress bar related to a task.
14+
15+
<Showcase name="hero" />

apps/website/src/routes/docs/styled/menu.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
- [Label](/docs/styled/label)
2626
- [Modal](/docs/styled/modal)
2727
- [Popover](/docs/styled/popover)
28+
- [Progress](/docs/styled/progress)
2829
- [RadioGroup](/docs/styled/radio-group)
2930
- [Separator](/docs/styled/separator)
3031
- [Skeleton](/docs/styled/skeleton)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { component$, useSignal, useVisibleTask$ } from '@builder.io/qwik';
2+
import { Progress } from '@qwik-ui/styled';
3+
4+
export default component$(() => {
5+
const progress = useSignal(30);
6+
7+
useVisibleTask$(() => {
8+
setTimeout(() => {
9+
progress.value = 50;
10+
}, 1000);
11+
});
12+
13+
return (
14+
<>
15+
<Progress value={progress.value} />
16+
</>
17+
);
18+
});

apps/website/src/routes/docs/styled/progress/index.mdx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ title: Qwik UI | Styled Progress Component
44

55
import { statusByComponent } from '~/_state/component-statuses';
66

7+
<StatusBanner status={statusByComponent.styled.Progress} />
8+
79
# Progress
810

9-
The Qwik UI Styled progress component is your digital cheerleader, celebrating each step forward with flashy colors and a positive attitude!
11+
Displays an indicator showing the completion progress of a task, typically displayed as a progress bar.
1012

11-
<StatusBanner status={statusByComponent.styled.Progress} />
13+
<Showcase name="hero" />
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './progress-indicator';
2+
export * from './progress';
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { createContextId } from '@builder.io/qwik';
2+
3+
export interface ProgressContext {
4+
value: number | null;
5+
max: number;
6+
}
7+
8+
export const ProgressContext = createContextId<ProgressContext>('progress');
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { PropsOf, component$, useContext } from '@builder.io/qwik';
2+
import { getProgressState } from './util';
3+
import { ProgressContext } from './progress-context';
4+
5+
type ProgressIndicatorElement = PropsOf<'div'>;
6+
export const Indicator = component$<ProgressIndicatorElement>((props) => {
7+
const { ...indicatorProps } = props;
8+
9+
const { max, value } = useContext(ProgressContext);
10+
const translateX = value ? `translateX(-${100 - value}%)` : undefined;
11+
12+
return (
13+
<div
14+
style={{
15+
transform: translateX,
16+
transition: 'transform 0.3s',
17+
}}
18+
data-state={getProgressState(value, max)}
19+
data-value={value ?? undefined}
20+
data-max={max}
21+
{...indicatorProps}
22+
/>
23+
);
24+
});

0 commit comments

Comments
 (0)