/
+page.svelte
135 lines (130 loc) · 5.02 KB
/
+page.svelte
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<script lang="ts">
import DocsShell from '$lib/layouts/DocsShell/DocsShell.svelte';
import { DocsFeature, type DocsShellSettings } from '$lib/layouts/DocsShell/types';
import DocsPreview from '$lib/components/DocsPreview/DocsPreview.svelte';
// Components
import { ProgressBar, CodeBlock } from '@skeletonlabs/skeleton';
// Sveld
import sveldProgressBar from '@skeletonlabs/skeleton/components/ProgressBar/ProgressBar.svelte?raw&sveld';
// Defaults
const defaultRounded = 'rounded-token';
const defaultMeter = 'bg-surface-900-50-token';
const defaultTrack = 'bg-surface-200-700-token';
// Docs Shell
const settings: DocsShellSettings = {
feature: DocsFeature.Component,
name: 'Progress Bars',
description: 'An indicator showing the progress or completion of a task.',
imports: ['ProgressBar'],
source: 'packages/skeleton/src/lib/components/ProgressBar',
aria: 'https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/progressbar_role',
components: [{ sveld: sveldProgressBar }]
};
// Reactive Props
$: props = {
determinate: true,
value: 50,
max: 100,
step: 10,
height: 'h-2',
rounded: defaultRounded,
meter: defaultMeter,
track: defaultTrack
};
</script>
<DocsShell {settings}>
<!-- Slot: Sandbox -->
<svelte:fragment slot="sandbox">
<DocsPreview>
<svelte:fragment slot="preview">
<ProgressBar bind:value={props.value} max={props.max} />
</svelte:fragment>
<svelte:fragment slot="footer">
<div class="w-48 mx-auto"><input type="range" min="0" bind:value={props.value} max={props.max} step={props.step} /></div>
</svelte:fragment>
<svelte:fragment slot="source">
<CodeBlock language="html" code={`<ProgressBar value={${props.value}} max={${props.max}} />`} />
</svelte:fragment>
</DocsPreview>
</svelte:fragment>
<!-- Slot: Usage -->
<svelte:fragment slot="usage">
<section class="space-y-4">
<h2 class="h2">Indeterminate Mode</h2>
<p>Remove the <code class="code">value</code> property or set value to <code class="code">undefined</code>.</p>
<DocsPreview background="neutral">
<svelte:fragment slot="preview">
<div class="w-full space-y-10">
<ProgressBar />
<div class="w-full space-y-4">
<ProgressBar meter="bg-primary-500" track="bg-primary-500/30" />
<ProgressBar meter="bg-secondary-500" track="bg-secondary-500/30" />
<ProgressBar meter="bg-tertiary-500" track="bg-tertiary-500/30" />
<ProgressBar meter="bg-success-500" track="bg-success-500/30" />
<ProgressBar meter="bg-warning-500" track="bg-warning-500/30" />
<ProgressBar meter="bg-error-500" track="bg-error-500/30" />
</div>
<!-- <ProgressBar
meter="bg-gradient-to-r variant-gradient-secondary-primary"
track="bg-gradient-to-r variant-gradient-primary-secondary"
/> -->
</div>
</svelte:fragment>
<svelte:fragment slot="source">
<CodeBlock language="html" code={`<ProgressBar />`} />
<CodeBlock language="html" code={`<ProgressBar value={undefined} />`} />
</svelte:fragment>
</DocsPreview>
<h3 class="h3">Custom Animation</h3>
<p>Use the <code class="code">animIndeterminate</code> prop to pass a custom CSS animation for the progress bar meter.</p>
<DocsPreview background="neutral">
<svelte:fragment slot="preview">
<div class="w-full space-y-10">
<ProgressBar animIndeterminate="anim-progress-bar-example" />
</div>
</svelte:fragment>
<svelte:fragment slot="source">
<p>Define your new animation class in your global stylesheet <code class="code">app.postcss</code>.</p>
<CodeBlock
language="css"
code={`
.anim-progress-bar {
transform-origin: 0% 50%;
animation: anim-progress-bar 2s infinite linear;
}
@keyframes anim-progress-bar {
0% { transform: translateX(50%) scaleX(0.5); }
50% { transform: translateX(0) scaleX(0.5); }
100% { transform: translateX(50%) scaleX(0.5); }
}
`}
/>
<p>Append the animation class to via the <code class="code">animIndeterminate</code> prop.</p>
<CodeBlock language="html" code={`<ProgressBar animIndeterminate="anim-progress-bar"/>`} />
</svelte:fragment>
</DocsPreview>
</section>
<section class="space-y-4">
<h2 class="h2">Native Alternative</h2>
<p>
The native <code class="code">progress</code> element works cross browser, but does not currently support Indeterminate mode when styled.
</p>
<DocsPreview background="neutral">
<svelte:fragment slot="preview">
<progress value={props.value} max={props.max} />
</svelte:fragment>
<svelte:fragment slot="source">
<CodeBlock language="html" code={`<progress value={props.value} max={props.max} />`} />
</svelte:fragment>
</DocsPreview>
</section>
<hr />
<section class="space-y-4">
<h2 class="h2">Accessibility</h2>
<!-- prettier-ignore -->
<p>
This component is treated as an <a class="anchor" href="https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/progressbar_role" target="_blank" rel="noreferrer">ARIA progressbar</a>.
</p>
</section>
</svelte:fragment>
</DocsShell>