shelving 1.301.0 → 1.301.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/package.json +2 -2
- package/ui/notice/Notices.d.ts +0 -1
- package/ui/notice/Notices.js +2 -2
- package/ui/notice/Notices.tsx +6 -2
- package/ui/notice/{NoticesTransition.css → NoticesTransition.module.css} +19 -5
- package/ui/transition/CollapseTransition.d.ts +0 -1
- package/ui/transition/CollapseTransition.js +4 -2
- package/ui/transition/CollapseTransition.md +1 -1
- package/ui/transition/{CollapseTransition.css → CollapseTransition.module.css} +0 -1
- package/ui/transition/CollapseTransition.tsx +5 -2
- package/ui/transition/HorizontalTransition.css +1 -1
- package/ui/transition/Transition.d.ts +1 -2
- package/ui/transition/Transition.js +4 -5
- package/ui/transition/Transition.md +1 -1
- package/ui/transition/Transition.module.css +3 -0
- package/ui/transition/Transition.tsx +4 -5
- package/ui/transition/VerticalTransition.css +1 -1
- package/ui/util/css.test.ts +4 -5
- package/ui/transition/Transition.css +0 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shelving",
|
|
3
|
-
"version": "1.301.
|
|
3
|
+
"version": "1.301.1",
|
|
4
4
|
"author": "Dave Houlbrooke <dave@shax.com>",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"description": "Toolkit for using data in JavaScript.",
|
|
43
43
|
"engineStrict": true,
|
|
44
44
|
"engines": {
|
|
45
|
-
"bun": ">=1.4.
|
|
45
|
+
"bun": ">=1.4.3",
|
|
46
46
|
"node": ">=16.0.0"
|
|
47
47
|
},
|
|
48
48
|
"keywords": [
|
package/ui/notice/Notices.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { type ReactElement } from "react";
|
|
2
2
|
import { type FlexVariants } from "../style/Flex.js";
|
|
3
3
|
import type { ClassProps } from "../util/props.js";
|
|
4
|
-
import "./NoticesTransition.css";
|
|
5
4
|
/**
|
|
6
5
|
* Corner of the screen where `<Notices>` shows the list of notices.
|
|
7
6
|
*
|
package/ui/notice/Notices.js
CHANGED
|
@@ -5,9 +5,9 @@ import { useTransitionValue } from "../transition/useTransitionValue.js";
|
|
|
5
5
|
import { getClass, getModuleClass } from "../util/css.js";
|
|
6
6
|
import { subscribeNotices } from "../util/notice.js";
|
|
7
7
|
import { Notice } from "./Notice.js";
|
|
8
|
-
import "./NoticesTransition.css";
|
|
9
8
|
import NOTICES_CSS from "./Notices.module.css";
|
|
10
9
|
import { NOTICES } from "./NoticesStore.js";
|
|
10
|
+
import NOTICES_TRANSITION_CSS from "./NoticesTransition.module.css";
|
|
11
11
|
const NOTICES_CLASS = getModuleClass(NOTICES_CSS, "notices");
|
|
12
12
|
/**
|
|
13
13
|
* Render the global list of notices and subscribe to incoming `"notice"` events.
|
|
@@ -36,5 +36,5 @@ function NoticeItem({ notice, position }) {
|
|
|
36
36
|
const { children, status } = useTransitionValue(notice);
|
|
37
37
|
// New and closed notices slide from the side of the corner. A notice that changes in place is drawn from the corner itself.
|
|
38
38
|
const side = position.endsWith("left") ? "left" : "right";
|
|
39
|
-
return (_jsx(ViewTransition, { enter: `notice-${side}
|
|
39
|
+
return (_jsx(ViewTransition, { enter: getModuleClass(NOTICES_TRANSITION_CSS, `notice-${side}`), exit: getModuleClass(NOTICES_TRANSITION_CSS, `notice-${side}`), update: getModuleClass(NOTICES_TRANSITION_CSS, `notice-update-${position}`), children: _jsx(Notice, { status: status, children: children }) }));
|
|
40
40
|
}
|
package/ui/notice/Notices.tsx
CHANGED
|
@@ -7,9 +7,9 @@ import { subscribeNotices } from "../util/notice.js";
|
|
|
7
7
|
import type { ClassProps } from "../util/props.js";
|
|
8
8
|
import { Notice } from "./Notice.js";
|
|
9
9
|
import type { NoticeStore } from "./NoticeStore.js";
|
|
10
|
-
import "./NoticesTransition.css";
|
|
11
10
|
import NOTICES_CSS from "./Notices.module.css";
|
|
12
11
|
import { NOTICES } from "./NoticesStore.js";
|
|
12
|
+
import NOTICES_TRANSITION_CSS from "./NoticesTransition.module.css";
|
|
13
13
|
|
|
14
14
|
const NOTICES_CLASS = getModuleClass(NOTICES_CSS, "notices");
|
|
15
15
|
|
|
@@ -68,7 +68,11 @@ function NoticeItem({ notice, position }: { notice: NoticeStore<Status>; positio
|
|
|
68
68
|
// New and closed notices slide from the side of the corner. A notice that changes in place is drawn from the corner itself.
|
|
69
69
|
const side = position.endsWith("left") ? "left" : "right";
|
|
70
70
|
return (
|
|
71
|
-
<ViewTransition
|
|
71
|
+
<ViewTransition
|
|
72
|
+
enter={getModuleClass(NOTICES_TRANSITION_CSS, `notice-${side}`)}
|
|
73
|
+
exit={getModuleClass(NOTICES_TRANSITION_CSS, `notice-${side}`)}
|
|
74
|
+
update={getModuleClass(NOTICES_TRANSITION_CSS, `notice-update-${position}`)}
|
|
75
|
+
>
|
|
72
76
|
<Notice status={status}>{children}</Notice>
|
|
73
77
|
</ViewTransition>
|
|
74
78
|
);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* Global CSS, not a CSS module. Bun hashes a class inside `::view-transition-*()` from the file basename, but hashes the exported names from the file path, so a module-scoped view-transition class can never match the name that JS passes to `view-transition-class`. Keep these names global until Bun fixes this — see dhoulb/shelving#325. */
|
|
2
1
|
@import url("../style/layers.css");
|
|
3
2
|
@import url("../style/Duration.module.css");
|
|
4
3
|
|
|
@@ -32,21 +31,36 @@
|
|
|
32
31
|
/*
|
|
33
32
|
* A new notice slides in from the side of its corner, and a closed notice slides out to that side.
|
|
34
33
|
* - `:only-child` stops Safari from also starting the animation on the missing image, which stops it later on the real one (see `FadeTransition.css`).
|
|
34
|
+
* - Longhands, not the `animation` shorthand: Bun rewrites `animation-name` to the hashed keyframes name but leaves a shorthand that holds a `var()` untouched.
|
|
35
35
|
*/
|
|
36
36
|
::view-transition-new(.notice-left):only-child {
|
|
37
|
-
animation: notice-from-left
|
|
37
|
+
animation-name: notice-from-left;
|
|
38
|
+
animation-duration: var(--notices-transition-duration);
|
|
39
|
+
animation-timing-function: ease-out;
|
|
40
|
+
animation-fill-mode: both;
|
|
38
41
|
}
|
|
39
42
|
|
|
40
43
|
::view-transition-old(.notice-left):only-child {
|
|
41
|
-
animation: notice-from-left
|
|
44
|
+
animation-name: notice-from-left;
|
|
45
|
+
animation-duration: var(--notices-transition-duration);
|
|
46
|
+
animation-timing-function: ease-in;
|
|
47
|
+
animation-direction: reverse;
|
|
48
|
+
animation-fill-mode: both;
|
|
42
49
|
}
|
|
43
50
|
|
|
44
51
|
::view-transition-new(.notice-right):only-child {
|
|
45
|
-
animation: notice-from-right
|
|
52
|
+
animation-name: notice-from-right;
|
|
53
|
+
animation-duration: var(--notices-transition-duration);
|
|
54
|
+
animation-timing-function: ease-out;
|
|
55
|
+
animation-fill-mode: both;
|
|
46
56
|
}
|
|
47
57
|
|
|
48
58
|
::view-transition-old(.notice-right):only-child {
|
|
49
|
-
animation: notice-from-right
|
|
59
|
+
animation-name: notice-from-right;
|
|
60
|
+
animation-duration: var(--notices-transition-duration);
|
|
61
|
+
animation-timing-function: ease-in;
|
|
62
|
+
animation-direction: reverse;
|
|
63
|
+
animation-fill-mode: both;
|
|
50
64
|
}
|
|
51
65
|
|
|
52
66
|
/* The other notices move to their new places (the default group morph). */
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import "
|
|
2
|
+
import { getModuleClass } from "../util/css.js";
|
|
3
|
+
import COLLAPSE_TRANSITION_CSS from "./CollapseTransition.module.css";
|
|
3
4
|
import { Transition } from "./Transition.js";
|
|
5
|
+
const COLLAPSE_TRANSITION_CLASS = getModuleClass(COLLAPSE_TRANSITION_CSS, "collapse");
|
|
4
6
|
/**
|
|
5
7
|
* Transition that collapses its children in and out by animating their size.
|
|
6
8
|
*
|
|
@@ -8,5 +10,5 @@ import { Transition } from "./Transition.js";
|
|
|
8
10
|
* @see https://shelving.cc/ui/CollapseTransition
|
|
9
11
|
*/
|
|
10
12
|
export function CollapseTransition(props) {
|
|
11
|
-
return _jsx(Transition, { default:
|
|
13
|
+
return _jsx(Transition, { default: COLLAPSE_TRANSITION_CLASS, ...props });
|
|
12
14
|
}
|
|
@@ -24,6 +24,6 @@ function Details({ open }: { open: boolean }) {
|
|
|
24
24
|
|
|
25
25
|
## Styling
|
|
26
26
|
|
|
27
|
-
This preset exposes no own `--collapse-transition-*` hooks. Its `CollapseTransition.css` only sets `overflow: hidden` on `::view-transition-image-pair(.collapse)` so the collapsing content is clipped.
|
|
27
|
+
This preset exposes no own `--collapse-transition-*` hooks. Its `CollapseTransition.module.css` only sets `overflow: hidden` on `::view-transition-image-pair(.collapse)` so the collapsing content is clipped.
|
|
28
28
|
|
|
29
29
|
**Global tokens it reads** — none.
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* Global CSS, not a CSS module. Bun hashes a class inside `::view-transition-*()` from the file basename, but hashes the exported names from the file path, so a module-scoped view-transition class can never match the name that JS passes to `view-transition-class`. Keep these names global until Bun fixes this — see dhoulb/shelving#325. */
|
|
2
1
|
::view-transition-image-pair(.collapse) {
|
|
3
2
|
overflow: hidden;
|
|
4
3
|
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import type { ReactElement } from "react";
|
|
2
|
-
import "
|
|
2
|
+
import { getModuleClass } from "../util/css.js";
|
|
3
|
+
import COLLAPSE_TRANSITION_CSS from "./CollapseTransition.module.css";
|
|
3
4
|
import { Transition, type TransitionProps } from "./Transition.js";
|
|
4
5
|
|
|
6
|
+
const COLLAPSE_TRANSITION_CLASS = getModuleClass(COLLAPSE_TRANSITION_CSS, "collapse");
|
|
7
|
+
|
|
5
8
|
/**
|
|
6
9
|
* Props for the `CollapseTransition` component — the shared transition variant props.
|
|
7
10
|
*
|
|
@@ -16,5 +19,5 @@ export interface CollapseTransitionProps extends TransitionProps {}
|
|
|
16
19
|
* @see https://shelving.cc/ui/CollapseTransition
|
|
17
20
|
*/
|
|
18
21
|
export function CollapseTransition(props: CollapseTransitionProps): ReactElement {
|
|
19
|
-
return <Transition default=
|
|
22
|
+
return <Transition default={COLLAPSE_TRANSITION_CLASS} {...props} />;
|
|
20
23
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
@import url("../style/layers.css");
|
|
2
2
|
@import url("../style/Duration.module.css");
|
|
3
3
|
|
|
4
|
-
/* Global CSS, not a CSS module — see
|
|
4
|
+
/* Global CSS, not a CSS module yet — see dhoulb/shelving#259. */
|
|
5
5
|
@layer defaults {
|
|
6
6
|
:root {
|
|
7
7
|
/* A percentage is of the snapshot's own size, so the old and new content sit edge to edge and never overlap. */
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { type ReactElement } from "react";
|
|
2
2
|
import type { ChildProps } from "../util/props.js";
|
|
3
|
-
import "./Transition.css";
|
|
4
3
|
/**
|
|
5
4
|
* Variant props shared by every transition component.
|
|
6
5
|
*
|
|
@@ -28,7 +27,7 @@ export interface TransitionProps extends ChildProps, TransitionVariants {
|
|
|
28
27
|
*
|
|
29
28
|
* - Allows known view transition types in `TransitionClasses` (`default`/`forward`/`back`) to be overridden.
|
|
30
29
|
* - These must correspond to a `::view-transition(.className)` that is set in CSS.
|
|
31
|
-
* - Supports variant classes, e.g. `<Transition overlay>` applies `::view-transition-group(.overlay)` from `Transition.css`.
|
|
30
|
+
* - Supports variant classes, e.g. `<Transition overlay>` applies `::view-transition-group(.overlay)` from `Transition.module.css`.
|
|
32
31
|
*
|
|
33
32
|
* @kind component
|
|
34
33
|
* @returns A `<ViewTransition>` element wrapping the children.
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
/// <reference types="react/canary" />
|
|
3
3
|
import { ViewTransition } from "react";
|
|
4
|
-
import { getClass } from "../util/css.js";
|
|
5
|
-
import "./Transition.css";
|
|
6
|
-
|
|
7
|
-
const TRANSITION_OVERLAY_CLASS = "overlay";
|
|
4
|
+
import { getClass, getModuleClass } from "../util/css.js";
|
|
5
|
+
import TRANSITION_CSS from "./Transition.module.css";
|
|
6
|
+
const TRANSITION_OVERLAY_CLASS = getModuleClass(TRANSITION_CSS, "overlay");
|
|
8
7
|
/**
|
|
9
8
|
* Wrap children in a React View Transition, applying the configured transition classes.
|
|
10
9
|
*
|
|
11
10
|
* - Allows known view transition types in `TransitionClasses` (`default`/`forward`/`back`) to be overridden.
|
|
12
11
|
* - These must correspond to a `::view-transition(.className)` that is set in CSS.
|
|
13
|
-
* - Supports variant classes, e.g. `<Transition overlay>` applies `::view-transition-group(.overlay)` from `Transition.css`.
|
|
12
|
+
* - Supports variant classes, e.g. `<Transition overlay>` applies `::view-transition-group(.overlay)` from `Transition.module.css`.
|
|
14
13
|
*
|
|
15
14
|
* @kind component
|
|
16
15
|
* @returns A `<ViewTransition>` element wrapping the children.
|
|
@@ -5,7 +5,7 @@ The base View Transition wrapper. It wraps its children in React 19's `<ViewTran
|
|
|
5
5
|
**Things to know:**
|
|
6
6
|
|
|
7
7
|
- Set `default` for the base transition; `forward` and `back` default to it and let you pick a direction-aware variant. The class names must correspond to `::view-transition-old(.className)` / `::view-transition-new(.className)` rules in your CSS.
|
|
8
|
-
- Pass `overlay` to raise the transition group above surrounding content during the animation (`z-index: 100`, from `Transition.css`).
|
|
8
|
+
- Pass `overlay` to raise the transition group above surrounding content during the animation (`z-index: 100`, from `Transition.module.css`).
|
|
9
9
|
- Direction is driven by the active view-transition type. `<Navigation>` sets it for each page change (`"forward"` for a link or `NavigationStore.forward()`, `"back"` for the browser back button). For any other change, call `setTransitionType("forward")` (or `"back"`) inside a `startTransition()` callback; the variants read that type to choose the correct slide.
|
|
10
10
|
- React runs a view transition only for a transition update (`startTransition()`, `useDeferredValue()` or a Suspense reveal). A sync update, for example a `useStore()` change, swaps the content with no animation.
|
|
11
11
|
- The preset variants honour `prefers-reduced-motion: reduce` — positional movement (slides, collapse) is removed while opacity-only fades are kept (see each preset's page). Custom transition classes should ship their own `@media (prefers-reduced-motion: reduce)` override; `animation: none` on the `::view-transition-*` pseudo-elements makes the swap an instant cut while the DOM update still happens.
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
/// <reference types="react/canary" />
|
|
2
2
|
import { type ReactElement, ViewTransition } from "react";
|
|
3
|
-
import { getClass } from "../util/css.js";
|
|
3
|
+
import { getClass, getModuleClass } from "../util/css.js";
|
|
4
4
|
import type { ChildProps } from "../util/props.js";
|
|
5
|
-
import "./Transition.css";
|
|
5
|
+
import TRANSITION_CSS from "./Transition.module.css";
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
const TRANSITION_OVERLAY_CLASS = "overlay";
|
|
7
|
+
const TRANSITION_OVERLAY_CLASS = getModuleClass(TRANSITION_CSS, "overlay");
|
|
9
8
|
|
|
10
9
|
/**
|
|
11
10
|
* Variant props shared by every transition component.
|
|
@@ -36,7 +35,7 @@ export interface TransitionProps extends ChildProps, TransitionVariants {
|
|
|
36
35
|
*
|
|
37
36
|
* - Allows known view transition types in `TransitionClasses` (`default`/`forward`/`back`) to be overridden.
|
|
38
37
|
* - These must correspond to a `::view-transition(.className)` that is set in CSS.
|
|
39
|
-
* - Supports variant classes, e.g. `<Transition overlay>` applies `::view-transition-group(.overlay)` from `Transition.css`.
|
|
38
|
+
* - Supports variant classes, e.g. `<Transition overlay>` applies `::view-transition-group(.overlay)` from `Transition.module.css`.
|
|
40
39
|
*
|
|
41
40
|
* @kind component
|
|
42
41
|
* @returns A `<ViewTransition>` element wrapping the children.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
@import url("../style/layers.css");
|
|
2
2
|
@import url("../style/Duration.module.css");
|
|
3
3
|
|
|
4
|
-
/* Global CSS, not a CSS module — see
|
|
4
|
+
/* Global CSS, not a CSS module yet — see dhoulb/shelving#259. */
|
|
5
5
|
@layer defaults {
|
|
6
6
|
:root {
|
|
7
7
|
/* A percentage is of the snapshot's own size, so the old and new content sit edge to edge and never overlap. */
|
package/ui/util/css.test.ts
CHANGED
|
@@ -58,18 +58,17 @@ describe("Bun CSS modules", () => {
|
|
|
58
58
|
expect(css).toContain(`animation-name: ${name};`);
|
|
59
59
|
});
|
|
60
60
|
|
|
61
|
-
// Before Bun 1.4.3, Bun hashed a class inside `::view-transition-*()` from the file basename but hashed exports from the path, so the two never matched
|
|
62
|
-
test("
|
|
61
|
+
// Before Bun 1.4.3, Bun hashed a class inside `::view-transition-*()` from the file basename but hashed exports from the path, so the two never matched (see dhoulb/shelving#325).
|
|
62
|
+
test("exports a view-transition class with the same hash as its selector", async () => {
|
|
63
63
|
const dir = await mkdtemp(join(tmpdir(), "shelving-css-"));
|
|
64
64
|
try {
|
|
65
65
|
const path = join(dir, "sub", "canary.module.css");
|
|
66
|
-
await Bun.write(path, ".plain { color: red; }\n
|
|
66
|
+
await Bun.write(path, ".plain { color: red; }\n::view-transition-group(.vt) { z-index: 1; }\n");
|
|
67
67
|
const { exports, css } = await _bundle(path);
|
|
68
68
|
expect(exports.plain).toBeString();
|
|
69
69
|
expect(exports.vt).toBeString();
|
|
70
70
|
expect(css).toContain(`.${exports.plain}`);
|
|
71
|
-
|
|
72
|
-
else expect(css).not.toContain(`(.${exports.vt})`);
|
|
71
|
+
expect(css).toContain(`(.${exports.vt})`);
|
|
73
72
|
} finally {
|
|
74
73
|
await rm(dir, { recursive: true, force: true });
|
|
75
74
|
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/* Global CSS, not a CSS module. Bun hashes a class inside `::view-transition-*()` from the file basename, but hashes the exported names from the file path, so a module-scoped view-transition class can never match the name that JS passes to `view-transition-class`. Keep these names global until Bun fixes this — see dhoulb/shelving#325. */
|
|
2
|
-
::view-transition-group(.overlay) {
|
|
3
|
-
z-index: 100;
|
|
4
|
-
}
|