@sdxc/ui 0.0.0-pre.1
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/LICENSE.md +21 -0
- package/README.md +812 -0
- package/dist/animations/index.d.ts +12 -0
- package/dist/animations/index.js +12 -0
- package/dist/animations/keyframes.d.ts +162 -0
- package/dist/animations/keyframes.js +297 -0
- package/dist/animations/scroll.d.ts +154 -0
- package/dist/animations/scroll.js +228 -0
- package/dist/animations/tokens.d.ts +47 -0
- package/dist/animations/tokens.js +47 -0
- package/dist/animations/transitions.d.ts +143 -0
- package/dist/animations/transitions.js +147 -0
- package/dist/behaviors/announcer.d.ts +90 -0
- package/dist/behaviors/announcer.js +93 -0
- package/dist/behaviors/calendar-model.d.ts +218 -0
- package/dist/behaviors/calendar-model.js +376 -0
- package/dist/behaviors/drag-session.d.ts +119 -0
- package/dist/behaviors/drag-session.js +110 -0
- package/dist/behaviors/filter-model.d.ts +117 -0
- package/dist/behaviors/filter-model.js +185 -0
- package/dist/behaviors/index.d.ts +16 -0
- package/dist/behaviors/index.js +16 -0
- package/dist/behaviors/resize-session.d.ts +115 -0
- package/dist/behaviors/resize-session.js +157 -0
- package/dist/behaviors/scroll-follow-model.d.ts +180 -0
- package/dist/behaviors/scroll-follow-model.js +197 -0
- package/dist/behaviors/selection-model.d.ts +129 -0
- package/dist/behaviors/selection-model.js +259 -0
- package/dist/behaviors/toaster.d.ts +144 -0
- package/dist/behaviors/toaster.js +228 -0
- package/dist/components/accordion.d.ts +93 -0
- package/dist/components/accordion.js +165 -0
- package/dist/components/alert-dialog.d.ts +110 -0
- package/dist/components/alert-dialog.js +169 -0
- package/dist/components/alert.d.ts +109 -0
- package/dist/components/alert.js +160 -0
- package/dist/components/aspect-ratio.d.ts +44 -0
- package/dist/components/aspect-ratio.js +35 -0
- package/dist/components/attachment.d.ts +146 -0
- package/dist/components/attachment.js +320 -0
- package/dist/components/avatar.d.ts +118 -0
- package/dist/components/avatar.js +89 -0
- package/dist/components/badge.d.ts +66 -0
- package/dist/components/badge.js +129 -0
- package/dist/components/breadcrumbs.d.ts +67 -0
- package/dist/components/breadcrumbs.js +121 -0
- package/dist/components/bubble.d.ts +91 -0
- package/dist/components/bubble.js +216 -0
- package/dist/components/button.d.ts +78 -0
- package/dist/components/button.js +207 -0
- package/dist/components/calendar.d.ts +166 -0
- package/dist/components/calendar.js +320 -0
- package/dist/components/card.d.ts +82 -0
- package/dist/components/card.js +126 -0
- package/dist/components/carousel.d.ts +96 -0
- package/dist/components/carousel.js +214 -0
- package/dist/components/chart.d.ts +485 -0
- package/dist/components/chart.js +563 -0
- package/dist/components/checkbox-group.d.ts +58 -0
- package/dist/components/checkbox-group.js +53 -0
- package/dist/components/checkbox.d.ts +61 -0
- package/dist/components/checkbox.js +81 -0
- package/dist/components/color-area.d.ts +83 -0
- package/dist/components/color-area.js +251 -0
- package/dist/components/color-field.d.ts +128 -0
- package/dist/components/color-field.js +73 -0
- package/dist/components/color-picker.d.ts +132 -0
- package/dist/components/color-picker.js +183 -0
- package/dist/components/color-slider.d.ts +103 -0
- package/dist/components/color-slider.js +198 -0
- package/dist/components/color-swatch-picker.d.ts +106 -0
- package/dist/components/color-swatch-picker.js +75 -0
- package/dist/components/color-swatch.d.ts +57 -0
- package/dist/components/color-swatch.js +82 -0
- package/dist/components/color-wheel.d.ts +58 -0
- package/dist/components/color-wheel.js +160 -0
- package/dist/components/combobox.d.ts +73 -0
- package/dist/components/combobox.js +108 -0
- package/dist/components/command.d.ts +80 -0
- package/dist/components/command.js +151 -0
- package/dist/components/confirm.d.ts +124 -0
- package/dist/components/confirm.js +56 -0
- package/dist/components/context-menu.d.ts +108 -0
- package/dist/components/context-menu.js +200 -0
- package/dist/components/date-field.d.ts +110 -0
- package/dist/components/date-field.js +49 -0
- package/dist/components/date-picker.d.ts +136 -0
- package/dist/components/date-picker.js +155 -0
- package/dist/components/date-range-picker.d.ts +152 -0
- package/dist/components/date-range-picker.js +106 -0
- package/dist/components/description.d.ts +36 -0
- package/dist/components/description.js +21 -0
- package/dist/components/dialog.d.ts +97 -0
- package/dist/components/dialog.js +203 -0
- package/dist/components/disclosure.d.ts +85 -0
- package/dist/components/disclosure.js +180 -0
- package/dist/components/drawer.d.ts +82 -0
- package/dist/components/drawer.js +162 -0
- package/dist/components/drop-indicator.d.ts +43 -0
- package/dist/components/drop-indicator.js +47 -0
- package/dist/components/drop-zone.d.ts +73 -0
- package/dist/components/drop-zone.js +54 -0
- package/dist/components/empty.d.ts +89 -0
- package/dist/components/empty.js +129 -0
- package/dist/components/field-error.d.ts +41 -0
- package/dist/components/field-error.js +36 -0
- package/dist/components/file-trigger.d.ts +84 -0
- package/dist/components/file-trigger.js +169 -0
- package/dist/components/form.d.ts +118 -0
- package/dist/components/form.js +113 -0
- package/dist/components/grid-list.d.ts +112 -0
- package/dist/components/grid-list.js +220 -0
- package/dist/components/group.d.ts +45 -0
- package/dist/components/group.js +44 -0
- package/dist/components/header.d.ts +33 -0
- package/dist/components/header.js +29 -0
- package/dist/components/heading-scope.d.ts +83 -0
- package/dist/components/heading-scope.js +82 -0
- package/dist/components/heading.d.ts +50 -0
- package/dist/components/heading.js +31 -0
- package/dist/components/hover-card.d.ts +77 -0
- package/dist/components/hover-card.js +151 -0
- package/dist/components/image-placeholder.d.ts +105 -0
- package/dist/components/image-placeholder.js +212 -0
- package/dist/components/index.d.ts +109 -0
- package/dist/components/index.js +109 -0
- package/dist/components/input.d.ts +53 -0
- package/dist/components/input.js +76 -0
- package/dist/components/item.d.ts +97 -0
- package/dist/components/item.js +185 -0
- package/dist/components/keyboard.d.ts +33 -0
- package/dist/components/keyboard.js +20 -0
- package/dist/components/label.d.ts +38 -0
- package/dist/components/label.js +24 -0
- package/dist/components/link-button.d.ts +59 -0
- package/dist/components/link-button.js +174 -0
- package/dist/components/link.d.ts +43 -0
- package/dist/components/link.js +85 -0
- package/dist/components/listbox.d.ts +119 -0
- package/dist/components/listbox.js +114 -0
- package/dist/components/logo.d.ts +117 -0
- package/dist/components/logo.js +89 -0
- package/dist/components/marker.d.ts +82 -0
- package/dist/components/marker.js +163 -0
- package/dist/components/menu.d.ts +90 -0
- package/dist/components/menu.js +146 -0
- package/dist/components/menubar.d.ts +54 -0
- package/dist/components/menubar.js +118 -0
- package/dist/components/message-scroller.d.ts +109 -0
- package/dist/components/message-scroller.js +180 -0
- package/dist/components/message.d.ts +104 -0
- package/dist/components/message.js +200 -0
- package/dist/components/meter.d.ts +60 -0
- package/dist/components/meter.js +110 -0
- package/dist/components/modal.d.ts +71 -0
- package/dist/components/modal.js +120 -0
- package/dist/components/nav-link.d.ts +53 -0
- package/dist/components/nav-link.js +83 -0
- package/dist/components/navigation-menu.d.ts +150 -0
- package/dist/components/navigation-menu.js +381 -0
- package/dist/components/number-field.d.ts +76 -0
- package/dist/components/number-field.js +190 -0
- package/dist/components/otp-field.d.ts +68 -0
- package/dist/components/otp-field.js +46 -0
- package/dist/components/overlay-arrow.d.ts +51 -0
- package/dist/components/overlay-arrow.js +77 -0
- package/dist/components/pagination.d.ts +67 -0
- package/dist/components/pagination.js +164 -0
- package/dist/components/popover.d.ts +69 -0
- package/dist/components/popover.js +68 -0
- package/dist/components/progress-bar.d.ts +53 -0
- package/dist/components/progress-bar.js +90 -0
- package/dist/components/radio-group.d.ts +102 -0
- package/dist/components/radio-group.js +114 -0
- package/dist/components/range-calendar.d.ts +169 -0
- package/dist/components/range-calendar.js +216 -0
- package/dist/components/resizable.d.ts +98 -0
- package/dist/components/resizable.js +151 -0
- package/dist/components/scroll-area.d.ts +54 -0
- package/dist/components/scroll-area.js +89 -0
- package/dist/components/search-field.d.ts +55 -0
- package/dist/components/search-field.js +49 -0
- package/dist/components/section.d.ts +37 -0
- package/dist/components/section.js +22 -0
- package/dist/components/select.d.ts +96 -0
- package/dist/components/select.js +285 -0
- package/dist/components/selection-indicator.d.ts +47 -0
- package/dist/components/selection-indicator.js +50 -0
- package/dist/components/sentinel-row.d.ts +22 -0
- package/dist/components/sentinel-row.js +29 -0
- package/dist/components/separator.d.ts +35 -0
- package/dist/components/separator.js +48 -0
- package/dist/components/shared-element.d.ts +45 -0
- package/dist/components/shared-element.js +48 -0
- package/dist/components/sheet.d.ts +78 -0
- package/dist/components/sheet.js +167 -0
- package/dist/components/sidebar.d.ts +288 -0
- package/dist/components/sidebar.js +1068 -0
- package/dist/components/skeleton.d.ts +36 -0
- package/dist/components/skeleton.js +38 -0
- package/dist/components/slider.d.ts +102 -0
- package/dist/components/slider.js +179 -0
- package/dist/components/spinner.d.ts +55 -0
- package/dist/components/spinner.js +51 -0
- package/dist/components/switch.d.ts +47 -0
- package/dist/components/switch.js +82 -0
- package/dist/components/table.d.ts +139 -0
- package/dist/components/table.js +216 -0
- package/dist/components/tabs.d.ts +124 -0
- package/dist/components/tabs.js +246 -0
- package/dist/components/tag-group.d.ts +83 -0
- package/dist/components/tag-group.js +157 -0
- package/dist/components/text-field.d.ts +119 -0
- package/dist/components/text-field.js +51 -0
- package/dist/components/text.d.ts +34 -0
- package/dist/components/text.js +19 -0
- package/dist/components/textarea.d.ts +52 -0
- package/dist/components/textarea.js +82 -0
- package/dist/components/time-field.d.ts +110 -0
- package/dist/components/time-field.js +48 -0
- package/dist/components/toast.d.ts +149 -0
- package/dist/components/toast.js +365 -0
- package/dist/components/toggle-button.d.ts +115 -0
- package/dist/components/toggle-button.js +237 -0
- package/dist/components/toolbar.d.ts +47 -0
- package/dist/components/toolbar.js +54 -0
- package/dist/components/tooltip.d.ts +52 -0
- package/dist/components/tooltip.js +92 -0
- package/dist/components/tree.d.ts +123 -0
- package/dist/components/tree.js +239 -0
- package/dist/components/typeset.d.ts +53 -0
- package/dist/components/typeset.js +271 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +8 -0
- package/dist/mixins/aria-checked.d.ts +42 -0
- package/dist/mixins/aria-checked.js +127 -0
- package/dist/mixins/attachment-trigger.d.ts +64 -0
- package/dist/mixins/attachment-trigger.js +190 -0
- package/dist/mixins/calendar-keys.d.ts +27 -0
- package/dist/mixins/calendar-keys.js +113 -0
- package/dist/mixins/carousel-controls.d.ts +30 -0
- package/dist/mixins/carousel-controls.js +222 -0
- package/dist/mixins/chart-tooltip.d.ts +118 -0
- package/dist/mixins/chart-tooltip.js +323 -0
- package/dist/mixins/clear-field.d.ts +60 -0
- package/dist/mixins/clear-field.js +100 -0
- package/dist/mixins/color-area-drag.d.ts +58 -0
- package/dist/mixins/color-area-drag.js +162 -0
- package/dist/mixins/color-channel-sync.d.ts +73 -0
- package/dist/mixins/color-channel-sync.js +169 -0
- package/dist/mixins/color-preview.d.ts +28 -0
- package/dist/mixins/color-preview.js +77 -0
- package/dist/mixins/color-wheel-drag.d.ts +58 -0
- package/dist/mixins/color-wheel-drag.js +139 -0
- package/dist/mixins/combobox-filter.d.ts +59 -0
- package/dist/mixins/combobox-filter.js +81 -0
- package/dist/mixins/command-filter.d.ts +55 -0
- package/dist/mixins/command-filter.js +121 -0
- package/dist/mixins/command-keys.d.ts +31 -0
- package/dist/mixins/command-keys.js +116 -0
- package/dist/mixins/context-menu.d.ts +24 -0
- package/dist/mixins/context-menu.js +64 -0
- package/dist/mixins/copy-to-clipboard.d.ts +64 -0
- package/dist/mixins/copy-to-clipboard.js +109 -0
- package/dist/mixins/dismiss.d.ts +77 -0
- package/dist/mixins/dismiss.js +151 -0
- package/dist/mixins/drag-reorder.d.ts +88 -0
- package/dist/mixins/drag-reorder.js +214 -0
- package/dist/mixins/drop-zone.d.ts +52 -0
- package/dist/mixins/drop-zone.js +132 -0
- package/dist/mixins/dual-range.d.ts +60 -0
- package/dist/mixins/dual-range.js +100 -0
- package/dist/mixins/grid-list-keys.d.ts +34 -0
- package/dist/mixins/grid-list-keys.js +260 -0
- package/dist/mixins/heading-level-fallback.d.ts +81 -0
- package/dist/mixins/heading-level-fallback.js +112 -0
- package/dist/mixins/hotkey.d.ts +26 -0
- package/dist/mixins/hotkey.js +132 -0
- package/dist/mixins/image-fallback.d.ts +57 -0
- package/dist/mixins/image-fallback.js +86 -0
- package/dist/mixins/index.d.ts +48 -0
- package/dist/mixins/index.js +48 -0
- package/dist/mixins/listbox-keys.d.ts +52 -0
- package/dist/mixins/listbox-keys.js +63 -0
- package/dist/mixins/long-press.d.ts +76 -0
- package/dist/mixins/long-press.js +130 -0
- package/dist/mixins/menu-keys.d.ts +40 -0
- package/dist/mixins/menu-keys.js +117 -0
- package/dist/mixins/menubar-keys.d.ts +59 -0
- package/dist/mixins/menubar-keys.js +230 -0
- package/dist/mixins/message-follow.d.ts +56 -0
- package/dist/mixins/message-follow.js +368 -0
- package/dist/mixins/otp-slots.d.ts +53 -0
- package/dist/mixins/otp-slots.js +175 -0
- package/dist/mixins/persist.d.ts +36 -0
- package/dist/mixins/persist.js +78 -0
- package/dist/mixins/press-toggle.d.ts +43 -0
- package/dist/mixins/press-toggle.js +61 -0
- package/dist/mixins/range-preview.d.ts +26 -0
- package/dist/mixins/range-preview.js +120 -0
- package/dist/mixins/resize-handle.d.ts +101 -0
- package/dist/mixins/resize-handle.js +288 -0
- package/dist/mixins/stepper.d.ts +81 -0
- package/dist/mixins/stepper.js +194 -0
- package/dist/mixins/tab-keys.d.ts +30 -0
- package/dist/mixins/tab-keys.js +63 -0
- package/dist/mixins/theme-toggle.d.ts +82 -0
- package/dist/mixins/theme-toggle.js +158 -0
- package/dist/mixins/track-host-node.d.ts +34 -0
- package/dist/mixins/track-host-node.js +42 -0
- package/dist/mixins/treeKeys.d.ts +57 -0
- package/dist/mixins/treeKeys.js +266 -0
- package/dist/mixins/validate.d.ts +65 -0
- package/dist/mixins/validate.js +139 -0
- package/dist/mixins/view-transition.d.ts +56 -0
- package/dist/mixins/view-transition.js +111 -0
- package/dist/styles/chart-palette.d.ts +34 -0
- package/dist/styles/chart-palette.js +27 -0
- package/dist/styles/field-stack-layout.d.ts +27 -0
- package/dist/styles/field-stack-layout.js +16 -0
- package/dist/styles/floating-surface.d.ts +32 -0
- package/dist/styles/floating-surface.js +30 -0
- package/dist/styles/graphic-host.d.ts +25 -0
- package/dist/styles/graphic-host.js +18 -0
- package/dist/styles/index.d.ts +20 -0
- package/dist/styles/index.js +20 -0
- package/dist/styles/interactive-transition.d.ts +32 -0
- package/dist/styles/interactive-transition.js +32 -0
- package/dist/styles/legend-toggle.d.ts +29 -0
- package/dist/styles/legend-toggle.js +24 -0
- package/dist/styles/output-caption-text.d.ts +22 -0
- package/dist/styles/output-caption-text.js +15 -0
- package/dist/styles/panel-chrome.d.ts +34 -0
- package/dist/styles/panel-chrome.js +26 -0
- package/dist/styles/range-thumb-appearance.d.ts +36 -0
- package/dist/styles/range-thumb-appearance.js +76 -0
- package/dist/styles/rtl-aware-gradient-direction.d.ts +28 -0
- package/dist/styles/rtl-aware-gradient-direction.js +28 -0
- package/dist/styles/semantic-color-panel.d.ts +35 -0
- package/dist/styles/semantic-color-panel.js +41 -0
- package/dist/utils/chart-marker-indices.d.ts +22 -0
- package/dist/utils/chart-marker-indices.js +45 -0
- package/dist/utils/chart-path.d.ts +86 -0
- package/dist/utils/chart-path.js +122 -0
- package/dist/utils/chart-scale.d.ts +182 -0
- package/dist/utils/chart-scale.js +221 -0
- package/dist/utils/color-math.d.ts +252 -0
- package/dist/utils/color-math.js +480 -0
- package/dist/utils/command-event.d.ts +24 -0
- package/dist/utils/command-event.js +26 -0
- package/dist/utils/css-styles.d.ts +21 -0
- package/dist/utils/css-styles.js +11 -0
- package/dist/utils/decorative-icon.d.ts +15 -0
- package/dist/utils/decorative-icon.js +15 -0
- package/dist/utils/disabled-selector.d.ts +22 -0
- package/dist/utils/disabled-selector.js +22 -0
- package/dist/utils/dispatch-change.d.ts +17 -0
- package/dist/utils/dispatch-change.js +19 -0
- package/dist/utils/field-parts.d.ts +26 -0
- package/dist/utils/field-parts.js +12 -0
- package/dist/utils/full-turn-radians.d.ts +16 -0
- package/dist/utils/full-turn-radians.js +16 -0
- package/dist/utils/geometry.d.ts +14 -0
- package/dist/utils/geometry.js +9 -0
- package/dist/utils/has-accessible-text.d.ts +19 -0
- package/dist/utils/has-accessible-text.js +30 -0
- package/dist/utils/hue-spectrum.d.ts +19 -0
- package/dist/utils/hue-spectrum.js +19 -0
- package/dist/utils/index.d.ts +35 -0
- package/dist/utils/index.js +35 -0
- package/dist/utils/is-new-primary-press.d.ts +29 -0
- package/dist/utils/is-new-primary-press.js +31 -0
- package/dist/utils/keyboard-nav.d.ts +64 -0
- package/dist/utils/keyboard-nav.js +79 -0
- package/dist/utils/merge-style.d.ts +33 -0
- package/dist/utils/merge-style.js +30 -0
- package/dist/utils/paired-range-inputs.d.ts +26 -0
- package/dist/utils/paired-range-inputs.js +29 -0
- package/dist/utils/placement.d.ts +18 -0
- package/dist/utils/placement.js +12 -0
- package/dist/utils/prefers-reduced-motion.d.ts +17 -0
- package/dist/utils/prefers-reduced-motion.js +19 -0
- package/dist/utils/resolve-field-wiring.d.ts +83 -0
- package/dist/utils/resolve-field-wiring.js +53 -0
- package/dist/utils/resolve-fill-percent.d.ts +28 -0
- package/dist/utils/resolve-fill-percent.js +34 -0
- package/dist/utils/round-precision.d.ts +22 -0
- package/dist/utils/round-precision.js +25 -0
- package/dist/utils/semantic-color-panel.d.ts +35 -0
- package/dist/utils/semantic-color-panel.js +28 -0
- package/dist/utils/semantic-color.d.ts +17 -0
- package/dist/utils/semantic-color.js +11 -0
- package/dist/utils/warn-if-no-accessible-name.d.ts +52 -0
- package/dist/utils/warn-if-no-accessible-name.js +55 -0
- package/dist/utils/write-cookie.d.ts +35 -0
- package/dist/utils/write-cookie.js +37 -0
- package/package.json +32 -0
- package/src/reset.css +223 -0
- package/src/theme.css +146 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Barrel for the animation layer: CSS-only `css()` mixin factories (`fade`,
|
|
3
|
+
* `zoom`, `slide`, and the `enterExit` composer) plus shared motion tokens,
|
|
4
|
+
* all keyed off native open states.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
export * from "./keyframes.js";
|
|
10
|
+
export * from "./scroll.js";
|
|
11
|
+
export * from "./tokens.js";
|
|
12
|
+
export * from "./transitions.js";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Barrel for the animation layer: CSS-only `css()` mixin factories (`fade`,
|
|
3
|
+
* `zoom`, `slide`, and the `enterExit` composer) plus shared motion tokens,
|
|
4
|
+
* all keyed off native open states.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
export * from "./keyframes.js";
|
|
10
|
+
export * from "./scroll.js";
|
|
11
|
+
export * from "./tokens.js";
|
|
12
|
+
export * from "./transitions.js";
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Looping `@keyframes`-backed mixin factories for busy indicators: spinner,
|
|
3
|
+
* skeleton breathe, indeterminate sweep, text glyph highlight. `keyframes()`
|
|
4
|
+
* hoists to the stylesheet root only from a mixin's top level or from inside
|
|
5
|
+
* `media()`/`supports()`, so `animationHost()` carries the `animation-*`
|
|
6
|
+
* declarations `when()` gates while the keyframes stay an ungated sibling.
|
|
7
|
+
*
|
|
8
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
9
|
+
* @copyright Sergio Xalambrí 2026
|
|
10
|
+
*/
|
|
11
|
+
import type { ElementProps, MixinDescriptor } from "remix/ui";
|
|
12
|
+
import type { CSSStyles } from "../utils/css-styles.js";
|
|
13
|
+
/** The `@sdxc/u` mixin type every factory in this file returns. */
|
|
14
|
+
type Mixin<Node extends Element> = MixinDescriptor<Node, [styles: CSSStyles], ElementProps>;
|
|
15
|
+
/**
|
|
16
|
+
* Options accepted by {@link spin}.
|
|
17
|
+
*/
|
|
18
|
+
export declare namespace Spin {
|
|
19
|
+
/**
|
|
20
|
+
* Tuning for a spin loop: timing and the platform state it runs under.
|
|
21
|
+
*/
|
|
22
|
+
interface Options {
|
|
23
|
+
/** Length of one full rotation, as a CSS time. Defaults to {@link DEFAULT_SPIN_DURATION}. */
|
|
24
|
+
duration?: string;
|
|
25
|
+
/** CSS easing function driving the rotation. Defaults to {@link DEFAULT_SPIN_EASING}. */
|
|
26
|
+
easing?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Selector fragment, relative to the host (e.g. `[aria-busy="true"]`),
|
|
29
|
+
* that gates the loop. Left unset, the loop runs as soon as it is
|
|
30
|
+
* mixed in, matching a spinner that is mounted only while busy.
|
|
31
|
+
*/
|
|
32
|
+
when?: string;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Continuous 360° rotation for a busy indicator's glyph, resolved entirely to
|
|
37
|
+
* `@keyframes` so it runs from server-rendered markup. Under
|
|
38
|
+
* `prefers-reduced-motion: reduce`, a gentle opacity breathe carries it.
|
|
39
|
+
*
|
|
40
|
+
* @param options Timing and gating for the loop.
|
|
41
|
+
* @returns A `@sdxc/u` mixin ready for a spinner's host element.
|
|
42
|
+
* @example
|
|
43
|
+
* <Spinner mix={[spin()]} aria-label={t("status.loading")} />
|
|
44
|
+
*/
|
|
45
|
+
export declare function spin<Node extends Element = Element>(options?: Spin.Options): Mixin<Node>;
|
|
46
|
+
/**
|
|
47
|
+
* Options accepted by {@link pulse}.
|
|
48
|
+
*/
|
|
49
|
+
export declare namespace Pulse {
|
|
50
|
+
/**
|
|
51
|
+
* Tuning for a pulse loop: timing, opacity range, and the platform state
|
|
52
|
+
* it runs under.
|
|
53
|
+
*/
|
|
54
|
+
interface Options {
|
|
55
|
+
/** Length of one breathe cycle, as a CSS time. Defaults to {@link DEFAULT_PULSE_DURATION}. */
|
|
56
|
+
duration?: string;
|
|
57
|
+
/** CSS easing function driving the breathe. Defaults to {@link DEFAULT_PULSE_EASING}. */
|
|
58
|
+
easing?: string;
|
|
59
|
+
/** Dimmest point of the breathe, from `0` to `1`. Defaults to {@link DEFAULT_PULSE_MIN_OPACITY}. */
|
|
60
|
+
minOpacity?: number;
|
|
61
|
+
/** Brightest point of the breathe, from `0` to `1`. Defaults to {@link DEFAULT_PULSE_MAX_OPACITY}. */
|
|
62
|
+
maxOpacity?: number;
|
|
63
|
+
/**
|
|
64
|
+
* Selector fragment, relative to the host (e.g. `[aria-busy="true"]`),
|
|
65
|
+
* that gates the loop. Left unset, the loop runs as soon as it is mixed
|
|
66
|
+
* in, matching a skeleton mounted only while its content loads.
|
|
67
|
+
*/
|
|
68
|
+
when?: string;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Gentle opacity breathe for a skeleton placeholder, resolved entirely to
|
|
73
|
+
* `@keyframes` so it runs from server-rendered markup. Reduced motion narrows
|
|
74
|
+
* the swing by overriding duration and the min-opacity token alone.
|
|
75
|
+
*
|
|
76
|
+
* @param options Timing, opacity range, and gating for the loop.
|
|
77
|
+
* @returns A `@sdxc/u` mixin ready for a skeleton placeholder's host element.
|
|
78
|
+
* @example
|
|
79
|
+
* <Skeleton mix={[pulse()]} aria-hidden="true" />
|
|
80
|
+
*/
|
|
81
|
+
export declare function pulse<Node extends Element = Element>(options?: Pulse.Options): Mixin<Node>;
|
|
82
|
+
/**
|
|
83
|
+
* Options accepted by {@link shimmer}.
|
|
84
|
+
*/
|
|
85
|
+
export declare namespace Shimmer {
|
|
86
|
+
/**
|
|
87
|
+
* Tuning for a shimmer loop: timing, highlight width, and the platform
|
|
88
|
+
* state it runs under.
|
|
89
|
+
*/
|
|
90
|
+
interface Options {
|
|
91
|
+
/** Length of one sweep across the band, as a CSS time. Defaults to {@link DEFAULT_SHIMMER_DURATION}. */
|
|
92
|
+
duration?: string;
|
|
93
|
+
/** CSS easing function driving the sweep. Defaults to {@link DEFAULT_SHIMMER_EASING}. */
|
|
94
|
+
easing?: string;
|
|
95
|
+
/** Width of the moving highlight band, as a CSS length or percentage. Defaults to {@link DEFAULT_SHIMMER_BAND_SIZE}. */
|
|
96
|
+
bandSize?: string;
|
|
97
|
+
/**
|
|
98
|
+
* Selector fragment, relative to the host, that gates the loop. Defaults
|
|
99
|
+
* to {@link DEFAULT_SHIMMER_WHEN}; pass a custom fragment (e.g.
|
|
100
|
+
* `[data-indeterminate="true"]`) for a hand-built progress indicator.
|
|
101
|
+
*/
|
|
102
|
+
when?: string;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Sweeping highlight band for an indeterminate progress fill, resolved
|
|
107
|
+
* entirely to `@keyframes` so it runs from server-rendered markup and settles
|
|
108
|
+
* once the gate clears; reduced motion breathes the fill's opacity instead.
|
|
109
|
+
*
|
|
110
|
+
* @param options Timing, band width, and gating for the loop.
|
|
111
|
+
* @returns A `@sdxc/u` mixin ready for a progress indicator's fill element.
|
|
112
|
+
* @example
|
|
113
|
+
* <ProgressBar.Indicator mix={[shimmer()]} />
|
|
114
|
+
*/
|
|
115
|
+
export declare function shimmer<Node extends Element = Element>(options?: Shimmer.Options): Mixin<Node>;
|
|
116
|
+
/**
|
|
117
|
+
* Options accepted by {@link textShimmer}.
|
|
118
|
+
*/
|
|
119
|
+
export declare namespace TextShimmer {
|
|
120
|
+
/**
|
|
121
|
+
* Tuning for a text shimmer loop: timing, the highlight band's width and
|
|
122
|
+
* angle of travel, its color, and the platform state it runs under.
|
|
123
|
+
*/
|
|
124
|
+
interface Options {
|
|
125
|
+
/** Length of one sweep across the band, as a CSS time. Defaults to {@link DEFAULT_TEXT_SHIMMER_DURATION}. */
|
|
126
|
+
duration?: string;
|
|
127
|
+
/** CSS easing function driving the sweep. Defaults to {@link DEFAULT_TEXT_SHIMMER_EASING}. */
|
|
128
|
+
easing?: string;
|
|
129
|
+
/** Width of the moving highlight band, as a CSS length or percentage. Defaults to {@link DEFAULT_TEXT_SHIMMER_BAND_SIZE}. */
|
|
130
|
+
bandSize?: string;
|
|
131
|
+
/** CSS angle the highlight band travels along. Defaults to {@link DEFAULT_TEXT_SHIMMER_ANGLE}. */
|
|
132
|
+
angle?: string;
|
|
133
|
+
/**
|
|
134
|
+
* Color the highlight band peaks at as it passes; the tone the text
|
|
135
|
+
* rests at between passes is this same color mixed toward
|
|
136
|
+
* transparency. Defaults to {@link DEFAULT_TEXT_SHIMMER_COLOR}.
|
|
137
|
+
*/
|
|
138
|
+
color?: string;
|
|
139
|
+
/**
|
|
140
|
+
* Selector fragment, relative to the host (e.g. `[data-streaming="true"]`),
|
|
141
|
+
* that gates the loop. Left unset, the loop runs as soon as it is mixed
|
|
142
|
+
* in, matching a caption mounted only while a response streams in.
|
|
143
|
+
*/
|
|
144
|
+
when?: string;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Sweeping highlight through a run of text's own glyphs for a caption that
|
|
149
|
+
* stands in for a busy state. The `background-clip: text` paint sits behind
|
|
150
|
+
* an `@supports` guard; reduced motion breathes the caption's opacity.
|
|
151
|
+
*
|
|
152
|
+
* @param options Timing, band width, angle, color, and gating for the loop.
|
|
153
|
+
* @returns A `@sdxc/u` mixin ready for a caption's host text element.
|
|
154
|
+
* @example
|
|
155
|
+
* <Text mix={[textShimmer()]}>{t("chat.generating")}</Text>
|
|
156
|
+
* @example
|
|
157
|
+
* <Text mix={[textShimmer({ color: "var(--ui-brand-fg)", duration: "1.5s" })]}>
|
|
158
|
+
* {t("chat.generating")}
|
|
159
|
+
* </Text>
|
|
160
|
+
*/
|
|
161
|
+
export declare function textShimmer<Node extends Element = Element>(options?: TextShimmer.Options): Mixin<Node>;
|
|
162
|
+
export {};
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Looping `@keyframes`-backed mixin factories for busy indicators: spinner,
|
|
3
|
+
* skeleton breathe, indeterminate sweep, text glyph highlight. `keyframes()`
|
|
4
|
+
* hoists to the stylesheet root only from a mixin's top level or from inside
|
|
5
|
+
* `media()`/`supports()`, so `animationHost()` carries the `animation-*`
|
|
6
|
+
* declarations `when()` gates while the keyframes stay an ungated sibling.
|
|
7
|
+
*
|
|
8
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
9
|
+
* @copyright Sergio Xalambrí 2026
|
|
10
|
+
*/
|
|
11
|
+
import { animationHost, keyframes } from "@sdxc/u/animation";
|
|
12
|
+
import { colorMix, linearGradient } from "@sdxc/u/color";
|
|
13
|
+
import { opacity, transitionBehavior } from "@sdxc/u/effects";
|
|
14
|
+
import { calc, combine, raw, var as varUtility } from "@sdxc/u/general";
|
|
15
|
+
import { media, startingStyle, supports } from "@sdxc/u/responsive";
|
|
16
|
+
import { when } from "@sdxc/u/state";
|
|
17
|
+
import { easings } from "./tokens.js";
|
|
18
|
+
/** Resting opacity a loop's mount-in transition fades up from and its exit fades down to. */
|
|
19
|
+
const HIDDEN_OPACITY = 0;
|
|
20
|
+
/** Fallback mount/gate transition length shared by every factory's `--ui-*-fade-duration` token. */
|
|
21
|
+
const DEFAULT_FADE_DURATION = "150ms";
|
|
22
|
+
/** Full rotation length {@link spin} falls back to when `duration` is omitted. */
|
|
23
|
+
const DEFAULT_SPIN_DURATION = "1s";
|
|
24
|
+
/**
|
|
25
|
+
* Easing {@link spin} falls back to when `easing` is omitted; a constant
|
|
26
|
+
* speed reads as a continuous loop.
|
|
27
|
+
*/
|
|
28
|
+
const DEFAULT_SPIN_EASING = easings.linear;
|
|
29
|
+
/** One breathe cycle length {@link pulse} falls back to when `duration` is omitted. */
|
|
30
|
+
const DEFAULT_PULSE_DURATION = "1.6s";
|
|
31
|
+
/** Easing {@link pulse} falls back to when `easing` is omitted. */
|
|
32
|
+
const DEFAULT_PULSE_EASING = "ease-in-out";
|
|
33
|
+
/** Dimmest opacity {@link pulse} falls back to when `minOpacity` is omitted. */
|
|
34
|
+
const DEFAULT_PULSE_MIN_OPACITY = 0.5;
|
|
35
|
+
/** Brightest opacity {@link pulse} falls back to when `maxOpacity` is omitted. */
|
|
36
|
+
const DEFAULT_PULSE_MAX_OPACITY = 1;
|
|
37
|
+
/**
|
|
38
|
+
* Fraction of {@link pulse}'s configured opacity range a reduced-motion
|
|
39
|
+
* viewer still sees, keeping the breathe perceptible at a gentler swing.
|
|
40
|
+
*/
|
|
41
|
+
const REDUCED_PULSE_AMPLITUDE_SCALE = 0.4;
|
|
42
|
+
/** Sweep length {@link shimmer} falls back to when `duration` is omitted. */
|
|
43
|
+
const DEFAULT_SHIMMER_DURATION = "1.6s";
|
|
44
|
+
/** Easing {@link shimmer} falls back to when `easing` is omitted. */
|
|
45
|
+
const DEFAULT_SHIMMER_EASING = "ease-in-out";
|
|
46
|
+
/** Width of the moving highlight band {@link shimmer} falls back to when `bandSize` is omitted. */
|
|
47
|
+
const DEFAULT_SHIMMER_BAND_SIZE = "50%";
|
|
48
|
+
/**
|
|
49
|
+
* Gate {@link shimmer} falls back to when `when` is omitted: the platform
|
|
50
|
+
* state a value-less `<progress>` carries.
|
|
51
|
+
*/
|
|
52
|
+
const DEFAULT_SHIMMER_WHEN = ":indeterminate";
|
|
53
|
+
/**
|
|
54
|
+
* Sweep length {@link textShimmer} falls back to when `duration` is omitted;
|
|
55
|
+
* a caption is read glyph by glyph, so its sweep runs slower than an
|
|
56
|
+
* indicator band's.
|
|
57
|
+
*/
|
|
58
|
+
const DEFAULT_TEXT_SHIMMER_DURATION = "2s";
|
|
59
|
+
/**
|
|
60
|
+
* Easing {@link textShimmer} falls back to when `easing` is omitted; a
|
|
61
|
+
* constant speed keeps the point where the sweep wraps reading as smooth.
|
|
62
|
+
*/
|
|
63
|
+
const DEFAULT_TEXT_SHIMMER_EASING = easings.linear;
|
|
64
|
+
/**
|
|
65
|
+
* Width of the moving highlight band {@link textShimmer} falls back to when
|
|
66
|
+
* `bandSize` is omitted; a narrow band suits a run of glyphs.
|
|
67
|
+
*/
|
|
68
|
+
const DEFAULT_TEXT_SHIMMER_BAND_SIZE = "30%";
|
|
69
|
+
/**
|
|
70
|
+
* Gradient angle the highlight band travels along, {@link textShimmer} falls
|
|
71
|
+
* back to when `angle` is omitted; `90deg` sweeps along the inline axis of a
|
|
72
|
+
* horizontal line of text.
|
|
73
|
+
*/
|
|
74
|
+
const DEFAULT_TEXT_SHIMMER_ANGLE = "90deg";
|
|
75
|
+
/**
|
|
76
|
+
* Highlight color {@link textShimmer} falls back to when `color` is omitted,
|
|
77
|
+
* tying the sweep to the color the caption's own styling already sets.
|
|
78
|
+
*/
|
|
79
|
+
const DEFAULT_TEXT_SHIMMER_COLOR = "currentColor";
|
|
80
|
+
/**
|
|
81
|
+
* Fraction of {@link textShimmer}'s configured `color` mixed against
|
|
82
|
+
* transparency for the resting tone, keeping the caption legible between
|
|
83
|
+
* passes of the brighter band.
|
|
84
|
+
*/
|
|
85
|
+
const TEXT_SHIMMER_REST_TONE_MIX = 45;
|
|
86
|
+
/**
|
|
87
|
+
* Turns an optional gate fragment into a host-relative selector: the bare
|
|
88
|
+
* host, or the host qualified by the gate (`&${when}`).
|
|
89
|
+
*/
|
|
90
|
+
function resolveTarget(when) {
|
|
91
|
+
return when === undefined ? "&" : `&${when}`;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Mount/gate shell every loop factory wraps its animation in: an
|
|
95
|
+
* `@starting-style` fade from {@link HIDDEN_OPACITY}, an `allow-discrete`
|
|
96
|
+
* transition, and a return to hidden outside the `when` gate.
|
|
97
|
+
*/
|
|
98
|
+
function loopShell(target, when, fadeDurationVar, restOpacity) {
|
|
99
|
+
return combine([
|
|
100
|
+
raw({
|
|
101
|
+
opacity: restOpacity,
|
|
102
|
+
transition: `opacity var(${fadeDurationVar}, ${DEFAULT_FADE_DURATION}) ease, display var(${fadeDurationVar}, ${DEFAULT_FADE_DURATION}) ease-out`,
|
|
103
|
+
}),
|
|
104
|
+
transitionBehavior("allow-discrete"),
|
|
105
|
+
when === undefined ? undefined : gate(`&:not(${when})`, opacity(HIDDEN_OPACITY)),
|
|
106
|
+
startingStyle(gate(target, opacity(HIDDEN_OPACITY))),
|
|
107
|
+
]);
|
|
108
|
+
}
|
|
109
|
+
/** Sugar for `when(selector, input)`, named to read alongside this file's own gating vocabulary. */
|
|
110
|
+
function gate(selector, input) {
|
|
111
|
+
return when(selector, input);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Continuous 360° rotation for a busy indicator's glyph, resolved entirely to
|
|
115
|
+
* `@keyframes` so it runs from server-rendered markup. Under
|
|
116
|
+
* `prefers-reduced-motion: reduce`, a gentle opacity breathe carries it.
|
|
117
|
+
*
|
|
118
|
+
* @param options Timing and gating for the loop.
|
|
119
|
+
* @returns A `@sdxc/u` mixin ready for a spinner's host element.
|
|
120
|
+
* @example
|
|
121
|
+
* <Spinner mix={[spin()]} aria-label={t("status.loading")} />
|
|
122
|
+
*/
|
|
123
|
+
export function spin(options = {}) {
|
|
124
|
+
let duration = options.duration ?? DEFAULT_SPIN_DURATION;
|
|
125
|
+
let easing = options.easing ?? DEFAULT_SPIN_EASING;
|
|
126
|
+
let when = options.when;
|
|
127
|
+
let target = resolveTarget(when);
|
|
128
|
+
return combine([
|
|
129
|
+
loopShell(target, when, "--ui-spin-fade-duration", 1),
|
|
130
|
+
keyframes("ui-spin-rotate", {
|
|
131
|
+
from: { transform: "rotate(0deg)" },
|
|
132
|
+
to: { transform: "rotate(360deg)" },
|
|
133
|
+
}),
|
|
134
|
+
keyframes("ui-spin-breathe", {
|
|
135
|
+
"0%, 100%": { opacity: 1 },
|
|
136
|
+
"50%": { opacity: 0.4 },
|
|
137
|
+
}),
|
|
138
|
+
gate(target, animationHost("ui-spin-rotate", {
|
|
139
|
+
duration: varUtility("ui-spin-duration", duration),
|
|
140
|
+
easing: varUtility("ui-spin-easing", easing),
|
|
141
|
+
iterationCount: "infinite",
|
|
142
|
+
})),
|
|
143
|
+
media("(prefers-reduced-motion: reduce)", gate(target, animationHost("ui-spin-breathe", {
|
|
144
|
+
duration: varUtility("ui-spin-duration", duration),
|
|
145
|
+
easing: "ease-in-out",
|
|
146
|
+
iterationCount: "infinite",
|
|
147
|
+
}))),
|
|
148
|
+
]);
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Gentle opacity breathe for a skeleton placeholder, resolved entirely to
|
|
152
|
+
* `@keyframes` so it runs from server-rendered markup. Reduced motion narrows
|
|
153
|
+
* the swing by overriding duration and the min-opacity token alone.
|
|
154
|
+
*
|
|
155
|
+
* @param options Timing, opacity range, and gating for the loop.
|
|
156
|
+
* @returns A `@sdxc/u` mixin ready for a skeleton placeholder's host element.
|
|
157
|
+
* @example
|
|
158
|
+
* <Skeleton mix={[pulse()]} aria-hidden="true" />
|
|
159
|
+
*/
|
|
160
|
+
export function pulse(options = {}) {
|
|
161
|
+
let duration = options.duration ?? DEFAULT_PULSE_DURATION;
|
|
162
|
+
let easing = options.easing ?? DEFAULT_PULSE_EASING;
|
|
163
|
+
let minOpacity = options.minOpacity ?? DEFAULT_PULSE_MIN_OPACITY;
|
|
164
|
+
let maxOpacity = options.maxOpacity ?? DEFAULT_PULSE_MAX_OPACITY;
|
|
165
|
+
let when = options.when;
|
|
166
|
+
let target = resolveTarget(when);
|
|
167
|
+
let reducedMinOpacity = maxOpacity - (maxOpacity - minOpacity) * REDUCED_PULSE_AMPLITUDE_SCALE;
|
|
168
|
+
return combine([
|
|
169
|
+
loopShell(target, when, "--ui-pulse-fade-duration", maxOpacity),
|
|
170
|
+
keyframes("ui-pulse-breathe", {
|
|
171
|
+
"0%, 100%": { opacity: `var(--ui-pulse-max-opacity, ${maxOpacity})` },
|
|
172
|
+
"50%": { opacity: `var(--ui-pulse-min-opacity, ${minOpacity})` },
|
|
173
|
+
}),
|
|
174
|
+
gate(target, animationHost("ui-pulse-breathe", {
|
|
175
|
+
duration: varUtility("ui-pulse-duration", duration),
|
|
176
|
+
easing: varUtility("ui-pulse-easing", easing),
|
|
177
|
+
iterationCount: "infinite",
|
|
178
|
+
})),
|
|
179
|
+
media("(prefers-reduced-motion: reduce)", gate(target, raw({
|
|
180
|
+
"--ui-pulse-min-opacity": String(reducedMinOpacity),
|
|
181
|
+
animationDuration: calc(`var(--ui-pulse-duration, ${duration}) * 1.5`),
|
|
182
|
+
}))),
|
|
183
|
+
]);
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Sweeping highlight band for an indeterminate progress fill, resolved
|
|
187
|
+
* entirely to `@keyframes` so it runs from server-rendered markup and settles
|
|
188
|
+
* once the gate clears; reduced motion breathes the fill's opacity instead.
|
|
189
|
+
*
|
|
190
|
+
* @param options Timing, band width, and gating for the loop.
|
|
191
|
+
* @returns A `@sdxc/u` mixin ready for a progress indicator's fill element.
|
|
192
|
+
* @example
|
|
193
|
+
* <ProgressBar.Indicator mix={[shimmer()]} />
|
|
194
|
+
*/
|
|
195
|
+
export function shimmer(options = {}) {
|
|
196
|
+
let duration = options.duration ?? DEFAULT_SHIMMER_DURATION;
|
|
197
|
+
let easing = options.easing ?? DEFAULT_SHIMMER_EASING;
|
|
198
|
+
let bandSize = options.bandSize ?? DEFAULT_SHIMMER_BAND_SIZE;
|
|
199
|
+
let when = options.when ?? DEFAULT_SHIMMER_WHEN;
|
|
200
|
+
let target = resolveTarget(when);
|
|
201
|
+
return combine([
|
|
202
|
+
loopShell(target, when, "--ui-shimmer-fade-duration", 1),
|
|
203
|
+
keyframes("ui-shimmer-sweep", {
|
|
204
|
+
from: { backgroundPosition: "-100% 0" },
|
|
205
|
+
to: { backgroundPosition: "200% 0" },
|
|
206
|
+
}),
|
|
207
|
+
keyframes("ui-shimmer-breathe", {
|
|
208
|
+
"0%, 100%": { opacity: 1 },
|
|
209
|
+
"50%": { opacity: 0.6 },
|
|
210
|
+
}),
|
|
211
|
+
gate(target, combine([
|
|
212
|
+
raw({
|
|
213
|
+
backgroundImage: linearGradient(90, "transparent", colorMix("oklab", { color: "currentColor", weight: 35 }, "transparent"), "transparent"),
|
|
214
|
+
backgroundRepeat: "no-repeat",
|
|
215
|
+
backgroundSize: `var(--ui-shimmer-band-size, ${bandSize}) 100%`,
|
|
216
|
+
}),
|
|
217
|
+
animationHost("ui-shimmer-sweep", {
|
|
218
|
+
duration: varUtility("ui-shimmer-duration", duration),
|
|
219
|
+
easing: varUtility("ui-shimmer-easing", easing),
|
|
220
|
+
iterationCount: "infinite",
|
|
221
|
+
}),
|
|
222
|
+
])),
|
|
223
|
+
media("(prefers-reduced-motion: reduce)", gate(target, animationHost("ui-shimmer-breathe", {
|
|
224
|
+
duration: varUtility("ui-shimmer-duration", duration),
|
|
225
|
+
easing: "ease-in-out",
|
|
226
|
+
iterationCount: "infinite",
|
|
227
|
+
}))),
|
|
228
|
+
]);
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Sweeping highlight through a run of text's own glyphs for a caption that
|
|
232
|
+
* stands in for a busy state. The `background-clip: text` paint sits behind
|
|
233
|
+
* an `@supports` guard; reduced motion breathes the caption's opacity.
|
|
234
|
+
*
|
|
235
|
+
* @param options Timing, band width, angle, color, and gating for the loop.
|
|
236
|
+
* @returns A `@sdxc/u` mixin ready for a caption's host text element.
|
|
237
|
+
* @example
|
|
238
|
+
* <Text mix={[textShimmer()]}>{t("chat.generating")}</Text>
|
|
239
|
+
* @example
|
|
240
|
+
* <Text mix={[textShimmer({ color: "var(--ui-brand-fg)", duration: "1.5s" })]}>
|
|
241
|
+
* {t("chat.generating")}
|
|
242
|
+
* </Text>
|
|
243
|
+
*/
|
|
244
|
+
export function textShimmer(options = {}) {
|
|
245
|
+
let duration = options.duration ?? DEFAULT_TEXT_SHIMMER_DURATION;
|
|
246
|
+
let easing = options.easing ?? DEFAULT_TEXT_SHIMMER_EASING;
|
|
247
|
+
let bandSize = options.bandSize ?? DEFAULT_TEXT_SHIMMER_BAND_SIZE;
|
|
248
|
+
let angle = options.angle ?? DEFAULT_TEXT_SHIMMER_ANGLE;
|
|
249
|
+
let color = options.color ?? DEFAULT_TEXT_SHIMMER_COLOR;
|
|
250
|
+
let when = options.when;
|
|
251
|
+
let target = resolveTarget(when);
|
|
252
|
+
let angleVar = `var(--ui-text-shimmer-angle, ${angle})`;
|
|
253
|
+
let bandSizeVar = `var(--ui-text-shimmer-band-size, ${bandSize})`;
|
|
254
|
+
let colorVar = `var(--ui-text-shimmer-color, ${color})`;
|
|
255
|
+
let restTone = colorMix("oklab", { color: colorVar, weight: TEXT_SHIMMER_REST_TONE_MIX }, "transparent");
|
|
256
|
+
return combine([
|
|
257
|
+
loopShell(target, when, "--ui-text-shimmer-fade-duration", 1),
|
|
258
|
+
supports("(background-clip: text) or (-webkit-background-clip: text)", [
|
|
259
|
+
keyframes("ui-text-shimmer-sweep", {
|
|
260
|
+
from: { backgroundPosition: "100% 0" },
|
|
261
|
+
to: { backgroundPosition: "-100% 0" },
|
|
262
|
+
}),
|
|
263
|
+
keyframes("ui-text-shimmer-breathe", {
|
|
264
|
+
"0%, 100%": { opacity: 1 },
|
|
265
|
+
"50%": { opacity: 0.6 },
|
|
266
|
+
}),
|
|
267
|
+
gate(target, combine([
|
|
268
|
+
raw({
|
|
269
|
+
backgroundImage: linearGradient(angleVar, { color: restTone, position: "0%" }, { color: restTone, position: calc(`50% - (${bandSizeVar} / 2)`) }, { color: colorVar, position: "50%" }, { color: restTone, position: calc(`50% + (${bandSizeVar} / 2)`) }, { color: restTone, position: "100%" }),
|
|
270
|
+
backgroundSize: "200% 100%",
|
|
271
|
+
backgroundRepeat: "no-repeat",
|
|
272
|
+
WebkitBackgroundClip: "text",
|
|
273
|
+
backgroundClip: "text",
|
|
274
|
+
WebkitTextFillColor: "transparent",
|
|
275
|
+
}),
|
|
276
|
+
animationHost("ui-text-shimmer-sweep", {
|
|
277
|
+
duration: varUtility("ui-text-shimmer-duration", duration),
|
|
278
|
+
easing: varUtility("ui-text-shimmer-easing", easing),
|
|
279
|
+
iterationCount: "infinite",
|
|
280
|
+
}),
|
|
281
|
+
])),
|
|
282
|
+
media("(prefers-reduced-motion: reduce)", gate(target, combine([
|
|
283
|
+
raw({
|
|
284
|
+
backgroundImage: "none",
|
|
285
|
+
WebkitBackgroundClip: "border-box",
|
|
286
|
+
backgroundClip: "border-box",
|
|
287
|
+
WebkitTextFillColor: "currentColor",
|
|
288
|
+
}),
|
|
289
|
+
animationHost("ui-text-shimmer-breathe", {
|
|
290
|
+
duration: varUtility("ui-text-shimmer-duration", duration),
|
|
291
|
+
easing: "ease-in-out",
|
|
292
|
+
iterationCount: "infinite",
|
|
293
|
+
}),
|
|
294
|
+
]))),
|
|
295
|
+
]),
|
|
296
|
+
]);
|
|
297
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scroll-driven animation factories riding `animation-timeline: scroll()` and
|
|
3
|
+
* `view()`: a sticky header's shadow, a scroll-position progress indicator,
|
|
4
|
+
* an element's entry motion as it scrolls into the viewport, and a scroll
|
|
5
|
+
* container's own edge fade hinting at content beyond its current view.
|
|
6
|
+
*
|
|
7
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
8
|
+
* @copyright Sergio Xalambrí 2026
|
|
9
|
+
*/
|
|
10
|
+
import type { UtilityMixin } from "@sdxc/u";
|
|
11
|
+
import type { CSSMixinDescriptor } from "remix/ui";
|
|
12
|
+
/**
|
|
13
|
+
* Options accepted by {@link scrollShadow}.
|
|
14
|
+
*/
|
|
15
|
+
export declare namespace ScrollShadow {
|
|
16
|
+
/**
|
|
17
|
+
* Options controlling how far a sticky element's own scroll container
|
|
18
|
+
* must scroll before its shadow fully settles in.
|
|
19
|
+
*/
|
|
20
|
+
interface Options {
|
|
21
|
+
/**
|
|
22
|
+
* CSS length the shadow ramps in over, measured from the top of the
|
|
23
|
+
* tracked scroll container. Defaults to `"120px"`.
|
|
24
|
+
*/
|
|
25
|
+
distance?: string;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Gives a sticky header a scroll-driven shadow, so it reads as elevated only
|
|
30
|
+
* once content has scrolled beneath it. Reduced motion pins the shadow on;
|
|
31
|
+
* engines without scroll timelines leave the header flat.
|
|
32
|
+
*
|
|
33
|
+
* @param options Tuning for how quickly the shadow settles in.
|
|
34
|
+
* @returns A style mixin, applicable through a host element's `mix` prop.
|
|
35
|
+
* @example
|
|
36
|
+
* mix={scrollShadow({ distance: "80px" })}
|
|
37
|
+
*/
|
|
38
|
+
export declare function scrollShadow(options?: ScrollShadow.Options): CSSMixinDescriptor;
|
|
39
|
+
/**
|
|
40
|
+
* Options accepted by {@link scrollProgress}.
|
|
41
|
+
*/
|
|
42
|
+
export declare namespace ScrollProgress {
|
|
43
|
+
/**
|
|
44
|
+
* Options selecting which scroll axis a progress indicator tracks.
|
|
45
|
+
*/
|
|
46
|
+
interface Options {
|
|
47
|
+
/**
|
|
48
|
+
* Scroll axis the indicator's timeline attaches to: `"block"` tracks
|
|
49
|
+
* vertical scroll (a reading-progress bar), `"inline"` horizontal scroll
|
|
50
|
+
* (a Carousel viewport). Defaults to `"block"`.
|
|
51
|
+
*/
|
|
52
|
+
axis?: "block" | "inline";
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Grows a fill element in lockstep with its scrollable ancestor's scroll
|
|
57
|
+
* position, from the inline-start edge so it reads correctly in both writing
|
|
58
|
+
* directions. Nest it in a fixed-size track; reduced motion ramps opacity.
|
|
59
|
+
*
|
|
60
|
+
* @param options Selects the scroll axis the indicator tracks.
|
|
61
|
+
* @returns A style mixin, applicable through a host element's `mix` prop.
|
|
62
|
+
* @example
|
|
63
|
+
* mix={scrollProgress({ axis: "inline" })}
|
|
64
|
+
*/
|
|
65
|
+
export declare function scrollProgress(options?: ScrollProgress.Options): CSSMixinDescriptor;
|
|
66
|
+
/**
|
|
67
|
+
* Options accepted by {@link viewReveal}.
|
|
68
|
+
*/
|
|
69
|
+
export declare namespace ViewReveal {
|
|
70
|
+
/**
|
|
71
|
+
* Edge an element's entry motion translates in from, expressed as a
|
|
72
|
+
* logical direction so it stays correct under both writing directions.
|
|
73
|
+
* `"none"` fades the element in place.
|
|
74
|
+
*/
|
|
75
|
+
type Direction = "block-start" | "block-end" | "inline-start" | "inline-end" | "none";
|
|
76
|
+
/**
|
|
77
|
+
* Options tuning an element's entry motion as it scrolls into view.
|
|
78
|
+
*/
|
|
79
|
+
interface Options {
|
|
80
|
+
/**
|
|
81
|
+
* Logical edge the element translates in from. Defaults to
|
|
82
|
+
* `"block-end"` — the element rises into place, matching the most
|
|
83
|
+
* common reveal-on-scroll convention.
|
|
84
|
+
*/
|
|
85
|
+
from?: Direction;
|
|
86
|
+
/**
|
|
87
|
+
* CSS length the element starts offset by. Ignored when `from` is
|
|
88
|
+
* `"none"`. Defaults to `"1.5rem"`.
|
|
89
|
+
*/
|
|
90
|
+
distance?: string;
|
|
91
|
+
/**
|
|
92
|
+
* Scroll axis the element's view-timeline progresses along: `"block"`
|
|
93
|
+
* for a vertically scrolling page or panel, `"inline"` for a
|
|
94
|
+
* horizontally scrolling one, such as a Carousel. Defaults to `"block"`.
|
|
95
|
+
*/
|
|
96
|
+
axis?: "block" | "inline";
|
|
97
|
+
/**
|
|
98
|
+
* Named view-timeline range the reveal completes over. Defaults to
|
|
99
|
+
* `"entry"` — the reveal finishes once the element has fully entered
|
|
100
|
+
* the scrollport and stays settled for the remainder of scroll.
|
|
101
|
+
*/
|
|
102
|
+
range?: string;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Plays a translate-and-fade entry as the element scrolls into view; out and
|
|
107
|
+
* back replays it. `@keyframes` names are document-global, so one shared set
|
|
108
|
+
* reads its distance from a custom property, mirrored under `:dir(rtl)`.
|
|
109
|
+
*
|
|
110
|
+
* @param options Tuning for the reveal's direction, distance, and range.
|
|
111
|
+
* @returns A style mixin, applicable through a host element's `mix` prop.
|
|
112
|
+
* @example
|
|
113
|
+
* mix={viewReveal({ from: "inline-start", distance: "2rem" })}
|
|
114
|
+
*/
|
|
115
|
+
export declare function viewReveal(options?: ViewReveal.Options): CSSMixinDescriptor;
|
|
116
|
+
/**
|
|
117
|
+
* Options accepted by {@link scrollFade}.
|
|
118
|
+
*/
|
|
119
|
+
export declare namespace ScrollFade {
|
|
120
|
+
/**
|
|
121
|
+
* Options tuning which edges a scroll container's own mask-driven fade
|
|
122
|
+
* tracks and how wide each faded band reads.
|
|
123
|
+
*/
|
|
124
|
+
interface Options {
|
|
125
|
+
/**
|
|
126
|
+
* Scroll axis the fade's timeline attaches to: `"block"` fades the top
|
|
127
|
+
* and bottom edges of a vertically scrolling list, `"inline"` the start
|
|
128
|
+
* and end edges of a horizontally scrolling row. Defaults to `"block"`.
|
|
129
|
+
*/
|
|
130
|
+
axis?: "block" | "inline";
|
|
131
|
+
/**
|
|
132
|
+
* CSS length each faded band extends inward from its edge. Defaults
|
|
133
|
+
* to `"3rem"`.
|
|
134
|
+
*/
|
|
135
|
+
size?: string;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Fades a scroll container's own edges through a mask on the scrolling
|
|
140
|
+
* element itself: each edge reads opaque once scroll reaches it and feathers
|
|
141
|
+
* while content lies beyond. Without scroll timelines both edges stay faded.
|
|
142
|
+
*
|
|
143
|
+
* @param options Selects the scroll axis the fade tracks and how wide each faded band reads.
|
|
144
|
+
* @returns A style mixin, applicable through a host element's `mix` prop.
|
|
145
|
+
* @example
|
|
146
|
+
* <MessageScroller.Viewport mix={scrollFade({ axis: "block" })}>
|
|
147
|
+
* {messages}
|
|
148
|
+
* </MessageScroller.Viewport>
|
|
149
|
+
* @example
|
|
150
|
+
* <Attachment.Group mix={scrollFade({ axis: "inline", size: "2rem" })}>
|
|
151
|
+
* {attachments}
|
|
152
|
+
* </Attachment.Group>
|
|
153
|
+
*/
|
|
154
|
+
export declare function scrollFade<node extends Element = Element>(options?: ScrollFade.Options): UtilityMixin<node>;
|