shelving 1.319.1 → 1.320.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/docs/llms-full.txt +123 -8
  2. package/docs/ui/FADE_TRANSITION_CLASS.md +9 -0
  3. package/docs/ui/FadeTransition.md +13 -0
  4. package/docs/ui/HorizontalTransition.md +20 -4
  5. package/docs/ui/SLIDE_DOWN_TRANSITION_CLASS.md +9 -0
  6. package/docs/ui/SLIDE_LEFT_TRANSITION_CLASS.md +9 -0
  7. package/docs/ui/SLIDE_RIGHT_TRANSITION_CLASS.md +9 -0
  8. package/docs/ui/SLIDE_UP_TRANSITION_CLASS.md +9 -0
  9. package/docs/ui/VerticalTransition.md +20 -4
  10. package/docs/ui.md +5 -0
  11. package/package.json +1 -1
  12. package/ui/dialog/Dialog.d.ts +0 -1
  13. package/ui/dialog/Dialog.js +2 -2
  14. package/ui/dialog/Dialog.tsx +2 -2
  15. package/ui/notice/NoticesTransition.module.css +1 -1
  16. package/ui/transition/FadeTransition.d.ts +9 -1
  17. package/ui/transition/FadeTransition.js +12 -2
  18. package/ui/transition/FadeTransition.md +13 -0
  19. package/ui/transition/{FadeTransition.css → FadeTransition.module.css} +9 -2
  20. package/ui/transition/FadeTransition.tsx +13 -2
  21. package/ui/transition/HorizontalTransition.d.ts +18 -1
  22. package/ui/transition/HorizontalTransition.js +21 -2
  23. package/ui/transition/HorizontalTransition.md +20 -4
  24. package/ui/transition/{HorizontalTransition.css → HorizontalTransition.module.css} +17 -5
  25. package/ui/transition/HorizontalTransition.tsx +30 -2
  26. package/ui/transition/VerticalTransition.d.ts +18 -1
  27. package/ui/transition/VerticalTransition.js +21 -2
  28. package/ui/transition/VerticalTransition.md +20 -4
  29. package/ui/transition/{VerticalTransition.css → VerticalTransition.module.css} +17 -5
  30. package/ui/transition/VerticalTransition.tsx +25 -2
@@ -20537,6 +20537,11 @@ The components below are listed in the index following this page; this is the sh
20537
20537
  - [RouteContext](ui/RouteContext.md): React context holding the RouteState of the current page, provided by <Router> and <RouteCache>.
20538
20538
  - [STATUSES](ui/STATUSES.md): Tuple of the status names selectable via the status variant prop.
20539
20539
  - [TINT_CLASS](ui/TINT_CLASS.md): CSS class that (re)calculates the full ladder of tint shades from the current global tint colour.
20540
+ - [FADE_TRANSITION_CLASS](ui/FADE_TRANSITION_CLASS.md): View transition class that fades content in and out.
20541
+ - [SLIDE_RIGHT_TRANSITION_CLASS](ui/SLIDE_RIGHT_TRANSITION_CLASS.md): View transition class that slides content right: the new content comes in from the right and the old content leaves to the left.
20542
+ - [SLIDE_LEFT_TRANSITION_CLASS](ui/SLIDE_LEFT_TRANSITION_CLASS.md): View transition class that slides content left: the new content comes in from the left and the old content leaves to the right.
20543
+ - [SLIDE_DOWN_TRANSITION_CLASS](ui/SLIDE_DOWN_TRANSITION_CLASS.md): View transition class that slides content down: the new content comes in from the top and the old content leaves to the bottom.
20544
+ - [SLIDE_UP_TRANSITION_CLASS](ui/SLIDE_UP_TRANSITION_CLASS.md): View transition class that slides content up: the new content comes in from the bottom and the old content leaves to the top.
20540
20545
  - [TreeContext](ui/TreeContext.md): React context holding a flattened key → element map of the surrounding tree(s).
20541
20546
  - [TREE_CODE_RULE](ui/TREE_CODE_RULE.md): Markup rule that renders an inline code span as a tree-resolved <TreeLink> instead of a plain <code>.
20542
20547
  - [TREE_MARKUP_RULES](ui/TREE_MARKUP_RULES.md): Default markup rules with the inline-code rule swapped for TREE_CODE_RULE — every backtick span auto-links to its documented token.
@@ -35529,6 +35534,19 @@ CollapseTransition(props: CollapseTransitionProps): ReactElement
35529
35534
  | `ReactElement` | |
35530
35535
 
35531
35536
 
35537
+ ---
35538
+
35539
+ # FADE_TRANSITION_CLASS
35540
+
35541
+ - Kind: constant
35542
+ - Import: `import { FADE_TRANSITION_CLASS } from "shelving/ui";`
35543
+
35544
+ View transition class that fades content in and out.
35545
+
35546
+ - Pass it to React's `<ViewTransition>` (for example `enter` or `exit`) to use this animation without the component.
35547
+ - Also adds the plain global `fade` class, so app CSS can target it with `::view-transition-group(.fade)`.
35548
+
35549
+
35532
35550
  ---
35533
35551
 
35534
35552
  # FadeTransitionProps
@@ -35577,6 +35595,19 @@ function Panel({ visible }: { visible: boolean }) {
35577
35595
  }
35578
35596
  ```
35579
35597
 
35598
+ ## Use the class without the component
35599
+
35600
+ The CSS is a CSS module, so its class names are hashed. To use the same animation on your own `<ViewTransition>`, import `FADE_TRANSITION_CLASS`. Each one also holds a plain global class name, so your CSS can still target it.
35601
+
35602
+ ```tsx
35603
+ import { ViewTransition } from "react";
35604
+ import { FADE_TRANSITION_CLASS } from "shelving/ui";
35605
+
35606
+ <ViewTransition enter={FADE_TRANSITION_CLASS} exit={FADE_TRANSITION_CLASS}>
35607
+ <div className="panel">…</div>
35608
+ </ViewTransition>
35609
+ ```
35610
+
35580
35611
  ## Styling
35581
35612
 
35582
35613
  | Variable | Styles | Default |
@@ -35605,6 +35636,32 @@ FadeTransition(props: FadeTransitionProps): ReactElement
35605
35636
  | `ReactElement` | |
35606
35637
 
35607
35638
 
35639
+ ---
35640
+
35641
+ # SLIDE_RIGHT_TRANSITION_CLASS
35642
+
35643
+ - Kind: constant
35644
+ - Import: `import { SLIDE_RIGHT_TRANSITION_CLASS } from "shelving/ui";`
35645
+
35646
+ View transition class that slides content right: the new content comes in from the right and the old content leaves to the left.
35647
+
35648
+ - Pass it to React's `<ViewTransition>` (for example `enter` or `exit`) to use this animation without the component.
35649
+ - Also adds the plain global `slide-right` class, so app CSS can target it with `::view-transition-group(.slide-right)`.
35650
+
35651
+
35652
+ ---
35653
+
35654
+ # SLIDE_LEFT_TRANSITION_CLASS
35655
+
35656
+ - Kind: constant
35657
+ - Import: `import { SLIDE_LEFT_TRANSITION_CLASS } from "shelving/ui";`
35658
+
35659
+ View transition class that slides content left: the new content comes in from the left and the old content leaves to the right.
35660
+
35661
+ - Pass it to React's `<ViewTransition>` (for example `enter` or `exit`) to use this animation without the component.
35662
+ - Also adds the plain global `slide-left` class, so app CSS can target it with `::view-transition-group(.slide-left)`.
35663
+
35664
+
35608
35665
  ---
35609
35666
 
35610
35667
  # HorizontalTransitionProps
@@ -35640,12 +35697,15 @@ A direction-aware `<Transition>` preset that slides its children horizontally
35640
35697
  - Pass `overlay` to raise the transition group above surrounding content during the animation (`z-index: 100`).
35641
35698
  - The old and new content slide a full width apart, so they sit edge to edge and never overlap.
35642
35699
  - The slide is clipped to the element's own box (`overflow: clip` on the group), so it does not paint over the content around it.
35643
- - During the slide, the snapshots paint above fixed elements such as a bottom bar. To keep a fixed element on top, give it its own `view-transition-name` and put the slide groups below it:
35700
+ - During the slide, the snapshots paint above fixed elements such as a bottom bar. To keep a fixed element on top, give it its own `view-transition-name` and raise its group:
35644
35701
 
35645
35702
  ```css
