solid-tom-ui 1.0.11 → 1.0.15
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/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 +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,192 +1,192 @@
|
|
|
1
|
-
## COMPONENT IDENTITY
|
|
2
|
-
- **Import**: `import { Skeleton } from 'solid-tom-ui';`
|
|
3
|
-
- **Export**: `Skeleton` (named export), `SkeletonProps` (type export)
|
|
4
|
-
- **Framework**: SolidJS
|
|
5
|
-
- **Purpose**: Loading placeholder that replaces real content with an animated shimmer block; when `enabled` is `false`, transparently renders `children`
|
|
6
|
-
|
|
7
|
-
> Always **wrap** the real content inside `<Skeleton>` — do not render them side-by-side.
|
|
8
|
-
|
|
9
|
-
## Props — Discriminated Union
|
|
10
|
-
|
|
11
|
-
`SkeletonProps` is a **discriminated union** on the `type` field. The `type` prop is **required** and determines which other props are available.
|
|
12
|
-
|
|
13
|
-
### `type="layout"` — Preset complex layouts
|
|
14
|
-
|
|
15
|
-
```ts
|
|
16
|
-
{
|
|
17
|
-
type: 'layout';
|
|
18
|
-
variant?: LayoutVariant;
|
|
19
|
-
enabled: boolean;
|
|
20
|
-
}
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
### `type="shape"` — Preset simple shapes
|
|
24
|
-
|
|
25
|
-
```ts
|
|
26
|
-
{
|
|
27
|
-
type: 'shape';
|
|
28
|
-
variant?: ShapeVariant;
|
|
29
|
-
enabled: boolean;
|
|
30
|
-
}
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
### `type="custom"` — Fully custom via class
|
|
34
|
-
|
|
35
|
-
```ts
|
|
36
|
-
{
|
|
37
|
-
type: 'custom';
|
|
38
|
-
enabled: boolean;
|
|
39
|
-
class: string; // required — defines size, shape, and border radius
|
|
40
|
-
}
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
> **Note:** `class` is only available on `type="custom"`. `variant` is only available on `type="layout"` and `type="shape"`.
|
|
44
|
-
|
|
45
|
-
## `enabled` Prop
|
|
46
|
-
|
|
47
|
-
`enabled` is the loading toggle:
|
|
48
|
-
|
|
49
|
-
- `enabled={true}` → renders the skeleton placeholder
|
|
50
|
-
- `enabled={false}` → renders `children` (real content)
|
|
51
|
-
|
|
52
|
-
## Layout Variants
|
|
53
|
-
|
|
54
|
-
Used with `type="layout"`. Each variant renders a multi-element composition:
|
|
55
|
-
|
|
56
|
-
| Variant | Description |
|
|
57
|
-
| ----------------- | ---------------------------------------------------- |
|
|
58
|
-
| `cardImage` | Image block on top + title + 3 text lines below |
|
|
59
|
-
| `cardHorizontal` | Square thumbnail on the left + text lines on the right |
|
|
60
|
-
| `profile` | Circular avatar (centered) + name + description lines |
|
|
61
|
-
| `article` | Large title + subtitle + 5-line paragraph |
|
|
62
|
-
| `feedItem` | Small circular avatar on the left + 2 text lines |
|
|
63
|
-
| `stat` | Small label + large number + small sublabel |
|
|
64
|
-
|
|
65
|
-
## Shape Variants
|
|
66
|
-
|
|
67
|
-
Used with `type="shape"`. Each variant renders a single skeleton block:
|
|
68
|
-
|
|
69
|
-
| Variant | Dimensions |
|
|
70
|
-
| --------------- | --------------------------------- |
|
|
71
|
-
| `rectangle` | `h-32 w-full rounded-lg` |
|
|
72
|
-
| `square` | `size-32 rounded-lg` |
|
|
73
|
-
| `circle` | `size-16 rounded-full` |
|
|
74
|
-
| `textLine` | `h-4 w-full rounded` |
|
|
75
|
-
| `textParagraph` | 4 lines of varying width |
|
|
76
|
-
|
|
77
|
-
## Usage Examples
|
|
78
|
-
|
|
79
|
-
### Layout skeleton
|
|
80
|
-
|
|
81
|
-
```tsx
|
|
82
|
-
<Skeleton type="layout" variant="cardImage" enabled={isLoading()}>
|
|
83
|
-
{/* Real content rendered when enabled=false */}
|
|
84
|
-
<div class="flex flex-col gap-2">
|
|
85
|
-
<img src={post.image} class="h-40 w-full rounded-lg object-cover" />
|
|
86
|
-
<h2 class="font-semibold">{post.title}</h2>
|
|
87
|
-
<p class="text-sm text-base-content/70">{post.description}</p>
|
|
88
|
-
</div>
|
|
89
|
-
</Skeleton>
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
### Shape skeleton
|
|
93
|
-
|
|
94
|
-
```tsx
|
|
95
|
-
<Skeleton type="shape" variant="circle" enabled={isLoading()}>
|
|
96
|
-
<img src={user.avatar} class="size-16 rounded-full" alt={user.name} />
|
|
97
|
-
</Skeleton>
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
### Custom skeleton
|
|
101
|
-
|
|
102
|
-
The `class` prop is applied directly to a `<div class="skeleton ...">`. Define size, shape, and rounding:
|
|
103
|
-
|
|
104
|
-
```tsx
|
|
105
|
-
<Skeleton type="custom" enabled={isLoading()} class="h-6 w-32 rounded-full">
|
|
106
|
-
<span class="text-sm font-medium">{label}</span>
|
|
107
|
-
</Skeleton>
|
|
108
|
-
|
|
109
|
-
<Skeleton type="custom" enabled={isLoading()} class="size-20 rounded-2xl">
|
|
110
|
-
<img src={thumbnail} class="size-20 rounded-2xl" />
|
|
111
|
-
</Skeleton>
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
### Async data loading pattern
|
|
115
|
-
|
|
116
|
-
```tsx
|
|
117
|
-
const [data, setData] = createSignal(null);
|
|
118
|
-
const [loading, setLoading] = createSignal(true);
|
|
119
|
-
|
|
120
|
-
onMount(async () => {
|
|
121
|
-
const result = await fetchUser();
|
|
122
|
-
setData(result);
|
|
123
|
-
setLoading(false);
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
// In JSX:
|
|
127
|
-
<Skeleton type="layout" variant="profile" enabled={loading()}>
|
|
128
|
-
<Show when={data()}>
|
|
129
|
-
{user => (
|
|
130
|
-
<div class="flex flex-col items-center gap-2">
|
|
131
|
-
<img src={user().avatar} class="size-20 rounded-full" />
|
|
132
|
-
<p class="font-semibold">{user().name}</p>
|
|
133
|
-
</div>
|
|
134
|
-
)}
|
|
135
|
-
</Show>
|
|
136
|
-
</Skeleton>
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
### Feed list with multiple skeleton items
|
|
140
|
-
|
|
141
|
-
```tsx
|
|
142
|
-
<For each={loading() ? Array(5).fill(null) : posts()}>
|
|
143
|
-
{(post, i) => (
|
|
144
|
-
<Skeleton type="layout" variant="feedItem" enabled={loading()}>
|
|
145
|
-
<FeedItem post={post} />
|
|
146
|
-
</Skeleton>
|
|
147
|
-
)}
|
|
148
|
-
</For>
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
## Animation & Styling
|
|
152
|
-
|
|
153
|
-
The `.skeleton` class (from `skeleton.daisy.css`) applies:
|
|
154
|
-
- Background: `var(--color-base-300)`
|
|
155
|
-
- Animated sweep: a `105deg` gradient from `base-100` that slides across via `background-position-x` at `1.8s ease-in-out infinite`
|
|
156
|
-
- Respects `prefers-reduced-motion`: slows animation to `15s` transition duration when reduced motion is preferred
|
|
157
|
-
- Default border radius: `var(--radius-box)`
|
|
158
|
-
|
|
159
|
-
The animation is purely CSS — no JavaScript timers involved.
|
|
160
|
-
|
|
161
|
-
## Render Structure
|
|
162
|
-
|
|
163
|
-
```
|
|
164
|
-
<Show when={enabled} fallback={children}>
|
|
165
|
-
{type === 'custom'
|
|
166
|
-
? <div class={cn('skeleton', class)} />
|
|
167
|
-
: <SkeletonDisplay type variant />
|
|
168
|
-
}
|
|
169
|
-
</Show>
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
When `enabled=true`, `children` are never mounted. When `enabled=false`, the skeleton is never mounted. There is no overlap.
|
|
173
|
-
|
|
174
|
-
## Class Slots
|
|
175
|
-
|
|
176
|
-
`Skeleton` uses `class` only for `type="custom"` (defines size + shape of the placeholder div). For `type="layout"` and `type="shape"`, there is no `class` prop — the shape is fully determined by `variant`.
|
|
177
|
-
|
|
178
|
-
No `Partial<Record<...>>` slot object — this component renders preset layouts without sub-element targeting.
|
|
179
|
-
|
|
180
|
-
> **CSS encoding**: internal CSS classes use short encoded names (e.g. `sk01`, `sk02`) per project convention.
|
|
181
|
-
|
|
182
|
-
## Common Mistakes
|
|
183
|
-
|
|
184
|
-
| Mistake | Fix |
|
|
185
|
-
| --- | --- |
|
|
186
|
-
| Using `type="custom"` without `class` | `class` is required for `type="custom"` — TypeScript will error |
|
|
187
|
-
| Placing real content alongside Skeleton | Wrap real content **inside** Skeleton as `children` |
|
|
188
|
-
| Omitting `type` prop | `type` is required — one of `'layout'`, `'shape'`, `'custom'` |
|
|
189
|
-
| Using `variant` with `type="custom"` | `variant` is not available on `type="custom"` — use `class` instead |
|
|
190
|
-
| Expecting skeleton animation in reduced-motion mode | Animation slows to ~15s; design should still look acceptable statically |
|
|
191
|
-
|
|
192
|
-
> **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 { Skeleton } from 'solid-tom-ui';`
|
|
3
|
+
- **Export**: `Skeleton` (named export), `SkeletonProps` (type export)
|
|
4
|
+
- **Framework**: SolidJS
|
|
5
|
+
- **Purpose**: Loading placeholder that replaces real content with an animated shimmer block; when `enabled` is `false`, transparently renders `children`
|
|
6
|
+
|
|
7
|
+
> Always **wrap** the real content inside `<Skeleton>` — do not render them side-by-side.
|
|
8
|
+
|
|
9
|
+
## Props — Discriminated Union
|
|
10
|
+
|
|
11
|
+
`SkeletonProps` is a **discriminated union** on the `type` field. The `type` prop is **required** and determines which other props are available.
|
|
12
|
+
|
|
13
|
+
### `type="layout"` — Preset complex layouts
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
{
|
|
17
|
+
type: 'layout';
|
|
18
|
+
variant?: LayoutVariant;
|
|
19
|
+
enabled: boolean;
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### `type="shape"` — Preset simple shapes
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
{
|
|
27
|
+
type: 'shape';
|
|
28
|
+
variant?: ShapeVariant;
|
|
29
|
+
enabled: boolean;
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### `type="custom"` — Fully custom via class
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
{
|
|
37
|
+
type: 'custom';
|
|
38
|
+
enabled: boolean;
|
|
39
|
+
class: string; // required — defines size, shape, and border radius
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
> **Note:** `class` is only available on `type="custom"`. `variant` is only available on `type="layout"` and `type="shape"`.
|
|
44
|
+
|
|
45
|
+
## `enabled` Prop
|
|
46
|
+
|
|
47
|
+
`enabled` is the loading toggle:
|
|
48
|
+
|
|
49
|
+
- `enabled={true}` → renders the skeleton placeholder
|
|
50
|
+
- `enabled={false}` → renders `children` (real content)
|
|
51
|
+
|
|
52
|
+
## Layout Variants
|
|
53
|
+
|
|
54
|
+
Used with `type="layout"`. Each variant renders a multi-element composition:
|
|
55
|
+
|
|
56
|
+
| Variant | Description |
|
|
57
|
+
| ----------------- | ---------------------------------------------------- |
|
|
58
|
+
| `cardImage` | Image block on top + title + 3 text lines below |
|
|
59
|
+
| `cardHorizontal` | Square thumbnail on the left + text lines on the right |
|
|
60
|
+
| `profile` | Circular avatar (centered) + name + description lines |
|
|
61
|
+
| `article` | Large title + subtitle + 5-line paragraph |
|
|
62
|
+
| `feedItem` | Small circular avatar on the left + 2 text lines |
|
|
63
|
+
| `stat` | Small label + large number + small sublabel |
|
|
64
|
+
|
|
65
|
+
## Shape Variants
|
|
66
|
+
|
|
67
|
+
Used with `type="shape"`. Each variant renders a single skeleton block:
|
|
68
|
+
|
|
69
|
+
| Variant | Dimensions |
|
|
70
|
+
| --------------- | --------------------------------- |
|
|
71
|
+
| `rectangle` | `h-32 w-full rounded-lg` |
|
|
72
|
+
| `square` | `size-32 rounded-lg` |
|
|
73
|
+
| `circle` | `size-16 rounded-full` |
|
|
74
|
+
| `textLine` | `h-4 w-full rounded` |
|
|
75
|
+
| `textParagraph` | 4 lines of varying width |
|
|
76
|
+
|
|
77
|
+
## Usage Examples
|
|
78
|
+
|
|
79
|
+
### Layout skeleton
|
|
80
|
+
|
|
81
|
+
```tsx
|
|
82
|
+
<Skeleton type="layout" variant="cardImage" enabled={isLoading()}>
|
|
83
|
+
{/* Real content rendered when enabled=false */}
|
|
84
|
+
<div class="flex flex-col gap-2">
|
|
85
|
+
<img src={post.image} class="h-40 w-full rounded-lg object-cover" />
|
|
86
|
+
<h2 class="font-semibold">{post.title}</h2>
|
|
87
|
+
<p class="text-sm text-base-content/70">{post.description}</p>
|
|
88
|
+
</div>
|
|
89
|
+
</Skeleton>
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Shape skeleton
|
|
93
|
+
|
|
94
|
+
```tsx
|
|
95
|
+
<Skeleton type="shape" variant="circle" enabled={isLoading()}>
|
|
96
|
+
<img src={user.avatar} class="size-16 rounded-full" alt={user.name} />
|
|
97
|
+
</Skeleton>
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Custom skeleton
|
|
101
|
+
|
|
102
|
+
The `class` prop is applied directly to a `<div class="skeleton ...">`. Define size, shape, and rounding:
|
|
103
|
+
|
|
104
|
+
```tsx
|
|
105
|
+
<Skeleton type="custom" enabled={isLoading()} class="h-6 w-32 rounded-full">
|
|
106
|
+
<span class="text-sm font-medium">{label}</span>
|
|
107
|
+
</Skeleton>
|
|
108
|
+
|
|
109
|
+
<Skeleton type="custom" enabled={isLoading()} class="size-20 rounded-2xl">
|
|
110
|
+
<img src={thumbnail} class="size-20 rounded-2xl" />
|
|
111
|
+
</Skeleton>
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Async data loading pattern
|
|
115
|
+
|
|
116
|
+
```tsx
|
|
117
|
+
const [data, setData] = createSignal(null);
|
|
118
|
+
const [loading, setLoading] = createSignal(true);
|
|
119
|
+
|
|
120
|
+
onMount(async () => {
|
|
121
|
+
const result = await fetchUser();
|
|
122
|
+
setData(result);
|
|
123
|
+
setLoading(false);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
// In JSX:
|
|
127
|
+
<Skeleton type="layout" variant="profile" enabled={loading()}>
|
|
128
|
+
<Show when={data()}>
|
|
129
|
+
{user => (
|
|
130
|
+
<div class="flex flex-col items-center gap-2">
|
|
131
|
+
<img src={user().avatar} class="size-20 rounded-full" />
|
|
132
|
+
<p class="font-semibold">{user().name}</p>
|
|
133
|
+
</div>
|
|
134
|
+
)}
|
|
135
|
+
</Show>
|
|
136
|
+
</Skeleton>
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Feed list with multiple skeleton items
|
|
140
|
+
|
|
141
|
+
```tsx
|
|
142
|
+
<For each={loading() ? Array(5).fill(null) : posts()}>
|
|
143
|
+
{(post, i) => (
|
|
144
|
+
<Skeleton type="layout" variant="feedItem" enabled={loading()}>
|
|
145
|
+
<FeedItem post={post} />
|
|
146
|
+
</Skeleton>
|
|
147
|
+
)}
|
|
148
|
+
</For>
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Animation & Styling
|
|
152
|
+
|
|
153
|
+
The `.skeleton` class (from `skeleton.daisy.css`) applies:
|
|
154
|
+
- Background: `var(--color-base-300)`
|
|
155
|
+
- Animated sweep: a `105deg` gradient from `base-100` that slides across via `background-position-x` at `1.8s ease-in-out infinite`
|
|
156
|
+
- Respects `prefers-reduced-motion`: slows animation to `15s` transition duration when reduced motion is preferred
|
|
157
|
+
- Default border radius: `var(--radius-box)`
|
|
158
|
+
|
|
159
|
+
The animation is purely CSS — no JavaScript timers involved.
|
|
160
|
+
|
|
161
|
+
## Render Structure
|
|
162
|
+
|
|
163
|
+
```
|
|
164
|
+
<Show when={enabled} fallback={children}>
|
|
165
|
+
{type === 'custom'
|
|
166
|
+
? <div class={cn('skeleton', class)} />
|
|
167
|
+
: <SkeletonDisplay type variant />
|
|
168
|
+
}
|
|
169
|
+
</Show>
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
When `enabled=true`, `children` are never mounted. When `enabled=false`, the skeleton is never mounted. There is no overlap.
|
|
173
|
+
|
|
174
|
+
## Class Slots
|
|
175
|
+
|
|
176
|
+
`Skeleton` uses `class` only for `type="custom"` (defines size + shape of the placeholder div). For `type="layout"` and `type="shape"`, there is no `class` prop — the shape is fully determined by `variant`.
|
|
177
|
+
|
|
178
|
+
No `Partial<Record<...>>` slot object — this component renders preset layouts without sub-element targeting.
|
|
179
|
+
|
|
180
|
+
> **CSS encoding**: internal CSS classes use short encoded names (e.g. `sk01`, `sk02`) per project convention.
|
|
181
|
+
|
|
182
|
+
## Common Mistakes
|
|
183
|
+
|
|
184
|
+
| Mistake | Fix |
|
|
185
|
+
| --- | --- |
|
|
186
|
+
| Using `type="custom"` without `class` | `class` is required for `type="custom"` — TypeScript will error |
|
|
187
|
+
| Placing real content alongside Skeleton | Wrap real content **inside** Skeleton as `children` |
|
|
188
|
+
| Omitting `type` prop | `type` is required — one of `'layout'`, `'shape'`, `'custom'` |
|
|
189
|
+
| Using `variant` with `type="custom"` | `variant` is not available on `type="custom"` — use `class` instead |
|
|
190
|
+
| Expecting skeleton animation in reduced-motion mode | Animation slows to ~15s; design should still look acceptable statically |
|
|
191
|
+
|
|
192
|
+
> **Unique IDs**: if this component needs to generate HTML `id` attributes, always use `createUniqueId()` from `solid-js` — never `Math.random()` or `Date.now()`.
|