@zyncat/ui 0.15.0 → 0.18.0
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 +32 -202
- package/dist/alert.css +1 -1
- package/dist/alert.js +18 -10
- package/dist/alert.js.map +1 -1
- package/dist/avatar.css +3 -2
- package/dist/badge.css +1 -1
- package/dist/bloom-HV23M4AW.js +81 -0
- package/dist/bloom-HV23M4AW.js.map +1 -0
- package/dist/button.css +38 -31
- package/dist/button.js +4 -1
- package/dist/checkbox.css +1 -1
- package/dist/{chunk-5W5TKANX.js → chunk-2DNKZ57E.js} +3 -3
- package/dist/{chunk-5W5TKANX.js.map → chunk-2DNKZ57E.js.map} +1 -1
- package/dist/chunk-2YGHPQ66.js +16 -0
- package/dist/chunk-2YGHPQ66.js.map +1 -0
- package/dist/{chunk-N2GJEO5Z.js → chunk-6H3IJ752.js} +24 -9
- package/dist/chunk-6H3IJ752.js.map +1 -0
- package/dist/chunk-7NHY2CRA.js +132 -0
- package/dist/chunk-7NHY2CRA.js.map +1 -0
- package/dist/{chunk-PWQVSVXR.js → chunk-AIAPXRCI.js} +20 -19
- package/dist/chunk-AIAPXRCI.js.map +1 -0
- package/dist/{chunk-K45CWVHS.js → chunk-BRKGYLEQ.js} +12 -9
- package/dist/chunk-BRKGYLEQ.js.map +1 -0
- package/dist/{chunk-MDSRZ4QR.js → chunk-C3D32LE3.js} +6 -5
- package/dist/chunk-C3D32LE3.js.map +1 -0
- package/dist/chunk-F2TB3TT6.js +103 -0
- package/dist/chunk-F2TB3TT6.js.map +1 -0
- package/dist/{chunk-FVPNICF4.js → chunk-F64Z42PJ.js} +6 -6
- package/dist/{chunk-FVPNICF4.js.map → chunk-F64Z42PJ.js.map} +1 -1
- package/dist/{chunk-QGVFFT2B.js → chunk-HBWRKEW4.js} +3 -3
- package/dist/{chunk-QGVFFT2B.js.map → chunk-HBWRKEW4.js.map} +1 -1
- package/dist/{chunk-CAXQJSIE.js → chunk-JINATP4N.js} +13 -13
- package/dist/chunk-JINATP4N.js.map +1 -0
- package/dist/chunk-KSAJ6DED.js +16 -0
- package/dist/chunk-KSAJ6DED.js.map +1 -0
- package/dist/{chunk-BH4JFWXQ.js → chunk-M2KGLH2G.js} +19 -16
- package/dist/chunk-M2KGLH2G.js.map +1 -0
- package/dist/{chunk-6X3G4GIM.js → chunk-N43NDSME.js} +3 -3
- package/dist/{chunk-6X3G4GIM.js.map → chunk-N43NDSME.js.map} +1 -1
- package/dist/chunk-NYQQH4R5.js +40 -0
- package/dist/chunk-NYQQH4R5.js.map +1 -0
- package/dist/{chunk-BTF6DAE3.js → chunk-ODRO3KS6.js} +4 -4
- package/dist/{chunk-BTF6DAE3.js.map → chunk-ODRO3KS6.js.map} +1 -1
- package/dist/chunk-PXQBJMPJ.js +50 -0
- package/dist/chunk-PXQBJMPJ.js.map +1 -0
- package/dist/{chunk-GJTHWB6O.js → chunk-QDAN43B6.js} +3 -3
- package/dist/{chunk-GJTHWB6O.js.map → chunk-QDAN43B6.js.map} +1 -1
- package/dist/{chunk-RBSHRRNO.js → chunk-RJENXXTI.js} +5 -5
- package/dist/{chunk-RBSHRRNO.js.map → chunk-RJENXXTI.js.map} +1 -1
- package/dist/chunk-RLNCRDAL.js +89 -0
- package/dist/chunk-RLNCRDAL.js.map +1 -0
- package/dist/{chunk-GOLSYGRA.js → chunk-TBLPZQSI.js} +84 -48
- package/dist/chunk-TBLPZQSI.js.map +1 -0
- package/dist/{chunk-WZUTBJC4.js → chunk-TDHLZY6I.js} +23 -5
- package/dist/chunk-TDHLZY6I.js.map +1 -0
- package/dist/chunk-TP2AC5MQ.js +13 -0
- package/dist/chunk-TP2AC5MQ.js.map +1 -0
- package/dist/chunk-TRPAKUIB.js +196 -0
- package/dist/chunk-TRPAKUIB.js.map +1 -0
- package/dist/{chunk-5X3MJRIM.js → chunk-UKPX3RIP.js} +3 -3
- package/dist/{chunk-5X3MJRIM.js.map → chunk-UKPX3RIP.js.map} +1 -1
- package/dist/{chunk-5GBV45YD.js → chunk-V6QAAOA5.js} +3 -3
- package/dist/{chunk-5GBV45YD.js.map → chunk-V6QAAOA5.js.map} +1 -1
- package/dist/{chunk-FLQVOSFC.js → chunk-VJXP256V.js} +10 -10
- package/dist/chunk-VJXP256V.js.map +1 -0
- package/dist/{chunk-IUQAUBVM.js → chunk-VQFILXQN.js} +5 -5
- package/dist/chunk-VQFILXQN.js.map +1 -0
- package/dist/{chunk-CFRGQJ23.js → chunk-VZXML7EH.js} +4 -4
- package/dist/{chunk-CFRGQJ23.js.map → chunk-VZXML7EH.js.map} +1 -1
- package/dist/{chunk-FEXUS4SV.js → chunk-XKDR22VE.js} +11 -5
- package/dist/chunk-XKDR22VE.js.map +1 -0
- package/dist/cli.js +262 -45
- package/dist/collapse.css +8 -5
- package/dist/confetti.css +3 -3
- package/dist/confetti.js +2 -2
- package/dist/date-field.js +20 -18
- package/dist/date-field.js.map +1 -1
- package/dist/date-picker.css +168 -43
- package/dist/date-range-field.js +42 -27
- package/dist/date-range-field.js.map +1 -1
- package/dist/datetime-field.js +21 -19
- package/dist/datetime-field.js.map +1 -1
- package/dist/dialog.css +4 -3
- package/dist/dialog.js +12 -12
- package/dist/dialog.js.map +1 -1
- package/dist/digit-strip.css +1 -1
- package/dist/dropdown.css +1 -1
- package/dist/dropdown.js +16 -16
- package/dist/dropdown.js.map +1 -1
- package/dist/emoji-picker.js +41 -26
- package/dist/emoji-picker.js.map +1 -1
- package/dist/facebook-feed.css +1 -1
- package/dist/flow-field.css +4 -4
- package/dist/flow-field.js +3 -3
- package/dist/flow-field.js.map +1 -1
- package/dist/glide.js +3 -3
- package/dist/icon.css +1 -1
- package/dist/input.css +7 -4
- package/dist/instagram-feed.css +1 -1
- package/dist/instagram-feed.js +2 -2
- package/dist/lens.css +1 -2
- package/dist/lens.js +2 -2
- package/dist/mcp.js +1 -1
- package/dist/menu-surface.css +1 -1
- package/dist/modal.css +1 -1
- package/dist/modal.js +10 -10
- package/dist/modal.js.map +1 -1
- package/dist/morphing-text.css +2 -2
- package/dist/morphing-text.js +2 -2
- package/dist/motion-devtools.css +77 -2
- package/dist/motion-devtools.js +194 -37
- package/dist/motion-devtools.js.map +1 -1
- package/dist/motion-tokens.js +1 -1
- package/dist/multi-select.js +12 -12
- package/dist/number-field.js +3 -3
- package/dist/odometer.css +1 -1
- package/dist/odometer.js +2 -2
- package/dist/overlay.css +1 -1
- package/dist/pagination.css +1 -1
- package/dist/pagination.js +6 -4
- package/dist/pagination.js.map +1 -1
- package/dist/paint-CJQCM6ZO.js +260 -0
- package/dist/paint-CJQCM6ZO.js.map +1 -0
- package/dist/popover.css +1 -1
- package/dist/popover.js +10 -10
- package/dist/radio-group.css +6 -4
- package/dist/radio-group.js +6 -6
- package/dist/select.css +1 -1
- package/dist/select.js +12 -12
- package/dist/sheet.css +1 -1
- package/dist/sheet.js +9 -9
- package/dist/spinner.css +115 -0
- package/dist/spinner.js +4 -0
- package/dist/spinner.js.map +1 -0
- package/dist/status-badge.js +2 -2
- package/dist/styles.css +1 -1
- package/dist/support-rail.css +76 -238
- package/dist/support-rail.js +99 -107
- package/dist/support-rail.js.map +1 -1
- package/dist/table.css +2 -2
- package/dist/table.js +8 -6
- package/dist/table.js.map +1 -1
- package/dist/tabs.css +10 -14
- package/dist/tabs.js +17 -11
- package/dist/tabs.js.map +1 -1
- package/dist/tag.css +1 -1
- package/dist/tag.js +6 -6
- package/dist/text-field.js +3 -3
- package/dist/textarea.css +1 -1
- package/dist/textarea.js +2 -2
- package/dist/theme-grid.js +11 -0
- package/dist/theme-grid.js.map +1 -0
- package/dist/theme-switcher.css +107 -0
- package/dist/theme-switcher.js +70 -0
- package/dist/theme-switcher.js.map +1 -0
- package/dist/theme-transition-VGLPZDJI.js +346 -0
- package/dist/theme-transition-VGLPZDJI.js.map +1 -0
- package/dist/theme-transition.css +48 -0
- package/dist/theme.js +57 -26
- package/dist/theme.js.map +1 -1
- package/dist/tide-DJZMDAFT.js +57 -0
- package/dist/tide-DJZMDAFT.js.map +1 -0
- package/dist/tiktok.css +2 -3
- package/dist/tiktok.js +2 -2
- package/dist/time-field.js +4 -4
- package/dist/toast.css +2 -14
- package/dist/toast.js +12 -10
- package/dist/toast.js.map +1 -1
- package/dist/toggle-tag.js +2 -2
- package/dist/toggle.css +1 -1
- package/dist/tooltip.css +1 -1
- package/dist/tooltip.js +25 -22
- package/dist/tooltip.js.map +1 -1
- package/dist/trigger.css +1 -1
- package/dist/types/components/composites/date-picker/month-jump.d.ts +11 -0
- package/dist/types/components/composites/theme-switcher/ThemeGrid.d.ts +20 -0
- package/dist/types/components/composites/theme-switcher/ThemeSwitcher.d.ts +24 -0
- package/dist/types/components/compound/support-rail/SupportRail.d.ts +10 -8
- package/dist/types/components/dev/MotionDevtools.d.ts +10 -5
- package/dist/types/components/expressive/theme-transition/bloom.d.ts +2 -0
- package/dist/types/components/expressive/theme-transition/paint.d.ts +2 -0
- package/dist/types/components/expressive/theme-transition/scene.d.ts +24 -0
- package/dist/types/components/expressive/theme-transition/theme-transition.d.ts +19 -0
- package/dist/types/components/expressive/theme-transition/tide.d.ts +2 -0
- package/dist/types/components/internal/hooks/use-press-feedback.d.ts +7 -0
- package/dist/types/components/internal/icon/Icon.d.ts +1 -0
- package/dist/types/components/internal/overlay/layer.d.ts +7 -1
- package/dist/types/components/internal/utils/token-px.d.ts +1 -1
- package/dist/types/components/primitives/button/Button.d.ts +9 -12
- package/dist/types/components/primitives/button/button-style.d.ts +15 -0
- package/dist/types/components/primitives/spinner/Spinner.d.ts +27 -0
- package/dist/types/engine/animate.d.ts +1 -0
- package/dist/types/motion/motion-timing.d.ts +1 -1
- package/dist/types/tokens/component-styles.generated.d.ts +35 -38
- package/dist/types/tokens/motion-tokens.d.ts +5 -3
- package/dist/types/tokens/theme-store.d.ts +47 -0
- package/dist/types/tokens/theme-sync.d.ts +7 -1
- package/dist/types/tokens/theme-tokens.generated.d.ts +125 -115
- package/dist/types/tokens/theme.d.ts +28 -5
- package/dist/typing-lines.css +1 -1
- package/dist/typing-lines.js +2 -2
- package/dist/typing-lines.js.map +1 -1
- package/dist/weight-field.css +2 -2
- package/dist/youtube.css +1 -1
- package/dist/youtube.js +2 -2
- package/package.json +20 -24
- package/skills/zyncat-ui/SKILL.md +1 -1
- package/skills/zyncat-ui/references/components.md +5 -2
- package/skills/zyncat-ui/references/theming.md +31 -23
- package/src/components/composites/alert/Alert.tsx +7 -3
- package/src/components/composites/alert/alert.css +1 -1
- package/src/components/composites/date-picker/calendar-panel.tsx +10 -4
- package/src/components/composites/date-picker/date-picker.css +168 -43
- package/src/components/composites/date-picker/month-jump.tsx +192 -0
- package/src/components/composites/date-picker/range-panel.tsx +20 -5
- package/src/components/composites/dialog/Dialog.tsx +2 -2
- package/src/components/composites/dialog/dialog.css +4 -3
- package/src/components/composites/dropdown/Dropdown.tsx +5 -5
- package/src/components/composites/dropdown/dropdown.css +1 -1
- package/src/components/composites/emoji-picker/react/category-bar.tsx +17 -5
- package/src/components/composites/emoji-picker/scaffold.ts +6 -5
- package/src/components/composites/emoji-picker/styles.css +1 -1
- package/src/components/composites/modal/Modal.tsx +2 -2
- package/src/components/composites/modal/modal.css +1 -1
- package/src/components/composites/pagination/pagination.css +1 -1
- package/src/components/composites/popover/Popover.tsx +5 -5
- package/src/components/composites/popover/popover.css +1 -1
- package/src/components/composites/select/core/menu.tsx +15 -10
- package/src/components/composites/select/select.css +1 -1
- package/src/components/composites/sheet/Sheet.tsx +2 -2
- package/src/components/composites/sheet/sheet.css +1 -1
- package/src/components/composites/table/table.css +2 -2
- package/src/components/composites/tabs/Tabs.tsx +13 -7
- package/src/components/composites/tabs/tabs.css +10 -14
- package/src/components/composites/theme-switcher/ThemeGrid.tsx +133 -0
- package/src/components/composites/theme-switcher/ThemeGrid.usage.md +20 -0
- package/src/components/composites/theme-switcher/ThemeSwitcher.tsx +75 -0
- package/src/components/composites/theme-switcher/ThemeSwitcher.usage.md +21 -0
- package/src/components/composites/theme-switcher/theme-switcher.css +107 -0
- package/src/components/composites/toast/Toast.tsx +2 -1
- package/src/components/composites/toast/toast.css +2 -14
- package/src/components/composites/tooltip/tooltip-host.tsx +19 -17
- package/src/components/composites/tooltip/tooltip.css +1 -1
- package/src/components/compound/support-rail/SupportRail.tsx +116 -128
- package/src/components/compound/support-rail/SupportRail.usage.md +7 -6
- package/src/components/compound/support-rail/support-rail.css +76 -238
- package/src/components/dev/MotionDevtools.tsx +252 -42
- package/src/components/dev/MotionDevtools.usage.md +12 -4
- package/src/components/dev/motion-devtools.css +77 -2
- package/src/components/dev/slowmo-engine.ts +1 -1
- package/src/components/expressive/confetti/confetti.css +3 -3
- package/src/components/expressive/facebook-feed/facebook-feed.css +1 -1
- package/src/components/expressive/flow-field/FlowField.tsx +1 -1
- package/src/components/expressive/flow-field/flow-field.css +4 -4
- package/src/components/expressive/instagram-feed/instagram-feed.css +1 -1
- package/src/components/expressive/lens/lens.css +1 -2
- package/src/components/expressive/morphing-text/morphing-text.css +2 -2
- package/src/components/expressive/odometer/odometer.css +1 -1
- package/src/components/expressive/theme-transition/bloom.ts +88 -0
- package/src/components/expressive/theme-transition/paint.ts +296 -0
- package/src/components/expressive/theme-transition/scene.ts +38 -0
- package/src/components/expressive/theme-transition/theme-transition.css +48 -0
- package/src/components/expressive/theme-transition/theme-transition.ts +423 -0
- package/src/components/expressive/theme-transition/tide.ts +65 -0
- package/src/components/expressive/tiktok/tiktok.css +2 -3
- package/src/components/expressive/typing-lines/TypingLines.tsx +0 -0
- package/src/components/expressive/typing-lines/typing-lines.css +1 -1
- package/src/components/expressive/weight-field/weight-field.css +2 -2
- package/src/components/expressive/youtube/youtube.css +1 -1
- package/src/components/internal/glass/glass.css +1 -1
- package/src/components/internal/hooks/use-press-feedback.ts +52 -0
- package/src/components/internal/icon/Icon.tsx +2 -0
- package/src/components/internal/icon/icon.css +1 -1
- package/src/components/internal/menu/menu-surface.css +1 -1
- package/src/components/internal/overlay/layer.tsx +35 -2
- package/src/components/internal/overlay/overlay.css +1 -1
- package/src/components/internal/overlay/position.ts +2 -2
- package/src/components/internal/overlay/trigger.css +1 -1
- package/src/components/internal/utils/token-px.ts +4 -4
- package/src/components/primitives/avatar/avatar.css +3 -2
- package/src/components/primitives/badge/badge.css +1 -1
- package/src/components/primitives/badge/digit-strip.css +1 -1
- package/src/components/primitives/button/Button.tsx +28 -27
- package/src/components/primitives/button/button-style.ts +28 -0
- package/src/components/primitives/button/button.css +38 -31
- package/src/components/primitives/checkbox/checkbox.css +1 -1
- package/src/components/primitives/collapse/collapse.css +8 -5
- package/src/components/primitives/input/input.css +7 -4
- package/src/components/primitives/radio-group/radio-group.css +6 -4
- package/src/components/primitives/spinner/Spinner.tsx +70 -0
- package/src/components/primitives/spinner/Spinner.usage.md +19 -0
- package/src/components/primitives/spinner/spinner.css +115 -0
- package/src/components/primitives/tag/tag.css +1 -1
- package/src/components/primitives/textarea/textarea.css +1 -1
- package/src/components/primitives/toggle/toggle.css +1 -1
- package/src/engine/animate.ts +10 -2
- package/src/mcp/server.ts +2 -1
- package/src/motion/glide.tsx +9 -6
- package/src/motion/motion-timing.ts +5 -2
- package/src/styles.css +3 -4
- package/src/tokens/base.css +5 -5
- package/src/tokens/color.css +8 -9
- package/src/tokens/component-styles.generated.ts +36 -38
- package/src/tokens/dark.css +8 -13
- package/src/tokens/decisions.css +9 -12
- package/src/tokens/elevation.css +18 -26
- package/src/tokens/glass.css +3 -2
- package/src/tokens/motion-defaults.generated.ts +1 -1
- package/src/tokens/motion-tokens.ts +27 -8
- package/src/tokens/motion.css +9 -9
- package/src/tokens/radius.css +3 -2
- package/src/tokens/reset.css +36 -0
- package/src/tokens/semantic.css +12 -22
- package/src/tokens/spacing.css +1 -1
- package/src/tokens/theme-store.ts +187 -0
- package/src/tokens/theme-sync.tsx +49 -2
- package/src/tokens/theme-tokens.generated.ts +128 -116
- package/src/tokens/theme.tsx +96 -24
- package/src/tokens/theme.usage.md +25 -24
- package/src/tokens/typography.css +4 -3
- package/tailwind.css +8 -14
- package/dist/chunk-6SUHSSOK.js +0 -25
- package/dist/chunk-6SUHSSOK.js.map +0 -1
- package/dist/chunk-BH4JFWXQ.js.map +0 -1
- package/dist/chunk-CAXQJSIE.js.map +0 -1
- package/dist/chunk-FEXUS4SV.js.map +0 -1
- package/dist/chunk-FLQVOSFC.js.map +0 -1
- package/dist/chunk-GOLSYGRA.js.map +0 -1
- package/dist/chunk-IUQAUBVM.js.map +0 -1
- package/dist/chunk-K45CWVHS.js.map +0 -1
- package/dist/chunk-MDSRZ4QR.js.map +0 -1
- package/dist/chunk-N2GJEO5Z.js.map +0 -1
- package/dist/chunk-PWQVSVXR.js.map +0 -1
- package/dist/chunk-UE63OOVG.js +0 -13
- package/dist/chunk-UE63OOVG.js.map +0 -1
- package/dist/chunk-UYSXJ7MH.js +0 -52
- package/dist/chunk-UYSXJ7MH.js.map +0 -1
- package/dist/chunk-WZUTBJC4.js.map +0 -1
- package/src/tokens/fonts.css +0 -1
|
@@ -30,9 +30,9 @@ export function useAnchorPosition({ side, align, arrow, anchor, triggerRef, pane
|
|
|
30
30
|
const pw = p.offsetWidth;
|
|
31
31
|
const ph = p.offsetHeight;
|
|
32
32
|
|
|
33
|
-
const edge = tokenPx('--space-2');
|
|
33
|
+
const edge = tokenPx('--space-2', 0, p);
|
|
34
34
|
|
|
35
|
-
const gap = arrow ? tokenPx('--space-2') + 3 : 0;
|
|
35
|
+
const gap = arrow ? tokenPx('--space-2', 0, p) + 3 : 0;
|
|
36
36
|
|
|
37
37
|
const vw = window.innerWidth;
|
|
38
38
|
const vh = window.innerHeight;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export function tokenPx(token: string, fallback = 0): number {
|
|
1
|
+
export function tokenPx(token: string, fallback = 0, scope?: Element | null): number {
|
|
2
2
|
if (typeof document === 'undefined') return fallback;
|
|
3
|
-
const
|
|
4
|
-
const v = getComputedStyle(
|
|
3
|
+
const el = scope ?? document.documentElement;
|
|
4
|
+
const v = getComputedStyle(el).getPropertyValue(token).trim();
|
|
5
5
|
const n = parseFloat(v);
|
|
6
6
|
if (Number.isNaN(n)) return fallback;
|
|
7
|
-
return v.endsWith('rem') ? n * parseFloat(getComputedStyle(
|
|
7
|
+
return v.endsWith('rem') ? n * parseFloat(getComputedStyle(document.documentElement).fontSize) : n;
|
|
8
8
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
@layer zyncat.tokens, zyncat.components;
|
|
1
|
+
@layer zyncat.reset, zyncat.tokens, zyncat.components;
|
|
2
2
|
|
|
3
3
|
@layer zyncat.components {
|
|
4
4
|
.zc-avatar {
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
--avatar-edge: oklch(1 0 0 / calc(0.5 * var(--sheen-strength)));
|
|
9
9
|
--avatar-shade: oklch(0.225 0.012 264 / 0.05);
|
|
10
10
|
--avatar-sheen: oklch(1 0 0 / calc(0.35 * var(--sheen-strength)));
|
|
11
|
-
/* The identity palette is the component's own, so it flips with the color-scheme the polarity
|
|
11
|
+
/* The identity palette is the component's own, so it flips with the color-scheme the polarity
|
|
12
|
+
blocks set instead of living in dark.css. */
|
|
12
13
|
--avatar-1-bg: light-dark(oklch(0.945 0.04 250), oklch(0.31 0.055 250));
|
|
13
14
|
--avatar-1-fg: light-dark(oklch(0.45 0.08 250), oklch(0.87 0.07 250));
|
|
14
15
|
--avatar-2-bg: light-dark(oklch(0.945 0.04 292), oklch(0.31 0.055 292));
|
|
@@ -1,25 +1,29 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import './button.css';
|
|
4
|
-
|
|
5
3
|
import type { ButtonHTMLAttributes, CSSProperties, ReactNode, Ref } from 'react';
|
|
6
4
|
|
|
7
5
|
import type { DataAttributes } from '../../../dom-props';
|
|
6
|
+
import { usePressFeedback } from '../../internal/hooks/use-press-feedback';
|
|
8
7
|
import { cx } from '../../internal/utils/cx';
|
|
8
|
+
import { Spinner } from '../spinner/Spinner';
|
|
9
|
+
import { buttonClass, type ButtonSize, type ButtonVariant } from './button-style';
|
|
10
|
+
|
|
11
|
+
export { buttonClass } from './button-style';
|
|
12
|
+
export type { ButtonSize, ButtonStyleProps, ButtonVariant } from './button-style';
|
|
9
13
|
|
|
10
14
|
interface ButtonOwnProps {
|
|
11
|
-
/** Visual weight / intent.
|
|
12
|
-
|
|
13
|
-
variant?: 'primary' | 'secondary' | 'ghost' | 'danger' | 'link' | 'unstyled';
|
|
15
|
+
/** Visual weight / intent. @default 'primary' */
|
|
16
|
+
variant?: ButtonVariant;
|
|
14
17
|
/** Forwarded to the underlying <button> (React 19 ref-as-prop). */
|
|
15
18
|
ref?: Ref<HTMLButtonElement>;
|
|
16
19
|
/** Control height. sm 28px - md 32px (default) - lg 37px. @default 'md' */
|
|
17
|
-
size?:
|
|
20
|
+
size?: ButtonSize;
|
|
18
21
|
/** `submit` / `reset` / `button`. @default 'button' */
|
|
19
22
|
type?: 'button' | 'submit' | 'reset';
|
|
20
23
|
/** Disable the control (also implied by `loading`). */
|
|
21
24
|
disabled?: boolean;
|
|
22
|
-
/** Loading - swaps
|
|
25
|
+
/** Loading - swaps the label for a spinner and makes the button inert. The label stays
|
|
26
|
+
* mounted but invisible, so the button holds its width. */
|
|
23
27
|
loading?: boolean;
|
|
24
28
|
/** Stretch to fill the container width. */
|
|
25
29
|
fullWidth?: boolean;
|
|
@@ -29,14 +33,17 @@ interface ButtonOwnProps {
|
|
|
29
33
|
style?: CSSProperties;
|
|
30
34
|
/** Button label. */
|
|
31
35
|
children?: ReactNode;
|
|
32
|
-
/** Click handler */
|
|
33
|
-
onClick?: React.MouseEventHandler<HTMLButtonElement>;
|
|
34
|
-
/** Pointer handler */
|
|
35
|
-
onPointerDown?: React.PointerEventHandler<HTMLButtonElement>;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
type ButtonRestProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, keyof ButtonOwnProps> & DataAttributes;
|
|
39
39
|
|
|
40
|
+
const chain =
|
|
41
|
+
<E,>(theirs: ((event: E) => void) | undefined, mine: (event: E) => void) =>
|
|
42
|
+
(event: E) => {
|
|
43
|
+
mine(event);
|
|
44
|
+
theirs?.(event);
|
|
45
|
+
};
|
|
46
|
+
|
|
40
47
|
export interface ButtonProps extends ButtonOwnProps, ButtonRestProps {
|
|
41
48
|
/** Standard <button> attributes (onClick, name, form, aria-*, data-*, ...) forwarded verbatim.
|
|
42
49
|
* Bare `<button>` attributes also pass through directly; `htmlProps` wins on conflict. */
|
|
@@ -53,20 +60,14 @@ export function Button({
|
|
|
53
60
|
className = '',
|
|
54
61
|
style,
|
|
55
62
|
children,
|
|
56
|
-
onClick,
|
|
57
63
|
ref,
|
|
58
|
-
onPointerDown,
|
|
59
64
|
htmlProps,
|
|
60
65
|
...rest
|
|
61
66
|
}: ButtonProps) {
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
fullWidth && 'zc-btn--block',
|
|
67
|
-
loading && 'zc-is-loading',
|
|
68
|
-
className,
|
|
69
|
-
);
|
|
67
|
+
const inert = disabled || loading;
|
|
68
|
+
const press = usePressFeedback(inert);
|
|
69
|
+
const cls = cx(buttonClass({ variant, size, fullWidth, className }), loading && 'zc-is-loading');
|
|
70
|
+
const merged = { ...rest, ...htmlProps };
|
|
70
71
|
|
|
71
72
|
return (
|
|
72
73
|
<button
|
|
@@ -74,15 +75,15 @@ export function Button({
|
|
|
74
75
|
ref={ref}
|
|
75
76
|
className={cls}
|
|
76
77
|
style={style}
|
|
77
|
-
disabled={
|
|
78
|
+
disabled={inert}
|
|
78
79
|
aria-busy={loading || undefined}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
{
|
|
82
|
-
{
|
|
80
|
+
{...merged}
|
|
81
|
+
data-pressed={press.pressed ? 'true' : undefined}
|
|
82
|
+
onPointerDown={chain(merged.onPointerDown, press.onPointerDown)}
|
|
83
|
+
onPointerLeave={chain(merged.onPointerLeave, press.onPointerLeave)}
|
|
83
84
|
>
|
|
84
85
|
<span className="zc-btn__label">{children}</span>
|
|
85
|
-
{loading ? <
|
|
86
|
+
{loading ? <Spinner label={null} className="zc-btn__spinner" /> : null}
|
|
86
87
|
</button>
|
|
87
88
|
);
|
|
88
89
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import './button.css';
|
|
2
|
+
|
|
3
|
+
import { cx } from '../../internal/utils/cx';
|
|
4
|
+
|
|
5
|
+
export type ButtonVariant = 'primary' | 'secondary' | 'ghost' | 'danger' | 'link';
|
|
6
|
+
export type ButtonSize = 'sm' | 'md' | 'lg' | 'icon';
|
|
7
|
+
|
|
8
|
+
export interface ButtonStyleProps {
|
|
9
|
+
/** Visual weight / intent. Omit for base chrome only - sizing, focus ring, layout -
|
|
10
|
+
* with no skin, for a local re-skin through `className`. */
|
|
11
|
+
variant?: ButtonVariant;
|
|
12
|
+
/** Control height. sm 28px - md 32px (default) - lg 37px. @default 'md' */
|
|
13
|
+
size?: ButtonSize;
|
|
14
|
+
/** Stretch to fill the container width. */
|
|
15
|
+
fullWidth?: boolean;
|
|
16
|
+
/** Extra class(es) merged onto the result. */
|
|
17
|
+
className?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function buttonClass({ variant, size = 'md', fullWidth, className }: ButtonStyleProps = {}): string {
|
|
21
|
+
return cx(
|
|
22
|
+
'zc-btn',
|
|
23
|
+
variant && `zc-btn--${variant}`,
|
|
24
|
+
size !== 'md' && `zc-btn--${size}`,
|
|
25
|
+
fullWidth && 'zc-btn--block',
|
|
26
|
+
className,
|
|
27
|
+
);
|
|
28
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
@layer zyncat.tokens, zyncat.components;
|
|
1
|
+
@layer zyncat.reset, zyncat.tokens, zyncat.components;
|
|
2
2
|
|
|
3
3
|
@property --btn-grad-a {
|
|
4
4
|
syntax: '<color>';
|
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
--btn-shadow: none;
|
|
17
17
|
--btn-ring: var(--ring-accent);
|
|
18
18
|
--btn-gap: var(--space-2);
|
|
19
|
+
--btn-press-scale: 0.96;
|
|
20
|
+
--btn-press-timing: var(--duration-base) var(--ease-spring);
|
|
19
21
|
|
|
20
22
|
position: relative;
|
|
21
23
|
isolation: isolate;
|
|
@@ -28,6 +30,7 @@
|
|
|
28
30
|
padding: 0 var(--space-4);
|
|
29
31
|
border: var(--border-hairline) solid transparent;
|
|
30
32
|
border-radius: var(--radius-md);
|
|
33
|
+
background-color: transparent;
|
|
31
34
|
background-origin: border-box;
|
|
32
35
|
|
|
33
36
|
font-family: var(--font-body);
|
|
@@ -52,7 +55,7 @@
|
|
|
52
55
|
color var(--duration-fast) var(--ease-standard),
|
|
53
56
|
box-shadow var(--duration-fast) var(--ease-standard),
|
|
54
57
|
outline-color var(--duration-fast) var(--ease-standard),
|
|
55
|
-
transform var(--
|
|
58
|
+
transform var(--btn-press-timing);
|
|
56
59
|
outline: var(--ring-rest);
|
|
57
60
|
}
|
|
58
61
|
|
|
@@ -60,6 +63,12 @@
|
|
|
60
63
|
outline: var(--btn-ring);
|
|
61
64
|
}
|
|
62
65
|
|
|
66
|
+
.zc-btn:active:not(:disabled):not(.zc-is-loading),
|
|
67
|
+
.zc-btn[data-pressed] {
|
|
68
|
+
--btn-press-timing: var(--duration-fast) var(--ease-standard);
|
|
69
|
+
transform: scale(var(--btn-press-scale));
|
|
70
|
+
}
|
|
71
|
+
|
|
63
72
|
.zc-btn--sm {
|
|
64
73
|
height: var(--control-height-sm);
|
|
65
74
|
padding: 0 var(--space-3);
|
|
@@ -122,11 +131,10 @@
|
|
|
122
131
|
inset 0 1px 0 0 rgb(255 255 255 / calc(0.36 * var(--sheen-strength))),
|
|
123
132
|
inset 0 -1px 0 0 rgb(var(--shadow-rgb) / 0.18), var(--shadow-md), var(--glow-accent);
|
|
124
133
|
}
|
|
125
|
-
.zc-btn--primary:active:not(:disabled):not(.zc-is-loading)
|
|
134
|
+
.zc-btn--primary:active:not(:disabled):not(.zc-is-loading),
|
|
135
|
+
.zc-btn--primary[data-pressed]:not(:disabled):not(.zc-is-loading) {
|
|
126
136
|
--btn-grad-a: color-mix(in oklab, var(--accent-hover) 70%, var(--accent-active));
|
|
127
137
|
--btn-grad-b: var(--accent-fill);
|
|
128
|
-
transform: translateY(var(--space-px));
|
|
129
|
-
--btn-shadow: inset 0 1px 2px 0 rgb(var(--shadow-rgb) / 0.16), 0 1px 1px 0 rgb(var(--shadow-rgb) / 0.08);
|
|
130
138
|
}
|
|
131
139
|
|
|
132
140
|
.zc-btn--secondary {
|
|
@@ -146,10 +154,10 @@
|
|
|
146
154
|
--btn-grad-a: color-mix(in oklab, var(--text-secondary) 3%, var(--btn-face-lit));
|
|
147
155
|
--btn-grad-b: color-mix(in oklab, var(--text-secondary) 3%, var(--btn-face-shade));
|
|
148
156
|
}
|
|
149
|
-
.zc-btn--secondary:active:not(:disabled):not(.zc-is-loading)
|
|
157
|
+
.zc-btn--secondary:active:not(:disabled):not(.zc-is-loading),
|
|
158
|
+
.zc-btn--secondary[data-pressed]:not(:disabled):not(.zc-is-loading) {
|
|
150
159
|
--btn-grad-a: color-mix(in oklab, var(--text-secondary) 5%, var(--btn-face-lit));
|
|
151
160
|
--btn-grad-b: color-mix(in oklab, var(--text-secondary) 5%, var(--btn-face-shade));
|
|
152
|
-
transform: translateY(var(--space-px));
|
|
153
161
|
--btn-shadow: inset 0 1px 2px 0 rgb(var(--shadow-rgb) / 0.06);
|
|
154
162
|
}
|
|
155
163
|
|
|
@@ -173,14 +181,13 @@
|
|
|
173
181
|
.zc-btn--ghost:hover:not(:disabled):not(.zc-is-loading) {
|
|
174
182
|
color: var(--text-strong);
|
|
175
183
|
}
|
|
176
|
-
.zc-btn--ghost:hover:not(:disabled):not(.zc-is-loading)::before
|
|
184
|
+
.zc-btn--ghost:hover:not(:disabled):not(.zc-is-loading)::before,
|
|
185
|
+
.zc-btn--ghost[data-pressed]::before {
|
|
177
186
|
opacity: 1;
|
|
178
187
|
transform: scale(1);
|
|
179
188
|
}
|
|
180
|
-
.zc-btn--ghost:active:not(:disabled):not(.zc-is-loading)
|
|
181
|
-
|
|
182
|
-
}
|
|
183
|
-
.zc-btn--ghost:active:not(:disabled):not(.zc-is-loading)::before {
|
|
189
|
+
.zc-btn--ghost:active:not(:disabled):not(.zc-is-loading)::before,
|
|
190
|
+
.zc-btn--ghost[data-pressed]:not(:disabled):not(.zc-is-loading)::before {
|
|
184
191
|
background: var(--neutral-wash-press);
|
|
185
192
|
}
|
|
186
193
|
|
|
@@ -201,10 +208,10 @@
|
|
|
201
208
|
inset 0 1px 0 0 rgb(255 255 255 / calc(0.36 * var(--sheen-strength))),
|
|
202
209
|
inset 0 -1px 0 0 rgb(var(--shadow-rgb) / 0.18), var(--shadow-md), var(--glow-danger);
|
|
203
210
|
}
|
|
204
|
-
.zc-btn--danger:active:not(:disabled):not(.zc-is-loading)
|
|
211
|
+
.zc-btn--danger:active:not(:disabled):not(.zc-is-loading),
|
|
212
|
+
.zc-btn--danger[data-pressed]:not(:disabled):not(.zc-is-loading) {
|
|
205
213
|
--btn-grad-a: color-mix(in oklab, var(--danger) 70%, var(--danger-active));
|
|
206
214
|
--btn-grad-b: var(--danger-fill);
|
|
207
|
-
transform: translateY(var(--space-px));
|
|
208
215
|
--btn-shadow: inset 0 1px 2px 0 rgb(var(--shadow-rgb) / 0.16), 0 1px 1px 0 rgb(var(--shadow-rgb) / 0.08);
|
|
209
216
|
}
|
|
210
217
|
|
|
@@ -215,6 +222,7 @@
|
|
|
215
222
|
color: var(--text-accent);
|
|
216
223
|
background: none;
|
|
217
224
|
--btn-shadow: none;
|
|
225
|
+
--btn-press-scale: 1;
|
|
218
226
|
font-weight: var(--weight-medium);
|
|
219
227
|
}
|
|
220
228
|
.zc-btn--link:hover:not(:disabled):not(.zc-is-loading) {
|
|
@@ -222,7 +230,8 @@
|
|
|
222
230
|
text-decoration: underline;
|
|
223
231
|
text-underline-offset: var(--space-px);
|
|
224
232
|
}
|
|
225
|
-
.zc-btn--link:active:not(:disabled):not(.zc-is-loading)
|
|
233
|
+
.zc-btn--link:active:not(:disabled):not(.zc-is-loading),
|
|
234
|
+
.zc-btn--link[data-pressed]:not(:disabled):not(.zc-is-loading) {
|
|
226
235
|
color: var(--accent-active);
|
|
227
236
|
}
|
|
228
237
|
.zc-btn--link:focus-visible {
|
|
@@ -234,22 +243,25 @@
|
|
|
234
243
|
.zc-btn.zc-is-loading {
|
|
235
244
|
cursor: default;
|
|
236
245
|
}
|
|
237
|
-
.zc-btn:disabled {
|
|
246
|
+
.zc-btn:disabled:not([data-pressed]) {
|
|
238
247
|
transform: none;
|
|
239
248
|
}
|
|
240
249
|
.zc-btn--primary:disabled {
|
|
241
|
-
|
|
250
|
+
--btn-grad-a: var(--accent-disabled);
|
|
251
|
+
--btn-grad-b: var(--accent-disabled);
|
|
242
252
|
color: var(--text-on-accent);
|
|
243
253
|
--btn-shadow: none;
|
|
244
254
|
}
|
|
245
255
|
.zc-btn--danger:disabled {
|
|
246
|
-
|
|
256
|
+
--btn-grad-a: var(--danger-disabled);
|
|
257
|
+
--btn-grad-b: var(--danger-disabled);
|
|
247
258
|
color: var(--text-on-accent);
|
|
248
259
|
--btn-shadow: none;
|
|
249
260
|
}
|
|
250
261
|
.zc-btn--secondary:disabled {
|
|
251
262
|
color: var(--text-disabled);
|
|
252
|
-
|
|
263
|
+
--btn-grad-a: var(--bg-subtle);
|
|
264
|
+
--btn-grad-b: var(--bg-subtle);
|
|
253
265
|
border-color: var(--border-subtle);
|
|
254
266
|
--btn-shadow: none;
|
|
255
267
|
}
|
|
@@ -270,18 +282,13 @@
|
|
|
270
282
|
position: absolute;
|
|
271
283
|
top: 50%;
|
|
272
284
|
left: 50%;
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
animation: btn-spin var(--duration-spin) var(--ease-standard) infinite;
|
|
281
|
-
}
|
|
282
|
-
@keyframes btn-spin {
|
|
283
|
-
to {
|
|
284
|
-
transform: rotate(360deg);
|
|
285
|
+
translate: -50% -50%;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
@media (prefers-reduced-motion: reduce) {
|
|
289
|
+
.zc-btn:active:not(:disabled):not(.zc-is-loading),
|
|
290
|
+
.zc-btn[data-pressed] {
|
|
291
|
+
transform: none;
|
|
285
292
|
}
|
|
286
293
|
}
|
|
287
294
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
@layer zyncat.tokens, zyncat.components;
|
|
1
|
+
@layer zyncat.reset, zyncat.tokens, zyncat.components;
|
|
2
2
|
|
|
3
3
|
/* Registered non-inheriting so a Collapse's inline timing never leaks into a Collapse nested
|
|
4
4
|
inside it; unset, they resolve invalid and the var() fallbacks supply the defaults. */
|
|
@@ -35,8 +35,7 @@
|
|
|
35
35
|
.zc-collapse[data-open='false'] {
|
|
36
36
|
visibility: hidden;
|
|
37
37
|
}
|
|
38
|
-
/* No visibility: visible here -
|
|
39
|
-
nested under a closed ancestor hidden. */
|
|
38
|
+
/* No visibility: visible here - inheriting it would reveal a Collapse nested under a closed one. */
|
|
40
39
|
.zc-collapse[data-open='true'] {
|
|
41
40
|
grid-template-rows: 1fr;
|
|
42
41
|
transition:
|
|
@@ -53,12 +52,16 @@
|
|
|
53
52
|
grid-template-columns: 1fr;
|
|
54
53
|
}
|
|
55
54
|
|
|
56
|
-
/* min-size:0 is what lets the grid track collapse to 0. */
|
|
57
55
|
.zc-collapse__inner {
|
|
58
|
-
overflow:
|
|
56
|
+
overflow-x: visible;
|
|
57
|
+
overflow-y: clip;
|
|
59
58
|
min-height: 0;
|
|
60
59
|
min-width: 0;
|
|
61
60
|
}
|
|
61
|
+
.zc-collapse[data-axis='width'] .zc-collapse__inner {
|
|
62
|
+
overflow-x: clip;
|
|
63
|
+
overflow-y: visible;
|
|
64
|
+
}
|
|
62
65
|
|
|
63
66
|
.zc-collapse--fade .zc-collapse__inner {
|
|
64
67
|
opacity: 0;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
@layer zyncat.tokens, zyncat.components;
|
|
1
|
+
@layer zyncat.reset, zyncat.tokens, zyncat.components;
|
|
2
2
|
|
|
3
3
|
@layer zyncat.components {
|
|
4
4
|
.zc-fld {
|
|
@@ -205,8 +205,6 @@
|
|
|
205
205
|
display: grid;
|
|
206
206
|
grid-template-rows: 1fr 1fr;
|
|
207
207
|
border-left: var(--border-hairline) solid var(--border-default);
|
|
208
|
-
border-radius: 0 var(--radius-md) var(--radius-md) 0;
|
|
209
|
-
overflow: hidden;
|
|
210
208
|
}
|
|
211
209
|
.zc-numf__step {
|
|
212
210
|
border: 0;
|
|
@@ -218,6 +216,12 @@
|
|
|
218
216
|
transition: var(--transition-control);
|
|
219
217
|
padding: 0;
|
|
220
218
|
}
|
|
219
|
+
.zc-numf__step:first-child {
|
|
220
|
+
border-start-end-radius: var(--radius-md);
|
|
221
|
+
}
|
|
222
|
+
.zc-numf__step:last-child {
|
|
223
|
+
border-end-end-radius: var(--radius-md);
|
|
224
|
+
}
|
|
221
225
|
.zc-numf__step:hover {
|
|
222
226
|
background: var(--neutral-wash);
|
|
223
227
|
color: var(--text-strong);
|
|
@@ -232,7 +236,6 @@
|
|
|
232
236
|
}
|
|
233
237
|
.zc-numf__step:focus-visible {
|
|
234
238
|
outline: var(--ring-accent);
|
|
235
|
-
outline-offset: var(--ring-inset);
|
|
236
239
|
}
|
|
237
240
|
.zc-numf__step + .zc-numf__step {
|
|
238
241
|
border-top: var(--border-hairline) solid var(--border-default);
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
@layer zyncat.tokens, zyncat.components;
|
|
1
|
+
@layer zyncat.reset, zyncat.tokens, zyncat.components;
|
|
2
2
|
|
|
3
3
|
@layer zyncat.components {
|
|
4
|
-
/* Bespoke px: the
|
|
4
|
+
/* Bespoke px: the authored value is the ring gap and the marker falls out of it, so the two
|
|
5
|
+
never leave an odd remainder to halve. */
|
|
5
6
|
.zc-rg {
|
|
6
7
|
--radio-group-dot: 18px;
|
|
7
|
-
--radio-group-dot-
|
|
8
|
+
--radio-group-dot-gap: 4px;
|
|
9
|
+
--radio-group-dot-inner: calc(var(--radio-group-dot) - 2 * (var(--border-hairline) + var(--radio-group-dot-gap)));
|
|
8
10
|
|
|
9
11
|
display: grid;
|
|
10
12
|
border: 0;
|
|
@@ -14,7 +16,7 @@
|
|
|
14
16
|
}
|
|
15
17
|
.zc-rg--sm {
|
|
16
18
|
--radio-group-dot: 16px;
|
|
17
|
-
--radio-group-dot-
|
|
19
|
+
--radio-group-dot-gap: 3px;
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
.zc-rg__label {
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import './spinner.css';
|
|
2
|
+
|
|
3
|
+
import type { CSSProperties } from 'react';
|
|
4
|
+
|
|
5
|
+
import type { DataAttributes } from '../../../dom-props';
|
|
6
|
+
import { cx } from '../../internal/utils/cx';
|
|
7
|
+
|
|
8
|
+
export type SpinnerSize = 'inherit' | 'sm' | 'md' | 'lg';
|
|
9
|
+
export type SpinnerThickness = 'thin' | 'regular' | 'bold';
|
|
10
|
+
export type SpinnerVariant = 'arc' | 'dots' | 'pulse';
|
|
11
|
+
|
|
12
|
+
const PART_COUNT: Record<SpinnerVariant, number> = { arc: 0, pulse: 0, dots: 3 };
|
|
13
|
+
|
|
14
|
+
export interface SpinnerProps {
|
|
15
|
+
/** Diameter. `inherit` tracks the parent's font size at 1em, so a spinner beside a label
|
|
16
|
+
* always matches it; for any other size set `style={{ fontSize }}`. @default 'inherit' */
|
|
17
|
+
size?: SpinnerSize;
|
|
18
|
+
/** Stroke weight, scaled to the diameter so it holds up at every size. @default 'regular' */
|
|
19
|
+
thickness?: SpinnerThickness;
|
|
20
|
+
/** Which loader to draw. @default 'arc' */
|
|
21
|
+
variant?: SpinnerVariant;
|
|
22
|
+
/** What assistive tech announces. Pass `null` when something nearby already announces the
|
|
23
|
+
* wait - a button's `aria-busy`, an enclosing `role="status"` - and the spinner turns
|
|
24
|
+
* decorative rather than announcing it twice. @default 'Loading' */
|
|
25
|
+
label?: string | null;
|
|
26
|
+
/** Hold invisible for a beat before fading in, so work that finishes quickly never flashes
|
|
27
|
+
* a spinner. @default false */
|
|
28
|
+
delay?: boolean;
|
|
29
|
+
/** Extra class(es) merged onto the root. */
|
|
30
|
+
className?: string;
|
|
31
|
+
/** Inline styles merged onto the root. */
|
|
32
|
+
style?: CSSProperties;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function Spinner({
|
|
36
|
+
size = 'inherit',
|
|
37
|
+
thickness = 'regular',
|
|
38
|
+
variant = 'arc',
|
|
39
|
+
label = 'Loading',
|
|
40
|
+
delay = false,
|
|
41
|
+
className,
|
|
42
|
+
style,
|
|
43
|
+
...rest
|
|
44
|
+
}: SpinnerProps & DataAttributes) {
|
|
45
|
+
const decorative = label === null;
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<span
|
|
49
|
+
className={cx(
|
|
50
|
+
'zc-spin',
|
|
51
|
+
`zc-spin--${variant}`,
|
|
52
|
+
size !== 'inherit' && `zc-spin--${size}`,
|
|
53
|
+
thickness !== 'regular' && `zc-spin--${thickness}`,
|
|
54
|
+
delay && 'zc-spin--delayed',
|
|
55
|
+
className,
|
|
56
|
+
)}
|
|
57
|
+
style={style}
|
|
58
|
+
role={decorative ? undefined : 'status'}
|
|
59
|
+
aria-label={decorative ? undefined : label}
|
|
60
|
+
aria-hidden={decorative ? true : undefined}
|
|
61
|
+
{...rest}
|
|
62
|
+
>
|
|
63
|
+
<span className="zc-spin__figure">
|
|
64
|
+
{Array.from({ length: PART_COUNT[variant] }, (_, i) => (
|
|
65
|
+
<span key={i} className="zc-spin__part" style={{ '--_spinner-i': i } as CSSProperties} />
|
|
66
|
+
))}
|
|
67
|
+
</span>
|
|
68
|
+
</span>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Spinner - @zyncat/ui/spinner
|
|
2
|
+
|
|
3
|
+
Group: primitives
|
|
4
|
+
Docs: https://ui.zyncat.app/spinner
|
|
5
|
+
|
|
6
|
+
Indeterminate loader; three looks, no JavaScript, no layout of its own.
|
|
7
|
+
|
|
8
|
+
Sizing is type-relative: the default `size="inherit"` draws at 1em, so a spinner beside a label
|
|
9
|
+
matches it without being told to, and `style={{ fontSize }}` sets any other diameter. thickness
|
|
10
|
+
scales with the diameter, so a large spinner is not a hairline. It announces itself as
|
|
11
|
+
`role="status"` labelled "Loading" by default; pass `label={null}` where something nearby already
|
|
12
|
+
announces the wait, as Button does through `aria-busy`. delay holds it invisible for a beat, so work
|
|
13
|
+
that finishes quickly never flashes a spinner.
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
<Spinner />
|
|
17
|
+
<Spinner variant="dots" size="lg" thickness="bold" />
|
|
18
|
+
<Spinner label={null} delay />
|
|
19
|
+
```
|