35646
- ::view-transition-group(.slide-right),
35647
- ::view-transition-group(.slide-left) {
35648
- z-index: -1;
35703
+ .bottom-bar {
35704
+ view-transition-name: bottom-bar;
35705
+ }
35706
+
35707
+ ::view-transition-group(bottom-bar) {
35708
+ z-index: 1;
35649
35709
  }
35650
35710
  ```
35651
35711
 
@@ -35664,6 +35724,19 @@ import { HorizontalTransition, Navigation, Router } from "shelving/ui";
35664
35724
  </Navigation>
35665
35725
  ```
35666
35726
 
35727
+ ## Use the class without the component
35728
+
35729
+ The CSS is a CSS module, so its class names are hashed. To use the same animation on your own `<ViewTransition>`, import `SLIDE_RIGHT_TRANSITION_CLASS` and `SLIDE_LEFT_TRANSITION_CLASS`. Each one also holds a plain global class name, so your CSS can still target it.
35730
+
35731
+ ```tsx
35732
+ import { ViewTransition } from "react";
35733
+ import { SLIDE_RIGHT_TRANSITION_CLASS } from "shelving/ui";
35734
+
35735
+ <ViewTransition enter={SLIDE_RIGHT_TRANSITION_CLASS} exit={SLIDE_RIGHT_TRANSITION_CLASS}>
35736
+ <div className="panel">…</div>
35737
+ </ViewTransition>
35738
+ ```
35739
+
35667
35740
  ## Styling
35668
35741
 
35669
35742
  | Variable | Styles | Default |
@@ -35973,6 +36046,32 @@ setTransitionType("forward")
35973
36046
  ```
35974
36047
 
35975
36048
 
36049
+ ---
36050
+
36051
+ # SLIDE_DOWN_TRANSITION_CLASS
36052
+
36053
+ - Kind: constant
36054
+ - Import: `import { SLIDE_DOWN_TRANSITION_CLASS } from "shelving/ui";`
36055
+
36056
+ View transition class that slides content down: the new content comes in from the top and the old content leaves to the bottom.
36057
+
36058
+ - Pass it to React's `<ViewTransition>` (for example `enter` or `exit`) to use this animation without the component.
36059
+ - Also adds the plain global `slide-down` class, so app CSS can target it with `::view-transition-group(.slide-down)`.
36060
+
36061
+
36062
+ ---
36063
+
36064
+ # SLIDE_UP_TRANSITION_CLASS
36065
+
36066
+ - Kind: constant
36067
+ - Import: `import { SLIDE_UP_TRANSITION_CLASS } from "shelving/ui";`
36068
+
36069
+ View transition class that slides content up: the new content comes in from the bottom and the old content leaves to the top.
36070
+
36071
+ - Pass it to React's `<ViewTransition>` (for example `enter` or `exit`) to use this animation without the component.
36072
+ - Also adds the plain global `slide-up` class, so app CSS can target it with `::view-transition-group(.slide-up)`.
36073
+
36074
+
35976
36075
  ---
35977
36076
 
35978
36077
  # VerticalTransitionProps
@@ -36008,12 +36107,15 @@ A direction-aware `<Transition>` preset that slides its children vertically —
36008
36107
  - Pass `overlay` to raise the transition group above surrounding content during the animation (`z-index: 100`).
36009
36108
  - The old and new content slide a full height apart, so they sit edge to edge and never overlap.
36010
36109
  - The slide is clipped to the element's own box (`overflow: clip` on the group), so it does not paint over the content around it.
36011
- - During the slide, the snapshots paint above fixed elements such as a bottom bar. To keep a fixed element on top, give it its own `view-transition-name` and put the slide groups below it:
36110
+ - During the slide, the snapshots paint above fixed elements such as a bottom bar. To keep a fixed element on top, give it its own `view-transition-name` and raise its group:
36012
36111
 
36013
36112
  ```css
36014
- ::view-transition-group(.slide-up),
36015
- ::view-transition-group(.slide-down) {
36016
- z-index: -1;
36113
+ .bottom-bar {
36114
+ view-transition-name: bottom-bar;
36115
+ }
36116
+
36117
+ ::view-transition-group(bottom-bar) {
36118
+ z-index: 1;
36017
36119
  }
36018
36120
  ```
36019
36121
 
@@ -36029,6 +36131,19 @@ import { VerticalTransition } from "shelving/ui";
36029
36131
  </VerticalTransition>
36030
36132
  ```
36031
36133
 
36134
+ ## Use the class without the component
36135
+
36136
+ The CSS is a CSS module, so its class names are hashed. To use the same animation on your own `<ViewTransition>`, import `SLIDE_DOWN_TRANSITION_CLASS` and `SLIDE_UP_TRANSITION_CLASS`. Each one also holds a plain global class name, so your CSS can still target it.
36137
+
36138
+ ```tsx
36139
+ import { ViewTransition } from "react";
36140
+ import { SLIDE_DOWN_TRANSITION_CLASS } from "shelving/ui";
36141
+
36142
+ <ViewTransition enter={SLIDE_DOWN_TRANSITION_CLASS} exit={SLIDE_DOWN_TRANSITION_CLASS}>
36143
+ <div className="panel">…</div>
36144
+ </ViewTransition>
36145
+ ```
36146
+
36032
36147
  ## Styling
36033
36148
 
36034
36149
  | Variable | Styles | Default |
@@ -0,0 +1,9 @@
1
+ # FADE_TRANSITION_CLASS
2
+
3
+ - Kind: constant
4
+ - Import: `import { FADE_TRANSITION_CLASS } from "shelving/ui";`
5
+
6
+ View transition class that fades content in and out.
7
+
8
+ - Pass it to React's `<ViewTransition>` (for example `enter` or `exit`) to use this animation without the component.
9
+ - Also adds the plain global `fade` class, so app CSS can target it with `::view-transition-group(.fade)`.
@@ -27,6 +27,19 @@ function Panel({ visible }: { visible: boolean }) {
27
27
  }
28
28
  ```
29
29
 
30
+ ## Use the class without the component
31
+
32
+ The CSS is a CSS module, so its class names are hashed. To use the same animation on your own `<ViewTransition>`, import `FADE_TRANSITION_CLASS`. Each one also holds a plain global class name, so your CSS can still target it.
33
+
34
+ ```tsx
35
+ import { ViewTransition } from "react";
36
+ import { FADE_TRANSITION_CLASS } from "shelving/ui";
37
+
38
+ <ViewTransition enter={FADE_TRANSITION_CLASS} exit={FADE_TRANSITION_CLASS}>
39
+ <div className="panel">…</div>
40
+ </ViewTransition>
41
+ ```
42
+
30
43
  ## Styling
31
44
 
32
45
  | Variable | Styles | Default |
@@ -14,12 +14,15 @@ A direction-aware `<Transition>` preset that slides its children horizontally
14
14
  - Pass `overlay` to raise the transition group above surrounding content during the animation (`z-index: 100`).
15
15
  - The old and new content slide a full width apart, so they sit edge to edge and never overlap.
16
16
  - The slide is clipped to the element's own box (`overflow: clip` on the group), so it does not paint over the content around it.
17
- - During the slide, the snapshots paint above fixed elements such as a bottom bar. To keep a fixed element on top, give it its own `view-transition-name` and put the slide groups below it:
17
+ - During the slide, the snapshots paint above fixed elements such as a bottom bar. To keep a fixed element on top, give it its own `view-transition-name` and raise its group:
18
18
 
19
19
  ```css
20
- ::view-transition-group(.slide-right),
21
- ::view-transition-group(.slide-left) {
22
- z-index: -1;
20
+ .bottom-bar {
21
+ view-transition-name: bottom-bar;
22
+ }
23
+
24
+ ::view-transition-group(bottom-bar) {
25
+ z-index: 1;
23
26
  }
24
27
  ```
25
28
 
@@ -38,6 +41,19 @@ import { HorizontalTransition, Navigation, Router } from "shelving/ui";
38
41
  </Navigation>
39
42
  ```
40
43
 
44
+ ## Use the class without the component
45
+
46
+ The CSS is a CSS module, so its class names are hashed. To use the same animation on your own `<ViewTransition>`, import `SLIDE_RIGHT_TRANSITION_CLASS` and `SLIDE_LEFT_TRANSITION_CLASS`. Each one also holds a plain global class name, so your CSS can still target it.
47
+
48
+ ```tsx
49
+ import { ViewTransition } from "react";
50
+ import { SLIDE_RIGHT_TRANSITION_CLASS } from "shelving/ui";
51
+
52
+ <ViewTransition enter={SLIDE_RIGHT_TRANSITION_CLASS} exit={SLIDE_RIGHT_TRANSITION_CLASS}>
53
+ <div className="panel">…</div>
54
+ </ViewTransition>
55
+ ```
56
+
41
57
  ## Styling
42
58
 
43
59
  | Variable | Styles | Default |
@@ -0,0 +1,9 @@
1
+ # SLIDE_DOWN_TRANSITION_CLASS
2
+
3
+ - Kind: constant
4
+ - Import: `import { SLIDE_DOWN_TRANSITION_CLASS } from "shelving/ui";`
5
+
6
+ View transition class that slides content down: the new content comes in from the top and the old content leaves to the bottom.
7
+
8
+ - Pass it to React's `<ViewTransition>` (for example `enter` or `exit`) to use this animation without the component.
9
+ - Also adds the plain global `slide-down` class, so app CSS can target it with `::view-transition-group(.slide-down)`.
@@ -0,0 +1,9 @@
1
+ # SLIDE_LEFT_TRANSITION_CLASS
2
+
3
+ - Kind: constant
4
+ - Import: `import { SLIDE_LEFT_TRANSITION_CLASS } from "shelving/ui";`
5
+
6
+ View transition class that slides content left: the new content comes in from the left and the old content leaves to the right.
7
+
8
+ - Pass it to React's `<ViewTransition>` (for example `enter` or `exit`) to use this animation without the component.
9
+ - Also adds the plain global `slide-left` class, so app CSS can target it with `::view-transition-group(.slide-left)`.
@@ -0,0 +1,9 @@
1
+ # SLIDE_RIGHT_TRANSITION_CLASS
2
+
3
+ - Kind: constant
4
+ - Import: `import { SLIDE_RIGHT_TRANSITION_CLASS } from "shelving/ui";`
5
+
6
+ View transition class that slides content right: the new content comes in from the right and the old content leaves to the left.
7
+
8
+ - Pass it to React's `<ViewTransition>` (for example `enter` or `exit`) to use this animation without the component.
9
+ - Also adds the plain global `slide-right` class, so app CSS can target it with `::view-transition-group(.slide-right)`.
@@ -0,0 +1,9 @@
1
+ # SLIDE_UP_TRANSITION_CLASS
2
+
3
+ - Kind: constant
4
+ - Import: `import { SLIDE_UP_TRANSITION_CLASS } from "shelving/ui";`
5
+
6
+ View transition class that slides content up: the new content comes in from the bottom and the old content leaves to the top.
7
+
8
+ - Pass it to React's `<ViewTransition>` (for example `enter` or `exit`) to use this animation without the component.
9
+ - Also adds the plain global `slide-up` class, so app CSS can target it with `::view-transition-group(.slide-up)`.
@@ -14,12 +14,15 @@ A direction-aware `<Transition>` preset that slides its children vertically —
14
14
  - Pass `overlay` to raise the transition group above surrounding content during the animation (`z-index: 100`).
15
15
  - The old and new content slide a full height apart, so they sit edge to edge and never overlap.
16
16
  - The slide is clipped to the element's own box (`overflow: clip` on the group), so it does not paint over the content around it.
17
- - During the slide, the snapshots paint above fixed elements such as a bottom bar. To keep a fixed element on top, give it its own `view-transition-name` and put the slide groups below it:
17
+ - During the slide, the snapshots paint above fixed elements such as a bottom bar. To keep a fixed element on top, give it its own `view-transition-name` and raise its group:
18
18
 
19
19
  ```css
20
- ::view-transition-group(.slide-up),
21
- ::view-transition-group(.slide-down) {
22
- z-index: -1;
20
+ .bottom-bar {
21
+ view-transition-name: bottom-bar;
22
+ }
23
+
24
+ ::view-transition-group(bottom-bar) {
25
+ z-index: 1;
23
26
  }
24
27
  ```
25
28
 
@@ -35,6 +38,19 @@ import { VerticalTransition } from "shelving/ui";
35
38
  </VerticalTransition>
36
39
  ```
37
40
 
41
+ ## Use the class without the component
42
+
43
+ The CSS is a CSS module, so its class names are hashed. To use the same animation on your own `<ViewTransition>`, import `SLIDE_DOWN_TRANSITION_CLASS` and `SLIDE_UP_TRANSITION_CLASS`. Each one also holds a plain global class name, so your CSS can still target it.
44
+
45
+ ```tsx
46
+ import { ViewTransition } from "react";
47
+ import { SLIDE_DOWN_TRANSITION_CLASS } from "shelving/ui";
48
+
49
+ <ViewTransition enter={SLIDE_DOWN_TRANSITION_CLASS} exit={SLIDE_DOWN_TRANSITION_CLASS}>
50
+ <div className="panel">…</div>
51
+ </ViewTransition>
52
+ ```
53
+
38
54
  ## Styling
39
55
 
40
56
  | Variable | Styles | Default |
package/docs/ui.md CHANGED
@@ -563,6 +563,11 @@ The components below are listed in the index following this page; this is the sh
563
563
  - [RouteContext](ui/RouteContext.md): React context holding the RouteState of the current page, provided by <Router> and <RouteCache>.
564
564
  - [STATUSES](ui/STATUSES.md): Tuple of the status names selectable via the status variant prop.
565
565
  - [TINT_CLASS](ui/TINT_CLASS.md): CSS class that (re)calculates the full ladder of tint shades from the current global tint colour.
566
+ - [FADE_TRANSITION_CLASS](ui/FADE_TRANSITION_CLASS.md): View transition class that fades content in and out.
567
+ - [SLIDE_RIGHT_TRANSITION_CLASS](ui/SLIDE_RIGHT_TRANSITION_CLASS.md): View transition class that slides content right: the new content comes in from the right and the old content leaves to the left.
568
+ - [SLIDE_LEFT_TRANSITION_CLASS](ui/SLIDE_LEFT_TRANSITION_CLASS.md): View transition class that slides content left: the new content comes in from the left and the old content leaves to the right.
569
+ - [SLIDE_DOWN_TRANSITION_CLASS](ui/SLIDE_DOWN_TRANSITION_CLASS.md): View transition class that slides content down: the new content comes in from the top and the old content leaves to the bottom.
570
+ - [SLIDE_UP_TRANSITION_CLASS](ui/SLIDE_UP_TRANSITION_CLASS.md): View transition class that slides content up: the new content comes in from the bottom and the old content leaves to the top.
566
571
  - [TreeContext](ui/TreeContext.md): React context holding a flattened key → element map of the surrounding tree(s).
567
572
  - [TREE_CODE_RULE](ui/TREE_CODE_RULE.md): Markup rule that renders an inline code span as a tree-resolved <TreeLink> instead of a plain <code>.
568
573
  - [TREE_MARKUP_RULES](ui/TREE_MARKUP_RULES.md): Default markup rules with the inline-code rule swapped for TREE_CODE_RULE — every backtick span auto-links to its documented token.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shelving",
3
- "version": "1.319.1",
3
+ "version": "1.320.0",
4
4
  "author": "Dave Houlbrooke <dave@shax.com>",
5
5
  "repository": {
6
6
  "type": "git",
@@ -2,7 +2,6 @@ import { type ReactElement } from "react";
2
2
  import type { Callback } from "../../util/function.js";
3
3
  import { type ButtonVariants } from "../button/Button.js";
4
4
  import type { ClassProps, OptionalChildProps } from "../util/props.js";
5
- import "../transition/FadeTransition.css";
6
5
  /**
7
6
  * Props for `<Dialog>` — optional `children` content and an `onClose` callback.
8
7
  *
@@ -2,8 +2,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { memo, Suspense, ViewTransition } from "react";
3
3
  import { CloseIcon } from "shelving/icon/CloseIcon";
4
4
  import { getButtonClass } from "../button/Button.js";
5
+ import { FADE_TRANSITION_CLASS } from "../transition/FadeTransition.js";
5
6
  import { getClass, getModuleClass } from "../util/css.js";
6
- import "../transition/FadeTransition.css";
7
7
  import styles from "./Dialog.module.css";
8
8
  import modalStyles from "./Modal.module.css";
9
9
  /**
@@ -21,7 +21,7 @@ import modalStyles from "./Modal.module.css";
21
21
  * @see https://shelving.cc/ui/Dialog
22
22
  */
23
23
  export const Dialog = memo(({ children, onClose, ...props }) => {
24
- return (_jsx(Suspense, { fallback: null, children: _jsx(ViewTransition, { default: "none", enter: "fade", exit: "fade", children: _jsxs("dialog", { ref: _showModal, className: getModuleClass(styles, "dialog"), onClick: _closeOnClick, onCancel: e => {
24
+ return (_jsx(Suspense, { fallback: null, children: _jsx(ViewTransition, { default: "none", enter: FADE_TRANSITION_CLASS, exit: FADE_TRANSITION_CLASS, children: _jsxs("dialog", { ref: _showModal, className: getModuleClass(styles, "dialog"), onClick: _closeOnClick, onCancel: e => {
25
25
  // Keep the dialog open until the parent unmounts it. An uncancelable request closes natively and fires `onClose` from the `close` event.
26
26
  if (!onClose || !e.cancelable)
27
27
  return;
@@ -2,9 +2,9 @@ import { type MouseEvent, memo, type ReactElement, Suspense, ViewTransition } fr
2
2
  import { CloseIcon } from "shelving/icon/CloseIcon";
3
3
  import type { Callback } from "../../util/function.js";
4
4
  import { type ButtonVariants, getButtonClass } from "../button/Button.js";
5
+ import { FADE_TRANSITION_CLASS } from "../transition/FadeTransition.js";
5
6
  import { getClass, getModuleClass } from "../util/css.js";
6
7
  import type { ClassProps, OptionalChildProps } from "../util/props.js";
7
- import "../transition/FadeTransition.css";
8
8
  import styles from "./Dialog.module.css";
9
9
  import modalStyles from "./Modal.module.css";
10
10
 
@@ -36,7 +36,7 @@ export const Dialog = memo(({ children, onClose, ...props }: DialogProps) => {
36
36
  return (
37
37
  <Suspense fallback={null}>
38
38
  {/* The transition must wrap the `<dialog>`: React only animates a `<ViewTransition>` that comes before any DOM element in the inserted or deleted tree. Fade only on enter and exit, so an open dialog stays still while another dialog opens or closes. No update transition: the page ignores taps while a view transition runs, so a change inside an open dialog must not start one. */}
39
- <ViewTransition default="none" enter="fade" exit="fade">
39
+ <ViewTransition default="none" enter={FADE_TRANSITION_CLASS} exit={FADE_TRANSITION_CLASS}>
40
40
  {/** biome-ignore lint/a11y/useKeyWithClickEvents: Dialogs also show a close button. */}
41
41
  <dialog
42
42
  ref={_showModal}
@@ -44,7 +44,7 @@
44
44
 
45
45
  /*
46
46
  * A new notice slides in from the side of its corner (or from the edge for a centred list), and a closed notice slides out the same way.
47
- * - `:only-child` stops Safari from also starting the animation on the missing image, which stops it later on the real one (see `FadeTransition.css`).
47
+ * - `:only-child` stops Safari from also starting the animation on the missing image, which stops it later on the real one (see `FadeTransition.module.css`).
48
48
  * - Longhands, not the `animation` shorthand: Bun rewrites `animation-name` to the hashed keyframes name but leaves a shorthand that holds a `var()` untouched.
49
49
  */
50
50
  ::view-transition-new(.notice-left):only-child {
@@ -1,6 +1,14 @@
1
1
  import type { ReactElement } from "react";
2
- import "./FadeTransition.css";
3
2
  import { type TransitionProps } from "./Transition.js";
3
+ /**
4
+ * View transition class that fades content in and out.
5
+ *
6
+ * - Pass it to React's `<ViewTransition>` (for example `enter` or `exit`) to use this animation without the component.
7
+ * - Also adds the plain global `fade` class, so app CSS can target it with `::view-transition-group(.fade)`.
8
+ *
9
+ * @see https://shelving.cc/ui/FADE_TRANSITION_CLASS
10
+ */
11
+ export declare const FADE_TRANSITION_CLASS: string;
4
12
  /**
5
13
  * Props for the `FadeTransition` component — the shared transition variant props.
6
14
  *
@@ -1,6 +1,16 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import "./FadeTransition.css";
2
+ import { getClass, getModuleClass } from "../util/css.js";
3
+ import FADE_TRANSITION_CSS from "./FadeTransition.module.css";
3
4
  import { Transition } from "./Transition.js";
5
+ /**
6
+ * View transition class that fades content in and out.
7
+ *
8
+ * - Pass it to React's `<ViewTransition>` (for example `enter` or `exit`) to use this animation without the component.
9
+ * - Also adds the plain global `fade` class, so app CSS can target it with `::view-transition-group(.fade)`.
10
+ *
11
+ * @see https://shelving.cc/ui/FADE_TRANSITION_CLASS
12
+ */
13
+ export const FADE_TRANSITION_CLASS = getClass("fade", getModuleClass(FADE_TRANSITION_CSS, "fade"));
4
14
  /**
5
15
  * Transition that fades its children in and out by animating their opacity.
6
16
  *
@@ -8,5 +18,5 @@ import { Transition } from "./Transition.js";
8
18
  * @see https://shelving.cc/ui/FadeTransition
9
19
  */
10
20
  export function FadeTransition(props) {
11
- return _jsx(Transition, { default: "fade", ...props });
21
+ return _jsx(Transition, { default: FADE_TRANSITION_CLASS, ...props });
12
22
  }
@@ -22,6 +22,19 @@ function Panel({ visible }: { visible: boolean }) {
22
22
  }
23
23
  ```
24
24
 
25
+ ## Use the class without the component
26
+
27
+ The CSS is a CSS module, so its class names are hashed. To use the same animation on your own `<ViewTransition>`, import `FADE_TRANSITION_CLASS`. Each one also holds a plain global class name, so your CSS can still target it.
28
+
29
+ ```tsx
30
+ import { ViewTransition } from "react";
31
+ import { FADE_TRANSITION_CLASS } from "shelving/ui";
32
+
33
+ <ViewTransition enter={FADE_TRANSITION_CLASS} exit={FADE_TRANSITION_CLASS}>
34
+ <div className="panel">…</div>
35
+ </ViewTransition>
36
+ ```
37
+
25
38
  ## Styling
26
39
 
27
40
  | Variable | Styles | Default |
@@ -21,13 +21,20 @@
21
21
  /*
22
22
  * Enter and exit: an image with no partner fades in or out.
23
23
  * - `:only-child` is necessary. Without it, Safari also starts the animation on the missing image (for example `fade-out` on the old image when the element enters). Then it does not start that animation again on the same image name, so the element does not fade out when it leaves.
24
+ * - Longhands, not the `animation` shorthand: Bun rewrites `animation-name` to the hashed keyframes name but leaves a shorthand that holds a `var()` untouched.
24
25
  */
25
26
  ::view-transition-new(.fade):only-child {
26
- animation: fade-in var(--fade-transition-duration, var(--duration-fast)) ease-in-out both;
27
+ animation-name: fade-in;
28
+ animation-duration: var(--fade-transition-duration, var(--duration-fast));
29
+ animation-timing-function: ease-in-out;
30
+ animation-fill-mode: both;
27
31
  }
28
32
 
29
33
  ::view-transition-old(.fade):only-child {
30
- animation: fade-out var(--fade-transition-duration, var(--duration-fast)) ease-in-out both;
34
+ animation-name: fade-out;
35
+ animation-duration: var(--fade-transition-duration, var(--duration-fast));
36
+ animation-timing-function: ease-in-out;
37
+ animation-fill-mode: both;
31
38
  }
32
39
 
33
40
  /* Update: the old and new images use the browser's own crossfade. Its images take their duration from the group. */
@@ -1,7 +1,18 @@
1
1
  import type { ReactElement } from "react";
2
- import "./FadeTransition.css";
2
+ import { getClass, getModuleClass } from "../util/css.js";
3
+ import FADE_TRANSITION_CSS from "./FadeTransition.module.css";
3
4
  import { Transition, type TransitionProps } from "./Transition.js";
4
5
 
6
+ /**
7
+ * View transition class that fades content in and out.
8
+ *
9
+ * - Pass it to React's `<ViewTransition>` (for example `enter` or `exit`) to use this animation without the component.
10
+ * - Also adds the plain global `fade` class, so app CSS can target it with `::view-transition-group(.fade)`.
11
+ *
12
+ * @see https://shelving.cc/ui/FADE_TRANSITION_CLASS
13
+ */
14
+ export const FADE_TRANSITION_CLASS = getClass("fade", getModuleClass(FADE_TRANSITION_CSS, "fade"));
15
+
5
16
  /**
6
17
  * Props for the `FadeTransition` component — the shared transition variant props.
7
18
  *
@@ -16,5 +27,5 @@ export interface FadeTransitionProps extends TransitionProps {}
16
27
  * @see https://shelving.cc/ui/FadeTransition
17
28
  */
18
29
  export function FadeTransition(props: FadeTransitionProps): ReactElement {
19
- return <Transition default="fade" {...props} />;
30
+ return <Transition default={FADE_TRANSITION_CLASS} {...props} />;
20
31
  }
@@ -1,6 +1,23 @@
1
1
  import type { ReactElement } from "react";
2
- import "./HorizontalTransition.css";
3
2
  import { type TransitionProps } from "./Transition.js";
3
+ /**
4
+ * View transition class that slides content right: the new content comes in from the right and the old content leaves to the left.
5
+ *
6
+ * - Pass it to React's `<ViewTransition>` (for example `enter` or `exit`) to use this animation without the component.
7
+ * - Also adds the plain global `slide-right` class, so app CSS can target it with `::view-transition-group(.slide-right)`.
8
+ *
9
+ * @see https://shelving.cc/ui/SLIDE_RIGHT_TRANSITION_CLASS
10
+ */
11
+ export declare const SLIDE_RIGHT_TRANSITION_CLASS: string;
12
+ /**
13
+ * View transition class that slides content left: the new content comes in from the left and the old content leaves to the right.
14
+ *
15
+ * - Pass it to React's `<ViewTransition>` (for example `enter` or `exit`) to use this animation without the component.
16
+ * - Also adds the plain global `slide-left` class, so app CSS can target it with `::view-transition-group(.slide-left)`.
17
+ *
18
+ * @see https://shelving.cc/ui/SLIDE_LEFT_TRANSITION_CLASS
19
+ */
20
+ export declare const SLIDE_LEFT_TRANSITION_CLASS: string;
4
21
  /**
5
22
  * Props for the `HorizontalTransition` component — the shared transition variant props.
6
23
  *
@@ -1,6 +1,25 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import "./HorizontalTransition.css";
2
+ import { getClass, getModuleClass } from "../util/css.js";
3
+ import HORIZONTAL_TRANSITION_CSS from "./HorizontalTransition.module.css";
3
4
  import { Transition } from "./Transition.js";
5
+ /**
6
+ * View transition class that slides content right: the new content comes in from the right and the old content leaves to the left.
7
+ *
8
+ * - Pass it to React's `<ViewTransition>` (for example `enter` or `exit`) to use this animation without the component.
9
+ * - Also adds the plain global `slide-right` class, so app CSS can target it with `::view-transition-group(.slide-right)`.
10
+ *
11
+ * @see https://shelving.cc/ui/SLIDE_RIGHT_TRANSITION_CLASS
12
+ */
13
+ export const SLIDE_RIGHT_TRANSITION_CLASS = getClass("slide-right", getModuleClass(HORIZONTAL_TRANSITION_CSS, "slide-right"));
14
+ /**
15
+ * View transition class that slides content left: the new content comes in from the left and the old content leaves to the right.
16
+ *
17
+ * - Pass it to React's `<ViewTransition>` (for example `enter` or `exit`) to use this animation without the component.
18
+ * - Also adds the plain global `slide-left` class, so app CSS can target it with `::view-transition-group(.slide-left)`.
19
+ *
20
+ * @see https://shelving.cc/ui/SLIDE_LEFT_TRANSITION_CLASS
21
+ */
22
+ export const SLIDE_LEFT_TRANSITION_CLASS = getClass("slide-left", getModuleClass(HORIZONTAL_TRANSITION_CSS, "slide-left"));
4
23
  /**
5
24
  * Transition that slides its children horizontally — right when moving forward, left when moving back.
6
25
  *
@@ -8,5 +27,5 @@ import { Transition } from "./Transition.js";
8
27
  * @see https://shelving.cc/ui/HorizontalTransition
9
28
  */
10
29
  export function HorizontalTransition(props) {
11
- return _jsx(Transition, { default: "slide-right", forward: "slide-right", back: "slide-left", ...props });
30
+ return (_jsx(Transition, { default: SLIDE_RIGHT_TRANSITION_CLASS, forward: SLIDE_RIGHT_TRANSITION_CLASS, back: SLIDE_LEFT_TRANSITION_CLASS, ...props }));
12
31
  }
@@ -9,12 +9,15 @@ A direction-aware `<Transition>` preset that slides its children horizontally
9
9
  - Pass `overlay` to raise the transition group above surrounding content during the animation (`z-index: 100`).
10
10
  - The old and new content slide a full width apart, so they sit edge to edge and never overlap.
11
11
  - The slide is clipped to the element's own box (`overflow: clip` on the group), so it does not paint over the content around it.
12
- - During the slide, the snapshots paint above fixed elements such as a bottom bar. To keep a fixed element on top, give it its own `view-transition-name` and put the slide groups below it:
12
+ - During the slide, the snapshots paint above fixed elements such as a bottom bar. To keep a fixed element on top, give it its own `view-transition-name` and raise its group:
13
13
 
14
14
  ```css
15
- ::view-transition-group(.slide-right),
16
- ::view-transition-group(.slide-left) {
17
- z-index: -1;
15
+ .bottom-bar {
16
+ view-transition-name: bottom-bar;
17
+ }
18
+
19
+ ::view-transition-group(bottom-bar) {
20
+ z-index: 1;
18
21
  }
19
22
  ```
20
23
 
@@ -33,6 +36,19 @@ import { HorizontalTransition, Navigation, Router } from "shelving/ui";
33
36
  </Navigation>
34
37
  ```
35
38
 
39
+ ## Use the class without the component
40
+
41
+ The CSS is a CSS module, so its class names are hashed. To use the same animation on your own `<ViewTransition>`, import `SLIDE_RIGHT_TRANSITION_CLASS` and `SLIDE_LEFT_TRANSITION_CLASS`. Each one also holds a plain global class name, so your CSS can still target it.
42
+
43
+ ```tsx
44
+ import { ViewTransition } from "react";
45
+ import { SLIDE_RIGHT_TRANSITION_CLASS } from "shelving/ui";
46
+
47
+ <ViewTransition enter={SLIDE_RIGHT_TRANSITION_CLASS} exit={SLIDE_RIGHT_TRANSITION_CLASS}>
48
+ <div className="panel">…</div>
49
+ </ViewTransition>
50
+ ```
51
+
36
52
  ## Styling
37
53
 
38
54
  | Variable | Styles | Default |
@@ -1,7 +1,6 @@
1
1
  @import url("../style/layers.css");
2
2
  @import url("../style/Duration.module.css");
3
3
 
4
- /* Global CSS, not a CSS module yet — see dhoulb/shelving#259. */
5
4
  @layer defaults {
6
5
  :root {
7
6
  /* A percentage is of the snapshot's own size, so the old and new content sit edge to edge and never overlap. */
@@ -64,20 +63,33 @@
64
63
  overflow: clip;
65
64
  }
66
65
 
66
+ /* Longhands, not the `animation` shorthand: Bun rewrites `animation-name` to the hashed keyframes name but leaves a shorthand that holds a `var()` untouched. */
67
67
  ::view-transition-new(.slide-right) {
68
- animation: slide-in-from-right var(--horizontal-transition-duration) ease-in-out both;
68
+ animation-name: slide-in-from-right;
69
+ animation-duration: var(--horizontal-transition-duration);
70
+ animation-timing-function: ease-in-out;
71
+ animation-fill-mode: both;
69
72
  }
70
73
 
71
74
  ::view-transition-old(.slide-right) {
72
- animation: slide-out-to-left var(--horizontal-transition-duration) ease-in-out both;
75
+ animation-name: slide-out-to-left;
76
+ animation-duration: var(--horizontal-transition-duration);
77
+ animation-timing-function: ease-in-out;
78
+ animation-fill-mode: both;
73
79
  }
74
80
 
75
81
  ::view-transition-new(.slide-left) {
76
- animation: slide-in-from-left var(--horizontal-transition-duration) ease-in-out both;
82
+ animation-name: slide-in-from-left;
83
+ animation-duration: var(--horizontal-transition-duration);
84
+ animation-timing-function: ease-in-out;
85
+ animation-fill-mode: both;
77
86
  }
78
87
 
79
88
  ::view-transition-old(.slide-left) {
80
- animation: slide-out-to-right var(--horizontal-transition-duration) ease-in-out both;
89
+ animation-name: slide-out-to-right;
90
+ animation-duration: var(--horizontal-transition-duration);
91
+ animation-timing-function: ease-in-out;
92
+ animation-fill-mode: both;
81
93
  }
82
94
 
83
95
  /* Reduced motion: null the slide distance so the keyframes above degrade to an opacity-only crossfade (reduced-motion-safe), and disable the group's default positional morph. Unlayered so it wins over app-level overrides of the distance hook. */
@@ -1,7 +1,28 @@
1
1
  import type { ReactElement } from "react";
2
- import "./HorizontalTransition.css";
2
+ import { getClass, getModuleClass } from "../util/css.js";
3
+ import HORIZONTAL_TRANSITION_CSS from "./HorizontalTransition.module.css";
3
4
  import { Transition, type TransitionProps } from "./Transition.js";
4
5
 
6
+ /**
7
+ * View transition class that slides content right: the new content comes in from the right and the old content leaves to the left.
8
+ *
9
+ * - Pass it to React's `<ViewTransition>` (for example `enter` or `exit`) to use this animation without the component.
10
+ * - Also adds the plain global `slide-right` class, so app CSS can target it with `::view-transition-group(.slide-right)`.
11
+ *
12
+ * @see https://shelving.cc/ui/SLIDE_RIGHT_TRANSITION_CLASS
13
+ */
14
+ export const SLIDE_RIGHT_TRANSITION_CLASS = getClass("slide-right", getModuleClass(HORIZONTAL_TRANSITION_CSS, "slide-right"));
15
+
16
+ /**
17
+ * View transition class that slides content left: the new content comes in from the left and the old content leaves to the right.
18
+ *
19
+ * - Pass it to React's `<ViewTransition>` (for example `enter` or `exit`) to use this animation without the component.
20
+ * - Also adds the plain global `slide-left` class, so app CSS can target it with `::view-transition-group(.slide-left)`.
21
+ *
22
+ * @see https://shelving.cc/ui/SLIDE_LEFT_TRANSITION_CLASS
23
+ */
24
+ export const SLIDE_LEFT_TRANSITION_CLASS = getClass("slide-left", getModuleClass(HORIZONTAL_TRANSITION_CSS, "slide-left"));
25
+
5
26
  /**
6
27
  * Props for the `HorizontalTransition` component — the shared transition variant props.
7
28
  *
@@ -16,5 +37,12 @@ export interface HorizontalTransitionProps extends TransitionProps {}
16
37
  * @see https://shelving.cc/ui/HorizontalTransition
17
38
  */
18
39
  export function HorizontalTransition(props: HorizontalTransitionProps): ReactElement {
19
- return <Transition default="slide-right" forward="slide-right" back="slide-left" {...props} />;
40
+ return (
41
+ <Transition
42
+ default={SLIDE_RIGHT_TRANSITION_CLASS}
43
+ forward={SLIDE_RIGHT_TRANSITION_CLASS}
44
+ back={SLIDE_LEFT_TRANSITION_CLASS}
45
+ {...props}
46
+ />
47
+ );
20
48
  }
@@ -1,6 +1,23 @@
1
1
  import type { ReactElement } from "react";
2
- import "./VerticalTransition.css";
3
2
  import { type TransitionProps } from "./Transition.js";
3
+ /**
4
+ * View transition class that slides content down: the new content comes in from the top and the old content leaves to the bottom.
5
+ *
6
+ * - Pass it to React's `<ViewTransition>` (for example `enter` or `exit`) to use this animation without the component.
7
+ * - Also adds the plain global `slide-down` class, so app CSS can target it with `::view-transition-group(.slide-down)`.
8
+ *
9
+ * @see https://shelving.cc/ui/SLIDE_DOWN_TRANSITION_CLASS
10
+ */
11
+ export declare const SLIDE_DOWN_TRANSITION_CLASS: string;
12
+ /**
13
+ * View transition class that slides content up: the new content comes in from the bottom and the old content leaves to the top.
14
+ *
15
+ * - Pass it to React's `<ViewTransition>` (for example `enter` or `exit`) to use this animation without the component.
16
+ * - Also adds the plain global `slide-up` class, so app CSS can target it with `::view-transition-group(.slide-up)`.
17
+ *
18
+ * @see https://shelving.cc/ui/SLIDE_UP_TRANSITION_CLASS
19
+ */
20
+ export declare const SLIDE_UP_TRANSITION_CLASS: string;
4
21
  /**
5
22
  * Props for the `VerticalTransition` component — the shared transition variant props.
6
23
  *
@@ -1,6 +1,25 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import "./VerticalTransition.css";
2
+ import { getClass, getModuleClass } from "../util/css.js";
3
3
  import { Transition } from "./Transition.js";
4
+ import VERTICAL_TRANSITION_CSS from "./VerticalTransition.module.css";
5
+ /**
6
+ * View transition class that slides content down: the new content comes in from the top and the old content leaves to the bottom.
7
+ *
8
+ * - Pass it to React's `<ViewTransition>` (for example `enter` or `exit`) to use this animation without the component.
9
+ * - Also adds the plain global `slide-down` class, so app CSS can target it with `::view-transition-group(.slide-down)`.
10
+ *
11
+ * @see https://shelving.cc/ui/SLIDE_DOWN_TRANSITION_CLASS
12
+ */
13
+ export const SLIDE_DOWN_TRANSITION_CLASS = getClass("slide-down", getModuleClass(VERTICAL_TRANSITION_CSS, "slide-down"));
14
+ /**
15
+ * View transition class that slides content up: the new content comes in from the bottom and the old content leaves to the top.
16
+ *
17
+ * - Pass it to React's `<ViewTransition>` (for example `enter` or `exit`) to use this animation without the component.
18
+ * - Also adds the plain global `slide-up` class, so app CSS can target it with `::view-transition-group(.slide-up)`.
19
+ *
20
+ * @see https://shelving.cc/ui/SLIDE_UP_TRANSITION_CLASS
21
+ */
22
+ export const SLIDE_UP_TRANSITION_CLASS = getClass("slide-up", getModuleClass(VERTICAL_TRANSITION_CSS, "slide-up"));
4
23
  /**
5
24
  * Transition that slides its children vertically — down when moving forward, up when moving back.
6
25
  *
@@ -8,5 +27,5 @@ import { Transition } from "./Transition.js";
8
27
  * @see https://shelving.cc/ui/VerticalTransition
9
28
  */
10
29
  export function VerticalTransition(props) {
11
- return _jsx(Transition, { default: "slide-down", forward: "slide-down", back: "slide-up", ...props });
30
+ return (_jsx(Transition, { default: SLIDE_DOWN_TRANSITION_CLASS, forward: SLIDE_DOWN_TRANSITION_CLASS, back: SLIDE_UP_TRANSITION_CLASS, ...props }));
12
31
  }
@@ -9,12 +9,15 @@ A direction-aware `<Transition>` preset that slides its children vertically —
9
9
  - Pass `overlay` to raise the transition group above surrounding content during the animation (`z-index: 100`).
10
10
  - The old and new content slide a full height apart, so they sit edge to edge and never overlap.
11
11
  - The slide is clipped to the element's own box (`overflow: clip` on the group), so it does not paint over the content around it.
12
- - During the slide, the snapshots paint above fixed elements such as a bottom bar. To keep a fixed element on top, give it its own `view-transition-name` and put the slide groups below it:
12
+ - During the slide, the snapshots paint above fixed elements such as a bottom bar. To keep a fixed element on top, give it its own `view-transition-name` and raise its group:
13
13
 
14
14
  ```css
15
- ::view-transition-group(.slide-up),
16
- ::view-transition-group(.slide-down) {
17
- z-index: -1;
15
+ .bottom-bar {
16
+ view-transition-name: bottom-bar;
17
+ }
18
+
19
+ ::view-transition-group(bottom-bar) {
20
+ z-index: 1;
18
21
  }
19
22
  ```
20
23
 
@@ -30,6 +33,19 @@ import { VerticalTransition } from "shelving/ui";
30
33
  </VerticalTransition>
31
34
  ```
32
35
 
36
+ ## Use the class without the component
37
+
38
+ The CSS is a CSS module, so its class names are hashed. To use the same animation on your own `<ViewTransition>`, import `SLIDE_DOWN_TRANSITION_CLASS` and `SLIDE_UP_TRANSITION_CLASS`. Each one also holds a plain global class name, so your CSS can still target it.
39
+
40
+ ```tsx
41
+ import { ViewTransition } from "react";
42
+ import { SLIDE_DOWN_TRANSITION_CLASS } from "shelving/ui";
43
+
44
+ <ViewTransition enter={SLIDE_DOWN_TRANSITION_CLASS} exit={SLIDE_DOWN_TRANSITION_CLASS}>
45
+ <div className="panel">…</div>
46
+ </ViewTransition>
47
+ ```
48
+
33
49
  ## Styling
34
50
 
35
51
  | Variable | Styles | Default |
@@ -1,7 +1,6 @@
1
1
  @import url("../style/layers.css");
2
2
  @import url("../style/Duration.module.css");
3
3
 
4
- /* Global CSS, not a CSS module yet — see dhoulb/shelving#259. */
5
4
  @layer defaults {
6
5
  :root {
7
6
  /* A percentage is of the snapshot's own size, so the old and new content sit edge to edge and never overlap. */
@@ -64,20 +63,33 @@
64
63
  overflow: clip;
65
64
  }
66
65
 
66
+ /* Longhands, not the `animation` shorthand: Bun rewrites `animation-name` to the hashed keyframes name but leaves a shorthand that holds a `var()` untouched. */
67
67
  ::view-transition-new(.slide-up) {
68
- animation: slide-in-from-bottom var(--vertical-transition-duration) ease-in-out both;
68
+ animation-name: slide-in-from-bottom;
69
+ animation-duration: var(--vertical-transition-duration);
70
+ animation-timing-function: ease-in-out;
71
+ animation-fill-mode: both;
69
72
  }
70
73
 
71
74
  ::view-transition-old(.slide-up) {
72
- animation: slide-out-to-top var(--vertical-transition-duration) ease-in-out both;
75
+ animation-name: slide-out-to-top;
76
+ animation-duration: var(--vertical-transition-duration);
77
+ animation-timing-function: ease-in-out;
78
+ animation-fill-mode: both;
73
79
  }
74
80
 
75
81
  ::view-transition-new(.slide-down) {
76
- animation: slide-in-from-top var(--vertical-transition-duration) ease-in-out both;
82
+ animation-name: slide-in-from-top;
83
+ animation-duration: var(--vertical-transition-duration);
84
+ animation-timing-function: ease-in-out;
85
+ animation-fill-mode: both;
77
86
  }
78
87
 
79
88
  ::view-transition-old(.slide-down) {
80
- animation: slide-out-to-bottom var(--vertical-transition-duration) ease-in-out both;
89
+ animation-name: slide-out-to-bottom;
90
+ animation-duration: var(--vertical-transition-duration);
91
+ animation-timing-function: ease-in-out;
92
+ animation-fill-mode: both;
81
93
  }
82
94
 
83
95
  /* Reduced motion: null the slide distance so the keyframes above degrade to an opacity-only crossfade (reduced-motion-safe), and disable the group's default positional morph. Unlayered so it wins over app-level overrides of the distance hook. */
@@ -1,6 +1,27 @@
1
1
  import type { ReactElement } from "react";
2
- import "./VerticalTransition.css";
2
+ import { getClass, getModuleClass } from "../util/css.js";
3
3
  import { Transition, type TransitionProps } from "./Transition.js";
4
+ import VERTICAL_TRANSITION_CSS from "./VerticalTransition.module.css";
5
+
6
+ /**
7
+ * View transition class that slides content down: the new content comes in from the top and the old content leaves to the bottom.
8
+ *
9
+ * - Pass it to React's `<ViewTransition>` (for example `enter` or `exit`) to use this animation without the component.
10
+ * - Also adds the plain global `slide-down` class, so app CSS can target it with `::view-transition-group(.slide-down)`.
11
+ *
12
+ * @see https://shelving.cc/ui/SLIDE_DOWN_TRANSITION_CLASS
13
+ */
14
+ export const SLIDE_DOWN_TRANSITION_CLASS = getClass("slide-down", getModuleClass(VERTICAL_TRANSITION_CSS, "slide-down"));
15
+
16
+ /**
17
+ * View transition class that slides content up: the new content comes in from the bottom and the old content leaves to the top.
18
+ *
19
+ * - Pass it to React's `<ViewTransition>` (for example `enter` or `exit`) to use this animation without the component.
20
+ * - Also adds the plain global `slide-up` class, so app CSS can target it with `::view-transition-group(.slide-up)`.
21
+ *
22
+ * @see https://shelving.cc/ui/SLIDE_UP_TRANSITION_CLASS
23
+ */
24
+ export const SLIDE_UP_TRANSITION_CLASS = getClass("slide-up", getModuleClass(VERTICAL_TRANSITION_CSS, "slide-up"));
4
25
 
5
26
  /**
6
27
  * Props for the `VerticalTransition` component — the shared transition variant props.
@@ -16,5 +37,7 @@ export interface VerticalTransitionProps extends TransitionProps {}
16
37
  * @see https://shelving.cc/ui/VerticalTransition
17
38
  */
18
39
  export function VerticalTransition(props: VerticalTransitionProps): ReactElement {
19
- return <Transition default="slide-down" forward="slide-down" back="slide-up" {...props} />;
40
+ return (
41
+ <Transition default={SLIDE_DOWN_TRANSITION_CLASS} forward={SLIDE_DOWN_TRANSITION_CLASS} back={SLIDE_UP_TRANSITION_CLASS} {...props} />
42
+ );
20
43
  }