@placeholderco/placeholder-ui 1.0.3 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +26 -26
- package/README.md +179 -179
- package/dist/display/Alert.svelte +179 -179
- package/dist/display/Avatar.svelte +166 -166
- package/dist/display/LinkCollection.svelte +161 -161
- package/dist/display/Paper.svelte +118 -118
- package/dist/form/Autocomplete.svelte +223 -191
- package/dist/form/Autocomplete.svelte.d.ts +3 -1
- package/dist/form/AutocompleteMulti.svelte +356 -0
- package/dist/form/AutocompleteMulti.svelte.d.ts +28 -0
- package/dist/form/Checkbox.svelte +201 -201
- package/dist/form/Chips.svelte +128 -128
- package/dist/form/ComboBox.svelte +158 -158
- package/dist/form/ComboBox.svelte.d.ts +1 -1
- package/dist/form/ComboBoxItemBuilder.svelte +460 -460
- package/dist/form/ComboBoxMulti.svelte +197 -197
- package/dist/form/ComboBoxMulti.svelte.d.ts +1 -1
- package/dist/form/CronBuilder.svelte +693 -693
- package/dist/form/DatePicker.svelte +672 -672
- package/dist/form/DateTimePicker.svelte +712 -712
- package/dist/form/FileInput.svelte +235 -235
- package/dist/form/FormGroup.svelte +68 -68
- package/dist/form/Number.svelte +238 -238
- package/dist/form/PasswordInput.svelte +252 -252
- package/dist/form/RadioGroup.svelte +210 -210
- package/dist/form/Rating.svelte +235 -235
- package/dist/form/SegmentedControl.svelte +149 -149
- package/dist/form/Select.svelte +590 -590
- package/dist/form/Select.svelte.d.ts +1 -1
- package/dist/form/SelectMulti.svelte +613 -613
- package/dist/form/SelectMulti.svelte.d.ts +1 -1
- package/dist/form/Slider.svelte +358 -358
- package/dist/form/Switch.svelte +147 -147
- package/dist/form/TextArea.svelte +148 -148
- package/dist/form/Textbox.svelte +228 -228
- package/dist/form/TimePicker.svelte +267 -267
- package/dist/icon/Icon.svelte +52 -52
- package/dist/icon/alert-octagon.svg +5 -5
- package/dist/icon/alert-triangle.svg +5 -5
- package/dist/icon/archive.svg +1 -1
- package/dist/icon/arrow-down.svg +1 -1
- package/dist/icon/arrow-left.svg +1 -1
- package/dist/icon/arrow-right.svg +1 -1
- package/dist/icon/arrow-up.svg +1 -1
- package/dist/icon/at.svg +1 -1
- package/dist/icon/bell.svg +1 -1
- package/dist/icon/bookmark.svg +1 -1
- package/dist/icon/calendar.svg +1 -1
- package/dist/icon/camera.svg +1 -1
- package/dist/icon/chart-bar.svg +1 -1
- package/dist/icon/chart-line.svg +1 -1
- package/dist/icon/chart-pie.svg +1 -1
- package/dist/icon/checkbox.svg +1 -1
- package/dist/icon/checklist.svg +1 -1
- package/dist/icon/circle-check.svg +1 -1
- package/dist/icon/circle-x.svg +1 -1
- package/dist/icon/clock.svg +1 -1
- package/dist/icon/credit-card.svg +1 -1
- package/dist/icon/dots-vertical.svg +1 -1
- package/dist/icon/dots.svg +1 -1
- package/dist/icon/external-link.svg +1 -1
- package/dist/icon/eye-off.svg +1 -1
- package/dist/icon/eye.svg +1 -1
- package/dist/icon/filter.svg +1 -1
- package/dist/icon/fingerprint.svg +1 -1
- package/dist/icon/flag.svg +1 -1
- package/dist/icon/heart.svg +1 -1
- package/dist/icon/home.svg +1 -1
- package/dist/icon/key.svg +1 -1
- package/dist/icon/list-check.svg +1 -1
- package/dist/icon/login.svg +1 -1
- package/dist/icon/logout.svg +1 -1
- package/dist/icon/map-pin.svg +1 -1
- package/dist/icon/maximize.svg +1 -1
- package/dist/icon/microphone.svg +1 -1
- package/dist/icon/minimize.svg +1 -1
- package/dist/icon/note.svg +1 -1
- package/dist/icon/player-pause.svg +1 -1
- package/dist/icon/printer.svg +1 -1
- package/dist/icon/qrcode.svg +1 -1
- package/dist/icon/send.svg +1 -1
- package/dist/icon/settings.svg +1 -1
- package/dist/icon/share.svg +1 -1
- package/dist/icon/shopping-cart.svg +1 -1
- package/dist/icon/sort-ascending.svg +1 -1
- package/dist/icon/sort-descending.svg +1 -1
- package/dist/icon/star.svg +1 -1
- package/dist/icon/tag.svg +1 -1
- package/dist/icon/trending-down.svg +1 -1
- package/dist/icon/trending-up.svg +1 -1
- package/dist/icon/upload.svg +1 -1
- package/dist/icon/volume-off.svg +1 -1
- package/dist/icon/volume.svg +1 -1
- package/dist/icon/world.svg +1 -1
- package/dist/icon/zoom-in.svg +1 -1
- package/dist/icon/zoom-out.svg +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/layout/AppShell.svelte +169 -169
- package/dist/layout/CustomNavbar.svelte +61 -61
- package/dist/layout/Navbar.svelte +206 -206
- package/dist/layout/NavbarItemDisplay.svelte +29 -29
- package/dist/layout/Sidenav.svelte +712 -712
- package/dist/styles/components.css +199 -199
- package/dist/styles/dark.css +146 -146
- package/dist/styles/index.css +116 -116
- package/dist/styles/reset.css +110 -110
- package/dist/styles/semantic.css +86 -86
- package/dist/styles/tokens.css +203 -197
- package/dist/styles/utilities.css +523 -523
- package/dist/ui/Accordion.svelte +289 -289
- package/dist/ui/ActionIcon.svelte +76 -76
- package/dist/ui/Badge.svelte +329 -279
- package/dist/ui/Breadcrumbs.svelte +131 -131
- package/dist/ui/Button.svelte +432 -370
- package/dist/ui/ButtonVariant.d.ts +1 -1
- package/dist/ui/Dialog.svelte +307 -307
- package/dist/ui/Drawer.svelte +524 -524
- package/dist/ui/Dropdown.svelte +97 -97
- package/dist/ui/Dropzone.svelte +122 -122
- package/dist/ui/Link.svelte +32 -32
- package/dist/ui/Loader.svelte +70 -70
- package/dist/ui/LoadingOverlay.svelte +53 -53
- package/dist/ui/Pagination.svelte +135 -135
- package/dist/ui/Popover.svelte +225 -225
- package/dist/ui/Progress.svelte +191 -191
- package/dist/ui/RingProgress.svelte +141 -141
- package/dist/ui/Skeleton.svelte +85 -85
- package/dist/ui/Stepper.svelte +355 -355
- package/dist/ui/Table.svelte +345 -345
- package/dist/ui/Tabs.svelte +146 -146
- package/dist/ui/ThemeSwitcher.svelte +39 -39
- package/dist/ui/Timeline.svelte +225 -225
- package/dist/ui/Toaster.svelte +6 -6
- package/dist/ui/Tooltip.svelte +434 -434
- package/package.json +14 -14
package/dist/ui/Progress.svelte
CHANGED
|
@@ -1,191 +1,191 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
interface Props {
|
|
3
|
-
value?: number;
|
|
4
|
-
max?: number;
|
|
5
|
-
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
6
|
-
color?: 'primary' | 'secondary' | 'accent' | 'success' | 'warning' | 'danger';
|
|
7
|
-
striped?: boolean;
|
|
8
|
-
animated?: boolean;
|
|
9
|
-
label?: string;
|
|
10
|
-
showValue?: boolean;
|
|
11
|
-
radius?: 'none' | 'sm' | 'md' | 'lg' | 'full';
|
|
12
|
-
class?: string;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
let {
|
|
16
|
-
value = 0,
|
|
17
|
-
max = 100,
|
|
18
|
-
size = 'md',
|
|
19
|
-
color = 'primary',
|
|
20
|
-
striped = false,
|
|
21
|
-
animated = false,
|
|
22
|
-
label = undefined,
|
|
23
|
-
showValue = false,
|
|
24
|
-
radius = 'full',
|
|
25
|
-
class: classes = ''
|
|
26
|
-
}: Props = $props();
|
|
27
|
-
|
|
28
|
-
const percentage = $derived(Math.min(100, Math.max(0, (value / max) * 100)));
|
|
29
|
-
const displayValue = $derived(showValue ? `${Math.round(percentage)}%` : '');
|
|
30
|
-
</script>
|
|
31
|
-
|
|
32
|
-
<div class="progress-wrapper {classes}">
|
|
33
|
-
{#if label}
|
|
34
|
-
<div class="progress-label">
|
|
35
|
-
<span>{label}</span>
|
|
36
|
-
{#if showValue}
|
|
37
|
-
<span class="progress-value">{displayValue}</span>
|
|
38
|
-
{/if}
|
|
39
|
-
</div>
|
|
40
|
-
{/if}
|
|
41
|
-
<div
|
|
42
|
-
class="progress size-{size} radius-{radius}"
|
|
43
|
-
role="progressbar"
|
|
44
|
-
aria-valuenow={value}
|
|
45
|
-
aria-valuemin={0}
|
|
46
|
-
aria-valuemax={max}
|
|
47
|
-
>
|
|
48
|
-
<div
|
|
49
|
-
class="progress-bar color-{color}"
|
|
50
|
-
class:striped
|
|
51
|
-
class:animated={animated && striped}
|
|
52
|
-
style="width: {percentage}%"
|
|
53
|
-
>
|
|
54
|
-
{#if showValue && !label}
|
|
55
|
-
<span class="progress-bar-label">{displayValue}</span>
|
|
56
|
-
{/if}
|
|
57
|
-
</div>
|
|
58
|
-
</div>
|
|
59
|
-
</div>
|
|
60
|
-
|
|
61
|
-
<style>
|
|
62
|
-
.progress-wrapper {
|
|
63
|
-
width: 100%;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
.progress-label {
|
|
67
|
-
display: flex;
|
|
68
|
-
justify-content: space-between;
|
|
69
|
-
align-items: center;
|
|
70
|
-
margin-bottom: var(--pui-spacing-1);
|
|
71
|
-
font-size: var(--pui-font-size-sm);
|
|
72
|
-
color: var(--pui-text-secondary);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
:global(.dark) .progress-label {
|
|
76
|
-
color: var(--pui-color-gray-300);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
.progress-value {
|
|
80
|
-
font-weight: var(--pui-font-weight-medium);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
.progress {
|
|
84
|
-
width: 100%;
|
|
85
|
-
background-color: var(--pui-color-gray-200);
|
|
86
|
-
overflow: hidden;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
:global(.dark) .progress {
|
|
90
|
-
background-color: var(--pui-color-dark-border);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/* Sizes */
|
|
94
|
-
.size-xs {
|
|
95
|
-
height: 4px;
|
|
96
|
-
}
|
|
97
|
-
.size-sm {
|
|
98
|
-
height: 6px;
|
|
99
|
-
}
|
|
100
|
-
.size-md {
|
|
101
|
-
height: 8px;
|
|
102
|
-
}
|
|
103
|
-
.size-lg {
|
|
104
|
-
height: 12px;
|
|
105
|
-
}
|
|
106
|
-
.size-xl {
|
|
107
|
-
height: 16px;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/* Radius */
|
|
111
|
-
.radius-none {
|
|
112
|
-
border-radius: 0;
|
|
113
|
-
}
|
|
114
|
-
.radius-sm {
|
|
115
|
-
border-radius: var(--pui-radius-sm);
|
|
116
|
-
}
|
|
117
|
-
.radius-md {
|
|
118
|
-
border-radius: var(--pui-radius-md);
|
|
119
|
-
}
|
|
120
|
-
.radius-lg {
|
|
121
|
-
border-radius: var(--pui-radius-lg);
|
|
122
|
-
}
|
|
123
|
-
.radius-full {
|
|
124
|
-
border-radius: var(--pui-radius-full);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
.progress-bar {
|
|
128
|
-
height: 100%;
|
|
129
|
-
border-radius: inherit;
|
|
130
|
-
transition: width var(--pui-transition-slow) var(--pui-ease-out);
|
|
131
|
-
display: flex;
|
|
132
|
-
align-items: center;
|
|
133
|
-
justify-content: center;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
.progress-bar-label {
|
|
137
|
-
font-size: var(--pui-font-size-xs);
|
|
138
|
-
font-weight: var(--pui-font-weight-medium);
|
|
139
|
-
color: var(--pui-color-white);
|
|
140
|
-
padding: 0 var(--pui-spacing-2);
|
|
141
|
-
white-space: nowrap;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/* Colors */
|
|
145
|
-
.color-primary {
|
|
146
|
-
background-color: var(--pui-color-primary);
|
|
147
|
-
}
|
|
148
|
-
.color-secondary {
|
|
149
|
-
background-color: var(--pui-color-secondary);
|
|
150
|
-
}
|
|
151
|
-
.color-accent {
|
|
152
|
-
background-color: var(--pui-color-accent);
|
|
153
|
-
}
|
|
154
|
-
.color-success {
|
|
155
|
-
background-color: var(--pui-color-success);
|
|
156
|
-
}
|
|
157
|
-
.color-warning {
|
|
158
|
-
background-color: var(--pui-color-warning);
|
|
159
|
-
}
|
|
160
|
-
.color-danger {
|
|
161
|
-
background-color: var(--pui-color-danger);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
/* Striped */
|
|
165
|
-
.striped {
|
|
166
|
-
background-image: linear-gradient(
|
|
167
|
-
45deg,
|
|
168
|
-
rgba(255, 255, 255, 0.15) 25%,
|
|
169
|
-
transparent 25%,
|
|
170
|
-
transparent 50%,
|
|
171
|
-
rgba(255, 255, 255, 0.15) 50%,
|
|
172
|
-
rgba(255, 255, 255, 0.15) 75%,
|
|
173
|
-
transparent 75%,
|
|
174
|
-
transparent
|
|
175
|
-
);
|
|
176
|
-
background-size: 1rem 1rem;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
.animated {
|
|
180
|
-
animation: progress-stripes 1s linear infinite;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
@keyframes progress-stripes {
|
|
184
|
-
from {
|
|
185
|
-
background-position: 1rem 0;
|
|
186
|
-
}
|
|
187
|
-
to {
|
|
188
|
-
background-position: 0 0;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
</style>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
interface Props {
|
|
3
|
+
value?: number;
|
|
4
|
+
max?: number;
|
|
5
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
6
|
+
color?: 'primary' | 'secondary' | 'accent' | 'success' | 'warning' | 'danger';
|
|
7
|
+
striped?: boolean;
|
|
8
|
+
animated?: boolean;
|
|
9
|
+
label?: string;
|
|
10
|
+
showValue?: boolean;
|
|
11
|
+
radius?: 'none' | 'sm' | 'md' | 'lg' | 'full';
|
|
12
|
+
class?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
let {
|
|
16
|
+
value = 0,
|
|
17
|
+
max = 100,
|
|
18
|
+
size = 'md',
|
|
19
|
+
color = 'primary',
|
|
20
|
+
striped = false,
|
|
21
|
+
animated = false,
|
|
22
|
+
label = undefined,
|
|
23
|
+
showValue = false,
|
|
24
|
+
radius = 'full',
|
|
25
|
+
class: classes = ''
|
|
26
|
+
}: Props = $props();
|
|
27
|
+
|
|
28
|
+
const percentage = $derived(Math.min(100, Math.max(0, (value / max) * 100)));
|
|
29
|
+
const displayValue = $derived(showValue ? `${Math.round(percentage)}%` : '');
|
|
30
|
+
</script>
|
|
31
|
+
|
|
32
|
+
<div class="progress-wrapper {classes}">
|
|
33
|
+
{#if label}
|
|
34
|
+
<div class="progress-label">
|
|
35
|
+
<span>{label}</span>
|
|
36
|
+
{#if showValue}
|
|
37
|
+
<span class="progress-value">{displayValue}</span>
|
|
38
|
+
{/if}
|
|
39
|
+
</div>
|
|
40
|
+
{/if}
|
|
41
|
+
<div
|
|
42
|
+
class="progress size-{size} radius-{radius}"
|
|
43
|
+
role="progressbar"
|
|
44
|
+
aria-valuenow={value}
|
|
45
|
+
aria-valuemin={0}
|
|
46
|
+
aria-valuemax={max}
|
|
47
|
+
>
|
|
48
|
+
<div
|
|
49
|
+
class="progress-bar color-{color}"
|
|
50
|
+
class:striped
|
|
51
|
+
class:animated={animated && striped}
|
|
52
|
+
style="width: {percentage}%"
|
|
53
|
+
>
|
|
54
|
+
{#if showValue && !label}
|
|
55
|
+
<span class="progress-bar-label">{displayValue}</span>
|
|
56
|
+
{/if}
|
|
57
|
+
</div>
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
|
|
61
|
+
<style>
|
|
62
|
+
.progress-wrapper {
|
|
63
|
+
width: 100%;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.progress-label {
|
|
67
|
+
display: flex;
|
|
68
|
+
justify-content: space-between;
|
|
69
|
+
align-items: center;
|
|
70
|
+
margin-bottom: var(--pui-spacing-1);
|
|
71
|
+
font-size: var(--pui-font-size-sm);
|
|
72
|
+
color: var(--pui-text-secondary);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
:global(.dark) .progress-label {
|
|
76
|
+
color: var(--pui-color-gray-300);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.progress-value {
|
|
80
|
+
font-weight: var(--pui-font-weight-medium);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.progress {
|
|
84
|
+
width: 100%;
|
|
85
|
+
background-color: var(--pui-color-gray-200);
|
|
86
|
+
overflow: hidden;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
:global(.dark) .progress {
|
|
90
|
+
background-color: var(--pui-color-dark-border);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/* Sizes */
|
|
94
|
+
.size-xs {
|
|
95
|
+
height: 4px;
|
|
96
|
+
}
|
|
97
|
+
.size-sm {
|
|
98
|
+
height: 6px;
|
|
99
|
+
}
|
|
100
|
+
.size-md {
|
|
101
|
+
height: 8px;
|
|
102
|
+
}
|
|
103
|
+
.size-lg {
|
|
104
|
+
height: 12px;
|
|
105
|
+
}
|
|
106
|
+
.size-xl {
|
|
107
|
+
height: 16px;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/* Radius */
|
|
111
|
+
.radius-none {
|
|
112
|
+
border-radius: 0;
|
|
113
|
+
}
|
|
114
|
+
.radius-sm {
|
|
115
|
+
border-radius: var(--pui-radius-sm);
|
|
116
|
+
}
|
|
117
|
+
.radius-md {
|
|
118
|
+
border-radius: var(--pui-radius-md);
|
|
119
|
+
}
|
|
120
|
+
.radius-lg {
|
|
121
|
+
border-radius: var(--pui-radius-lg);
|
|
122
|
+
}
|
|
123
|
+
.radius-full {
|
|
124
|
+
border-radius: var(--pui-radius-full);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.progress-bar {
|
|
128
|
+
height: 100%;
|
|
129
|
+
border-radius: inherit;
|
|
130
|
+
transition: width var(--pui-transition-slow) var(--pui-ease-out);
|
|
131
|
+
display: flex;
|
|
132
|
+
align-items: center;
|
|
133
|
+
justify-content: center;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.progress-bar-label {
|
|
137
|
+
font-size: var(--pui-font-size-xs);
|
|
138
|
+
font-weight: var(--pui-font-weight-medium);
|
|
139
|
+
color: var(--pui-color-white);
|
|
140
|
+
padding: 0 var(--pui-spacing-2);
|
|
141
|
+
white-space: nowrap;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/* Colors */
|
|
145
|
+
.color-primary {
|
|
146
|
+
background-color: var(--pui-color-primary);
|
|
147
|
+
}
|
|
148
|
+
.color-secondary {
|
|
149
|
+
background-color: var(--pui-color-secondary);
|
|
150
|
+
}
|
|
151
|
+
.color-accent {
|
|
152
|
+
background-color: var(--pui-color-accent);
|
|
153
|
+
}
|
|
154
|
+
.color-success {
|
|
155
|
+
background-color: var(--pui-color-success);
|
|
156
|
+
}
|
|
157
|
+
.color-warning {
|
|
158
|
+
background-color: var(--pui-color-warning);
|
|
159
|
+
}
|
|
160
|
+
.color-danger {
|
|
161
|
+
background-color: var(--pui-color-danger);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/* Striped */
|
|
165
|
+
.striped {
|
|
166
|
+
background-image: linear-gradient(
|
|
167
|
+
45deg,
|
|
168
|
+
rgba(255, 255, 255, 0.15) 25%,
|
|
169
|
+
transparent 25%,
|
|
170
|
+
transparent 50%,
|
|
171
|
+
rgba(255, 255, 255, 0.15) 50%,
|
|
172
|
+
rgba(255, 255, 255, 0.15) 75%,
|
|
173
|
+
transparent 75%,
|
|
174
|
+
transparent
|
|
175
|
+
);
|
|
176
|
+
background-size: 1rem 1rem;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
.animated {
|
|
180
|
+
animation: progress-stripes 1s linear infinite;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
@keyframes progress-stripes {
|
|
184
|
+
from {
|
|
185
|
+
background-position: 1rem 0;
|
|
186
|
+
}
|
|
187
|
+
to {
|
|
188
|
+
background-position: 0 0;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
</style>
|
|
@@ -1,141 +1,141 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type { Snippet } from 'svelte';
|
|
3
|
-
|
|
4
|
-
interface Section {
|
|
5
|
-
value: number;
|
|
6
|
-
color: string;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
interface Props {
|
|
10
|
-
value?: number;
|
|
11
|
-
size?: number;
|
|
12
|
-
thickness?: number;
|
|
13
|
-
roundCaps?: boolean;
|
|
14
|
-
color?: 'primary' | 'secondary' | 'accent' | 'success' | 'warning' | 'danger' | string;
|
|
15
|
-
sections?: Section[];
|
|
16
|
-
label?: Snippet;
|
|
17
|
-
class?: string;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
let {
|
|
21
|
-
value = 0,
|
|
22
|
-
size = 120,
|
|
23
|
-
thickness = 8,
|
|
24
|
-
roundCaps = true,
|
|
25
|
-
color = 'primary',
|
|
26
|
-
sections = [],
|
|
27
|
-
label,
|
|
28
|
-
class: classes = ''
|
|
29
|
-
}: Props = $props();
|
|
30
|
-
|
|
31
|
-
const radius = $derived((size - thickness) / 2);
|
|
32
|
-
const circumference = $derived(2 * Math.PI * radius);
|
|
33
|
-
const center = $derived(size / 2);
|
|
34
|
-
|
|
35
|
-
// Color mapping
|
|
36
|
-
const colorMap: Record<string, string> = {
|
|
37
|
-
primary: 'var(--pui-color-primary)',
|
|
38
|
-
secondary: 'var(--pui-color-secondary)',
|
|
39
|
-
accent: 'var(--pui-color-accent)',
|
|
40
|
-
success: 'var(--pui-color-success)',
|
|
41
|
-
warning: 'var(--pui-color-warning)',
|
|
42
|
-
danger: 'var(--pui-color-danger)'
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const strokeColor = $derived(colorMap[color] || color);
|
|
46
|
-
|
|
47
|
-
// Calculate sections or single value
|
|
48
|
-
const computedSections = $derived.by(() => {
|
|
49
|
-
if (sections.length > 0) {
|
|
50
|
-
return sections;
|
|
51
|
-
}
|
|
52
|
-
return [{ value: Math.min(100, Math.max(0, value)), color: strokeColor }];
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
// Calculate stroke dash arrays for each section
|
|
56
|
-
const sectionData = $derived.by(() => {
|
|
57
|
-
let offset = 0;
|
|
58
|
-
return computedSections.map((section) => {
|
|
59
|
-
const sectionLength = (section.value / 100) * circumference;
|
|
60
|
-
const data = {
|
|
61
|
-
dashArray: `${sectionLength} ${circumference - sectionLength}`,
|
|
62
|
-
dashOffset: -offset + circumference * 0.25, // Start from top
|
|
63
|
-
color: colorMap[section.color] || section.color
|
|
64
|
-
};
|
|
65
|
-
offset += sectionLength;
|
|
66
|
-
return data;
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
</script>
|
|
70
|
-
|
|
71
|
-
<div class="ring-progress {classes}" style="width: {size}px; height: {size}px;">
|
|
72
|
-
<svg width={size} height={size} viewBox="0 0 {size} {size}">
|
|
73
|
-
<!-- Background circle -->
|
|
74
|
-
<circle
|
|
75
|
-
cx={center}
|
|
76
|
-
cy={center}
|
|
77
|
-
r={radius}
|
|
78
|
-
fill="none"
|
|
79
|
-
stroke="var(--ring-progress-bg, var(--pui-color-gray-200))"
|
|
80
|
-
stroke-width={thickness}
|
|
81
|
-
/>
|
|
82
|
-
<!-- Progress sections -->
|
|
83
|
-
{#each sectionData as section}
|
|
84
|
-
<circle
|
|
85
|
-
cx={center}
|
|
86
|
-
cy={center}
|
|
87
|
-
r={radius}
|
|
88
|
-
fill="none"
|
|
89
|
-
stroke={section.color}
|
|
90
|
-
stroke-width={thickness}
|
|
91
|
-
stroke-dasharray={section.dashArray}
|
|
92
|
-
stroke-dashoffset={section.dashOffset}
|
|
93
|
-
stroke-linecap={roundCaps ? 'round' : 'butt'}
|
|
94
|
-
class="progress-ring"
|
|
95
|
-
/>
|
|
96
|
-
{/each}
|
|
97
|
-
</svg>
|
|
98
|
-
{#if label}
|
|
99
|
-
<div class="ring-label">
|
|
100
|
-
{@render label()}
|
|
101
|
-
</div>
|
|
102
|
-
{/if}
|
|
103
|
-
</div>
|
|
104
|
-
|
|
105
|
-
<style>
|
|
106
|
-
.ring-progress {
|
|
107
|
-
position: relative;
|
|
108
|
-
display: inline-flex;
|
|
109
|
-
align-items: center;
|
|
110
|
-
justify-content: center;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
:global(.dark) .ring-progress {
|
|
114
|
-
--ring-progress-bg: var(--pui-color-dark-border);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
svg {
|
|
118
|
-
transform: rotate(-90deg);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
.progress-ring {
|
|
122
|
-
transition:
|
|
123
|
-
stroke-dasharray var(--pui-transition-slow) var(--pui-ease-out),
|
|
124
|
-
stroke-dashoffset var(--pui-transition-slow) var(--pui-ease-out);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
.ring-label {
|
|
128
|
-
position: absolute;
|
|
129
|
-
top: 50%;
|
|
130
|
-
left: 50%;
|
|
131
|
-
transform: translate(-50%, -50%);
|
|
132
|
-
text-align: center;
|
|
133
|
-
font-size: var(--pui-font-size-lg);
|
|
134
|
-
font-weight: var(--pui-font-weight-semibold);
|
|
135
|
-
color: var(--pui-text-primary);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
:global(.dark) .ring-label {
|
|
139
|
-
color: var(--pui-color-gray-100);
|
|
140
|
-
}
|
|
141
|
-
</style>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
|
|
4
|
+
interface Section {
|
|
5
|
+
value: number;
|
|
6
|
+
color: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface Props {
|
|
10
|
+
value?: number;
|
|
11
|
+
size?: number;
|
|
12
|
+
thickness?: number;
|
|
13
|
+
roundCaps?: boolean;
|
|
14
|
+
color?: 'primary' | 'secondary' | 'accent' | 'success' | 'warning' | 'danger' | string;
|
|
15
|
+
sections?: Section[];
|
|
16
|
+
label?: Snippet;
|
|
17
|
+
class?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
let {
|
|
21
|
+
value = 0,
|
|
22
|
+
size = 120,
|
|
23
|
+
thickness = 8,
|
|
24
|
+
roundCaps = true,
|
|
25
|
+
color = 'primary',
|
|
26
|
+
sections = [],
|
|
27
|
+
label,
|
|
28
|
+
class: classes = ''
|
|
29
|
+
}: Props = $props();
|
|
30
|
+
|
|
31
|
+
const radius = $derived((size - thickness) / 2);
|
|
32
|
+
const circumference = $derived(2 * Math.PI * radius);
|
|
33
|
+
const center = $derived(size / 2);
|
|
34
|
+
|
|
35
|
+
// Color mapping
|
|
36
|
+
const colorMap: Record<string, string> = {
|
|
37
|
+
primary: 'var(--pui-color-primary)',
|
|
38
|
+
secondary: 'var(--pui-color-secondary)',
|
|
39
|
+
accent: 'var(--pui-color-accent)',
|
|
40
|
+
success: 'var(--pui-color-success)',
|
|
41
|
+
warning: 'var(--pui-color-warning)',
|
|
42
|
+
danger: 'var(--pui-color-danger)'
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const strokeColor = $derived(colorMap[color] || color);
|
|
46
|
+
|
|
47
|
+
// Calculate sections or single value
|
|
48
|
+
const computedSections = $derived.by(() => {
|
|
49
|
+
if (sections.length > 0) {
|
|
50
|
+
return sections;
|
|
51
|
+
}
|
|
52
|
+
return [{ value: Math.min(100, Math.max(0, value)), color: strokeColor }];
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// Calculate stroke dash arrays for each section
|
|
56
|
+
const sectionData = $derived.by(() => {
|
|
57
|
+
let offset = 0;
|
|
58
|
+
return computedSections.map((section) => {
|
|
59
|
+
const sectionLength = (section.value / 100) * circumference;
|
|
60
|
+
const data = {
|
|
61
|
+
dashArray: `${sectionLength} ${circumference - sectionLength}`,
|
|
62
|
+
dashOffset: -offset + circumference * 0.25, // Start from top
|
|
63
|
+
color: colorMap[section.color] || section.color
|
|
64
|
+
};
|
|
65
|
+
offset += sectionLength;
|
|
66
|
+
return data;
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
</script>
|
|
70
|
+
|
|
71
|
+
<div class="ring-progress {classes}" style="width: {size}px; height: {size}px;">
|
|
72
|
+
<svg width={size} height={size} viewBox="0 0 {size} {size}">
|
|
73
|
+
<!-- Background circle -->
|
|
74
|
+
<circle
|
|
75
|
+
cx={center}
|
|
76
|
+
cy={center}
|
|
77
|
+
r={radius}
|
|
78
|
+
fill="none"
|
|
79
|
+
stroke="var(--ring-progress-bg, var(--pui-color-gray-200))"
|
|
80
|
+
stroke-width={thickness}
|
|
81
|
+
/>
|
|
82
|
+
<!-- Progress sections -->
|
|
83
|
+
{#each sectionData as section}
|
|
84
|
+
<circle
|
|
85
|
+
cx={center}
|
|
86
|
+
cy={center}
|
|
87
|
+
r={radius}
|
|
88
|
+
fill="none"
|
|
89
|
+
stroke={section.color}
|
|
90
|
+
stroke-width={thickness}
|
|
91
|
+
stroke-dasharray={section.dashArray}
|
|
92
|
+
stroke-dashoffset={section.dashOffset}
|
|
93
|
+
stroke-linecap={roundCaps ? 'round' : 'butt'}
|
|
94
|
+
class="progress-ring"
|
|
95
|
+
/>
|
|
96
|
+
{/each}
|
|
97
|
+
</svg>
|
|
98
|
+
{#if label}
|
|
99
|
+
<div class="ring-label">
|
|
100
|
+
{@render label()}
|
|
101
|
+
</div>
|
|
102
|
+
{/if}
|
|
103
|
+
</div>
|
|
104
|
+
|
|
105
|
+
<style>
|
|
106
|
+
.ring-progress {
|
|
107
|
+
position: relative;
|
|
108
|
+
display: inline-flex;
|
|
109
|
+
align-items: center;
|
|
110
|
+
justify-content: center;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
:global(.dark) .ring-progress {
|
|
114
|
+
--ring-progress-bg: var(--pui-color-dark-border);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
svg {
|
|
118
|
+
transform: rotate(-90deg);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.progress-ring {
|
|
122
|
+
transition:
|
|
123
|
+
stroke-dasharray var(--pui-transition-slow) var(--pui-ease-out),
|
|
124
|
+
stroke-dashoffset var(--pui-transition-slow) var(--pui-ease-out);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.ring-label {
|
|
128
|
+
position: absolute;
|
|
129
|
+
top: 50%;
|
|
130
|
+
left: 50%;
|
|
131
|
+
transform: translate(-50%, -50%);
|
|
132
|
+
text-align: center;
|
|
133
|
+
font-size: var(--pui-font-size-lg);
|
|
134
|
+
font-weight: var(--pui-font-weight-semibold);
|
|
135
|
+
color: var(--pui-text-primary);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
:global(.dark) .ring-label {
|
|
139
|
+
color: var(--pui-color-gray-100);
|
|
140
|
+
}
|
|
141
|
+
</style>
|