@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,228 @@
|
|
|
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 { animation, keyframes } from "@sdxc/u/animation";
|
|
11
|
+
import { mask } from "@sdxc/u/effects";
|
|
12
|
+
import { combine, raw } from "@sdxc/u/general";
|
|
13
|
+
import { media, supports } from "@sdxc/u/responsive";
|
|
14
|
+
import { is } from "@sdxc/u/size";
|
|
15
|
+
import { when } from "@sdxc/u/state";
|
|
16
|
+
import { translateProperty } from "@sdxc/u/transform";
|
|
17
|
+
import { easings } from "./tokens.js";
|
|
18
|
+
const DEFAULT_SCROLL_SHADOW_DISTANCE = "120px";
|
|
19
|
+
const SCROLL_SHADOW_KEYFRAMES_NAME = "ui-scroll-shadow-reveal";
|
|
20
|
+
const DEFAULT_SCROLL_PROGRESS_AXIS = "block";
|
|
21
|
+
const SCROLL_PROGRESS_FILL_KEYFRAMES_NAME = "ui-scroll-progress-fill";
|
|
22
|
+
const SCROLL_PROGRESS_FADE_KEYFRAMES_NAME = "ui-scroll-progress-fade";
|
|
23
|
+
const DEFAULT_VIEW_REVEAL_FROM = "block-end";
|
|
24
|
+
const DEFAULT_VIEW_REVEAL_DISTANCE = "1.5rem";
|
|
25
|
+
const DEFAULT_VIEW_REVEAL_AXIS = "block";
|
|
26
|
+
const DEFAULT_VIEW_REVEAL_RANGE = "entry";
|
|
27
|
+
const VIEW_REVEAL_TRANSLATE_PROPERTY = "--ui-view-reveal-translate";
|
|
28
|
+
const VIEW_REVEAL_KEYFRAMES_NAME = "ui-view-reveal-enter";
|
|
29
|
+
const VIEW_REVEAL_REDUCED_KEYFRAMES_NAME = "ui-view-reveal-reduced";
|
|
30
|
+
const DEFAULT_SCROLL_FADE_AXIS = "block";
|
|
31
|
+
const DEFAULT_SCROLL_FADE_SIZE = "3rem";
|
|
32
|
+
const SCROLL_FADE_DIRECTION_PROPERTY = "--ui-scroll-fade-direction";
|
|
33
|
+
const SCROLL_FADE_KEYFRAMES_NAME = "ui-scroll-fade-mask";
|
|
34
|
+
/**
|
|
35
|
+
* Proportion of the tracked scroll range each edge's fade takes to ramp
|
|
36
|
+
* fully in or out. Held as a proportion because the scroll-linked keyframes
|
|
37
|
+
* below sit at percentages of whatever range the container's content scrolls.
|
|
38
|
+
*/
|
|
39
|
+
const SCROLL_FADE_RAMP_PERCENT = 8;
|
|
40
|
+
/** Gradient direction each axis paints its mask along; `"inline"` reads its actual value from {@link SCROLL_FADE_DIRECTION_PROPERTY}, mirrored under `:dir(rtl)`. */
|
|
41
|
+
const SCROLL_FADE_AXIS_DIRECTION = {
|
|
42
|
+
block: "to bottom",
|
|
43
|
+
inline: `to var(${SCROLL_FADE_DIRECTION_PROPERTY}, right)`,
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Gives a sticky header a scroll-driven shadow, so it reads as elevated only
|
|
47
|
+
* once content has scrolled beneath it. Reduced motion pins the shadow on;
|
|
48
|
+
* engines without scroll timelines leave the header flat.
|
|
49
|
+
*
|
|
50
|
+
* @param options Tuning for how quickly the shadow settles in.
|
|
51
|
+
* @returns A style mixin, applicable through a host element's `mix` prop.
|
|
52
|
+
* @example
|
|
53
|
+
* mix={scrollShadow({ distance: "80px" })}
|
|
54
|
+
*/
|
|
55
|
+
export function scrollShadow(options = {}) {
|
|
56
|
+
let distance = options.distance ?? DEFAULT_SCROLL_SHADOW_DISTANCE;
|
|
57
|
+
return supports("(animation-timeline: scroll())", [
|
|
58
|
+
animation(SCROLL_SHADOW_KEYFRAMES_NAME, {
|
|
59
|
+
keyframes: {
|
|
60
|
+
from: { boxShadow: "0 0 0 0 transparent" },
|
|
61
|
+
to: { boxShadow: "var(--ui-scroll-shadow, 0 4px 12px -4px rgb(0 0 0 / 0.18))" },
|
|
62
|
+
},
|
|
63
|
+
duration: "auto",
|
|
64
|
+
easing: easings.linear,
|
|
65
|
+
fillMode: "both",
|
|
66
|
+
timeline: "scroll(nearest block)",
|
|
67
|
+
range: `0 ${distance}`,
|
|
68
|
+
}),
|
|
69
|
+
media("(prefers-reduced-motion: reduce)", raw({
|
|
70
|
+
animationName: "none",
|
|
71
|
+
boxShadow: "var(--ui-scroll-shadow, 0 4px 12px -4px rgb(0 0 0 / 0.18))",
|
|
72
|
+
})),
|
|
73
|
+
]);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Grows a fill element in lockstep with its scrollable ancestor's scroll
|
|
77
|
+
* position, from the inline-start edge so it reads correctly in both writing
|
|
78
|
+
* directions. Nest it in a fixed-size track; reduced motion ramps opacity.
|
|
79
|
+
*
|
|
80
|
+
* @param options Selects the scroll axis the indicator tracks.
|
|
81
|
+
* @returns A style mixin, applicable through a host element's `mix` prop.
|
|
82
|
+
* @example
|
|
83
|
+
* mix={scrollProgress({ axis: "inline" })}
|
|
84
|
+
*/
|
|
85
|
+
export function scrollProgress(options = {}) {
|
|
86
|
+
let axis = options.axis ?? DEFAULT_SCROLL_PROGRESS_AXIS;
|
|
87
|
+
return supports("(animation-timeline: scroll())", [
|
|
88
|
+
animation(SCROLL_PROGRESS_FILL_KEYFRAMES_NAME, {
|
|
89
|
+
keyframes: {
|
|
90
|
+
from: { inlineSize: "0%" },
|
|
91
|
+
to: { inlineSize: "100%" },
|
|
92
|
+
},
|
|
93
|
+
duration: "auto",
|
|
94
|
+
easing: easings.linear,
|
|
95
|
+
fillMode: "both",
|
|
96
|
+
timeline: `scroll(nearest ${axis})`,
|
|
97
|
+
}),
|
|
98
|
+
media("(prefers-reduced-motion: reduce)", [
|
|
99
|
+
keyframes(SCROLL_PROGRESS_FADE_KEYFRAMES_NAME, {
|
|
100
|
+
from: { opacity: 0 },
|
|
101
|
+
to: { opacity: 1 },
|
|
102
|
+
}),
|
|
103
|
+
raw({ animationName: SCROLL_PROGRESS_FADE_KEYFRAMES_NAME }),
|
|
104
|
+
is("full"),
|
|
105
|
+
]),
|
|
106
|
+
]);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Plays a translate-and-fade entry as the element scrolls into view; out and
|
|
110
|
+
* back replays it. `@keyframes` names are document-global, so one shared set
|
|
111
|
+
* reads its distance from a custom property, mirrored under `:dir(rtl)`.
|
|
112
|
+
*
|
|
113
|
+
* @param options Tuning for the reveal's direction, distance, and range.
|
|
114
|
+
* @returns A style mixin, applicable through a host element's `mix` prop.
|
|
115
|
+
* @example
|
|
116
|
+
* mix={viewReveal({ from: "inline-start", distance: "2rem" })}
|
|
117
|
+
*/
|
|
118
|
+
export function viewReveal(options = {}) {
|
|
119
|
+
let from = options.from ?? DEFAULT_VIEW_REVEAL_FROM;
|
|
120
|
+
let distance = options.distance ?? DEFAULT_VIEW_REVEAL_DISTANCE;
|
|
121
|
+
let axis = options.axis ?? DEFAULT_VIEW_REVEAL_AXIS;
|
|
122
|
+
let range = options.range ?? DEFAULT_VIEW_REVEAL_RANGE;
|
|
123
|
+
let negatedDistance = `calc(-1 * ${distance})`;
|
|
124
|
+
let enterTranslate = "0 0";
|
|
125
|
+
let enterTranslateMirrored = "0 0";
|
|
126
|
+
let needsMirror = false;
|
|
127
|
+
switch (from) {
|
|
128
|
+
case "block-start":
|
|
129
|
+
enterTranslate = `0 ${negatedDistance}`;
|
|
130
|
+
enterTranslateMirrored = enterTranslate;
|
|
131
|
+
break;
|
|
132
|
+
case "block-end":
|
|
133
|
+
enterTranslate = `0 ${distance}`;
|
|
134
|
+
enterTranslateMirrored = enterTranslate;
|
|
135
|
+
break;
|
|
136
|
+
case "inline-start":
|
|
137
|
+
enterTranslate = `${negatedDistance} 0`;
|
|
138
|
+
enterTranslateMirrored = `${distance} 0`;
|
|
139
|
+
needsMirror = true;
|
|
140
|
+
break;
|
|
141
|
+
case "inline-end":
|
|
142
|
+
enterTranslate = `${distance} 0`;
|
|
143
|
+
enterTranslateMirrored = `${negatedDistance} 0`;
|
|
144
|
+
needsMirror = true;
|
|
145
|
+
break;
|
|
146
|
+
case "none":
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
return supports("(animation-timeline: scroll())", [
|
|
150
|
+
raw({ [VIEW_REVEAL_TRANSLATE_PROPERTY]: enterTranslate }),
|
|
151
|
+
animation(VIEW_REVEAL_KEYFRAMES_NAME, {
|
|
152
|
+
keyframes: {
|
|
153
|
+
from: { opacity: 0, translate: `var(${VIEW_REVEAL_TRANSLATE_PROPERTY}, 0 0)` },
|
|
154
|
+
to: { opacity: 1, translate: "0 0" },
|
|
155
|
+
},
|
|
156
|
+
duration: "auto",
|
|
157
|
+
easing: easings.decelerate,
|
|
158
|
+
fillMode: "both",
|
|
159
|
+
timeline: `view(${axis})`,
|
|
160
|
+
range: range,
|
|
161
|
+
}),
|
|
162
|
+
needsMirror &&
|
|
163
|
+
when("&:dir(rtl)", raw({ [VIEW_REVEAL_TRANSLATE_PROPERTY]: enterTranslateMirrored })),
|
|
164
|
+
media("(prefers-reduced-motion: reduce)", [
|
|
165
|
+
keyframes(VIEW_REVEAL_REDUCED_KEYFRAMES_NAME, {
|
|
166
|
+
from: { opacity: 0 },
|
|
167
|
+
to: { opacity: 1 },
|
|
168
|
+
}),
|
|
169
|
+
raw({ animationName: VIEW_REVEAL_REDUCED_KEYFRAMES_NAME }),
|
|
170
|
+
translateProperty("0 0"),
|
|
171
|
+
]),
|
|
172
|
+
]);
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Builds the four-stop mask gradient every {@link scrollFade} state paints.
|
|
176
|
+
* Collapsing a middle stop onto its neighboring fixed stop reads as a fully
|
|
177
|
+
* opaque edge, so one gradient shape serves every state.
|
|
178
|
+
*/
|
|
179
|
+
function scrollFadeMask(direction, startStop, endStop) {
|
|
180
|
+
return `linear-gradient(${direction}, transparent 0%, black ${startStop}, black ${endStop}, transparent 100%)`;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Fades a scroll container's own edges through a mask on the scrolling
|
|
184
|
+
* element itself: each edge reads opaque once scroll reaches it and feathers
|
|
185
|
+
* while content lies beyond. Without scroll timelines both edges stay faded.
|
|
186
|
+
*
|
|
187
|
+
* @param options Selects the scroll axis the fade tracks and how wide each faded band reads.
|
|
188
|
+
* @returns A style mixin, applicable through a host element's `mix` prop.
|
|
189
|
+
* @example
|
|
190
|
+
* <MessageScroller.Viewport mix={scrollFade({ axis: "block" })}>
|
|
191
|
+
* {messages}
|
|
192
|
+
* </MessageScroller.Viewport>
|
|
193
|
+
* @example
|
|
194
|
+
* <Attachment.Group mix={scrollFade({ axis: "inline", size: "2rem" })}>
|
|
195
|
+
* {attachments}
|
|
196
|
+
* </Attachment.Group>
|
|
197
|
+
*/
|
|
198
|
+
export function scrollFade(options = {}) {
|
|
199
|
+
let axis = options.axis ?? DEFAULT_SCROLL_FADE_AXIS;
|
|
200
|
+
let size = options.size ?? DEFAULT_SCROLL_FADE_SIZE;
|
|
201
|
+
let direction = SCROLL_FADE_AXIS_DIRECTION[axis];
|
|
202
|
+
let settledStop = `calc(100% - ${size})`;
|
|
203
|
+
let settledMask = scrollFadeMask(direction, size, settledStop);
|
|
204
|
+
let rampPercent = SCROLL_FADE_RAMP_PERCENT;
|
|
205
|
+
let fadeKeyframes = {
|
|
206
|
+
"0%": { maskImage: scrollFadeMask(direction, "0%", settledStop) },
|
|
207
|
+
"100%": { maskImage: scrollFadeMask(direction, size, "100%") },
|
|
208
|
+
};
|
|
209
|
+
fadeKeyframes[`${rampPercent}%, ${100 - rampPercent}%`] = { maskImage: settledMask };
|
|
210
|
+
return combine([
|
|
211
|
+
mask(settledMask),
|
|
212
|
+
axis === "inline" &&
|
|
213
|
+
when("&:dir(rtl)", raw({ [SCROLL_FADE_DIRECTION_PROPERTY]: "left" })),
|
|
214
|
+
supports("(animation-timeline: scroll())", [
|
|
215
|
+
animation(SCROLL_FADE_KEYFRAMES_NAME, {
|
|
216
|
+
keyframes: fadeKeyframes,
|
|
217
|
+
duration: "auto",
|
|
218
|
+
easing: easings.linear,
|
|
219
|
+
fillMode: "both",
|
|
220
|
+
timeline: `scroll(self ${axis})`,
|
|
221
|
+
}),
|
|
222
|
+
media("(prefers-reduced-motion: reduce)", [
|
|
223
|
+
raw({ animationName: "none" }),
|
|
224
|
+
mask(settledMask),
|
|
225
|
+
]),
|
|
226
|
+
]),
|
|
227
|
+
]);
|
|
228
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared motion vocabulary for the animation layer: named transition-duration
|
|
3
|
+
* steps and named `transition-timing-function` curves. Every factory in
|
|
4
|
+
* `transitions.ts` defaults to one of these, so overlays across the whole
|
|
5
|
+
* catalog settle into the same rhythm.
|
|
6
|
+
*
|
|
7
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
8
|
+
* @copyright Sergio Xalambrí 2026
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Named `transition-timing-function` curves shared by every animation
|
|
12
|
+
* factory, component, and mixin that needs one, so every transition across
|
|
13
|
+
* the catalog settles into the same small set of curves.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* fade({ easing: easings.decelerate });
|
|
17
|
+
* @example
|
|
18
|
+
* transitionTimingFunction: easings.standard,
|
|
19
|
+
*/
|
|
20
|
+
export declare const easings: {
|
|
21
|
+
/** The general-purpose curve for enter/exit transitions: gentle acceleration, gentle deceleration. */
|
|
22
|
+
readonly standard: "cubic-bezier(0.4, 0, 0.2, 1)";
|
|
23
|
+
/** Starts fast and settles slowly; reads as an element arriving into place. Suits entrances. */
|
|
24
|
+
readonly decelerate: "cubic-bezier(0, 0, 0.2, 1)";
|
|
25
|
+
/** Starts slowly and leaves quickly; reads as an element departing the screen. Suits exits. */
|
|
26
|
+
readonly accelerate: "cubic-bezier(0.4, 0, 1, 1)";
|
|
27
|
+
/** Constant rate from start to end; matches the platform's own `linear` keyword. */
|
|
28
|
+
readonly linear: "linear";
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Named `transition-duration` steps, in milliseconds, ordered from the
|
|
32
|
+
* snappiest anchored surface to the largest edge-docked one. Pass one as an
|
|
33
|
+
* animation factory's `duration` option so every overlay shares one rhythm.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* fade({ duration: durations.fast });
|
|
37
|
+
*/
|
|
38
|
+
export declare const durations: {
|
|
39
|
+
/** Small surfaces anchored to a trigger: Tooltip, HoverCard, Menu. */
|
|
40
|
+
readonly fast: 150;
|
|
41
|
+
/** The default for most overlays: Popover, Dialog, Toast. */
|
|
42
|
+
readonly normal: 200;
|
|
43
|
+
/** Larger surfaces that cover more of the viewport: Sheet, Drawer. */
|
|
44
|
+
readonly slow: 300;
|
|
45
|
+
/** The largest surfaces, or a transition carrying secondary motion alongside the primary one. */
|
|
46
|
+
readonly slower: 400;
|
|
47
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared motion vocabulary for the animation layer: named transition-duration
|
|
3
|
+
* steps and named `transition-timing-function` curves. Every factory in
|
|
4
|
+
* `transitions.ts` defaults to one of these, so overlays across the whole
|
|
5
|
+
* catalog settle into the same rhythm.
|
|
6
|
+
*
|
|
7
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
8
|
+
* @copyright Sergio Xalambrí 2026
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Named `transition-timing-function` curves shared by every animation
|
|
12
|
+
* factory, component, and mixin that needs one, so every transition across
|
|
13
|
+
* the catalog settles into the same small set of curves.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* fade({ easing: easings.decelerate });
|
|
17
|
+
* @example
|
|
18
|
+
* transitionTimingFunction: easings.standard,
|
|
19
|
+
*/
|
|
20
|
+
export const easings = {
|
|
21
|
+
/** The general-purpose curve for enter/exit transitions: gentle acceleration, gentle deceleration. */
|
|
22
|
+
standard: "cubic-bezier(0.4, 0, 0.2, 1)",
|
|
23
|
+
/** Starts fast and settles slowly; reads as an element arriving into place. Suits entrances. */
|
|
24
|
+
decelerate: "cubic-bezier(0, 0, 0.2, 1)",
|
|
25
|
+
/** Starts slowly and leaves quickly; reads as an element departing the screen. Suits exits. */
|
|
26
|
+
accelerate: "cubic-bezier(0.4, 0, 1, 1)",
|
|
27
|
+
/** Constant rate from start to end; matches the platform's own `linear` keyword. */
|
|
28
|
+
linear: "linear",
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Named `transition-duration` steps, in milliseconds, ordered from the
|
|
32
|
+
* snappiest anchored surface to the largest edge-docked one. Pass one as an
|
|
33
|
+
* animation factory's `duration` option so every overlay shares one rhythm.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* fade({ duration: durations.fast });
|
|
37
|
+
*/
|
|
38
|
+
export const durations = {
|
|
39
|
+
/** Small surfaces anchored to a trigger: Tooltip, HoverCard, Menu. */
|
|
40
|
+
fast: 150,
|
|
41
|
+
/** The default for most overlays: Popover, Dialog, Toast. */
|
|
42
|
+
normal: 200,
|
|
43
|
+
/** Larger surfaces that cover more of the viewport: Sheet, Drawer. */
|
|
44
|
+
slow: 300,
|
|
45
|
+
/** The largest surfaces, or a transition carrying secondary motion alongside the primary one. */
|
|
46
|
+
slower: 400,
|
|
47
|
+
};
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The core CSS-only enter/exit transition system: the `enterExit()` composer
|
|
3
|
+
* and the `fade()`/`zoom()`/`slide()` presets built on top of it. Every
|
|
4
|
+
* factory returns a `css()`-compatible style mixin driven entirely by
|
|
5
|
+
* platform state, leaving the whole animation to the browser.
|
|
6
|
+
*
|
|
7
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
8
|
+
* @copyright Sergio Xalambrí 2026
|
|
9
|
+
*/
|
|
10
|
+
import type { CSSMixinDescriptor } from "remix/ui";
|
|
11
|
+
/**
|
|
12
|
+
* Options accepted by {@link enterExit}.
|
|
13
|
+
*/
|
|
14
|
+
export declare namespace EnterExit {
|
|
15
|
+
/**
|
|
16
|
+
* Every field is the host's closed/exit-state value for one CSS property;
|
|
17
|
+
* the entered state is always that property's reset (`1` for opacity,
|
|
18
|
+
* `none` for `scale`/`translate`). Omitted fields leave their property as is.
|
|
19
|
+
*/
|
|
20
|
+
interface Options {
|
|
21
|
+
/** Exit-state `opacity`, 0 to 1. */
|
|
22
|
+
opacity?: number;
|
|
23
|
+
/** Exit-state `scale` factor, e.g. `0.95`. */
|
|
24
|
+
scale?: number;
|
|
25
|
+
/** Exit-state `translate` value, e.g. `"0 0.5rem"`. */
|
|
26
|
+
translate?: string;
|
|
27
|
+
/** Transition duration in milliseconds. Defaults to `durations.normal`. */
|
|
28
|
+
duration?: number;
|
|
29
|
+
/** A `transition-timing-function` value. Defaults to `easings.standard`. */
|
|
30
|
+
easing?: string;
|
|
31
|
+
/**
|
|
32
|
+
* A selector fragment relative to the host (e.g. `"[data-visible]"`)
|
|
33
|
+
* marking the entered state, replacing the `[open]`/`:popover-open`
|
|
34
|
+
* default for hosts that carry their own entered-state attribute.
|
|
35
|
+
*/
|
|
36
|
+
when?: string;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Composes a CSS-only enter/exit transition mixin whose `@starting-style`
|
|
41
|
+
* block animates the first entered paint from the exit values. Owns the
|
|
42
|
+
* host's `transition`, so apply exactly one animation factory per host.
|
|
43
|
+
*
|
|
44
|
+
* @param options Which axes to animate, the timing, and the entered-state selector.
|
|
45
|
+
* @returns A `css()` mixin ready for a host element's `mix` prop.
|
|
46
|
+
* @example
|
|
47
|
+
* <div id="filters" popover="auto" mix={enterExit({ opacity: 0, scale: 0.95, duration: 150 })}>
|
|
48
|
+
* ...
|
|
49
|
+
* </div>;
|
|
50
|
+
* @example
|
|
51
|
+
* <div data-visible mix={enterExit({ opacity: 0, when: "[data-visible]" })}>...</div>;
|
|
52
|
+
*/
|
|
53
|
+
export declare function enterExit(options?: EnterExit.Options): CSSMixinDescriptor;
|
|
54
|
+
/**
|
|
55
|
+
* Options accepted by {@link fade}.
|
|
56
|
+
*/
|
|
57
|
+
export declare namespace Fade {
|
|
58
|
+
interface Options {
|
|
59
|
+
/** Exit-state opacity (0 to 1). Defaults to `0` — fully transparent when closed. */
|
|
60
|
+
opacity?: number;
|
|
61
|
+
/** Transition duration in milliseconds. Defaults to `durations.normal`. */
|
|
62
|
+
duration?: number;
|
|
63
|
+
/** A `transition-timing-function` value. Defaults to `easings.standard`. */
|
|
64
|
+
easing?: string;
|
|
65
|
+
/** A selector fragment overriding the default `[open]`/`:popover-open` entered state. */
|
|
66
|
+
when?: string;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* An opacity-only enter/exit transition: sugar over {@link enterExit} for a
|
|
71
|
+
* surface that fades in place.
|
|
72
|
+
*
|
|
73
|
+
* @param options Exit-state opacity, timing, and entered-state selector.
|
|
74
|
+
* @returns A `css()` mixin ready for a host element's `mix` prop.
|
|
75
|
+
* @example
|
|
76
|
+
* <div id="tooltip-1" popover="hint" mix={fade({ duration: durations.fast })}>
|
|
77
|
+
* Copied!
|
|
78
|
+
* </div>;
|
|
79
|
+
*/
|
|
80
|
+
export declare function fade(options?: Fade.Options): CSSMixinDescriptor;
|
|
81
|
+
/**
|
|
82
|
+
* Options accepted by {@link zoom}.
|
|
83
|
+
*/
|
|
84
|
+
export declare namespace Zoom {
|
|
85
|
+
interface Options {
|
|
86
|
+
/** Exit-state opacity (0 to 1). Defaults to `0`. */
|
|
87
|
+
opacity?: number;
|
|
88
|
+
/** Exit-state scale factor (e.g. `0.95`). Defaults to `0.95`. */
|
|
89
|
+
scale?: number;
|
|
90
|
+
/** Transition duration in milliseconds. Defaults to `durations.normal`. */
|
|
91
|
+
duration?: number;
|
|
92
|
+
/** A `transition-timing-function` value. Defaults to `easings.standard`. */
|
|
93
|
+
easing?: string;
|
|
94
|
+
/** A selector fragment overriding the default `[open]`/`:popover-open` entered state. */
|
|
95
|
+
when?: string;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* A fade paired with a scale, entering from slightly smaller than rest and
|
|
100
|
+
* exiting back down to it: sugar over {@link enterExit} for the dialog/menu/
|
|
101
|
+
* popover "pop" that most overlay surfaces in the catalog use by default.
|
|
102
|
+
*
|
|
103
|
+
* @param options Exit-state opacity and scale, timing, and entered-state selector.
|
|
104
|
+
* @returns A `css()` mixin ready for a host element's `mix` prop.
|
|
105
|
+
* @example
|
|
106
|
+
* <dialog id="confirm-delete" mix={zoom({ scale: 0.9, duration: durations.normal })}>
|
|
107
|
+
* ...
|
|
108
|
+
* </dialog>;
|
|
109
|
+
*/
|
|
110
|
+
export declare function zoom(options?: Zoom.Options): CSSMixinDescriptor;
|
|
111
|
+
/**
|
|
112
|
+
* Options accepted by {@link slide}.
|
|
113
|
+
*/
|
|
114
|
+
export declare namespace Slide {
|
|
115
|
+
/** Which edge the host travels in from (and back out toward on exit). */
|
|
116
|
+
type From = "top" | "right" | "bottom" | "left";
|
|
117
|
+
interface Options {
|
|
118
|
+
from: From;
|
|
119
|
+
/** How far the exit state is offset along that edge. Defaults to `"0.5rem"`. */
|
|
120
|
+
distance?: string;
|
|
121
|
+
/** Exit-state opacity (0 to 1). Defaults to `0`. */
|
|
122
|
+
opacity?: number;
|
|
123
|
+
/** Transition duration in milliseconds. Defaults to `durations.normal`. */
|
|
124
|
+
duration?: number;
|
|
125
|
+
/** A `transition-timing-function` value. Defaults to `easings.standard`. */
|
|
126
|
+
easing?: string;
|
|
127
|
+
/** A selector fragment overriding the default `[open]`/`:popover-open` entered state. */
|
|
128
|
+
when?: string;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* A fade paired with a directional offset, entering from just off one edge
|
|
133
|
+
* of its resting position and exiting back toward it: sugar over
|
|
134
|
+
* {@link enterExit} for Sheet, Drawer, and NavigationMenu-style surfaces.
|
|
135
|
+
*
|
|
136
|
+
* @param options Which edge to travel from, the offset distance, opacity, timing, and entered-state selector.
|
|
137
|
+
* @returns A `css()` mixin ready for a host element's `mix` prop.
|
|
138
|
+
* @example
|
|
139
|
+
* <dialog id="cart-drawer" mix={slide({ from: "right", duration: durations.slow })}>
|
|
140
|
+
* ...
|
|
141
|
+
* </dialog>;
|
|
142
|
+
*/
|
|
143
|
+
export declare function slide(options: Slide.Options): CSSMixinDescriptor;
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { css } from "remix/ui";
|
|
2
|
+
import { durations, easings } from "./tokens.js";
|
|
3
|
+
const RESET_TRANSFORM = "none";
|
|
4
|
+
const DEFAULT_DURATION_MS = durations.normal;
|
|
5
|
+
const DEFAULT_EASING = easings.standard;
|
|
6
|
+
/**
|
|
7
|
+
* Default entered-state selector: matches the `open` attribute shared by
|
|
8
|
+
* `<dialog open>` and `<details open>`, and the `:popover-open` pseudo-class
|
|
9
|
+
* carried by elements with the `popover` attribute while shown.
|
|
10
|
+
*/
|
|
11
|
+
const DEFAULT_ENTERED_SELECTOR = "&[open], &:popover-open";
|
|
12
|
+
/**
|
|
13
|
+
* Composes a CSS-only enter/exit transition mixin whose `@starting-style`
|
|
14
|
+
* block animates the first entered paint from the exit values. Owns the
|
|
15
|
+
* host's `transition`, so apply exactly one animation factory per host.
|
|
16
|
+
*
|
|
17
|
+
* @param options Which axes to animate, the timing, and the entered-state selector.
|
|
18
|
+
* @returns A `css()` mixin ready for a host element's `mix` prop.
|
|
19
|
+
* @example
|
|
20
|
+
* <div id="filters" popover="auto" mix={enterExit({ opacity: 0, scale: 0.95, duration: 150 })}>
|
|
21
|
+
* ...
|
|
22
|
+
* </div>;
|
|
23
|
+
* @example
|
|
24
|
+
* <div data-visible mix={enterExit({ opacity: 0, when: "[data-visible]" })}>...</div>;
|
|
25
|
+
*/
|
|
26
|
+
export function enterExit(options = {}) {
|
|
27
|
+
let duration = options.duration ?? DEFAULT_DURATION_MS;
|
|
28
|
+
let easing = options.easing ?? DEFAULT_EASING;
|
|
29
|
+
let entered = options.when ? `&${options.when}` : DEFAULT_ENTERED_SELECTOR;
|
|
30
|
+
let transitionProperties = [];
|
|
31
|
+
let exitState = {};
|
|
32
|
+
let enteredState = {};
|
|
33
|
+
let reducedMotion = {};
|
|
34
|
+
if (options.opacity !== undefined) {
|
|
35
|
+
transitionProperties.push("opacity");
|
|
36
|
+
exitState.opacity = options.opacity;
|
|
37
|
+
enteredState.opacity = 1;
|
|
38
|
+
}
|
|
39
|
+
if (options.scale !== undefined) {
|
|
40
|
+
transitionProperties.push("scale");
|
|
41
|
+
exitState.scale = String(options.scale);
|
|
42
|
+
enteredState.scale = RESET_TRANSFORM;
|
|
43
|
+
reducedMotion.scale = RESET_TRANSFORM;
|
|
44
|
+
}
|
|
45
|
+
if (options.translate !== undefined) {
|
|
46
|
+
transitionProperties.push("translate");
|
|
47
|
+
exitState.translate = options.translate;
|
|
48
|
+
enteredState.translate = RESET_TRANSFORM;
|
|
49
|
+
reducedMotion.translate = RESET_TRANSFORM;
|
|
50
|
+
}
|
|
51
|
+
transitionProperties.push("display", "overlay");
|
|
52
|
+
let startingStyle = {};
|
|
53
|
+
startingStyle[entered] = exitState;
|
|
54
|
+
reducedMotion.transitionProperty = transitionProperties
|
|
55
|
+
.filter((property) => property !== "scale" && property !== "translate")
|
|
56
|
+
.join(", ");
|
|
57
|
+
let output = Object.assign({}, exitState, {
|
|
58
|
+
transitionProperty: transitionProperties.join(", "),
|
|
59
|
+
transitionDuration: `${duration}ms`,
|
|
60
|
+
transitionTimingFunction: easing,
|
|
61
|
+
transitionBehavior: "allow-discrete",
|
|
62
|
+
"@starting-style": startingStyle,
|
|
63
|
+
"@media (prefers-reduced-motion: reduce)": reducedMotion,
|
|
64
|
+
});
|
|
65
|
+
output[entered] = enteredState;
|
|
66
|
+
return css(output);
|
|
67
|
+
}
|
|
68
|
+
const DEFAULT_FADE_OPACITY = 0;
|
|
69
|
+
/**
|
|
70
|
+
* An opacity-only enter/exit transition: sugar over {@link enterExit} for a
|
|
71
|
+
* surface that fades in place.
|
|
72
|
+
*
|
|
73
|
+
* @param options Exit-state opacity, timing, and entered-state selector.
|
|
74
|
+
* @returns A `css()` mixin ready for a host element's `mix` prop.
|
|
75
|
+
* @example
|
|
76
|
+
* <div id="tooltip-1" popover="hint" mix={fade({ duration: durations.fast })}>
|
|
77
|
+
* Copied!
|
|
78
|
+
* </div>;
|
|
79
|
+
*/
|
|
80
|
+
export function fade(options = {}) {
|
|
81
|
+
return enterExit({
|
|
82
|
+
opacity: options.opacity ?? DEFAULT_FADE_OPACITY,
|
|
83
|
+
duration: options.duration,
|
|
84
|
+
easing: options.easing,
|
|
85
|
+
when: options.when,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
const DEFAULT_ZOOM_OPACITY = 0;
|
|
89
|
+
const DEFAULT_ZOOM_SCALE = 0.95;
|
|
90
|
+
/**
|
|
91
|
+
* A fade paired with a scale, entering from slightly smaller than rest and
|
|
92
|
+
* exiting back down to it: sugar over {@link enterExit} for the dialog/menu/
|
|
93
|
+
* popover "pop" that most overlay surfaces in the catalog use by default.
|
|
94
|
+
*
|
|
95
|
+
* @param options Exit-state opacity and scale, timing, and entered-state selector.
|
|
96
|
+
* @returns A `css()` mixin ready for a host element's `mix` prop.
|
|
97
|
+
* @example
|
|
98
|
+
* <dialog id="confirm-delete" mix={zoom({ scale: 0.9, duration: durations.normal })}>
|
|
99
|
+
* ...
|
|
100
|
+
* </dialog>;
|
|
101
|
+
*/
|
|
102
|
+
export function zoom(options = {}) {
|
|
103
|
+
return enterExit({
|
|
104
|
+
opacity: options.opacity ?? DEFAULT_ZOOM_OPACITY,
|
|
105
|
+
scale: options.scale ?? DEFAULT_ZOOM_SCALE,
|
|
106
|
+
duration: options.duration,
|
|
107
|
+
easing: options.easing,
|
|
108
|
+
when: options.when,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
const DEFAULT_SLIDE_OPACITY = 0;
|
|
112
|
+
const DEFAULT_SLIDE_DISTANCE = "0.5rem";
|
|
113
|
+
/** Builds the exit-state `translate` value that offsets the host toward the given edge. */
|
|
114
|
+
function offsetFor(from, distance) {
|
|
115
|
+
switch (from) {
|
|
116
|
+
case "top":
|
|
117
|
+
return `0 -${distance}`;
|
|
118
|
+
case "bottom":
|
|
119
|
+
return `0 ${distance}`;
|
|
120
|
+
case "left":
|
|
121
|
+
return `-${distance} 0`;
|
|
122
|
+
case "right":
|
|
123
|
+
return `${distance} 0`;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* A fade paired with a directional offset, entering from just off one edge
|
|
128
|
+
* of its resting position and exiting back toward it: sugar over
|
|
129
|
+
* {@link enterExit} for Sheet, Drawer, and NavigationMenu-style surfaces.
|
|
130
|
+
*
|
|
131
|
+
* @param options Which edge to travel from, the offset distance, opacity, timing, and entered-state selector.
|
|
132
|
+
* @returns A `css()` mixin ready for a host element's `mix` prop.
|
|
133
|
+
* @example
|
|
134
|
+
* <dialog id="cart-drawer" mix={slide({ from: "right", duration: durations.slow })}>
|
|
135
|
+
* ...
|
|
136
|
+
* </dialog>;
|
|
137
|
+
*/
|
|
138
|
+
export function slide(options) {
|
|
139
|
+
let { from, distance, opacity, duration, easing, when } = options;
|
|
140
|
+
return enterExit({
|
|
141
|
+
opacity: opacity ?? DEFAULT_SLIDE_OPACITY,
|
|
142
|
+
translate: offsetFor(from, distance ?? DEFAULT_SLIDE_DISTANCE),
|
|
143
|
+
duration,
|
|
144
|
+
easing,
|
|
145
|
+
when,
|
|
146
|
+
});
|
|
147
|
+
}
|