@zeyolabs/ui 0.0.0-stage → 2026.11.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.
Files changed (143) hide show
  1. package/README.md +43 -2
  2. package/back-button/BackButton.svelte +26 -0
  3. package/badge/Badge.svelte +73 -0
  4. package/badge/PromoBadge.svelte +319 -0
  5. package/badge/color.ts +10 -0
  6. package/bar/Bar.svelte +63 -0
  7. package/base.css +47 -0
  8. package/boundary/Boundary.svelte +59 -0
  9. package/boundary/BoundaryFailed.svelte +40 -0
  10. package/boundary/PendingTracker.svelte +14 -0
  11. package/boundary/pending-context.ts +15 -0
  12. package/boundary/pending-flag.svelte.ts +33 -0
  13. package/boundary/report-boundary-error.ts +13 -0
  14. package/card/Card.svelte +239 -0
  15. package/card/CardBody.svelte +41 -0
  16. package/card/CardFooter.svelte +36 -0
  17. package/card/CardHeader.svelte +36 -0
  18. package/copy/CopyArea.svelte +37 -0
  19. package/copy/CopyButton.svelte +59 -0
  20. package/copy/copy-state.svelte.ts +23 -0
  21. package/copy/types.ts +1 -0
  22. package/dialog/ConfirmDialog.svelte +61 -0
  23. package/dialog/Dialog.svelte +31 -0
  24. package/dialog/DialogBody.svelte +88 -0
  25. package/dialog/DialogCloseButton.svelte +26 -0
  26. package/dialog/DialogFooter.svelte +23 -0
  27. package/dialog/DialogTrigger.svelte +15 -0
  28. package/distribution-bar/DistributionBar.svelte +37 -0
  29. package/drawer/Drawer.svelte +31 -0
  30. package/drawer/DrawerBody.svelte +61 -0
  31. package/empty-state/EmptyState.svelte +74 -0
  32. package/error/ErrorPage.svelte +54 -0
  33. package/eyebrow/Eyebrow.svelte +10 -0
  34. package/faq/FAQList.svelte +89 -0
  35. package/filter/FilterChipGroup.svelte +78 -0
  36. package/filter/FilterOptionList.svelte +188 -0
  37. package/filter/FilterPopover.svelte +122 -0
  38. package/filter/filter-draft.svelte.ts +25 -0
  39. package/form/Button.svelte +73 -0
  40. package/form/Field.svelte +111 -0
  41. package/form/FieldLabel.svelte +19 -0
  42. package/form/Form.svelte +133 -0
  43. package/form/PhoneField.svelte +214 -0
  44. package/form/UnsavedBar.svelte +22 -0
  45. package/form/field-view.svelte.ts +213 -0
  46. package/form/fields/CheckboxField.svelte +85 -0
  47. package/form/fields/Combobox.svelte +327 -0
  48. package/form/fields/ComboboxAction.svelte +16 -0
  49. package/form/fields/DateField.svelte +31 -0
  50. package/form/fields/DateRangeField.svelte +188 -0
  51. package/form/fields/DateRangePresetField.svelte +119 -0
  52. package/form/fields/EmailField.svelte +63 -0
  53. package/form/fields/FileField.svelte +145 -0
  54. package/form/fields/HexColorField.svelte +83 -0
  55. package/form/fields/IntervalField.svelte +100 -0
  56. package/form/fields/MessageField.svelte +99 -0
  57. package/form/fields/NumberField.svelte +64 -0
  58. package/form/fields/Option.svelte +48 -0
  59. package/form/fields/OptionRegistrar.svelte +15 -0
  60. package/form/fields/PasswordField.svelte +44 -0
  61. package/form/fields/RadioField.svelte +60 -0
  62. package/form/fields/RichTextField.svelte +221 -0
  63. package/form/fields/SelectField.svelte +216 -0
  64. package/form/fields/SliderField.svelte +182 -0
  65. package/form/fields/SwitchField.svelte +102 -0
  66. package/form/fields/TextField.svelte +72 -0
  67. package/form/fields/TimeField.svelte +31 -0
  68. package/form/fields/index.ts +19 -0
  69. package/form/fields/select-field-context.ts +21 -0
  70. package/form/index.ts +21 -0
  71. package/form/primitives/Checkbox.svelte +103 -0
  72. package/form/primitives/DateInput.svelte +51 -0
  73. package/form/primitives/IconInputWrapper.svelte +40 -0
  74. package/form/primitives/Input.svelte +47 -0
  75. package/form/primitives/SearchBar.svelte +37 -0
  76. package/form/primitives/Select.svelte +139 -0
  77. package/form/primitives/TextArea.svelte +51 -0
  78. package/form/primitives/index.ts +6 -0
  79. package/gallery/ImageGallery.svelte +133 -0
  80. package/gallery/flickity-fullscreen.d.ts +2 -0
  81. package/grouped-grid/GroupedGrid.svelte +143 -0
  82. package/grouped-grid/types.ts +25 -0
  83. package/layout/Cluster.svelte +92 -0
  84. package/layout/Container.svelte +9 -0
  85. package/layout/Grid.svelte +131 -0
  86. package/layout/Section.svelte +146 -0
  87. package/layout/Shell.svelte +32 -0
  88. package/layout/SplitShell.svelte +47 -0
  89. package/layout/Stack.svelte +78 -0
  90. package/list-row/ListRow.svelte +77 -0
  91. package/menu/MenuButton.svelte +101 -0
  92. package/mini-stat/MiniStat.svelte +13 -0
  93. package/package.json +171 -5
  94. package/page-hero/PageHero.svelte +35 -0
  95. package/pagination/Pagination.svelte +44 -0
  96. package/pagination/finder-pagination.svelte.ts +55 -0
  97. package/pagination/finder-search.svelte.ts +292 -0
  98. package/percentage-ring/PercentageRing.svelte +76 -0
  99. package/percentage-ring/types.ts +1 -0
  100. package/popover/InfoTip.svelte +36 -0
  101. package/popover/Popover.svelte +157 -0
  102. package/query-state/QueryState.svelte +42 -0
  103. package/schema.ts +20 -0
  104. package/sidebar/Sidebar.svelte +73 -0
  105. package/sidebar/SidebarBrand.svelte +32 -0
  106. package/sidebar/SidebarButton.svelte +31 -0
  107. package/sidebar/SidebarGroup.svelte +39 -0
  108. package/sidebar/SidebarItem.svelte +48 -0
  109. package/skeleton/Skeleton.svelte +86 -0
  110. package/skeleton/SkeletonButton.svelte +27 -0
  111. package/skeleton/SkeletonCard.svelte +49 -0
  112. package/skeleton/SkeletonCircle.svelte +25 -0
  113. package/skeleton/SkeletonField.svelte +19 -0
  114. package/skeleton/SkeletonRow.svelte +47 -0
  115. package/skeleton/SkeletonText.svelte +46 -0
  116. package/skeleton/TableSkeleton.svelte +60 -0
  117. package/spacing.css +32 -0
  118. package/stat/NextPayoutCountdown.svelte +52 -0
  119. package/stat/Stat.svelte +103 -0
  120. package/stat/ValueBox.svelte +38 -0
  121. package/status-row/StatusRow.svelte +176 -0
  122. package/status-row/types.ts +5 -0
  123. package/table/SelectAllCell.svelte +34 -0
  124. package/table/SelectAllTableCell.svelte +25 -0
  125. package/table/SelectRowCell.svelte +31 -0
  126. package/table/SelectRowTableCell.svelte +25 -0
  127. package/table/SelectionBar.svelte +68 -0
  128. package/table/SelectionOverlay.svelte +83 -0
  129. package/table/Table.svelte +64 -0
  130. package/table/TableCell.svelte +185 -0
  131. package/table/TableRow.svelte +86 -0
  132. package/table/index.ts +9 -0
  133. package/table/selection.svelte.ts +79 -0
  134. package/tabs/TabBlock.svelte +56 -0
  135. package/tabs/TabButton.svelte +33 -0
  136. package/template.css +1393 -0
  137. package/text/Span.svelte +83 -0
  138. package/text/Text.svelte +94 -0
  139. package/text/Title.svelte +75 -0
  140. package/text/color.ts +41 -0
  141. package/theme/theme.svelte.ts +33 -0
  142. package/tokens.css +62 -0
  143. package/typography.css +164 -0
