Skip to content

Commit 22feaf0

Browse files
committed
docs: progress headless and styled doc
1 parent 1062017 commit 22feaf0

File tree

3 files changed

+108
-1
lines changed

3 files changed

+108
-1
lines changed

apps/website/src/routes/docs/headless/progress/examples/hero.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export default component$(() => {
2020
class="h-full w-full bg-slate-700"
2121
style={{
2222
transform: `translateX(-${100 - progress.value}%)`,
23-
transition: 'transform 0.3s',
2423
}}
2524
/>
2625
</Progress.Root>

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

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,74 @@ import { Note } from '~/components/note/note';
1313
Displays a progress bar related to a task.
1414

1515
<Showcase name="hero" />
16+
17+
Qwik UI's Progress implementation follows the [WAI-Aria](https://www.w3.org/WAI/ARIA/apg/patterns/accordion/) design pattern, along with some additional API's that enhance the flexibility, types, and performance.
18+
19+
<FeatureList
20+
features={['Provides context for assistive technology to read the progress of a task.']}
21+
/>
22+
23+
<div class="mb-6 flex flex-col gap-2">
24+
[View Source Code ↗️](https://github.com/qwikifiers/qwik-ui/tree/main/packages/kit-headless/src/components/progress)
25+
26+
[Report an issue 🚨](https://github.com/qwikifiers/qwik-ui/issues)
27+
28+
[Edit This Page 🗒️](<https://github.com/qwikifiers/qwik-ui/edit/main/apps/website/src/routes/docs/headless/(components)/progress/index.mdx>)
29+
30+
</div>
31+
32+
> Rather than using the `details` and `summary` tags as disclosure widgets, we use a custom implementation. While these widgets can be used without JavaScript, they come with [their own accessibility drawbacks](https://www.scottohara.me/blog/2022/09/12/details-summary.html).
33+
34+
## Building blocks
35+
36+
```tsx
37+
import { component$, useSignal } from '@builder.io/qwik';
38+
import * as Progress from '@qwik-ui/headless';
39+
40+
export default component$(() => {
41+
const progress = useSignal(30);
42+
return (
43+
<Progress.Root value={progress.value}>
44+
<Progress.Indicator
45+
style={{ transform: `translateX(-${100 - progress.value}%)` }}
46+
/>
47+
</Progress.Root>
48+
);
49+
});
50+
```
51+
52+
## Accessibility
53+
54+
Adheres to the [progressbar role requirements](https://www.w3.org/WAI/ARIA/apg/patterns/meter/).
55+
56+
## API
57+
58+
### Root
59+
60+
Contains all of the progress parts.
61+
62+
<APITable
63+
propDescriptors={[
64+
{
65+
name: 'class',
66+
type: 'string',
67+
description: 'CSS classes to apply to the Progress.',
68+
},
69+
{
70+
name: 'value',
71+
type: 'number',
72+
description: 'The progress value.',
73+
},
74+
{
75+
name: 'max',
76+
type: 'number',
77+
description: 'The maximum progress value',
78+
},
79+
{
80+
name: 'getValueLabel',
81+
type: 'function',
82+
description:
83+
'A function to get the accessible label text representing the current value in a human-readable format. If not provided, the value label will be read as the numeric value as a percentage of the max value.',
84+
},
85+
]}
86+
/>

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

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,40 @@ import { statusByComponent } from '~/_state/component-statuses';
1111
Displays an indicator showing the completion progress of a task, typically displayed as a progress bar.
1212

1313
<Showcase name="hero" />
14+
15+
## Installation
16+
17+
### Run the following cli command or copy/paste the component code into your project
18+
19+
```sh
20+
qwik-ui add progress
21+
```
22+
23+
```tsx
24+
import { cn } from '@qwik-ui/utils';
25+
import * as ProgressPrimitive from '@qwik-ui/headless';
26+
import { PropsOf, component$ } from '@builder.io/qwik';
27+
28+
export const Progress = component$<PropsOf<typeof ProgressPrimitive.Root>>((props) => {
29+
return (
30+
<ProgressPrimitive.Root
31+
class={cn('bg-secondary relative h-4 w-full overflow-hidden rounded', props?.class)}
32+
>
33+
<ProgressPrimitive.Indicator
34+
class="bg-primary h-full w-full flex-1 transition-all"
35+
style={{ transform: `translateX(-${100 - (props.value || 0)}%)` }}
36+
/>
37+
</ProgressPrimitive.Root>
38+
);
39+
});
40+
```
41+
42+
## Usage
43+
44+
```tsx
45+
import { Progress } from '@qwik-ui/styled';
46+
```
47+
48+
```tsx
49+
<Progress value={30} />
50+
```

0 commit comments

Comments
 (0)