@zyncat/ui 0.19.0 → 0.21.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/dist/alert.css +1 -2
- package/dist/alert.js +6 -6
- package/dist/avatar.css +1 -1
- package/dist/badge.css +21 -12
- package/dist/badge.js +100 -2
- package/dist/badge.js.map +1 -1
- package/dist/{bloom-HV23M4AW.js → bloom-5MZXLNKG.js} +23 -5
- package/dist/bloom-5MZXLNKG.js.map +1 -0
- package/dist/button.css +1 -2
- package/dist/button.js +2 -2
- package/dist/checkbox.css +1 -1
- package/dist/{chunk-JINATP4N.js → chunk-2W7FOMWE.js} +7 -8
- package/dist/chunk-2W7FOMWE.js.map +1 -0
- package/dist/{chunk-LNAV5E7S.js → chunk-3HE7N3UK.js} +7 -3
- package/dist/chunk-3HE7N3UK.js.map +1 -0
- package/dist/{chunk-UKPX3RIP.js → chunk-47OMFFIB.js} +3 -3
- package/dist/{chunk-UKPX3RIP.js.map → chunk-47OMFFIB.js.map} +1 -1
- package/dist/chunk-4M5FMCFJ.js +16 -0
- package/dist/chunk-4M5FMCFJ.js.map +1 -0
- package/dist/chunk-6BY5G7BI.js +122 -0
- package/dist/chunk-6BY5G7BI.js.map +1 -0
- package/dist/{chunk-RLNCRDAL.js → chunk-AOEO2LCZ.js} +4 -4
- package/dist/{chunk-RLNCRDAL.js.map → chunk-AOEO2LCZ.js.map} +1 -1
- package/dist/{chunk-BRKGYLEQ.js → chunk-AQMR7ZYO.js} +8 -3
- package/dist/chunk-AQMR7ZYO.js.map +1 -0
- package/dist/{chunk-N43NDSME.js → chunk-AXZBD7LY.js} +6 -3
- package/dist/chunk-AXZBD7LY.js.map +1 -0
- package/dist/{chunk-V6QAAOA5.js → chunk-BWGK3OD6.js} +9 -6
- package/dist/chunk-BWGK3OD6.js.map +1 -0
- package/dist/{chunk-VQFILXQN.js → chunk-CYZKPUCG.js} +70 -8
- package/dist/chunk-CYZKPUCG.js.map +1 -0
- package/dist/{chunk-AIAPXRCI.js → chunk-DEZIQTBW.js} +176 -103
- package/dist/chunk-DEZIQTBW.js.map +1 -0
- package/dist/{tide-DJZMDAFT.js → chunk-DVLKB3CZ.js} +15 -12
- package/dist/chunk-DVLKB3CZ.js.map +1 -0
- package/dist/{chunk-F64Z42PJ.js → chunk-GM7IPTTT.js} +5 -6
- package/dist/chunk-GM7IPTTT.js.map +1 -0
- package/dist/chunk-ITW5UCVU.js +24 -0
- package/dist/chunk-ITW5UCVU.js.map +1 -0
- package/dist/{chunk-TDHLZY6I.js → chunk-JQZ3FTHP.js} +77 -18
- package/dist/chunk-JQZ3FTHP.js.map +1 -0
- package/dist/{chunk-PXQBJMPJ.js → chunk-LC6NQQER.js} +3 -3
- package/dist/{chunk-PXQBJMPJ.js.map → chunk-LC6NQQER.js.map} +1 -1
- package/dist/{chunk-M2KGLH2G.js → chunk-LV442ZOR.js} +10 -10
- package/dist/{chunk-M2KGLH2G.js.map → chunk-LV442ZOR.js.map} +1 -1
- package/dist/{chunk-F2TB3TT6.js → chunk-PNFFK5HY.js} +4 -4
- package/dist/{chunk-F2TB3TT6.js.map → chunk-PNFFK5HY.js.map} +1 -1
- package/dist/{chunk-2YGHPQ66.js → chunk-Q5N24VII.js} +2 -2
- package/dist/{chunk-2YGHPQ66.js.map → chunk-Q5N24VII.js.map} +1 -1
- package/dist/{chunk-XKDR22VE.js → chunk-SPFHWHJ6.js} +8 -4
- package/dist/chunk-SPFHWHJ6.js.map +1 -0
- package/dist/{chunk-TRPAKUIB.js → chunk-TBIY5YR5.js} +8 -8
- package/dist/{chunk-TRPAKUIB.js.map → chunk-TBIY5YR5.js.map} +1 -1
- package/dist/chunk-TXJQUN7C.js +108 -0
- package/dist/chunk-TXJQUN7C.js.map +1 -0
- package/dist/{chunk-VZXML7EH.js → chunk-V4ZN5RD4.js} +12 -3
- package/dist/chunk-V4ZN5RD4.js.map +1 -0
- package/dist/{chunk-VJXP256V.js → chunk-ZSP4ZTII.js} +7 -7
- package/dist/{chunk-VJXP256V.js.map → chunk-ZSP4ZTII.js.map} +1 -1
- package/dist/collapse.css +1 -1
- package/dist/confetti.css +1 -1
- package/dist/confetti.js +1 -1
- package/dist/crossfade-XFZLFLT7.js +91 -0
- package/dist/crossfade-XFZLFLT7.js.map +1 -0
- package/dist/date-field.js +20 -18
- package/dist/date-field.js.map +1 -1
- package/dist/date-picker.css +7 -8
- package/dist/date-range-field.js +22 -20
- 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 +1 -2
- package/dist/dialog.js +9 -9
- package/dist/digit-strip.css +1 -1
- package/dist/dropdown.css +13 -10
- package/dist/dropdown.js +37 -20
- package/dist/dropdown.js.map +1 -1
- package/dist/emoji-picker.js +14 -14
- package/dist/facebook-feed.css +1 -1
- package/dist/flow-field.css +1 -1
- package/dist/flow-field.js +1 -1
- package/dist/glide.js +2 -2
- package/dist/icon.css +1 -1
- package/dist/input.css +1 -4
- package/dist/instagram-feed.css +1 -1
- package/dist/instagram-feed.js +2 -2
- package/dist/lens.css +1 -1
- package/dist/lens.js +1 -1
- package/dist/menu-surface.css +82 -8
- package/dist/modal.css +1 -1
- package/dist/modal.js +8 -8
- package/dist/morphing-text.css +1 -1
- package/dist/morphing-text.js +1 -1
- package/dist/motion-devtools.css +1 -1
- package/dist/motion-devtools.js +3 -3
- package/dist/motion.js +9 -0
- package/dist/motion.js.map +1 -0
- package/dist/multi-select.js +34 -16
- package/dist/multi-select.js.map +1 -1
- package/dist/number-field.js +2 -2
- package/dist/odometer.css +17 -11
- package/dist/odometer.js +105 -72
- package/dist/odometer.js.map +1 -1
- package/dist/otp-field.js +17 -9
- package/dist/otp-field.js.map +1 -1
- package/dist/overlay.css +1 -1
- package/dist/pagination.css +1 -1
- package/dist/pagination.js +4 -4
- package/dist/{paint-CJQCM6ZO.js → paint-NLTI6TEF.js} +5 -3
- package/dist/paint-NLTI6TEF.js.map +1 -0
- package/dist/popover.css +1 -1
- package/dist/popover.js +9 -9
- package/dist/radio-group.css +11 -5
- package/dist/radio-group.js +5 -5
- package/dist/select.css +34 -8
- package/dist/select.js +25 -12
- package/dist/select.js.map +1 -1
- package/dist/sheet.css +1 -1
- package/dist/sheet.js +9 -9
- package/dist/spinner.css +1 -1
- package/dist/styles.css +1 -1
- package/dist/support-rail.css +7 -2
- package/dist/support-rail.js +11 -11
- package/dist/table.css +10 -5
- package/dist/table.js +7 -7
- package/dist/tabs.css +32 -7
- package/dist/tabs.js +55 -44
- package/dist/tabs.js.map +1 -1
- package/dist/tag.css +1 -1
- package/dist/tag.js +4 -4
- package/dist/textarea.css +14 -2
- package/dist/textarea.js +36 -23
- package/dist/textarea.js.map +1 -1
- package/dist/theme-grid.js +5 -5
- package/dist/theme-switcher.css +1 -2
- package/dist/theme-switcher.js +14 -14
- package/dist/{theme-transition-VGLPZDJI.js → theme-transition-FDF2REFD.js} +27 -7
- package/dist/theme-transition-FDF2REFD.js.map +1 -0
- package/dist/theme-transition.css +50 -1
- package/dist/theme.js +2 -2
- package/dist/theme.js.map +1 -1
- package/dist/tide-AGGMQEJV.js +4 -0
- package/dist/tide-AGGMQEJV.js.map +1 -0
- package/dist/tiktok.css +1 -1
- package/dist/tiktok.js +2 -2
- package/dist/time-field.js +5 -3
- package/dist/time-field.js.map +1 -1
- package/dist/toast.css +1 -1
- package/dist/toast.js +7 -7
- package/dist/toggle-tag.js +2 -2
- package/dist/toggle.css +1 -1
- package/dist/toggle.js +4 -15
- package/dist/toggle.js.map +1 -1
- package/dist/tooltip.css +1 -1
- package/dist/tooltip.js +6 -7
- package/dist/tooltip.js.map +1 -1
- package/dist/trigger.css +1 -2
- package/dist/types/components/composites/date-picker/DateField.d.ts +1 -1
- package/dist/types/components/composites/date-picker/DateRangeField.d.ts +1 -1
- package/dist/types/components/composites/date-picker/DateTimeField.d.ts +1 -1
- package/dist/types/components/composites/date-picker/TimeField.d.ts +1 -1
- package/dist/types/components/composites/date-picker/field-shell.d.ts +5 -1
- package/dist/types/components/composites/dropdown/Dropdown.d.ts +13 -2
- package/dist/types/components/composites/dropdown/types.d.ts +5 -2
- package/dist/types/components/composites/select/MultiSelect.d.ts +23 -3
- package/dist/types/components/composites/select/Select.d.ts +20 -4
- package/dist/types/components/composites/select/core/index.d.ts +2 -1
- package/dist/types/components/composites/select/core/menu.d.ts +8 -5
- package/dist/types/components/composites/select/core/panel.d.ts +6 -4
- package/dist/types/components/composites/select/core/trigger.d.ts +7 -2
- package/dist/types/components/composites/select/core/types.d.ts +9 -0
- package/dist/types/components/composites/select/core/use-listbox.d.ts +5 -3
- package/dist/types/components/composites/tabs/Tabs.d.ts +6 -1
- package/dist/types/components/expressive/odometer/Odometer.d.ts +1 -1
- package/dist/types/components/expressive/odometer/roll.d.ts +20 -0
- package/dist/types/components/expressive/theme-transition/scene.d.ts +3 -0
- package/dist/types/components/internal/menu/highlight.d.ts +9 -1
- package/dist/types/components/internal/menu/menu-row.d.ts +4 -0
- package/dist/types/components/internal/menu/use-anchor-width.d.ts +2 -0
- package/dist/types/components/internal/overlay/layer.d.ts +5 -8
- package/dist/types/components/internal/overlay/track-anchor.d.ts +5 -0
- package/dist/types/components/internal/utils/activation.d.ts +1 -0
- package/dist/types/components/primitives/badge/Badge.d.ts +17 -8
- package/dist/types/components/primitives/badge/morph-label.d.ts +3 -0
- package/dist/types/components/primitives/badge/use-glint-on-change.d.ts +2 -0
- package/dist/types/components/primitives/input/OtpField.d.ts +2 -2
- package/dist/types/components/primitives/textarea/Textarea.d.ts +2 -2
- package/dist/types/components/primitives/textarea/char-meter.d.ts +6 -0
- package/dist/types/components/primitives/toggle/switch-glyph.d.ts +6 -0
- package/dist/types/motion/crossfade.d.ts +3 -0
- package/dist/types/motion/element.d.ts +6 -3
- package/dist/types/motion/flip.d.ts +8 -2
- package/dist/types/motion/motion.d.ts +7 -0
- package/dist/types/theme-scope.d.ts +5 -0
- package/dist/types/tokens/component-styles.generated.d.ts +0 -2
- package/dist/types/tokens/theme-tokens.generated.d.ts +38 -32
- package/dist/typing-lines.css +1 -1
- package/dist/typing-lines.js +1 -1
- package/dist/weight-field.css +1 -1
- package/dist/youtube.css +1 -1
- package/dist/youtube.js +2 -2
- package/package.json +6 -11
- package/skills/zyncat-ui/SKILL.md +2 -2
- package/skills/zyncat-ui/references/components.md +3 -4
- package/skills/zyncat-ui/references/theming.md +3 -3
- package/src/components/composites/alert/alert.css +1 -2
- package/src/components/composites/date-picker/DateField.tsx +2 -0
- package/src/components/composites/date-picker/DateRangeField.tsx +2 -0
- package/src/components/composites/date-picker/DateTimeField.tsx +2 -0
- package/src/components/composites/date-picker/TimeField.tsx +2 -0
- package/src/components/composites/date-picker/date-picker.css +7 -8
- package/src/components/composites/date-picker/field-shell.tsx +14 -1
- package/src/components/composites/dialog/dialog.css +1 -2
- package/src/components/composites/dropdown/Dropdown.tsx +20 -3
- package/src/components/composites/dropdown/Dropdown.usage.md +2 -0
- package/src/components/composites/dropdown/dropdown.css +13 -10
- package/src/components/composites/dropdown/menu-panel.tsx +28 -13
- package/src/components/composites/dropdown/types.ts +5 -2
- package/src/components/composites/emoji-picker/styles.css +1 -1
- package/src/components/composites/modal/modal.css +1 -1
- package/src/components/composites/pagination/pagination.css +1 -1
- package/src/components/composites/popover/popover.css +1 -1
- package/src/components/composites/select/MultiSelect.tsx +56 -5
- package/src/components/composites/select/MultiSelect.usage.md +10 -0
- package/src/components/composites/select/Select.tsx +32 -2
- package/src/components/composites/select/Select.usage.md +13 -1
- package/src/components/composites/select/core/index.ts +2 -1
- package/src/components/composites/select/core/menu.tsx +28 -15
- package/src/components/composites/select/core/panel.tsx +57 -52
- package/src/components/composites/select/core/trigger.tsx +44 -11
- package/src/components/composites/select/core/types.ts +10 -0
- package/src/components/composites/select/core/use-listbox.ts +77 -31
- package/src/components/composites/select/select.css +34 -8
- package/src/components/composites/sheet/sheet.css +1 -1
- package/src/components/composites/table/table.css +10 -5
- package/src/components/composites/tabs/Tabs.tsx +13 -1
- package/src/components/composites/tabs/tabs.css +32 -7
- package/src/components/composites/theme-switcher/theme-switcher.css +1 -2
- package/src/components/composites/toast/toast.css +1 -1
- package/src/components/composites/tooltip/tooltip-host.tsx +1 -1
- package/src/components/composites/tooltip/tooltip.css +1 -1
- package/src/components/compound/support-rail/support-rail.css +7 -2
- package/src/components/dev/motion-devtools.css +1 -1
- package/src/components/expressive/confetti/confetti.css +1 -1
- package/src/components/expressive/facebook-feed/facebook-feed.css +1 -1
- package/src/components/expressive/flow-field/flow-field.css +1 -1
- package/src/components/expressive/instagram-feed/instagram-feed.css +1 -1
- package/src/components/expressive/lens/lens.css +1 -1
- package/src/components/expressive/morphing-text/morphing-text.css +1 -1
- package/src/components/expressive/odometer/Odometer.tsx +45 -92
- package/src/components/expressive/odometer/Odometer.usage.md +2 -2
- package/src/components/expressive/odometer/odometer.css +17 -11
- package/src/components/expressive/odometer/roll.ts +94 -0
- package/src/components/expressive/theme-transition/bloom.ts +22 -2
- package/src/components/expressive/theme-transition/paint.ts +2 -0
- package/src/components/expressive/theme-transition/scene.ts +3 -0
- package/src/components/expressive/theme-transition/theme-transition.css +50 -1
- package/src/components/expressive/theme-transition/theme-transition.ts +21 -1
- package/src/components/expressive/theme-transition/tide.ts +15 -10
- package/src/components/expressive/tiktok/tiktok.css +1 -1
- package/src/components/expressive/typing-lines/typing-lines.css +1 -1
- package/src/components/expressive/weight-field/weight-field.css +1 -1
- package/src/components/expressive/youtube/youtube.css +1 -1
- package/src/components/internal/glass/glass.css +1 -1
- package/src/components/internal/icon/icon.css +1 -1
- package/src/components/internal/menu/highlight.ts +20 -2
- package/src/components/internal/menu/menu-row.tsx +36 -8
- package/src/components/internal/menu/menu-surface.css +82 -8
- package/src/components/internal/menu/use-anchor-width.ts +26 -0
- package/src/components/internal/overlay/layer.tsx +11 -23
- package/src/components/internal/overlay/overlay.css +1 -1
- package/src/components/internal/overlay/position.ts +17 -6
- package/src/components/internal/overlay/track-anchor.ts +69 -0
- package/src/components/internal/overlay/trigger.css +1 -2
- package/src/components/internal/utils/activation.ts +5 -0
- package/src/components/primitives/avatar/avatar.css +1 -1
- package/src/components/primitives/badge/Badge.tsx +38 -15
- package/src/components/primitives/badge/Badge.usage.md +12 -5
- package/src/components/primitives/badge/badge.css +21 -12
- package/src/components/primitives/badge/digit-strip.css +1 -1
- package/src/components/primitives/badge/morph-label.tsx +71 -0
- package/src/components/primitives/badge/use-glint-on-change.ts +16 -0
- package/src/components/primitives/button/button.css +1 -2
- package/src/components/primitives/checkbox/checkbox.css +1 -1
- package/src/components/primitives/collapse/collapse.css +1 -1
- package/src/components/primitives/input/OtpField.tsx +17 -9
- package/src/components/primitives/input/input.css +1 -4
- package/src/components/primitives/radio-group/radio-group.css +11 -5
- package/src/components/primitives/spinner/spinner.css +1 -1
- package/src/components/primitives/tag/tag.css +1 -1
- package/src/components/primitives/textarea/Textarea.tsx +20 -24
- package/src/components/primitives/textarea/char-meter.tsx +34 -0
- package/src/components/primitives/textarea/textarea.css +14 -2
- package/src/components/primitives/toggle/Toggle.tsx +3 -12
- package/src/components/primitives/toggle/switch-glyph.tsx +25 -0
- package/src/components/primitives/toggle/toggle.css +1 -1
- package/src/engine/flip.ts +5 -1
- package/src/motion/crossfade.ts +97 -0
- package/src/motion/element.tsx +10 -7
- package/src/motion/flip.ts +62 -23
- package/src/motion/glide.tsx +5 -0
- package/src/motion/motion.ts +7 -0
- package/src/motion/motion.usage.md +34 -0
- package/src/motion/presence.tsx +4 -0
- package/src/motion/use-motion.ts +8 -3
- package/src/styles.css +1 -1
- package/src/theme-scope.ts +19 -0
- package/src/tokens/base.css +62 -13
- package/src/tokens/color.css +18 -16
- package/src/tokens/component-styles.generated.ts +0 -2
- package/src/tokens/dark.css +4 -1
- package/src/tokens/decisions.css +6 -4
- package/src/tokens/elevation.css +1 -1
- package/src/tokens/glass.css +1 -1
- package/src/tokens/motion.css +4 -4
- package/src/tokens/radius.css +1 -1
- package/src/tokens/reset.css +17 -45
- package/src/tokens/semantic.css +13 -7
- package/src/tokens/spacing.css +4 -4
- package/src/tokens/theme-tokens.generated.ts +38 -32
- package/src/tokens/typography.css +1 -1
- package/tailwind.css +3 -1
- package/dist/bloom-HV23M4AW.js.map +0 -1
- package/dist/chunk-2DNKZ57E.js +0 -72
- package/dist/chunk-2DNKZ57E.js.map +0 -1
- package/dist/chunk-AIAPXRCI.js.map +0 -1
- package/dist/chunk-BRKGYLEQ.js.map +0 -1
- package/dist/chunk-F64Z42PJ.js.map +0 -1
- package/dist/chunk-JINATP4N.js.map +0 -1
- package/dist/chunk-LNAV5E7S.js.map +0 -1
- package/dist/chunk-N43NDSME.js.map +0 -1
- package/dist/chunk-RJENXXTI.js +0 -93
- package/dist/chunk-RJENXXTI.js.map +0 -1
- package/dist/chunk-RW2A4M2Q.js +0 -57
- package/dist/chunk-RW2A4M2Q.js.map +0 -1
- package/dist/chunk-TDHLZY6I.js.map +0 -1
- package/dist/chunk-V6QAAOA5.js.map +0 -1
- package/dist/chunk-VDOBLABP.js +0 -38
- package/dist/chunk-VDOBLABP.js.map +0 -1
- package/dist/chunk-VQFILXQN.js.map +0 -1
- package/dist/chunk-VZXML7EH.js.map +0 -1
- package/dist/chunk-XKDR22VE.js.map +0 -1
- package/dist/count-badge.js +0 -13
- package/dist/count-badge.js.map +0 -1
- package/dist/paint-CJQCM6ZO.js.map +0 -1
- package/dist/status-badge.js +0 -72
- package/dist/status-badge.js.map +0 -1
- package/dist/theme-transition-VGLPZDJI.js.map +0 -1
- package/dist/tide-DJZMDAFT.js.map +0 -1
- package/dist/types/components/primitives/badge/CountBadge.d.ts +0 -8
- package/dist/types/components/primitives/badge/StatusBadge.d.ts +0 -15
- package/src/components/primitives/badge/CountBadge.tsx +0 -20
- package/src/components/primitives/badge/CountBadge.usage.md +0 -13
- package/src/components/primitives/badge/StatusBadge.tsx +0 -113
- package/src/components/primitives/badge/StatusBadge.usage.md +0 -14
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { animate, measure, type Box, type FlipOptions, type Playback } from '../engine';
|
|
2
|
+
import { claim } from '../engine/animate';
|
|
3
|
+
import { sharedSlot } from '../shared-slot';
|
|
4
|
+
import { inheritedThemeAttrs } from '../theme-scope';
|
|
5
|
+
|
|
6
|
+
const SHOWN_BY = 0.45;
|
|
7
|
+
const GONE_BY = 0.5;
|
|
8
|
+
|
|
9
|
+
interface Copy {
|
|
10
|
+
el: HTMLElement;
|
|
11
|
+
box: Box;
|
|
12
|
+
of: HTMLElement;
|
|
13
|
+
play?: Playback;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const kept = sharedSlot('motion.crossfade@2', () => new Map<string, Copy>());
|
|
17
|
+
const riding = new WeakMap<HTMLElement, Copy>();
|
|
18
|
+
|
|
19
|
+
function onto(el: HTMLElement, box: Box, target: Box): { x: number; y: number; scale: number } {
|
|
20
|
+
const [px, py] = getComputedStyle(el).transformOrigin.split(' ').map(parseFloat);
|
|
21
|
+
const scale = target.width / box.width;
|
|
22
|
+
return {
|
|
23
|
+
x: target.left - box.left + (target.width - box.width) / 2 + (box.width / 2 - px) * (1 - scale),
|
|
24
|
+
y: target.top - box.top + (target.height - box.height) / 2 + (box.height / 2 - py) * (1 - scale),
|
|
25
|
+
scale,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function keep(id: string, el: HTMLElement, box: Box, { timing }: FlipOptions): void {
|
|
30
|
+
const copy = el.cloneNode(true) as HTMLElement;
|
|
31
|
+
for (const node of [copy, ...copy.querySelectorAll('[id]')]) node.removeAttribute('id');
|
|
32
|
+
for (const [name, value] of Object.entries(inheritedThemeAttrs(el))) if (value) copy.setAttribute(name, value);
|
|
33
|
+
const { font, color, opacity } = getComputedStyle(el);
|
|
34
|
+
Object.assign(copy.style, {
|
|
35
|
+
position: 'fixed',
|
|
36
|
+
left: `${box.left - window.scrollX}px`,
|
|
37
|
+
top: `${box.top - window.scrollY}px`,
|
|
38
|
+
width: `${box.width}px`,
|
|
39
|
+
height: `${box.height}px`,
|
|
40
|
+
boxSizing: 'border-box',
|
|
41
|
+
margin: '0',
|
|
42
|
+
pointerEvents: 'none',
|
|
43
|
+
translate: 'none',
|
|
44
|
+
scale: 'none',
|
|
45
|
+
transform: 'none',
|
|
46
|
+
font,
|
|
47
|
+
color,
|
|
48
|
+
opacity,
|
|
49
|
+
});
|
|
50
|
+
copy.inert = true;
|
|
51
|
+
copy.setAttribute('aria-hidden', 'true');
|
|
52
|
+
document.body.append(copy);
|
|
53
|
+
const entry: Copy = { el: copy, box, of: el };
|
|
54
|
+
kept.set(id, entry);
|
|
55
|
+
queueMicrotask(() => {
|
|
56
|
+
if (kept.get(id) !== entry) return;
|
|
57
|
+
kept.delete(id);
|
|
58
|
+
if (el.isConnected) copy.remove();
|
|
59
|
+
else animate(copy, { opacity: [0], timing }).finished.then(() => copy.remove());
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function play(id: string, el: HTMLElement, from: Box, { timing }: FlipOptions): Playback | undefined {
|
|
64
|
+
const next = kept.get(id);
|
|
65
|
+
if (!next) return undefined;
|
|
66
|
+
const replay = next.of === el;
|
|
67
|
+
const copy = replay ? riding.get(el) : next;
|
|
68
|
+
if (!copy) return undefined;
|
|
69
|
+
claim(el, ['translate', 'scale', 'opacity'], null);
|
|
70
|
+
const to = measure(el);
|
|
71
|
+
if (!to.width || !to.height) return undefined;
|
|
72
|
+
kept.delete(id);
|
|
73
|
+
if (replay) next.el.remove();
|
|
74
|
+
copy.play?.stop();
|
|
75
|
+
const rest = Number(getComputedStyle(el).opacity);
|
|
76
|
+
const out = onto(copy.el, copy.box, to);
|
|
77
|
+
const back = onto(el, to, from);
|
|
78
|
+
const run = animate(copy.el, {
|
|
79
|
+
x: [0, out.x],
|
|
80
|
+
y: [0, out.y],
|
|
81
|
+
scale: [1, out.scale],
|
|
82
|
+
opacity: [Number(copy.el.style.opacity), 0, 0],
|
|
83
|
+
timing: { fill: 'backwards', ...timing, times: [0, GONE_BY, 1] },
|
|
84
|
+
});
|
|
85
|
+
copy.play = run;
|
|
86
|
+
riding.set(el, copy);
|
|
87
|
+
run.finished.then(() => {
|
|
88
|
+
if (copy.play === run) copy.el.remove();
|
|
89
|
+
});
|
|
90
|
+
return animate(el, {
|
|
91
|
+
x: [back.x, 0],
|
|
92
|
+
y: [back.y, 0],
|
|
93
|
+
scale: [back.scale, 1],
|
|
94
|
+
opacity: [0, rest, rest],
|
|
95
|
+
timing: { fill: 'backwards', ...timing, times: [0, SHOWN_BY, 1] },
|
|
96
|
+
});
|
|
97
|
+
}
|
package/src/motion/element.tsx
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { createElement, useCallback, useRef, type ReactNode, type Ref } from 'react';
|
|
3
|
+
import { createElement, useCallback, useLayoutEffect, useRef, type ReactNode, type Ref } from 'react';
|
|
4
4
|
|
|
5
5
|
import { useFlip, type FlipTuning } from './flip';
|
|
6
|
+
import { usePresence } from './presence-context';
|
|
6
7
|
import { useMotion, type MotionSpecs } from './use-motion';
|
|
7
8
|
|
|
8
9
|
export interface MotionProps extends MotionSpecs {
|
|
9
10
|
/** Tag for the element this renders. @default 'div' */
|
|
10
11
|
as?: string;
|
|
11
|
-
/** FLIP this element from its previous box
|
|
12
|
+
/** FLIP this element from its previous box whenever a render moves it. */
|
|
12
13
|
layout?: boolean;
|
|
13
|
-
/** FLIP from whatever element last held this id, so the box travels between nodes. */
|
|
14
|
+
/** FLIP from whatever element last held this id, so the box travels between nodes. Add `layout` to FLIP its own moves too. */
|
|
14
15
|
layoutId?: string;
|
|
15
16
|
/** Tunes whichever layout animation is active; ignored without `layout` or `layoutId`. */
|
|
16
17
|
layoutTransition?: FlipTuning;
|
|
@@ -32,23 +33,25 @@ export function Motion({
|
|
|
32
33
|
children,
|
|
33
34
|
...rest
|
|
34
35
|
}: MotionProps) {
|
|
35
|
-
const
|
|
36
|
+
const { isPresent } = usePresence();
|
|
37
|
+
const flip = useFlip<HTMLElement>(layoutId ?? null, layoutTransition, !!layout);
|
|
36
38
|
const host = useRef<HTMLElement | null>(null);
|
|
37
39
|
const forwarded = useRef(ref);
|
|
38
40
|
forwarded.current = ref;
|
|
39
41
|
|
|
40
42
|
useMotion(host, { animate, exit, initial, deps });
|
|
43
|
+
useLayoutEffect(flip.play);
|
|
41
44
|
|
|
42
45
|
const attach = useCallback(
|
|
43
46
|
(el: HTMLElement | null) => {
|
|
44
47
|
host.current = el;
|
|
45
|
-
|
|
48
|
+
flip.ref.current = el;
|
|
46
49
|
const outer = forwarded.current;
|
|
47
50
|
if (typeof outer === 'function') outer(el);
|
|
48
51
|
else if (outer) outer.current = el;
|
|
49
52
|
},
|
|
50
|
-
[
|
|
53
|
+
[flip.ref],
|
|
51
54
|
);
|
|
52
55
|
|
|
53
|
-
return createElement(as, { ...rest, ref: attach }, children);
|
|
56
|
+
return createElement(as, { ...rest, 'data-exiting': isPresent ? undefined : 'true', ref: attach }, children);
|
|
54
57
|
}
|
package/src/motion/flip.ts
CHANGED
|
@@ -15,56 +15,74 @@ import {
|
|
|
15
15
|
import { sharedSlot } from '../shared-slot';
|
|
16
16
|
import { UIMotion } from '../tokens/motion-tokens';
|
|
17
17
|
|
|
18
|
-
export
|
|
18
|
+
export interface FlipTuning extends FlipOptions {
|
|
19
|
+
/** Keep the element that last held the `layoutId` on screen through the handoff: a copy of it takes the same path and fades out while this one fades in. */
|
|
20
|
+
crossfade?: boolean;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const SAME_BOX_PX = 0.5;
|
|
19
24
|
|
|
20
25
|
const sharedOwner = sharedSlot('motion.flip-owner@1', () => new Map<string, HTMLElement>());
|
|
21
26
|
|
|
27
|
+
let loadedCrossfade: typeof import('./crossfade') | null = null;
|
|
28
|
+
|
|
29
|
+
const loadCrossfade = (): void => {
|
|
30
|
+
if (!loadedCrossfade) void import('./crossfade').then((module) => (loadedCrossfade = module));
|
|
31
|
+
};
|
|
32
|
+
|
|
22
33
|
const usable = (box: Box | null): box is Box => !!box && box.width > 0 && box.height > 0;
|
|
23
34
|
|
|
35
|
+
const sameBox = (a: Box, b: Box): boolean =>
|
|
36
|
+
(['left', 'top', 'width', 'height'] as const).every((side) => Math.abs(a[side] - b[side]) < SAME_BOX_PX);
|
|
37
|
+
|
|
24
38
|
export function useFlip<T extends HTMLElement>(
|
|
25
39
|
sharedId: string | null,
|
|
26
40
|
tuning: FlipTuning = {},
|
|
27
|
-
|
|
28
|
-
): RefObject<T | null
|
|
41
|
+
inPlace: boolean,
|
|
42
|
+
): { ref: RefObject<T | null>; play: () => void } {
|
|
29
43
|
const ref = useRef<T | null>(null);
|
|
30
44
|
const playing = useRef<{ play: Playback; el: T } | null>(null);
|
|
31
45
|
const interrupted = useRef<Box | null>(null);
|
|
32
|
-
const
|
|
33
|
-
const
|
|
46
|
+
const origin = useRef<Box | null>(null);
|
|
47
|
+
const latest = useRef(tuning);
|
|
48
|
+
latest.current = tuning;
|
|
49
|
+
const { size, timing, crossfade } = tuning;
|
|
50
|
+
const enabled = inPlace || sharedId !== null;
|
|
51
|
+
const lastCommitted = ref.current && (inPlace || playing.current) ? measure(ref.current) : null;
|
|
34
52
|
|
|
35
53
|
useLayoutEffect(() => {
|
|
36
54
|
const el = ref.current;
|
|
37
55
|
if (!el || !enabled) return;
|
|
56
|
+
if (crossfade) loadCrossfade();
|
|
38
57
|
const live = playing.current;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
58
|
+
const midFlight = live?.el === el;
|
|
59
|
+
const moved = !!lastCommitted && !sameBox(lastCommitted, measure(el));
|
|
60
|
+
if (midFlight && !moved) return;
|
|
61
|
+
let from = moved ? lastCommitted : null;
|
|
62
|
+
if (sharedId !== null && !midFlight) {
|
|
63
|
+
if (interrupted.current) from = interrupted.current;
|
|
64
|
+
else if (sharedOwner.get(sharedId) !== el) from = readShared(sharedId);
|
|
65
|
+
}
|
|
44
66
|
live?.play.stop();
|
|
67
|
+
playing.current = null;
|
|
68
|
+
interrupted.current = null;
|
|
45
69
|
if (sharedId !== null) {
|
|
46
70
|
keepShared(sharedId, measure(el));
|
|
47
71
|
sharedOwner.set(sharedId, el);
|
|
48
72
|
}
|
|
49
|
-
|
|
50
|
-
playing.current = next ? { play: next, el } : null;
|
|
51
|
-
interrupted.current = next ? from : null;
|
|
52
|
-
next?.finished.then(() => {
|
|
53
|
-
if (playing.current?.play === next) {
|
|
54
|
-
playing.current = null;
|
|
55
|
-
interrupted.current = null;
|
|
56
|
-
}
|
|
57
|
-
});
|
|
73
|
+
origin.current = from;
|
|
58
74
|
});
|
|
59
75
|
|
|
60
76
|
useLayoutEffect(() => {
|
|
61
|
-
if (
|
|
77
|
+
if (sharedId === null) return;
|
|
62
78
|
return () => {
|
|
63
79
|
const live = playing.current;
|
|
64
80
|
let box: Box | null = live ? measure(live.el) : null;
|
|
81
|
+
if (!usable(box)) box = ref.current ? measure(ref.current) : null;
|
|
82
|
+
if (latest.current.crossfade && loadedCrossfade && ref.current && usable(box) && !UIMotion.reduced)
|
|
83
|
+
loadedCrossfade.keep(sharedId, ref.current, box, latest.current);
|
|
65
84
|
live?.play.stop();
|
|
66
85
|
playing.current = null;
|
|
67
|
-
if (!usable(box)) box = ref.current ? measure(ref.current) : null;
|
|
68
86
|
if (usable(box)) keepShared(sharedId, box);
|
|
69
87
|
const mine = readShared(sharedId);
|
|
70
88
|
queueMicrotask(() => {
|
|
@@ -73,7 +91,28 @@ export function useFlip<T extends HTMLElement>(
|
|
|
73
91
|
if (owner && !owner.isConnected) sharedOwner.delete(sharedId);
|
|
74
92
|
});
|
|
75
93
|
};
|
|
76
|
-
}, [sharedId
|
|
94
|
+
}, [sharedId]);
|
|
95
|
+
|
|
96
|
+
const play = () => {
|
|
97
|
+
const el = ref.current;
|
|
98
|
+
const from = origin.current;
|
|
99
|
+
origin.current = null;
|
|
100
|
+
if (!el || !usable(from) || UIMotion.reduced) return;
|
|
101
|
+
const handoff =
|
|
102
|
+
sharedId !== null && crossfade && loadedCrossfade
|
|
103
|
+
? loadedCrossfade.play(sharedId, el, from, { timing })
|
|
104
|
+
: undefined;
|
|
105
|
+
const next = handoff === undefined ? flip(el, from, { size, timing }) : handoff;
|
|
106
|
+
if (!next) return;
|
|
107
|
+
playing.current = { play: next, el };
|
|
108
|
+
interrupted.current = from;
|
|
109
|
+
next.finished.then(() => {
|
|
110
|
+
if (playing.current?.play === next) {
|
|
111
|
+
playing.current = null;
|
|
112
|
+
interrupted.current = null;
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
};
|
|
77
116
|
|
|
78
|
-
return ref;
|
|
117
|
+
return { ref, play };
|
|
79
118
|
}
|
package/src/motion/glide.tsx
CHANGED
|
@@ -28,6 +28,7 @@ function layoutBox(target: HTMLElement, container: HTMLElement): Box | null {
|
|
|
28
28
|
export function useGlide<T extends HTMLElement>(containerRef: RefObject<T | null>) {
|
|
29
29
|
const ref = useRef<HTMLSpanElement | null>(null);
|
|
30
30
|
const visible = useRef(false);
|
|
31
|
+
const tracked = useRef<HTMLElement | null>(null);
|
|
31
32
|
|
|
32
33
|
const enter = useCallback(
|
|
33
34
|
(target: HTMLElement | null) => {
|
|
@@ -38,7 +39,10 @@ export function useGlide<T extends HTMLElement>(containerRef: RefObject<T | null
|
|
|
38
39
|
if (!at) return;
|
|
39
40
|
const motion = motionFor(box);
|
|
40
41
|
const was = measure(pill);
|
|
42
|
+
const arrived = tracked.current !== target;
|
|
43
|
+
tracked.current = target;
|
|
41
44
|
set(pill, { x: [at.left], y: [at.top], width: [at.width], height: [at.height] });
|
|
45
|
+
if (!arrived) return;
|
|
42
46
|
animate(pill, { opacity: [1], timing: { duration: motion.dur.fast, ease: motion.ease.standard } });
|
|
43
47
|
const glided = visible.current && !motion.reduced && was.width > 0 && was.height > 0;
|
|
44
48
|
visible.current = true;
|
|
@@ -49,6 +53,7 @@ export function useGlide<T extends HTMLElement>(containerRef: RefObject<T | null
|
|
|
49
53
|
|
|
50
54
|
const leave = useCallback(() => {
|
|
51
55
|
visible.current = false;
|
|
56
|
+
tracked.current = null;
|
|
52
57
|
if (!ref.current) return;
|
|
53
58
|
const motion = motionFor(containerRef.current);
|
|
54
59
|
animate(ref.current, { opacity: [0], timing: { duration: motion.dur.fast, ease: motion.ease.exit } });
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type { Layer, Playback } from '../engine';
|
|
2
|
+
export { Motion, type MotionProps } from './element';
|
|
3
|
+
export type { FlipTuning } from './flip';
|
|
4
|
+
export { usePresence, type PresenceState } from './presence-context';
|
|
5
|
+
export { Presence, type PresenceProps } from './presence';
|
|
6
|
+
export { popIn, popOut, slideIn } from './presets';
|
|
7
|
+
export { useMotion, type MotionSpec, type MotionSpecs, type Plays } from './use-motion';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Motion / Presence - @zyncat/ui/motion
|
|
2
|
+
|
|
3
|
+
Group: primitives
|
|
4
|
+
|
|
5
|
+
The React layer over the engine: animate an element you render, and hold a leaving one mounted until its exit finishes.
|
|
6
|
+
|
|
7
|
+
`<Motion>` renders the tag in `as` and plays `animate` on mount, then again whenever `deps` change.
|
|
8
|
+
`exit` plays when a parent `<Presence>` drops the child, which stays mounted until it finishes - a
|
|
9
|
+
child with no `exit` is dropped at once. `layout` and `layoutId` FLIP the box from where it last was
|
|
10
|
+
instead of animating a value. Every spec is a `Layer`, a `Layer[]`, or a function returning the
|
|
11
|
+
`Playback`s to wait on.
|
|
12
|
+
|
|
13
|
+
`<Presence>` needs keyed children; `mode="wait"` holds the entering child back until the outgoing one
|
|
14
|
+
has left, and `initial={false}` skips the entrance for children present at its own first paint.
|
|
15
|
+
|
|
16
|
+
`useMotion(ref, specs)` is the same machinery for an element you hold a ref to but do not render.
|
|
17
|
+
`usePresence()` reads whether the current child is leaving. `popIn` / `popOut` / `slideIn` are the
|
|
18
|
+
named presets - feed them `UIMotion.scale` and `UIMotion.dist` from `@zyncat/ui/motion-tokens`, never
|
|
19
|
+
literals.
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
<Presence mode="wait" onExitComplete={clearStep}>
|
|
23
|
+
{step && (
|
|
24
|
+
<Motion
|
|
25
|
+
key={step.id}
|
|
26
|
+
animate={popIn(UIMotion.scale.panel, UIMotion.t.enter)}
|
|
27
|
+
exit={popOut(UIMotion.scale.panel, UIMotion.t.exit)}
|
|
28
|
+
deps={[step.id]}
|
|
29
|
+
>
|
|
30
|
+
{step.body}
|
|
31
|
+
</Motion>
|
|
32
|
+
)}
|
|
33
|
+
</Presence>
|
|
34
|
+
```
|
package/src/motion/presence.tsx
CHANGED
|
@@ -103,6 +103,10 @@ export function Presence({ children, initial = true, mode = 'sync', onExitComple
|
|
|
103
103
|
|
|
104
104
|
const leaving = shown.some((entry) => entry.exiting);
|
|
105
105
|
|
|
106
|
+
useEffect(() => {
|
|
107
|
+
bornAtMount.current.clear();
|
|
108
|
+
}, []);
|
|
109
|
+
|
|
106
110
|
useEffect(() => {
|
|
107
111
|
if (wasExiting.current && !leaving) complete.current?.();
|
|
108
112
|
wasExiting.current = leaving;
|
package/src/motion/use-motion.ts
CHANGED
|
@@ -16,6 +16,9 @@ export function run(spec: MotionSpec | undefined, el: HTMLElement): Playback[] {
|
|
|
16
16
|
return [Array.isArray(spec) ? animate(el, ...spec) : animate(el, spec)];
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
const sameDeps = (a: unknown[], b: unknown[]): boolean =>
|
|
20
|
+
a.length === b.length && a.every((v, i) => Object.is(v, b[i]));
|
|
21
|
+
|
|
19
22
|
const allSettled = (plays: Playback[]): Promise<void> =>
|
|
20
23
|
plays.length ? Promise.all(plays.map((play) => play.finished)).then((): void => {}) : Promise.resolve();
|
|
21
24
|
|
|
@@ -34,7 +37,7 @@ export interface MotionSpecs {
|
|
|
34
37
|
export function useMotion(ref: RefObject<HTMLElement | null>, { animate, exit, initial, deps }: MotionSpecs): void {
|
|
35
38
|
const presence = usePresence();
|
|
36
39
|
const playing = useRef<Playback[]>([]);
|
|
37
|
-
const
|
|
40
|
+
const ran = useRef<unknown[] | null>(null);
|
|
38
41
|
const exiting = useRef(false);
|
|
39
42
|
const spec = useRef({ animate, exit, initial });
|
|
40
43
|
spec.current = { animate, exit, initial };
|
|
@@ -57,9 +60,11 @@ export function useMotion(ref: RefObject<HTMLElement | null>, { animate, exit, i
|
|
|
57
60
|
|
|
58
61
|
useLayoutEffect(() => {
|
|
59
62
|
const el = ref.current;
|
|
60
|
-
const atMount = !mounted.current;
|
|
61
|
-
mounted.current = true;
|
|
62
63
|
if (!el) return;
|
|
64
|
+
const current = deps ?? [];
|
|
65
|
+
const previous = ran.current;
|
|
66
|
+
ran.current = current;
|
|
67
|
+
const atMount = !previous || sameDeps(previous, current);
|
|
63
68
|
if (atMount && (spec.current.initial ?? presence.initial) === false) return;
|
|
64
69
|
stop();
|
|
65
70
|
playing.current = run(spec.current.animate, el);
|
package/src/styles.css
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* Zyncat UI global layer - import ONCE at your app root: import '@zyncat/ui/styles.css'.
|
|
2
2
|
The reset layer is first, so everything else outranks it. Component CSS ships per component. */
|
|
3
3
|
|
|
4
|
-
@layer zyncat.reset, zyncat.tokens, zyncat.components;
|
|
4
|
+
@layer zyncat.reset, zyncat.tokens, zyncat.base, zyncat.components;
|
|
5
5
|
|
|
6
6
|
@import './tokens/reset.css';
|
|
7
7
|
@import './tokens/decisions.css';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const nearestTheme = (el: Element | null | undefined, attr: string): string | null =>
|
|
2
|
+
el?.closest(`[${attr}]`)?.getAttribute(attr) ?? null;
|
|
3
|
+
|
|
4
|
+
const themeDifferingFromPage = (scope: Element | null | undefined, attr: string): string | undefined => {
|
|
5
|
+
const own = nearestTheme(scope, attr);
|
|
6
|
+
return own !== null && own !== nearestTheme(document.body, attr) ? own : undefined;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export interface InheritedThemeAttrs {
|
|
10
|
+
'data-theme'?: string;
|
|
11
|
+
'data-polarity'?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function inheritedThemeAttrs(scope: Element | null | undefined): InheritedThemeAttrs {
|
|
15
|
+
return {
|
|
16
|
+
'data-theme': themeDifferingFromPage(scope, 'data-theme'),
|
|
17
|
+
'data-polarity': themeDifferingFromPage(scope, 'data-polarity'),
|
|
18
|
+
};
|
|
19
|
+
}
|
package/src/tokens/base.css
CHANGED
|
@@ -1,29 +1,78 @@
|
|
|
1
|
-
@layer zyncat.reset, zyncat.tokens, zyncat.components;
|
|
1
|
+
@layer zyncat.reset, zyncat.tokens, zyncat.base, zyncat.components;
|
|
2
2
|
|
|
3
3
|
@layer zyncat.base {
|
|
4
|
+
/* Drives native scrollbars, caret, select popups, and autofill background. */
|
|
5
|
+
:root {
|
|
6
|
+
color-scheme: light dark;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/* Only reaches these four; scoped so it stops inheriting everywhere. */
|
|
10
|
+
:where(input[type='checkbox'], input[type='radio'], input[type='range'], progress) {
|
|
11
|
+
accent-color: var(--accent);
|
|
12
|
+
}
|
|
13
|
+
|
|
4
14
|
body {
|
|
5
15
|
background: var(--bg-app);
|
|
6
16
|
color: var(--text-body);
|
|
7
17
|
font: var(--type-body);
|
|
8
|
-
|
|
9
|
-
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
b,
|
|
21
|
+
strong {
|
|
22
|
+
font-weight: var(--weight-semibold);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
code,
|
|
26
|
+
kbd,
|
|
27
|
+
pre,
|
|
28
|
+
samp {
|
|
29
|
+
font-family: var(--font-code);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
button,
|
|
33
|
+
[type='button'],
|
|
34
|
+
[type='reset'],
|
|
35
|
+
[type='submit'] {
|
|
36
|
+
cursor: pointer;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
:where(button, [type='button'], [type='reset'], [type='submit']):disabled {
|
|
40
|
+
cursor: not-allowed;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/* Horizontal drag reflows the page around the field; only the vertical axis is safe. */
|
|
44
|
+
textarea {
|
|
45
|
+
resize: vertical;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
::placeholder {
|
|
49
|
+
color: var(--text-subtle);
|
|
10
50
|
}
|
|
11
51
|
|
|
12
52
|
::selection {
|
|
13
53
|
background-color: color-mix(in oklab, var(--accent) 30%, transparent);
|
|
14
54
|
}
|
|
15
55
|
|
|
16
|
-
/*
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
56
|
+
/* outline-style is discrete, so only outline-color can animate from here. */
|
|
57
|
+
:where(a[href], button, input, select, textarea, summary, [tabindex]:not([tabindex='-1'])) {
|
|
58
|
+
outline: var(--ring-rest);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/* Without this, unskinned focusables lose the ring the rule above displaced. */
|
|
62
|
+
:where(a[href], button, input, select, textarea, summary, [tabindex]:not([tabindex='-1'])):focus-visible {
|
|
63
|
+
outline-color: var(--ring-color-accent);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/* Both rules above skip tabindex="-1", so a programmatic focus target - a listbox scroller, a menu
|
|
67
|
+
surface, a modal panel - would otherwise fall through to the UA outline. Its indicator is the
|
|
68
|
+
active descendant, not the container. */
|
|
69
|
+
:where([tabindex='-1']):focus {
|
|
70
|
+
outline: none;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/* Chrome forces both at paint time, so neither color nor background-color reaches them. */
|
|
74
|
+
:is(:autofill, :-webkit-autofill) {
|
|
25
75
|
-webkit-text-fill-color: var(--text-strong);
|
|
26
76
|
caret-color: var(--text-strong);
|
|
27
|
-
transition: background-color 0s 8000000s;
|
|
28
77
|
}
|
|
29
78
|
}
|
package/src/tokens/color.css
CHANGED
|
@@ -1,28 +1,30 @@
|
|
|
1
|
-
@layer zyncat.reset, zyncat.tokens, zyncat.components;
|
|
1
|
+
@layer zyncat.reset, zyncat.tokens, zyncat.base, zyncat.components;
|
|
2
2
|
|
|
3
3
|
@layer zyncat.tokens {
|
|
4
4
|
:root,
|
|
5
5
|
[data-theme],
|
|
6
6
|
[data-polarity] {
|
|
7
|
-
/*
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
--gray-
|
|
11
|
-
--gray-
|
|
12
|
-
--gray-
|
|
13
|
-
--gray-
|
|
14
|
-
--gray-
|
|
15
|
-
--gray-
|
|
16
|
-
--gray-
|
|
17
|
-
--gray-
|
|
18
|
-
--gray-
|
|
19
|
-
--gray-
|
|
20
|
-
--gray-
|
|
7
|
+
/* Stripe's neutral ramp, rung for rung: --neutral is its midpoint, and every step holds that
|
|
8
|
+
hue's distance from it, so a new --neutral carries the whole ramp with it. The top rung is
|
|
9
|
+
pure white - the only rung Stripe leaves untinted. */
|
|
10
|
+
--gray-0: oklch(from var(--neutral) 1 0 h);
|
|
11
|
+
--gray-50: oklch(from var(--neutral) 0.978 0.0034 calc(h - 12.4));
|
|
12
|
+
--gray-100: oklch(from var(--neutral) 0.948 0.0052 calc(h - 12.4));
|
|
13
|
+
--gray-150: oklch(from var(--neutral) 0.889 0.0105 calc(h - 12.3));
|
|
14
|
+
--gray-200: oklch(from var(--neutral) 0.83 0.0165 calc(h - 6.4));
|
|
15
|
+
--gray-300: oklch(from var(--neutral) 0.742 0.0226 calc(h - 1.1));
|
|
16
|
+
--gray-400: oklch(from var(--neutral) 0.651 0.0247 calc(h + 0.4));
|
|
17
|
+
--gray-500: oklch(from var(--neutral) 0.553 0.031 h);
|
|
18
|
+
--gray-600: oklch(from var(--neutral) 0.466 0.0267 calc(h + 11.4));
|
|
19
|
+
--gray-700: oklch(from var(--neutral) 0.392 0.0226 calc(h + 11.6));
|
|
20
|
+
--gray-800: oklch(from var(--neutral) 0.317 0.0214 calc(h + 21.1));
|
|
21
|
+
--gray-900: oklch(from var(--neutral) 0.226 0.0194 calc(h + 20));
|
|
22
|
+
--gray-950: oklch(from var(--neutral) 0.181 0.0185 calc(h + 19.2));
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
:root,
|
|
24
26
|
[data-polarity='light'] {
|
|
25
27
|
/* Cool near-black on the white canvas. */
|
|
26
|
-
--shadow-rgb:
|
|
28
|
+
--shadow-rgb: 16 17 26;
|
|
27
29
|
}
|
|
28
30
|
}
|
|
@@ -109,8 +109,6 @@ export interface OdometerStyle extends CSSProperties {
|
|
|
109
109
|
'--odometer-gap'?: string | number;
|
|
110
110
|
/** `--odometer-ink` - Digit ink. Default: `var(--text-strong)`. */
|
|
111
111
|
'--odometer-ink'?: string | number;
|
|
112
|
-
/** `--odometer-accent` - The tint digits take while they roll fast. Default: `var(--accent)`. */
|
|
113
|
-
'--odometer-accent'?: string | number;
|
|
114
112
|
/** `--odometer-separator-ink` - The thousands separator. Default: `var(--text-muted)`. */
|
|
115
113
|
'--odometer-separator-ink'?: string | number;
|
|
116
114
|
/** `--odometer-size` - Digit size. Default: `var(--size-display)`. */
|
package/src/tokens/dark.css
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
@layer zyncat.reset, zyncat.tokens, zyncat.components;
|
|
1
|
+
@layer zyncat.reset, zyncat.tokens, zyncat.base, zyncat.components;
|
|
2
2
|
|
|
3
3
|
@layer zyncat.tokens {
|
|
4
4
|
[data-polarity='dark'] {
|
|
@@ -24,6 +24,9 @@
|
|
|
24
24
|
--border-default: oklch(from var(--neutral) 0.315 0.009 h);
|
|
25
25
|
--border-strong: oklch(from var(--neutral) 0.4 0.011 h);
|
|
26
26
|
|
|
27
|
+
--bg-hover: color-mix(in oklab, var(--text-secondary) 6%, transparent);
|
|
28
|
+
--bg-press: color-mix(in oklab, var(--text-secondary) 10%, transparent);
|
|
29
|
+
|
|
27
30
|
--shadow-rgb: 0 0 0;
|
|
28
31
|
--shadow-strength: 3.5;
|
|
29
32
|
--sheen-strength: 0.2;
|
package/src/tokens/decisions.css
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
@layer zyncat.reset, zyncat.tokens, zyncat.components;
|
|
1
|
+
@layer zyncat.reset, zyncat.tokens, zyncat.base, zyncat.components;
|
|
2
2
|
|
|
3
3
|
@layer zyncat.tokens {
|
|
4
4
|
:root,
|
|
5
5
|
[data-theme='default'] {
|
|
6
6
|
/* The brand hue - hover, active, lift, subtle, border, wash, the focus ring and info follow. */
|
|
7
|
-
--accent: oklch(0.
|
|
7
|
+
--accent: oklch(0.7 0.118 198);
|
|
8
8
|
/* Positive status - its subtle, text and wash follow. */
|
|
9
9
|
--success: oklch(0.548 0.122 152);
|
|
10
10
|
/* Caution - its subtle, text and wash follow. */
|
|
11
11
|
--warning: oklch(0.7 0.142 75);
|
|
12
12
|
/* Destructive actions and errors - the danger button ladder, ring, subtle, text and wash follow. */
|
|
13
13
|
--danger: oklch(0.545 0.196 27);
|
|
14
|
-
/* The gray ramp
|
|
15
|
-
|
|
14
|
+
/* The middle of the gray ramp - every rung holds its hue distance from this one, so moving it
|
|
15
|
+
retints the whole ramp. Stripe's gray-500 lightness and chroma over the accent's hue, so the
|
|
16
|
+
grays carry the brand temperature; give it a literal hue for a ramp that does not follow. */
|
|
17
|
+
--neutral: oklch(from var(--accent) 0.553 0.031 h);
|
|
16
18
|
/* Roundness - every --radius-<step> is a fixed ratio of it, 0 squaring every corner. */
|
|
17
19
|
--radius: 0.5rem;
|
|
18
20
|
/* The body face - every --type-* bundle follows. The package loads no webfont; point this at yours. */
|
package/src/tokens/elevation.css
CHANGED
package/src/tokens/glass.css
CHANGED
package/src/tokens/motion.css
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
@layer zyncat.reset, zyncat.tokens, zyncat.components;
|
|
1
|
+
@layer zyncat.reset, zyncat.tokens, zyncat.base, zyncat.components;
|
|
2
2
|
|
|
3
3
|
@layer zyncat.tokens {
|
|
4
4
|
:root {
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
[data-theme],
|
|
36
36
|
[data-polarity] {
|
|
37
37
|
--transition-control:
|
|
38
|
-
color var(--duration-
|
|
39
|
-
border-color var(--duration-
|
|
40
|
-
outline-color var(--duration-
|
|
38
|
+
color var(--duration-base) var(--ease-standard), background-color var(--duration-base) var(--ease-standard),
|
|
39
|
+
border-color var(--duration-base) var(--ease-standard), box-shadow var(--duration-base) var(--ease-standard),
|
|
40
|
+
outline-color var(--duration-base) var(--ease-standard);
|
|
41
41
|
--transition-colors:
|
|
42
42
|
color var(--duration-fast) var(--ease-standard), background-color var(--duration-fast) var(--ease-standard),
|
|
43
43
|
border-color var(--duration-fast) var(--ease-standard);
|
package/src/tokens/radius.css
CHANGED