@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
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import './theme-switcher.css';
|
|
4
|
+
|
|
5
|
+
import { useState, type CSSProperties } from 'react';
|
|
6
|
+
|
|
7
|
+
import type { DisableableAnimation } from '../../../motion/timing';
|
|
8
|
+
import { useTheme, useThemeTarget } from '../../../tokens/theme-sync';
|
|
9
|
+
import { cx } from '../../internal/utils/cx';
|
|
10
|
+
import { Button, type ButtonProps } from '../../primitives/button/Button';
|
|
11
|
+
import { Popover } from '../popover/Popover';
|
|
12
|
+
import { ThemeGrid, type ThemeGridProps } from './ThemeGrid';
|
|
13
|
+
|
|
14
|
+
const CAPTIONS: Record<string, string> = { system: 'System', light: 'Light', dark: 'Dark' };
|
|
15
|
+
|
|
16
|
+
export interface ThemeSwitcherProps {
|
|
17
|
+
/** Overrides the palette's own `name`, keyed like `themes`. For names that come from a translation. */
|
|
18
|
+
labels?: ThemeGridProps['labels'];
|
|
19
|
+
/** Accessible name of the control and its grid. @default 'Theme' */
|
|
20
|
+
label?: string;
|
|
21
|
+
/** Preferred side of the panel; flips to the opposite side when cramped. @default 'bottom' */
|
|
22
|
+
side?: 'top' | 'bottom' | 'left' | 'right';
|
|
23
|
+
/** Cross-axis alignment of the panel against the chip. @default 'end' */
|
|
24
|
+
align?: 'start' | 'center' | 'end';
|
|
25
|
+
/** Open/close timing - motion tokens only, or `null` to disable. @default open 'base'/'entrance', close 'fast'/'exit' */
|
|
26
|
+
animation?: DisableableAnimation;
|
|
27
|
+
/** Extra class(es) merged onto the chip. */
|
|
28
|
+
className?: string;
|
|
29
|
+
/** Inline styles merged onto the chip. */
|
|
30
|
+
style?: CSSProperties;
|
|
31
|
+
/** Standard <button> attributes (aria-*, data-*, ...) forwarded to the chip. */
|
|
32
|
+
htmlProps?: ButtonProps['htmlProps'];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function ThemeSwitcher({
|
|
36
|
+
labels,
|
|
37
|
+
label = 'Theme',
|
|
38
|
+
side = 'bottom',
|
|
39
|
+
align = 'end',
|
|
40
|
+
animation,
|
|
41
|
+
className,
|
|
42
|
+
style,
|
|
43
|
+
htmlProps,
|
|
44
|
+
}: ThemeSwitcherProps) {
|
|
45
|
+
const [open, setOpen] = useState(false);
|
|
46
|
+
const { themeNames } = useTheme();
|
|
47
|
+
const { theme, polarity } = useThemeTarget();
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<Popover
|
|
51
|
+
open={open}
|
|
52
|
+
onOpenChange={setOpen}
|
|
53
|
+
side={side}
|
|
54
|
+
align={align}
|
|
55
|
+
animation={animation}
|
|
56
|
+
htmlProps={{ className: 'zc-theme-switcher__panel', 'data-theme-lead': '' }}
|
|
57
|
+
trigger={
|
|
58
|
+
<Button
|
|
59
|
+
variant="ghost"
|
|
60
|
+
size="sm"
|
|
61
|
+
className={cx('zc-theme-switcher', className)}
|
|
62
|
+
style={style}
|
|
63
|
+
aria-label={`${label}: ${labels?.[theme] ?? themeNames[theme] ?? theme}, ${CAPTIONS[polarity]}`}
|
|
64
|
+
htmlProps={{ 'data-theme-lead': '', ...htmlProps }}
|
|
65
|
+
>
|
|
66
|
+
<span className="zc-theme-switcher__preview zc-theme-switcher__preview--chip" aria-hidden="true">
|
|
67
|
+
<span className="zc-theme-switcher__mini" />
|
|
68
|
+
</span>
|
|
69
|
+
</Button>
|
|
70
|
+
}
|
|
71
|
+
>
|
|
72
|
+
<ThemeGrid labels={labels} label={label} autoFocus onDismiss={() => setOpen(false)} />
|
|
73
|
+
</Popover>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# ThemeSwitcher - @zyncat/ui/theme-switcher
|
|
2
|
+
|
|
3
|
+
Group: overlays
|
|
4
|
+
Docs: https://ui.zyncat.app/theme-switcher
|
|
5
|
+
|
|
6
|
+
The theme control: a chip painted in the live palette opens a grid of miniatures, one card per palette and side plus a split System card, each drawn from that theme's real tokens.
|
|
7
|
+
|
|
8
|
+
Needs no props: mount `ZyncatTheme` once for the palettes and the flash-free boot, and the grid lists
|
|
9
|
+
every palette it declared, `default` first. A click applies the theme live and leaves the panel open to
|
|
10
|
+
compare; Escape, Enter, Tab or an outside press closes it and focus returns to the chip. Arrow keys
|
|
11
|
+
move through the grid as a radio group and select as they go - left and right change the side, up and
|
|
12
|
+
down the palette. Each palette shows its own `name`; `labels` overrides that per key, for names that
|
|
13
|
+
come from a translation. `label` is the accessible name, `side` and `align` place the panel,
|
|
14
|
+
`animation` retimes it. The chip is the miniature under the
|
|
15
|
+
page's current tokens, so it is right before hydration and after a change made elsewhere. For the grid
|
|
16
|
+
on its own surface - a settings page, a `Sheet` - reach for `@zyncat/ui/theme-grid`, which is the panel
|
|
17
|
+
body without the popover.
|
|
18
|
+
|
|
19
|
+
```tsx
|
|
20
|
+
<ThemeSwitcher align="end" />
|
|
21
|
+
```
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
@layer zyncat.reset, zyncat.tokens, zyncat.components;
|
|
2
|
+
|
|
3
|
+
@layer zyncat.components {
|
|
4
|
+
.zc-theme-switcher.zc-btn {
|
|
5
|
+
padding-inline: var(--space-1);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.zc-theme-switcher__preview {
|
|
9
|
+
--_theme-switcher-unit: 4px;
|
|
10
|
+
--_theme-switcher-stroke: 2px;
|
|
11
|
+
position: relative;
|
|
12
|
+
display: grid;
|
|
13
|
+
width: calc(19 * var(--_theme-switcher-unit));
|
|
14
|
+
height: calc(12 * var(--_theme-switcher-unit));
|
|
15
|
+
border: var(--border-hairline) solid var(--border-default);
|
|
16
|
+
border-radius: var(--radius-sm);
|
|
17
|
+
background: var(--bg-app);
|
|
18
|
+
box-shadow: var(--shadow-xs);
|
|
19
|
+
transition:
|
|
20
|
+
transform var(--duration-fast) var(--ease-entrance),
|
|
21
|
+
box-shadow var(--duration-base) var(--ease-entrance),
|
|
22
|
+
border-color var(--duration-fast) var(--ease-standard);
|
|
23
|
+
}
|
|
24
|
+
.zc-theme-switcher__preview--chip {
|
|
25
|
+
--_theme-switcher-unit: 1.8px;
|
|
26
|
+
border-color: var(--border-strong);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.zc-theme-switcher__mini {
|
|
30
|
+
grid-area: 1 / 1;
|
|
31
|
+
border-radius: calc(var(--radius-sm) - var(--border-hairline));
|
|
32
|
+
background:
|
|
33
|
+
radial-gradient(circle closest-side, var(--accent) 92%, transparent) 8% 8% / 6.5% 10.5%,
|
|
34
|
+
linear-gradient(var(--text-strong), var(--text-strong)) 24% 11% / 24% var(--_theme-switcher-stroke),
|
|
35
|
+
linear-gradient(var(--text-secondary), var(--text-secondary)) 24% 41% / 57% var(--_theme-switcher-stroke),
|
|
36
|
+
linear-gradient(var(--accent-fill), var(--accent-fill)) 86% 83% / 26% 14.5%,
|
|
37
|
+
linear-gradient(var(--border-subtle), var(--border-subtle)) 0 25% / 100% var(--border-hairline),
|
|
38
|
+
linear-gradient(var(--bg-surface), var(--bg-surface)) 0 0 / 100% 25%,
|
|
39
|
+
var(--bg-app);
|
|
40
|
+
background-repeat: no-repeat;
|
|
41
|
+
}
|
|
42
|
+
.zc-theme-switcher__mini--half {
|
|
43
|
+
clip-path: polygon(58% 0, 100% 0, 100% 100%, 42% 100%);
|
|
44
|
+
}
|
|
45
|
+
.zc-theme-switcher__ring {
|
|
46
|
+
position: absolute;
|
|
47
|
+
inset: calc(-0.75 * var(--_theme-switcher-unit));
|
|
48
|
+
border: var(--border-emphasis) solid var(--accent);
|
|
49
|
+
border-radius: calc(var(--radius-sm) + 0.75 * var(--_theme-switcher-unit));
|
|
50
|
+
pointer-events: none;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.zc-theme-switcher__panel {
|
|
54
|
+
padding: var(--space-2);
|
|
55
|
+
background: var(--bg-surface-raised);
|
|
56
|
+
border: var(--border-hairline) solid var(--border-default);
|
|
57
|
+
border-radius: var(--radius-lg);
|
|
58
|
+
box-shadow: var(--shadow-lg);
|
|
59
|
+
color: var(--text-body);
|
|
60
|
+
}
|
|
61
|
+
.zc-theme-switcher__grid {
|
|
62
|
+
display: grid;
|
|
63
|
+
gap: var(--space-2);
|
|
64
|
+
}
|
|
65
|
+
.zc-theme-switcher__row {
|
|
66
|
+
display: grid;
|
|
67
|
+
grid-template-columns: repeat(3, auto);
|
|
68
|
+
gap: var(--space-px) var(--space-1);
|
|
69
|
+
}
|
|
70
|
+
.zc-theme-switcher__row-label {
|
|
71
|
+
grid-column: 1 / -1;
|
|
72
|
+
padding: var(--space-1) var(--space-1) 0;
|
|
73
|
+
font: var(--type-micro);
|
|
74
|
+
color: var(--text-subtle);
|
|
75
|
+
}
|
|
76
|
+
.zc-theme-switcher__card {
|
|
77
|
+
appearance: none;
|
|
78
|
+
display: grid;
|
|
79
|
+
justify-items: center;
|
|
80
|
+
gap: var(--space-1);
|
|
81
|
+
padding: var(--space-1);
|
|
82
|
+
border: 0;
|
|
83
|
+
border-radius: var(--radius-md);
|
|
84
|
+
background: transparent;
|
|
85
|
+
font: var(--type-micro);
|
|
86
|
+
color: var(--text-muted);
|
|
87
|
+
cursor: pointer;
|
|
88
|
+
transition: var(--transition-colors);
|
|
89
|
+
outline: var(--ring-rest);
|
|
90
|
+
}
|
|
91
|
+
.zc-theme-switcher__card:hover,
|
|
92
|
+
.zc-theme-switcher__card.zc-is-selected {
|
|
93
|
+
color: var(--text-strong);
|
|
94
|
+
}
|
|
95
|
+
.zc-theme-switcher__card:focus-visible {
|
|
96
|
+
outline: var(--ring-accent);
|
|
97
|
+
}
|
|
98
|
+
.zc-theme-switcher__card:hover .zc-theme-switcher__preview {
|
|
99
|
+
transform: translateY(calc(-2 * var(--space-px))) scale(1.06);
|
|
100
|
+
border-color: var(--border-strong);
|
|
101
|
+
box-shadow: var(--shadow-md);
|
|
102
|
+
}
|
|
103
|
+
.zc-theme-switcher__card:active .zc-theme-switcher__preview {
|
|
104
|
+
transform: none;
|
|
105
|
+
box-shadow: var(--shadow-xs);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -31,6 +31,7 @@ import { Icon, type IconName } from '../../internal/icon/Icon';
|
|
|
31
31
|
import { cx } from '../../internal/utils/cx';
|
|
32
32
|
import { tokenPx } from '../../internal/utils/token-px';
|
|
33
33
|
import { Button } from '../../primitives/button/Button';
|
|
34
|
+
import { Spinner } from '../../primitives/spinner/Spinner';
|
|
34
35
|
import { DEFAULT_TOASTER_CONFIG, UIToast, type ToasterConfig, type ToastRecord, type ToastTone } from './toast-store';
|
|
35
36
|
|
|
36
37
|
const SM = UIMotion;
|
|
@@ -187,7 +188,7 @@ function ToastBody({ t }: { t: ToastRecord }) {
|
|
|
187
188
|
{t.tone !== 'default' && (
|
|
188
189
|
<Motion as="span" className="zc-toast__icon-glyph" animate={GLYPH_POP} deps={[t.tone]}>
|
|
189
190
|
{t.tone === 'loading' ? (
|
|
190
|
-
<
|
|
191
|
+
<Spinner label={null} className="zc-toast__spinner" />
|
|
191
192
|
) : (
|
|
192
193
|
<Icon name={TONE_ICON[t.tone] || 'info'} weight="fill" />
|
|
193
194
|
)}
|
|
@@ -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-toast-viewport {
|
|
@@ -212,20 +212,8 @@
|
|
|
212
212
|
}
|
|
213
213
|
|
|
214
214
|
.zc-toast__spinner {
|
|
215
|
-
|
|
216
|
-
box-sizing: border-box;
|
|
217
|
-
width: var(--icon-sm);
|
|
218
|
-
height: var(--icon-sm);
|
|
219
|
-
border-radius: var(--radius-full);
|
|
220
|
-
border: var(--border-emphasis) solid currentColor;
|
|
221
|
-
border-right-color: transparent;
|
|
215
|
+
font-size: var(--icon-sm);
|
|
222
216
|
color: var(--text-muted);
|
|
223
|
-
animation: toast-spin var(--duration-spin) linear infinite;
|
|
224
|
-
}
|
|
225
|
-
@keyframes toast-spin {
|
|
226
|
-
to {
|
|
227
|
-
transform: rotate(1turn);
|
|
228
|
-
}
|
|
229
217
|
}
|
|
230
218
|
|
|
231
219
|
.zc-toast__custom {
|
|
@@ -6,12 +6,12 @@ import { createPortal } from 'react-dom';
|
|
|
6
6
|
import { Motion } from '../../../motion/element';
|
|
7
7
|
import { Presence } from '../../../motion/presence';
|
|
8
8
|
import { popIn, popOut } from '../../../motion/presets';
|
|
9
|
-
import {
|
|
9
|
+
import { motionFor } from '../../../tokens/motion-tokens';
|
|
10
|
+
import { inheritedThemeAttrs } from '../../internal/overlay/layer';
|
|
10
11
|
import { tokenPx } from '../../internal/utils/token-px';
|
|
11
12
|
import { store, TOOLTIP_DOM_ID, type ActivePayload, type Placement } from './tooltip-store';
|
|
12
13
|
|
|
13
|
-
const
|
|
14
|
-
const TIP_LAYOUT = { size: 'morph' as const, timing: UIMotion.t.layout };
|
|
14
|
+
const tipLayout = (scope?: Element | null) => ({ size: 'morph' as const, timing: motionFor(scope).t.layout });
|
|
15
15
|
|
|
16
16
|
interface Size {
|
|
17
17
|
w: number;
|
|
@@ -26,10 +26,10 @@ interface RenderedBox extends TargetBox {
|
|
|
26
26
|
bodyW: number;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
function targetBox(size: Size, t: DOMRect, want: Placement): TargetBox {
|
|
29
|
+
function targetBox(size: Size, t: DOMRect, want: Placement, scope?: Element | null): TargetBox {
|
|
30
30
|
const vw = window.innerWidth,
|
|
31
31
|
vh = window.innerHeight,
|
|
32
|
-
TIP_GAP = tokenPx('--space-2', 8) || 8,
|
|
32
|
+
TIP_GAP = tokenPx('--space-2', 8, scope) || 8,
|
|
33
33
|
M = TIP_GAP;
|
|
34
34
|
let p = want;
|
|
35
35
|
if (p === 'top' && t.top - size.h - TIP_GAP < M) p = 'bottom';
|
|
@@ -61,10 +61,10 @@ function targetBox(size: Size, t: DOMRect, want: Placement): TargetBox {
|
|
|
61
61
|
|
|
62
62
|
const surface = () => document.getElementById(TOOLTIP_DOM_ID);
|
|
63
63
|
|
|
64
|
-
const fromEdge = (p: Placement) =>
|
|
65
|
-
|
|
66
|
-
y: p === 'top' ?
|
|
67
|
-
}
|
|
64
|
+
const fromEdge = (p: Placement, scope?: Element | null) => {
|
|
65
|
+
const { sm } = motionFor(scope).dist;
|
|
66
|
+
return { x: p === 'left' ? sm : p === 'right' ? -sm : 0, y: p === 'top' ? sm : p === 'bottom' ? -sm : 0 };
|
|
67
|
+
};
|
|
68
68
|
|
|
69
69
|
function Body({ a, width }: { a: ActivePayload; width?: number }) {
|
|
70
70
|
return (
|
|
@@ -82,26 +82,28 @@ function Body({ a, width }: { a: ActivePayload; width?: number }) {
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
function TipSurface({ a, box }: { a: ActivePayload; box: RenderedBox }) {
|
|
85
|
-
const
|
|
85
|
+
const motion = motionFor(a.anchor());
|
|
86
|
+
const edge = fromEdge(box.placement, a.anchor());
|
|
86
87
|
return (
|
|
87
88
|
<Motion
|
|
88
89
|
layout
|
|
89
|
-
layoutTransition={
|
|
90
|
+
layoutTransition={tipLayout(a.anchor())}
|
|
90
91
|
className="zc-tooltip"
|
|
92
|
+
{...inheritedThemeAttrs(a.anchor())}
|
|
91
93
|
id={TOOLTIP_DOM_ID}
|
|
92
94
|
role="tooltip"
|
|
93
95
|
data-placement={box.placement}
|
|
94
96
|
style={{ translate: `${box.x}px ${box.y}px`, width: box.w, height: box.h }}
|
|
95
97
|
animate={[
|
|
96
|
-
{ x: [edge.x, 0], y: [edge.y, 0], timing: { ...
|
|
97
|
-
popIn(
|
|
98
|
+
{ x: [edge.x, 0], y: [edge.y, 0], timing: { ...motion.t.layout, fill: 'none' }, composite: 'add' },
|
|
99
|
+
popIn(motion.scale.floating, motion.t.enter),
|
|
98
100
|
]}
|
|
99
101
|
exit={[
|
|
100
|
-
{ x: [0, edge.x], y: [0, edge.y], timing:
|
|
101
|
-
popOut(
|
|
102
|
+
{ x: [0, edge.x], y: [0, edge.y], timing: motion.t.exit, composite: 'add' },
|
|
103
|
+
popOut(motion.scale.floating, motion.t.exit),
|
|
102
104
|
]}
|
|
103
105
|
>
|
|
104
|
-
<Motion as="span" key={a.id} animate={{ opacity: [0, 1], timing:
|
|
106
|
+
<Motion as="span" key={a.id} animate={{ opacity: [0, 1], timing: motion.t.enter }}>
|
|
105
107
|
<Body a={a} width={box.bodyW} />
|
|
106
108
|
</Motion>
|
|
107
109
|
</Motion>
|
|
@@ -131,7 +133,7 @@ export function TooltipHost() {
|
|
|
131
133
|
if (!from.width && !from.height) return;
|
|
132
134
|
if (!surface()) drift.current = { x: 0, y: 0 };
|
|
133
135
|
anchored.current = { x: from.left, y: from.top };
|
|
134
|
-
const to = targetBox({ w: Math.ceil(bubble.width), h: Math.ceil(bubble.height) }, from, active.placement);
|
|
136
|
+
const to = targetBox({ w: Math.ceil(bubble.width), h: Math.ceil(bubble.height) }, from, active.placement, anchor);
|
|
135
137
|
setShown({
|
|
136
138
|
a: active,
|
|
137
139
|
box: { ...to, x: to.x - drift.current.x, y: to.y - drift.current.y, bodyW: Math.ceil(body.width) },
|