@@ -0,0 +1,157 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte';
3
+
4
+ import { fade } from 'svelte/transition';
5
+
6
+ // Floating popover anchored to its own parent element. Rendered with
7
+ // position: fixed (viewport coords computed on open) so it escapes any
8
+ // `overflow: auto` clip from ancestors — e.g. a table's horizontal scroll
9
+ // wrapper. Place <Popover> as a direct child of the element you want to
10
+ // anchor under (the trigger cell/wrapper); it reads that parent's rect.
11
+ let {
12
+ /** Anchor edge the panel lines up with: 'right' = right-aligned (default). */
13
+ align = 'right',
14
+ ariaLabel = 'Popover',
15
+ children,
16
+ /** Panel max-height in px (content scrolls inside). */
17
+ maxHeight = 360,
18
+ /** Fired after the popover closes via outside click / Esc. */
19
+ onClose,
20
+ open = $bindable(false),
21
+ /** Where the panel opens: under the anchor (default) or beside it (`align` is ignored). */
22
+ side = 'bottom',
23
+ /** Panel width in px. Also used to keep the panel inside the viewport. */
24
+ width = 260,
25
+ }: {
26
+ align?: 'left' | 'right';
27
+ ariaLabel?: string;
28
+ children: Snippet;
29
+ maxHeight?: number;
30
+ onClose?: () => void;
31
+ open?: boolean;
32
+ side?: 'bottom' | 'right';
33
+ width?: number;
34
+ } = $props();
35
+
36
+ let panelEl: HTMLDivElement | undefined = $state();
37
+ let pos = $state({ left: 0, top: 0 });
38
+
39
+ function close() {
40
+ open = false;
41
+ onClose?.();
42
+ }
43
+
44
+ // Outside-click / Escape detection via document-level listeners instead of a
45
+ // full-viewport backdrop element. A backdrop is a real hit target covering the
46
+ // whole page, so it swallows any click made while the popover is open — e.g.
47
+ // rapid-clicking a second row's trigger closed the first popover but the click
48
+ // never reached the second trigger, and nothing opened. Listeners observe
49
+ // without being a target, so the same click closes this popover AND still
50
+ // reaches whatever it landed on.
51
+ $effect(() => {
52
+ if (!open) return;
53
+
54
+ const onPointerDown = (e: PointerEvent) => {
55
+ const target = e.target as Node;
56
+ // The anchor (panel's parent) holds the trigger, and every consumer's
57
+ // trigger toggles `open` — closing here too would make that click
58
+ // reopen the popover it just closed. Excluding the anchor also means
59
+ // the click that opened the popover can never immediately close it.
60
+ if (panelEl?.contains(target) || panelEl?.parentElement?.contains(target)) return;
61
+ close();
62
+ };
63
+ const onKeydown = (e: KeyboardEvent) => {
64
+ if (e.key === 'Escape') close();
65
+ };
66
+ // capture: true so a stopPropagation() anywhere in the page's bubble phase
67
+ // (including this panel's own onclick/onkeydown) can't suppress the checks.
68
+ document.addEventListener('pointerdown', onPointerDown, { capture: true });
69
+ document.addEventListener('keydown', onKeydown, { capture: true });
70
+ return () => {
71
+ document.removeEventListener('pointerdown', onPointerDown, { capture: true });
72
+ document.removeEventListener('keydown', onKeydown, { capture: true });
73
+ };
74
+ });
75
+
76
+ $effect(() => {
77
+ if (!open || !panelEl) return;
78
+ const anchor = panelEl.parentElement;
79
+ if (!anchor) return;
80
+
81
+ const reposition = () => {
82
+ const r = anchor.getBoundingClientRect();
83
+ const panelHeight = panelEl?.offsetHeight ?? 0;
84
+ if (side === 'right') {
85
+ const rightLeft = r.right + 4;
86
+ const left = Math.max(
87
+ 8,
88
+ rightLeft + width > window.innerWidth - 8 ? r.left - width - 4 : rightLeft
89
+ );
90
+ const maxTop = window.innerHeight - panelHeight - 8;
91
+ pos = { left, top: Math.max(8, Math.min(maxTop, r.top)) };
92
+ return;
93
+ }
94
+ const spaceBelow = window.innerHeight - r.bottom;
95
+ const spaceAbove = r.top;
96
+ const top =
97
+ spaceBelow < panelHeight + 4 && spaceAbove > spaceBelow
98
+ ? Math.max(8, r.top - panelHeight - 4)
99
+ : r.bottom + 4;
100
+ // Align to the chosen edge, but never let the panel run off-screen.
101
+ const desiredLeft = align === 'right' ? r.right - width : r.left;
102
+ const left = Math.max(8, Math.min(window.innerWidth - width - 8, desiredLeft));
103
+ pos = { left, top };
104
+ };
105
+
106
+ reposition();
107
+ // Keep the panel glued to the anchor as the page scrolls or resizes.
108
+ // capture: true catches scroll on any ancestor (e.g. a table's own
109
+ // overflow-x: auto wrapper), not just window. passive: true because we
110
+ // never preventDefault. Listeners are removed in the effect cleanup.
111
+ window.addEventListener('scroll', reposition, { capture: true, passive: true });
112
+ window.addEventListener('resize', reposition, { passive: true });
113
+ return () => {
114
+ window.removeEventListener('scroll', reposition, { capture: true });
115
+ window.removeEventListener('resize', reposition);
116
+ };
117
+ });
118
+ </script>
119
+
120
+ {#if open}
121
+ <div
122
+ bind:this={panelEl}
123
+ style:top="{pos.top}px"
124
+ style:left="{pos.left}px"
125
+ style:width="{width}px"
126
+ style:max-height="{maxHeight}px"
127
+ class="popover"
128
+ aria-label={ariaLabel}
129
+ onclick={(e) => e.stopPropagation()}
130
+ onkeydown={(e) => e.stopPropagation()}
131
+ role="dialog"
132
+ tabindex="-1"
133
+ transition:fade={{
134
+ duration: window.matchMedia('(prefers-reduced-motion: reduce)').matches ? 0 : 120,
135
+ }}
136
+ >
137
+ {@render children()}
138
+ </div>
139
+ {/if}
140
+
141
+ <style>
142
+ .popover {
143
+ /* position: fixed (with computed top/left in JS) escapes any ancestor's
144
+ overflow clip — see the $effect block in <script>. */
145
+ position: fixed;
146
+ z-index: 9100;
147
+ background: var(--bg);
148
+ border: 1px solid var(--bd);
149
+ border-radius: var(--radius);
150
+ box-shadow: 0 8px 24px rgba(20, 18, 24, 0.12);
151
+ display: flex;
152
+ flex-direction: column;
153
+ gap: 4px;
154
+ padding: 6px;
155
+ overflow-y: auto;
156
+ }
157
+ </style>
@@ -0,0 +1,42 @@
1
+ <script generics="T" lang="ts">
2
+ import type { Snippet } from 'svelte';
3
+
4
+ import { getHttpStatus } from '@zeyolabs/kit/utils/errors';
5
+
6
+ import SkeletonRow from '../skeleton/SkeletonRow.svelte';
7
+
8
+ /**
9
+ * The standard load/error/ready gate for a remote `query`. Renders `children(data)` once the
10
+ * query resolves, a muted error line on failure, and a skeleton while loading — so pages stop
11
+ * re-implementing the `{#if current}{:else if error}{:else}` boilerplate.
12
+ */
13
+ let {
14
+ children,
15
+ errorMessage,
16
+ failed = 'Failed to load.',
17
+ loading,
18
+ query,
19
+ skeletonCols = 2,
20
+ }: {
21
+ children: Snippet<[T]>;
22
+ /** Status-aware error text, e.g. distinguishing a 404 from a 500. Overrides `failed`. */
23
+ errorMessage?: (status: null | number) => string;
24
+ failed?: string;
25
+ /** Custom loading state; defaults to a skeleton row. */
26
+ loading?: Snippet;
27
+ query: { current: T | undefined; error?: unknown };
28
+ skeletonCols?: number;
29
+ } = $props();
30
+ </script>
31
+
32
+ {#if query.current !== undefined}
33
+ {@render children(query.current)}
34
+ {:else if query.error}
35
+ <div style="color: var(--txs);" class="py-10 text-center">
36
+ {errorMessage ? errorMessage(getHttpStatus(query.error)) : failed}
37
+ </div>
38
+ {:else if loading}
39
+ {@render loading()}
40
+ {:else}
41
+ <div class="py-6"><SkeletonRow avatar={false} cols={skeletonCols} /></div>
42
+ {/if}
package/schema.ts ADDED
@@ -0,0 +1,20 @@
1
+ // Checked only at compile time — a value cast past the type system (`as CssVariable`) is not validated
2
+ // at runtime.
3
+ export type CssVariable = `var(--${string})`;
4
+
5
+ type Bounded<Brand extends string> = number & { readonly __brand: Brand };
6
+
7
+ // 0-100, clamped at construction — a raw number isn't assignable without going through toPercentage.
8
+ export type Percentage = Bounded<'Percentage'>;
9
+ export const toPercentage = (value: number): Percentage =>
10
+ Math.min(100, Math.max(0, value)) as Percentage;
11
+
12
+ // 0-1, clamped at construction — a raw number isn't assignable without going through toOpacity.
13
+ export type Opacity = Bounded<'Opacity'>;
14
+ export const toOpacity = (value: number): Opacity => Math.min(1, Math.max(0, value)) as Opacity;
15
+
16
+ // A closed set of severity states, not a color value — a consumer maps each to its own color/class.
17
+ export type StatusColor = 'error' | 'ok' | 'warning';
18
+
19
+ // A background-color Tailwind class referencing a design token, e.g. bg-[var(--ok)].
20
+ export type BackgroundColorClass = `bg-[${CssVariable}]`;
@@ -0,0 +1,73 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte';
3
+
4
+ /** App sidebar column: brand on top, fixed primary links, a scrolling body of groups, and a
5
+ * footer row (user, theme toggle, sign out). Fills its parent's height; pair with SplitShell. */
6
+ let {
7
+ brand,
8
+ children,
9
+ foot,
10
+ label = 'Main',
11
+ links,
12
+ }: {
13
+ brand?: Snippet;
14
+ children?: Snippet;
15
+ foot?: Snippet;
16
+ label?: string;
17
+ links?: Snippet;
18
+ } = $props();
19
+ </script>
20
+
21
+ <nav class="sidebar" aria-label={label}>
22
+ {@render brand?.()}
23
+
24
+ {#if links}
25
+ <ul class="sidebar-links">{@render links()}</ul>
26
+ {/if}
27
+
28
+ {#if children}
29
+ <div class="sidebar-body" class:sidebar-body--ruled={!!links}>{@render children()}</div>
30
+ {/if}
31
+
32
+ {#if foot}
33
+ <div class="sidebar-foot">{@render foot()}</div>
34
+ {/if}
35
+ </nav>
36
+
37
+ <style>
38
+ .sidebar {
39
+ display: flex;
40
+ flex-direction: column;
41
+ gap: 10px;
42
+ height: 100%;
43
+ padding: 10px 8px;
44
+ background: var(--sf);
45
+ }
46
+ .sidebar-links {
47
+ display: flex;
48
+ flex-direction: column;
49
+ gap: 1px;
50
+ list-style: none;
51
+ margin: 0;
52
+ padding: 0;
53
+ }
54
+ .sidebar-body {
55
+ flex: 1;
56
+ min-height: 0;
57
+ overflow-y: auto;
58
+ display: flex;
59
+ flex-direction: column;
60
+ gap: 10px;
61
+ }
62
+ .sidebar-body--ruled {
63
+ padding-top: 6px;
64
+ border-top: 1px solid var(--bds);
65
+ }
66
+ .sidebar-foot {
67
+ display: flex;
68
+ align-items: center;
69
+ gap: 4px;
70
+ padding-top: 8px;
71
+ border-top: 1px solid var(--bds);
72
+ }
73
+ </style>
@@ -0,0 +1,32 @@
1
+ <script lang="ts">
2
+ /** Sidebar header: a small filled mark (one letter) beside the product name. */
3
+ let { href, label, mark }: { href: string; label: string; mark?: string } = $props();
4
+ </script>
5
+
6
+ <a class="sidebar-brand" {href}>
7
+ <span class="sidebar-mark" aria-hidden="true">{mark ?? label.charAt(0).toLowerCase()}</span>
8
+ <span>{label}</span>
9
+ </a>
10
+
11
+ <style>
12
+ .sidebar-brand {
13
+ display: flex;
14
+ align-items: center;
15
+ gap: 8px;
16
+ padding: 2px 6px;
17
+ font-weight: 700;
18
+ font-size: 15px;
19
+ color: var(--tx);
20
+ text-decoration: none;
21
+ }
22
+ .sidebar-mark {
23
+ display: grid;
24
+ place-items: center;
25
+ width: 22px;
26
+ height: 22px;
27
+ border-radius: var(--radius-sm);
28
+ background: var(--primary-strong);
29
+ color: var(--primary-soft);
30
+ font-size: 13px;
31
+ }
32
+ </style>
@@ -0,0 +1,31 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte';
3
+ import type { HTMLButtonAttributes } from 'svelte/elements';
4
+
5
+ /** Square 26px icon button for the sidebar footer (theme toggle, sign out). Pass `aria-label`. */
6
+ let {
7
+ children,
8
+ type = 'button',
9
+ ...rest
10
+ }: HTMLButtonAttributes & { children: Snippet } = $props();
11
+ </script>
12
+
13
+ <button class="sidebar-btn" {type} {...rest}>{@render children()}</button>
14
+
15
+ <style>
16
+ .sidebar-btn {
17
+ display: grid;
18
+ place-items: center;
19
+ width: 26px;
20
+ height: 26px;
21
+ border-radius: var(--radius-sm);
22
+ border: none;
23
+ background: none;
24
+ color: var(--txs);
25
+ cursor: pointer;
26
+ }
27
+ .sidebar-btn:hover {
28
+ background: var(--sfh);
29
+ color: var(--tx);
30
+ }
31
+ </style>
@@ -0,0 +1,39 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte';
3
+
4
+ /** A titled list of SidebarItems. `href` makes the uppercase title a link (e.g. a project). */
5
+ let { children, href, label }: { children: Snippet; href?: string; label: string } = $props();
6
+ </script>
7
+
8
+ <section>
9
+ {#if href}
10
+ <a class="sidebar-group-label sidebar-group-label--link" {href}>{label}</a>
11
+ {:else}
12
+ <span class="sidebar-group-label">{label}</span>
13
+ {/if}
14
+ <ul>{@render children()}</ul>
15
+ </section>
16
+
17
+ <style>
18
+ ul {
19
+ display: flex;
20
+ flex-direction: column;
21
+ gap: 1px;
22
+ list-style: none;
23
+ margin: 0;
24
+ padding: 0;
25
+ }
26
+ .sidebar-group-label {
27
+ display: block;
28
+ padding: 2px 8px;
29
+ font-size: 11px;
30
+ font-weight: 600;
31
+ letter-spacing: 0.04em;
32
+ text-transform: uppercase;
33
+ color: var(--txt);
34
+ text-decoration: none;
35
+ }
36
+ .sidebar-group-label--link:hover {
37
+ color: var(--tx);
38
+ }
39
+ </style>
@@ -0,0 +1,48 @@
1
+ <script lang="ts">
2
+ import type { Component, Snippet } from 'svelte';
3
+
4
+ /** One 26px sidebar row (renders its own `<li>`). `current` tints it and sets
5
+ * aria-current="page"; the caller decides what counts as current. */
6
+ let {
7
+ children,
8
+ current = false,
9
+ href,
10
+ icon: Icon,
11
+ iconSize = 14,
12
+ }: {
13
+ children: Snippet;
14
+ current?: boolean;
15
+ href: string;
16
+ icon?: Component<{ size?: number }>;
17
+ iconSize?: number;
18
+ } = $props();
19
+ </script>
20
+
21
+ <li>
22
+ <a class="sidebar-item" aria-current={current ? 'page' : undefined} {href}>
23
+ {#if Icon}<Icon size={iconSize} />{/if}
24
+ {@render children()}
25
+ </a>
26
+ </li>
27
+
28
+ <style>
29
+ .sidebar-item {
30
+ display: flex;
31
+ align-items: center;
32
+ gap: 6px;
33
+ height: 26px;
34
+ padding: 0 8px;
35
+ border-radius: var(--radius-sm);
36
+ color: var(--txs);
37
+ text-decoration: none;
38
+ }
39
+ .sidebar-item:hover {
40
+ background: var(--sfh);
41
+ color: var(--tx);
42
+ }
43
+ .sidebar-item[aria-current='page'] {
44
+ background: color-mix(in srgb, var(--primary) 16%, transparent);
45
+ color: var(--primary);
46
+ font-weight: 500;
47
+ }
48
+ </style>
@@ -0,0 +1,86 @@
1
+ <script lang="ts">
2
+ type Radius = 'full' | 'lg' | 'md' | 'sm' | 'xl' | 'xs';
3
+ type Variant = 'pulse' | 'shimmer';
4
+
5
+ let {
6
+ class: klass = '',
7
+ h = '1rem',
8
+ radius = 'xs',
9
+ style = '',
10
+ variant = 'pulse',
11
+ w = '100%',
12
+ }: {
13
+ class?: string;
14
+ h?: string;
15
+ /** A step on the radius scale (see @zeyolabs/ui/base.css); defaults to 'xs'. */
16
+ radius?: Radius;
17
+ style?: string;
18
+ variant?: Variant;
19
+ w?: string;
20
+ } = $props();
21
+
22
+ const resolvedRadius = $derived(`var(--radius-${radius})`);
23
+ </script>
24
+
25
+ <span
26
+ style="width: {w}; height: {h}; border-radius: {resolvedRadius}; {style}"
27
+ class="sk {variant === 'shimmer' ? 'sk-shimmer' : 'sk-pulse'} {klass}"
28
+ aria-hidden="true"
29
+ ></span>
30
+
31
+ <style>
32
+ .sk {
33
+ display: block;
34
+ flex-shrink: 0;
35
+ background-color: var(--bd, #e5e3e0);
36
+ }
37
+
38
+ .sk-pulse {
39
+ animation: sk-pulse 1.5s ease-in-out infinite;
40
+ }
41
+
42
+ .sk-shimmer {
43
+ position: relative;
44
+ overflow: hidden;
45
+ }
46
+ .sk-shimmer::after {
47
+ content: '';
48
+ position: absolute;
49
+ inset: 0;
50
+ transform: translateX(-100%);
51
+ background: linear-gradient(
52
+ 90deg,
53
+ transparent,
54
+ var(--sfh, rgba(255, 255, 255, 0.55)),
55
+ transparent
56
+ );
57
+ animation: sk-shimmer 1.6s ease-in-out infinite;
58
+ }
59
+
60
+ @keyframes sk-pulse {
61
+ 0%,
62
+ 100% {
63
+ opacity: 1;
64
+ }
65
+ 50% {
66
+ opacity: 0.45;
67
+ }
68
+ }
69
+
70
+ @keyframes sk-shimmer {
71
+ 100% {
72
+ transform: translateX(100%);
73
+ }
74
+ }
75
+
76
+ @media (prefers-reduced-motion: reduce) {
77
+ .sk-pulse {
78
+ animation: none;
79
+ opacity: 0.7;
80
+ }
81
+ .sk-shimmer::after {
82
+ animation: none;
83
+ display: none;
84
+ }
85
+ }
86
+ </style>
@@ -0,0 +1,27 @@
1
+ <script lang="ts">
2
+ import Skeleton from './Skeleton.svelte';
3
+
4
+ /** Mirrors `<Button size>`: omit for the default 35px button. */
5
+ type Size = 'sm' | 'xs';
6
+
7
+ let {
8
+ class: klass = '',
9
+ size,
10
+ variant = 'pulse',
11
+ w = '6rem',
12
+ }: {
13
+ class?: string;
14
+ size?: Size;
15
+ variant?: 'pulse' | 'shimmer';
16
+ /** Button width — any CSS length. */
17
+ w?: string;
18
+ } = $props();
19
+
20
+ const HEIGHTS: Record<Size, string> = {
21
+ sm: 'var(--control-h-sm)',
22
+ xs: '20px',
23
+ };
24
+ const h = $derived(size ? HEIGHTS[size] : 'var(--control-h)');
25
+ </script>
26
+
27
+ <Skeleton class={klass} {h} radius="md" {variant} {w} />
@@ -0,0 +1,49 @@
1
+ <script lang="ts">
2
+ import Skeleton from './Skeleton.svelte';
3
+ import SkeletonCircle from './SkeletonCircle.svelte';
4
+ import SkeletonText from './SkeletonText.svelte';
5
+
6
+ let {
7
+ avatar = false,
8
+ class: klass = '',
9
+ lines = 2,
10
+ variant = 'pulse',
11
+ }: {
12
+ /** Show a leading avatar header. */
13
+ avatar?: boolean;
14
+ class?: string;
15
+ /** Body text lines. */
16
+ lines?: number;
17
+ variant?: 'pulse' | 'shimmer';
18
+ } = $props();
19
+ </script>
20
+
21
+ <div class="sk-card {klass}">
22
+ <div class="sk-card-head">
23
+ {#if avatar}
24
+ <SkeletonCircle size="md" {variant} />
25
+ {/if}
26
+ <Skeleton h="0.75rem" radius="xs" {variant} w="45%" />
27
+ </div>
28
+ <Skeleton h="1.75rem" radius="xs" {variant} w="60%" />
29
+ {#if lines > 0}
30
+ <SkeletonText lastLineWidth="50%" {lines} size="sm" {variant} />
31
+ {/if}
32
+ </div>
33
+
34
+ <style>
35
+ .sk-card {
36
+ display: flex;
37
+ flex-direction: column;
38
+ gap: 0.75rem;
39
+ padding: 1rem;
40
+ border: 1px solid var(--bd, #e5e3e0);
41
+ border-radius: var(--radius-md);
42
+ width: 100%;
43
+ }
44
+ .sk-card-head {
45
+ display: flex;
46
+ align-items: center;
47
+ gap: 0.625rem;
48
+ }
49
+ </style>
@@ -0,0 +1,25 @@
1
+ <script lang="ts">
2
+ import Skeleton from './Skeleton.svelte';
3
+
4
+ type Size = 'lg' | 'md' | 'sm';
5
+
6
+ let {
7
+ class: klass = '',
8
+ size = 'md',
9
+ variant = 'pulse',
10
+ }: {
11
+ class?: string;
12
+ /** Diameter preset, or any CSS length for a custom size. */
13
+ size?: Size | string;
14
+ variant?: 'pulse' | 'shimmer';
15
+ } = $props();
16
+
17
+ const PRESETS: Record<Size, string> = {
18
+ lg: '3.5rem',
19
+ md: '2.5rem',
20
+ sm: '1.5rem',
21
+ };
22
+ const d = $derived((PRESETS as Record<string, string>)[size] ?? size);
23
+ </script>
24
+
25
+ <Skeleton class={klass} h={d} radius="full" {variant} w={d} />
@@ -0,0 +1,19 @@
1
+ <script lang="ts">
2
+ import Stack from '../layout/Stack.svelte';
3
+ import Skeleton from './Skeleton.svelte';
4
+ import SkeletonButton from './SkeletonButton.svelte';
5
+
6
+ let {
7
+ labelWidth = '6rem',
8
+ variant = 'pulse',
9
+ }: {
10
+ /** Width of the label placeholder above the field. */
11
+ labelWidth?: string;
12
+ variant?: 'pulse' | 'shimmer';
13
+ } = $props();
14
+ </script>
15
+
16
+ <Stack gap="xs">
17
+ <Skeleton h="0.7rem" radius="xs" {variant} w={labelWidth} />
18
+ <SkeletonButton {variant} w="100%" />
19
+ </Stack>