Skip to content

Commit 5bf8262

Browse files
luisbeqjagioboa
andauthored
feat(component): add new Progress Bar component (#174)
* feat(component): add new Progress Bar component fix #129 * feat(components): add new Progress Bar component * feat(component): add new Progress Bar component - headless * remove unused import --------- Co-authored-by: Giorgio Boa <[email protected]>
1 parent 3298d77 commit 5bf8262

File tree

8 files changed

+149
-0
lines changed

8 files changed

+149
-0
lines changed

apps/website/src/components/menu/menu.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ export const Menu = component$<Props>(({ onClose$ }) => {
2828
{ label: 'Tabs', path: `/docs/${appState.theme.toLowerCase()}/tabs` },
2929
{ label: 'Toggle', path: `/docs/${appState.theme.toLowerCase()}/toggle` },
3030
{ label: 'Tooltip', path: `/docs/${appState.theme.toLowerCase()}/tooltip` },
31+
{
32+
label: 'Progress',
33+
path: `/docs/${appState.theme.toLowerCase()}/progress`,
34+
},
3135
];
3236

3337
const onChangePage = $(() => {
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { component$, $, useStylesScoped$ } from '@builder.io/qwik';
2+
import { Progress } from '@qwik-ui/theme-daisy';
3+
4+
export default component$(() => {
5+
useStylesScoped$(`
6+
.panel {
7+
display: flex;
8+
flex-direction: column;
9+
gap: 8px;
10+
flex-wrap: wrap;
11+
}`);
12+
13+
return (
14+
<>
15+
<h2>This is the documentation for the Progress</h2>
16+
17+
<div class="flex flex-col gap-8 mt-4">
18+
<h2>Basic Example</h2>
19+
<div class="panel">
20+
<Progress variant="primary" value={10} max={100} class="w-56" />
21+
<Progress variant="primary" value={20} max={100} class="w-56" />
22+
<Progress variant="primary" value={30} max={100} class="w-56" />
23+
<Progress variant="primary" value={40} max={100} class="w-56" />
24+
<Progress variant="primary" value={50} max={100} class="w-56" />
25+
<Progress variant="primary" value={60} max={100} class="w-56" />
26+
27+
<h2>secondary color</h2>
28+
<Progress variant="secondary" value={50} max={100} class="w-56" />
29+
30+
<h2>accent color</h2>
31+
<Progress variant="accent" value={50} max={100} class="w-56" />
32+
33+
<h2>success color</h2>
34+
<Progress variant="success" value={50} max={100} class="w-56" />
35+
36+
<h2>info color</h2>
37+
<Progress variant="info" value={50} max={100} class="w-56" />
38+
39+
<h2>warning color</h2>
40+
<Progress variant="warning" value={50} max={100} class="w-56" />
41+
42+
<h2>error color</h2>
43+
<Progress variant="error" value={50} max={100} class="w-56" />
44+
45+
<h2>Indeterminate (no value) </h2>
46+
<Progress variant="error" class="w-56" />
47+
</div>
48+
</div>
49+
</>
50+
);
51+
});
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { component$, useStylesScoped$ } from '@builder.io/qwik';
2+
import { Progress } from '@qwik-ui/headless';
3+
4+
export default component$(() => {
5+
useStylesScoped$(`
6+
.panel {
7+
display: flex;
8+
flex-direction: column;
9+
gap: 8px;
10+
flex-wrap: wrap;
11+
}`);
12+
13+
return (
14+
<>
15+
<h2>This is the documentation for the Progress</h2>
16+
17+
<div class="flex flex-col gap-8 mt-4">
18+
<h2>Basic Example</h2>
19+
<div class="panel">
20+
<Progress value={10} max={100} class="w-56" />
21+
<Progress value={20} max={100} class="w-56" />
22+
<Progress value={30} max={100} class="w-56" />
23+
<Progress value={40} max={100} class="w-56" />
24+
<Progress value={50} max={100} class="w-56" />
25+
<Progress value={60} max={100} class="w-56" />
26+
</div>
27+
</div>
28+
</>
29+
);
30+
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export const daisyConfig = {
2+
variants: {
3+
accent: 'progress-accent',
4+
error: 'progress-error',
5+
info: 'progress-info',
6+
primary: 'progress-primary',
7+
secondary: 'progress-secondary',
8+
success: 'progress-success',
9+
warning: 'progress-warning',
10+
},
11+
};
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { component$, QwikIntrinsicElements, Slot } from '@builder.io/qwik';
2+
import { Progress as HeadlessProgress } from '@qwik-ui/headless';
3+
import { clsq } from '@qwik-ui/shared';
4+
import { daisyConfig } from './daisy.config';
5+
6+
export type HTMLProgressProps = QwikIntrinsicElements['progress'];
7+
8+
export type DaisyProgressProps = {
9+
variant?: DaisyProgressVariants;
10+
value?: number;
11+
max?: number;
12+
};
13+
14+
export type DaisyProgressVariants =
15+
| 'primary'
16+
| 'secondary'
17+
| 'accent'
18+
| 'info'
19+
| 'success'
20+
| 'warning'
21+
| 'error';
22+
23+
export type ProgressProps = HTMLProgressProps & DaisyProgressProps;
24+
25+
export const Progress = component$((props: ProgressProps) => {
26+
const {
27+
variant = 'primary',
28+
class: classNames,
29+
value = 0,
30+
max = 100,
31+
...rest
32+
} = props;
33+
34+
const { variants } = daisyConfig;
35+
36+
return (
37+
<HeadlessProgress
38+
{...rest}
39+
value={value}
40+
max={max}
41+
class={clsq('progress', variants[variant], classNames)}
42+
></HeadlessProgress>
43+
);
44+
});

packages/daisy/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export * from './components/button/button';
2+
export * from './components/progress/progress';
23
export * from './components/button-group/button-group';
34
export * from './components/card';
45
export * from './components/collapse/collapse';
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { component$, QwikIntrinsicElements } from '@builder.io/qwik';
2+
3+
export type ProgressProps = QwikIntrinsicElements['progress'];
4+
5+
export const Progress = component$((props: ProgressProps) => {
6+
return <progress {...props} />;
7+
});

packages/headless/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export * from './components/button/button';
2+
export * from './components/progress/progress';
23
export * from './components/button-group/button-group';
34
export * from './components/card';
45
export * from './components/collapse/collapse';

0 commit comments

Comments
 (0)