solid-tom-ui 1.0.10 → 1.0.14
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/README.md +246 -246
- package/dist/README.md +246 -246
- package/dist/components/avatar/avatar.js.map +1 -1
- package/dist/components/badge/badge.js.map +1 -1
- package/dist/components/breadcrumb/breadcrumb.js.map +1 -1
- package/dist/components/button/button.js.map +1 -1
- package/dist/components/carousel/carousel.js.map +1 -1
- package/dist/components/chat-bubble/chatBubble.js.map +1 -1
- package/dist/components/checkbox/checkbox.js.map +1 -1
- package/dist/components/collapse/collapse.js.map +1 -1
- package/dist/components/context-menu/context-menu.js.map +1 -1
- package/dist/components/context-menu/context-menu.store.js.map +1 -1
- package/dist/components/divider/divider.js.map +1 -1
- package/dist/components/dropdown/dropdown.js.map +1 -1
- package/dist/components/dropdown/dropdown.store.js.map +1 -1
- package/dist/components/float-button/float-button.js.map +1 -1
- package/dist/components/hover-3d-image/hover-3d-image.js.map +1 -1
- package/dist/components/image-preview/image-preview.js.map +1 -1
- package/dist/components/input/input.js.map +1 -1
- package/dist/components/input/input.utils.js.map +1 -1
- package/dist/components/input/variants/input-color.js.map +1 -1
- package/dist/components/input/variants/input-date.js.map +1 -1
- package/dist/components/input/variants/input-number.d.ts.map +1 -1
- package/dist/components/input/variants/input-number.js +1 -1
- package/dist/components/input/variants/input-number.js.map +1 -1
- package/dist/components/input/variants/input-otp.js.map +1 -1
- package/dist/components/input/variants/input-password.js.map +1 -1
- package/dist/components/input/variants/input-radio.js.map +1 -1
- package/dist/components/input/variants/input-range.js.map +1 -1
- package/dist/components/input/variants/input-text.d.ts.map +1 -1
- package/dist/components/input/variants/input-text.js +1 -1
- package/dist/components/input/variants/input-text.js.map +1 -1
- package/dist/components/input/variants/input-textarea.js.map +1 -1
- package/dist/components/loading/loading.js.map +1 -1
- package/dist/components/mansory/mansory.js.map +1 -1
- package/dist/components/menu/menu.js.map +1 -1
- package/dist/components/menu/menu.types.d.ts +2 -3
- package/dist/components/menu/menu.types.d.ts.map +1 -1
- package/dist/components/modal/modal.js.map +1 -1
- package/dist/components/modal/modalContext.js.map +1 -1
- package/dist/components/pagination/pagination.js.map +1 -1
- package/dist/components/progress-bar/progress-bar.js.map +1 -1
- package/dist/components/qr-code/qr-code.js.map +1 -1
- package/dist/components/select/select.js.map +1 -1
- package/dist/components/select-zone/select-zone.js.map +1 -1
- package/dist/components/skeleton/skeleton.js.map +1 -1
- package/dist/components/slider/slider.js.map +1 -1
- package/dist/components/splitter/splitter.js.map +1 -1
- package/dist/components/steps/steps.js.map +1 -1
- package/dist/components/swap/swap.js.map +1 -1
- package/dist/components/switch/switch.js.map +1 -1
- package/dist/components/tab/tab.js.map +1 -1
- package/dist/components/table/table.js.map +1 -1
- package/dist/components/timeline/timeline.js.map +1 -1
- package/dist/components/toast/icons/ErrorIcon.js.map +1 -1
- package/dist/components/toast/icons/IconCircle.js.map +1 -1
- package/dist/components/toast/icons/InfoIcon.js.map +1 -1
- package/dist/components/toast/icons/LoaderIcon.js.map +1 -1
- package/dist/components/toast/icons/SuccessIcon.js.map +1 -1
- package/dist/components/toast/icons/WarningIcon.js.map +1 -1
- package/dist/components/toast/toast.js.map +1 -1
- package/dist/components/toast/toast.store.js.map +1 -1
- package/dist/components/tooltip/tooltip.js.map +1 -1
- package/dist/components/tour/tour.js.map +1 -1
- package/dist/components/upload/upload.js.map +1 -1
- package/dist/components/z-index/z-index.context.js.map +1 -1
- package/dist/components/z-index/z-index.js.map +1 -1
- package/dist/components/z-index/z-index.store.js.map +1 -1
- package/dist/components/z-index/z-index.types.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/skill/avatar.skill.md.txt +255 -255
- package/dist/skill/badge.skill.md.txt +223 -223
- package/dist/skill/breadcrumb.skill.md.txt +177 -177
- package/dist/skill/button.skill.md.txt +198 -198
- package/dist/skill/carousel.skill.md.txt +406 -406
- package/dist/skill/chat-bubble.skill.md.txt +342 -342
- package/dist/skill/checkbox.skill.md.txt +326 -326
- package/dist/skill/code-preview.skill.md.txt +240 -240
- package/dist/skill/collapse.skill.md.txt +329 -329
- package/dist/skill/context-menu.skill.md.txt +233 -233
- package/dist/skill/diff.skill.md.txt +244 -244
- package/dist/skill/divider.skill.md.txt +151 -151
- package/dist/skill/doc.skill.md.txt +191 -191
- package/dist/skill/drawer.skill.md.txt +157 -157
- package/dist/skill/dropdown.skill.md.txt +198 -198
- package/dist/skill/float-button.skill.md.txt +315 -315
- package/dist/skill/hover-3d-image.skill.md.txt +120 -120
- package/dist/skill/iframe.skill.md.txt +114 -114
- package/dist/skill/image-preview.skill.md.txt +162 -162
- package/dist/skill/indicator.skill.md.txt +60 -60
- package/dist/skill/input.skill.md.txt +489 -489
- package/dist/skill/loading.skill.md.txt +127 -127
- package/dist/skill/menu.skill.md.txt +476 -476
- package/dist/skill/modal.skill.md.txt +359 -359
- package/dist/skill/pagination.skill.md.txt +405 -405
- package/dist/skill/progress-bar.skill.md.txt +207 -207
- package/dist/skill/qr-code.skill.md.txt +136 -136
- package/dist/skill/rating.skill.md.txt +167 -167
- package/dist/skill/select-zone.skill.md.txt +93 -93
- package/dist/skill/select.skill.md.txt +663 -663
- package/dist/skill/skeleton.skill.md.txt +192 -192
- package/dist/skill/slider.skill.md.txt +404 -404
- package/dist/skill/splitter.skill.md.txt +411 -411
- package/dist/skill/steps.skill.md.txt +264 -264
- package/dist/skill/swap.skill.md.txt +139 -139
- package/dist/skill/switch.skill.md.txt +191 -191
- package/dist/skill/tab.skill.md.txt +484 -484
- package/dist/skill/table.example.header.md.txt +666 -666
- package/dist/skill/table.skill.md.txt +1407 -1407
- package/dist/skill/text-rotate.skill.md.txt +186 -186
- package/dist/skill/timeline.skill.md.txt +247 -247
- package/dist/skill/toast.skill.md.txt +531 -531
- package/dist/skill/tooltip.skill.md.txt +222 -222
- package/dist/skill/tour.skill.md.txt +156 -156
- package/dist/skill/upload.skill.md.txt +358 -358
- package/dist/utils/cn.js.map +1 -1
- package/dist/utils/element-tracker.js.map +1 -1
- package/dist/utils/helper.js.map +1 -1
- package/dist/utils/hoc.js.map +1 -1
- package/package.json +132 -133
|
@@ -1,207 +1,207 @@
|
|
|
1
|
-
## COMPONENT IDENTITY
|
|
2
|
-
- **Import**: `import { progressBar } from 'solid-tom-ui';`
|
|
3
|
-
- **Export**: `progressBar` (singleton object), `ProgressBarOptions`, `ProgressBarAPI` (type exports)
|
|
4
|
-
- **Framework**: SolidJS
|
|
5
|
-
- **Purpose**: Fixed-position, imperative page-load indicator (NProgress-inspired) — singleton API; do NOT render in JSX; mounts itself into `document.body` on first use
|
|
6
|
-
|
|
7
|
-
## API
|
|
8
|
-
|
|
9
|
-
```ts
|
|
10
|
-
interface ProgressBarAPI {
|
|
11
|
-
start(options?: ProgressBarOptions): void;
|
|
12
|
-
dismiss(): void;
|
|
13
|
-
}
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
### `progressBar.start(options?)`
|
|
17
|
-
|
|
18
|
-
Starts the progress animation immediately. The bar begins at 0% and creeps toward 99% using an exponential-decay speed curve — it **never reaches 100% on its own**. Only `dismiss()` can complete it.
|
|
19
|
-
|
|
20
|
-
If a bar is already running, calling `start()` again **replaces it immediately** — the old instance is destroyed synchronously with no animation.
|
|
21
|
-
|
|
22
|
-
### `progressBar.dismiss()`
|
|
23
|
-
|
|
24
|
-
Snaps the bar to 100%, waits 80ms, then fades it out over `fadeOutDuration` ms before removing it from the DOM. Safe to call when no bar is running (no-op).
|
|
25
|
-
|
|
26
|
-
---
|
|
27
|
-
|
|
28
|
-
## Options
|
|
29
|
-
|
|
30
|
-
| Option | Type | Default | Description |
|
|
31
|
-
| ----------------- | --------------------------------- | ----------------- | ------------------------------------------------------------------------ |
|
|
32
|
-
| `color` | `BaseColorProps \| (string & {})` | `'primary'` | Bar color. Accepts any `BaseColorProps` token or a raw CSS color string |
|
|
33
|
-
| `height` | `number` | `3` | Bar height in pixels |
|
|
34
|
-
| `shimmer` | `boolean` | `true` | Animated shimmer sweep across the bar |
|
|
35
|
-
| `rounded` | `boolean` | `true` | Rounded leading tip of the bar |
|
|
36
|
-
| `zIndex` | `number` | `9999` | CSS `z-index` of the bar container |
|
|
37
|
-
| `fadeOutDuration` | `number` | `300` | Fade-out duration in milliseconds after `dismiss()` |
|
|
38
|
-
| `position` | `'top' \| 'bottom'` | `'top'` | Whether the bar sticks to the top or bottom of the viewport |
|
|
39
|
-
| `direction` | `'leftToRight' \| 'rightToLeft'` | `'leftToRight'` | Fill direction of the bar |
|
|
40
|
-
|
|
41
|
-
---
|
|
42
|
-
|
|
43
|
-
## Usage Examples
|
|
44
|
-
|
|
45
|
-
### Basic — manual start and dismiss
|
|
46
|
-
|
|
47
|
-
```ts
|
|
48
|
-
import { progressBar } from 'solid-tom-ui';
|
|
49
|
-
|
|
50
|
-
progressBar.start();
|
|
51
|
-
|
|
52
|
-
// When work is done:
|
|
53
|
-
progressBar.dismiss();
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
### Async operation (network request)
|
|
57
|
-
|
|
58
|
-
```ts
|
|
59
|
-
progressBar.start({ color: 'primary', height: 3 });
|
|
60
|
-
|
|
61
|
-
try {
|
|
62
|
-
await fetchData();
|
|
63
|
-
} finally {
|
|
64
|
-
progressBar.dismiss();
|
|
65
|
-
}
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
### Custom color
|
|
69
|
-
|
|
70
|
-
```ts
|
|
71
|
-
// Any BaseColorProps value is valid
|
|
72
|
-
progressBar.start({ color: 'success' });
|
|
73
|
-
progressBar.start({ color: 'error' });
|
|
74
|
-
progressBar.start({ color: 'warning' });
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
### Full customization
|
|
78
|
-
|
|
79
|
-
```ts
|
|
80
|
-
progressBar.start({
|
|
81
|
-
color: 'accent',
|
|
82
|
-
height: 5, // thicker bar
|
|
83
|
-
shimmer: false, // disable shimmer
|
|
84
|
-
rounded: false, // square tip
|
|
85
|
-
zIndex: 10000,
|
|
86
|
-
fadeOutDuration: 500, // slower fade
|
|
87
|
-
position: 'bottom', // pin to bottom
|
|
88
|
-
direction: 'rightToLeft',
|
|
89
|
-
});
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
### Multiple rapid starts — only the last one wins
|
|
93
|
-
|
|
94
|
-
```ts
|
|
95
|
-
progressBar.start({ color: 'info' });
|
|
96
|
-
setTimeout(() => progressBar.start({ color: 'warning' }), 300);
|
|
97
|
-
setTimeout(() => progressBar.start({ color: 'success' }), 600);
|
|
98
|
-
// Result: only the success bar remains — previous ones are destroyed immediately
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
### Router integration (SolidJS Router)
|
|
102
|
-
|
|
103
|
-
```ts
|
|
104
|
-
import { useBeforeLeave, useLocation } from '@solidjs/router';
|
|
105
|
-
import { createEffect, on } from 'solid-js';
|
|
106
|
-
|
|
107
|
-
// In your root component:
|
|
108
|
-
const location = useLocation();
|
|
109
|
-
|
|
110
|
-
createEffect(on(() => location.pathname, () => {
|
|
111
|
-
progressBar.start();
|
|
112
|
-
}));
|
|
113
|
-
|
|
114
|
-
// After route resolves / data loads:
|
|
115
|
-
progressBar.dismiss();
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
---
|
|
119
|
-
|
|
120
|
-
## Animation Behavior
|
|
121
|
-
|
|
122
|
-
### Auto-advance (start → 99%)
|
|
123
|
-
|
|
124
|
-
Uses a `requestAnimationFrame` loop with an exponential-decay speed model:
|
|
125
|
-
|
|
126
|
-
```
|
|
127
|
-
speed = 28 * (0.88 ^ (elapsed_seconds * 2.5)) // % per second
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
- Starts fast (~28%/s), then slows exponentially.
|
|
131
|
-
- Asymptotes at **99%** — never auto-completes.
|
|
132
|
-
- This mirrors real page-load UX: responsive at first, then conveys "still working."
|
|
133
|
-
|
|
134
|
-
### Completion sequence (dismiss)
|
|
135
|
-
|
|
136
|
-
```
|
|
137
|
-
setProgress(100)
|
|
138
|
-
→ wait 80ms
|
|
139
|
-
→ setOpacity(0), transition = fadeOutDuration ms
|
|
140
|
-
→ after fadeOutDuration ms → dispose() + remove slot from DOM
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
### Instance replacement
|
|
144
|
-
|
|
145
|
-
When `start()` is called while a bar is already running, the old instance is destroyed **synchronously** (no animation) and the new instance starts from 0%.
|
|
146
|
-
|
|
147
|
-
---
|
|
148
|
-
|
|
149
|
-
## DOM Structure
|
|
150
|
-
|
|
151
|
-
The component self-injects this into `<body>` on the first `start()` call:
|
|
152
|
-
|
|
153
|
-
```
|
|
154
|
-
document.body
|
|
155
|
-
└── <div id="sui-progress-bar-container">
|
|
156
|
-
└── <div> (slot per instance)
|
|
157
|
-
└── <ProgressBarInner> (SolidJS render)
|
|
158
|
-
└── <div style="position:fixed; top|bottom:0; left:0; right:0; pointer-events:none">
|
|
159
|
-
└── <div style="width:X%; height:Ypx"> (the bar)
|
|
160
|
-
└── <div class="animate-[shimmer...]"> (optional shimmer)
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
The container (`#sui-progress-bar-container`) persists for the lifetime of the page. Each `start()` call appends a new slot; it is removed after `dismiss()` completes.
|
|
164
|
-
|
|
165
|
-
---
|
|
166
|
-
|
|
167
|
-
## Styling Notes
|
|
168
|
-
|
|
169
|
-
- Bar color uses `getColor(color)` → `bg-(--color)` via DaisyUI CSS variables.
|
|
170
|
-
- Shimmer: `bg-linear-to-r from-transparent via-white/40 to-transparent` with `animate-[shimmer_1.2s_ease-in-out_infinite]`.
|
|
171
|
-
- Rounded tip: `border-radius: 0 9999px 9999px 0` (leading-end only) for `leftToRight`; mirrored for `rightToLeft`.
|
|
172
|
-
- Width transition: `width 0.06s linear` for smooth per-frame updates.
|
|
173
|
-
|
|
174
|
-
---
|
|
175
|
-
|
|
176
|
-
## Edge Cases
|
|
177
|
-
|
|
178
|
-
| Scenario | Behavior |
|
|
179
|
-
| --- | --- |
|
|
180
|
-
| `dismiss()` with no running bar | No-op — safe to call unconditionally |
|
|
181
|
-
| Multiple `dismiss()` calls in a row | No-op after the first — `activeDisposers` is empty |
|
|
182
|
-
| `start()` immediately after `dismiss()` | Old instance destroyed synchronously (no fade), new bar starts from 0% |
|
|
183
|
-
| Bar stuck at 99% | Only `dismiss()` can push it to 100% — always call it in a `finally` block |
|
|
184
|
-
| Calling `start()` before DOM exists | Will throw — avoid calling at module top-level in SSR environments |
|
|
185
|
-
|
|
186
|
-
---
|
|
187
|
-
|
|
188
|
-
## Do / Don't
|
|
189
|
-
|
|
190
|
-
**Do**
|
|
191
|
-
- Call `progressBar.start()` at the beginning of any async operation (navigation, fetch, upload).
|
|
192
|
-
- Always call `progressBar.dismiss()` in a `finally` block to guarantee the bar completes.
|
|
193
|
-
- Use `color: 'error'` to signal a failed operation before dismissing.
|
|
194
|
-
- Import from the barrel: `import { progressBar } from 'solid-tom-ui'`.
|
|
195
|
-
|
|
196
|
-
**Don't**
|
|
197
|
-
- Don't place `<ProgressBar />` in JSX — there is no JSX API. Use the imperative calls only.
|
|
198
|
-
- Don't rely on multiple bars running simultaneously — `start()` always clears previous instances first.
|
|
199
|
-
- Don't pass a Tailwind class name to `color` — it expects a `BaseColorProps` token or a CSS color value.
|
|
200
|
-
- Don't import `ProgressBarExample` in production — it is for documentation/demo only.
|
|
201
|
-
---
|
|
202
|
-
|
|
203
|
-
## Component Conventions
|
|
204
|
-
|
|
205
|
-
> **CSS encoding**: internal CSS classes use short encoded names (e.g. `pb01`, `pb02`) per project convention.
|
|
206
|
-
|
|
207
|
-
> **Unique IDs**: if this component needs to generate HTML `id` attributes, always use `createUniqueId()` from `solid-js` — never `Math.random()` or `Date.now()`.
|
|
1
|
+
## COMPONENT IDENTITY
|
|
2
|
+
- **Import**: `import { progressBar } from 'solid-tom-ui';`
|
|
3
|
+
- **Export**: `progressBar` (singleton object), `ProgressBarOptions`, `ProgressBarAPI` (type exports)
|
|
4
|
+
- **Framework**: SolidJS
|
|
5
|
+
- **Purpose**: Fixed-position, imperative page-load indicator (NProgress-inspired) — singleton API; do NOT render in JSX; mounts itself into `document.body` on first use
|
|
6
|
+
|
|
7
|
+
## API
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
interface ProgressBarAPI {
|
|
11
|
+
start(options?: ProgressBarOptions): void;
|
|
12
|
+
dismiss(): void;
|
|
13
|
+
}
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
### `progressBar.start(options?)`
|
|
17
|
+
|
|
18
|
+
Starts the progress animation immediately. The bar begins at 0% and creeps toward 99% using an exponential-decay speed curve — it **never reaches 100% on its own**. Only `dismiss()` can complete it.
|
|
19
|
+
|
|
20
|
+
If a bar is already running, calling `start()` again **replaces it immediately** — the old instance is destroyed synchronously with no animation.
|
|
21
|
+
|
|
22
|
+
### `progressBar.dismiss()`
|
|
23
|
+
|
|
24
|
+
Snaps the bar to 100%, waits 80ms, then fades it out over `fadeOutDuration` ms before removing it from the DOM. Safe to call when no bar is running (no-op).
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Options
|
|
29
|
+
|
|
30
|
+
| Option | Type | Default | Description |
|
|
31
|
+
| ----------------- | --------------------------------- | ----------------- | ------------------------------------------------------------------------ |
|
|
32
|
+
| `color` | `BaseColorProps \| (string & {})` | `'primary'` | Bar color. Accepts any `BaseColorProps` token or a raw CSS color string |
|
|
33
|
+
| `height` | `number` | `3` | Bar height in pixels |
|
|
34
|
+
| `shimmer` | `boolean` | `true` | Animated shimmer sweep across the bar |
|
|
35
|
+
| `rounded` | `boolean` | `true` | Rounded leading tip of the bar |
|
|
36
|
+
| `zIndex` | `number` | `9999` | CSS `z-index` of the bar container |
|
|
37
|
+
| `fadeOutDuration` | `number` | `300` | Fade-out duration in milliseconds after `dismiss()` |
|
|
38
|
+
| `position` | `'top' \| 'bottom'` | `'top'` | Whether the bar sticks to the top or bottom of the viewport |
|
|
39
|
+
| `direction` | `'leftToRight' \| 'rightToLeft'` | `'leftToRight'` | Fill direction of the bar |
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Usage Examples
|
|
44
|
+
|
|
45
|
+
### Basic — manual start and dismiss
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
import { progressBar } from 'solid-tom-ui';
|
|
49
|
+
|
|
50
|
+
progressBar.start();
|
|
51
|
+
|
|
52
|
+
// When work is done:
|
|
53
|
+
progressBar.dismiss();
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Async operation (network request)
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
progressBar.start({ color: 'primary', height: 3 });
|
|
60
|
+
|
|
61
|
+
try {
|
|
62
|
+
await fetchData();
|
|
63
|
+
} finally {
|
|
64
|
+
progressBar.dismiss();
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Custom color
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
// Any BaseColorProps value is valid
|
|
72
|
+
progressBar.start({ color: 'success' });
|
|
73
|
+
progressBar.start({ color: 'error' });
|
|
74
|
+
progressBar.start({ color: 'warning' });
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Full customization
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
progressBar.start({
|
|
81
|
+
color: 'accent',
|
|
82
|
+
height: 5, // thicker bar
|
|
83
|
+
shimmer: false, // disable shimmer
|
|
84
|
+
rounded: false, // square tip
|
|
85
|
+
zIndex: 10000,
|
|
86
|
+
fadeOutDuration: 500, // slower fade
|
|
87
|
+
position: 'bottom', // pin to bottom
|
|
88
|
+
direction: 'rightToLeft',
|
|
89
|
+
});
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Multiple rapid starts — only the last one wins
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
progressBar.start({ color: 'info' });
|
|
96
|
+
setTimeout(() => progressBar.start({ color: 'warning' }), 300);
|
|
97
|
+
setTimeout(() => progressBar.start({ color: 'success' }), 600);
|
|
98
|
+
// Result: only the success bar remains — previous ones are destroyed immediately
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Router integration (SolidJS Router)
|
|
102
|
+
|
|
103
|
+
```ts
|
|
104
|
+
import { useBeforeLeave, useLocation } from '@solidjs/router';
|
|
105
|
+
import { createEffect, on } from 'solid-js';
|
|
106
|
+
|
|
107
|
+
// In your root component:
|
|
108
|
+
const location = useLocation();
|
|
109
|
+
|
|
110
|
+
createEffect(on(() => location.pathname, () => {
|
|
111
|
+
progressBar.start();
|
|
112
|
+
}));
|
|
113
|
+
|
|
114
|
+
// After route resolves / data loads:
|
|
115
|
+
progressBar.dismiss();
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## Animation Behavior
|
|
121
|
+
|
|
122
|
+
### Auto-advance (start → 99%)
|
|
123
|
+
|
|
124
|
+
Uses a `requestAnimationFrame` loop with an exponential-decay speed model:
|
|
125
|
+
|
|
126
|
+
```
|
|
127
|
+
speed = 28 * (0.88 ^ (elapsed_seconds * 2.5)) // % per second
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
- Starts fast (~28%/s), then slows exponentially.
|
|
131
|
+
- Asymptotes at **99%** — never auto-completes.
|
|
132
|
+
- This mirrors real page-load UX: responsive at first, then conveys "still working."
|
|
133
|
+
|
|
134
|
+
### Completion sequence (dismiss)
|
|
135
|
+
|
|
136
|
+
```
|
|
137
|
+
setProgress(100)
|
|
138
|
+
→ wait 80ms
|
|
139
|
+
→ setOpacity(0), transition = fadeOutDuration ms
|
|
140
|
+
→ after fadeOutDuration ms → dispose() + remove slot from DOM
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Instance replacement
|
|
144
|
+
|
|
145
|
+
When `start()` is called while a bar is already running, the old instance is destroyed **synchronously** (no animation) and the new instance starts from 0%.
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
## DOM Structure
|
|
150
|
+
|
|
151
|
+
The component self-injects this into `<body>` on the first `start()` call:
|
|
152
|
+
|
|
153
|
+
```
|
|
154
|
+
document.body
|
|
155
|
+
└── <div id="sui-progress-bar-container">
|
|
156
|
+
└── <div> (slot per instance)
|
|
157
|
+
└── <ProgressBarInner> (SolidJS render)
|
|
158
|
+
└── <div style="position:fixed; top|bottom:0; left:0; right:0; pointer-events:none">
|
|
159
|
+
└── <div style="width:X%; height:Ypx"> (the bar)
|
|
160
|
+
└── <div class="animate-[shimmer...]"> (optional shimmer)
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
The container (`#sui-progress-bar-container`) persists for the lifetime of the page. Each `start()` call appends a new slot; it is removed after `dismiss()` completes.
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## Styling Notes
|
|
168
|
+
|
|
169
|
+
- Bar color uses `getColor(color)` → `bg-(--color)` via DaisyUI CSS variables.
|
|
170
|
+
- Shimmer: `bg-linear-to-r from-transparent via-white/40 to-transparent` with `animate-[shimmer_1.2s_ease-in-out_infinite]`.
|
|
171
|
+
- Rounded tip: `border-radius: 0 9999px 9999px 0` (leading-end only) for `leftToRight`; mirrored for `rightToLeft`.
|
|
172
|
+
- Width transition: `width 0.06s linear` for smooth per-frame updates.
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## Edge Cases
|
|
177
|
+
|
|
178
|
+
| Scenario | Behavior |
|
|
179
|
+
| --- | --- |
|
|
180
|
+
| `dismiss()` with no running bar | No-op — safe to call unconditionally |
|
|
181
|
+
| Multiple `dismiss()` calls in a row | No-op after the first — `activeDisposers` is empty |
|
|
182
|
+
| `start()` immediately after `dismiss()` | Old instance destroyed synchronously (no fade), new bar starts from 0% |
|
|
183
|
+
| Bar stuck at 99% | Only `dismiss()` can push it to 100% — always call it in a `finally` block |
|
|
184
|
+
| Calling `start()` before DOM exists | Will throw — avoid calling at module top-level in SSR environments |
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
## Do / Don't
|
|
189
|
+
|
|
190
|
+
**Do**
|
|
191
|
+
- Call `progressBar.start()` at the beginning of any async operation (navigation, fetch, upload).
|
|
192
|
+
- Always call `progressBar.dismiss()` in a `finally` block to guarantee the bar completes.
|
|
193
|
+
- Use `color: 'error'` to signal a failed operation before dismissing.
|
|
194
|
+
- Import from the barrel: `import { progressBar } from 'solid-tom-ui'`.
|
|
195
|
+
|
|
196
|
+
**Don't**
|
|
197
|
+
- Don't place `<ProgressBar />` in JSX — there is no JSX API. Use the imperative calls only.
|
|
198
|
+
- Don't rely on multiple bars running simultaneously — `start()` always clears previous instances first.
|
|
199
|
+
- Don't pass a Tailwind class name to `color` — it expects a `BaseColorProps` token or a CSS color value.
|
|
200
|
+
- Don't import `ProgressBarExample` in production — it is for documentation/demo only.
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
## Component Conventions
|
|
204
|
+
|
|
205
|
+
> **CSS encoding**: internal CSS classes use short encoded names (e.g. `pb01`, `pb02`) per project convention.
|
|
206
|
+
|
|
207
|
+
> **Unique IDs**: if this component needs to generate HTML `id` attributes, always use `createUniqueId()` from `solid-js` — never `Math.random()` or `Date.now()`.
|