shelving 1.295.3 → 1.297.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shelving",
3
- "version": "1.295.3",
3
+ "version": "1.297.0",
4
4
  "author": "Dave Houlbrooke <dave@shax.com>",
5
5
  "repository": {
6
6
  "type": "git",
@@ -71,10 +71,10 @@ function DeleteButton({ onConfirm }: { onConfirm: () => void }) {
71
71
  | `--dialog-padding` | Top and bottom padding around the centred content (one length) | `var(--space-normal)` (16px) |
72
72
  | `--dialog-indent` | Left and right padding around the centred content (one length) | `var(--space-normal)` (16px) |
73
73
  | `--dialog-width` | Width of the centred content, and so of a centred `<Modal>` | `var(--width-narrow)` (36rem) |
74
- | `--dialog-background` | Overlay fill behind the content | `var(--shadow-color)` |
74
+ | `--dialog-background` | Overlay fill behind the content | `var(--color-backdrop)` |
75
75
  | `--dialog-color` | Text colour directly on the overlay | `var(--tint-100)` (white) |
76
76
  | `--dialog-close-offset` | Inset of the close button from the top-right corner | `var(--space-small)` (12px) |
77
77
 
78
78
  The fade uses the `fade` class from `<FadeTransition>`, so `--fade-transition-duration` sets its length. It runs only as the dialog opens and closes; an open dialog stays still while other dialogs open and close.
79
79
 
80
- **Global tokens it reads** — move these to retheme broadly: `--tint-100`, `--width-narrow`, `--space-normal`, `--space-small`, `--shadow-color`, and `--duration-fast` (through `<FadeTransition>`).
80
+ **Global tokens it reads** — move these to retheme broadly: `--tint-100`, `--width-narrow`, `--space-normal`, `--space-small`, `--color-backdrop`, and `--duration-fast` (through `<FadeTransition>`).
@@ -1,7 +1,6 @@
1
1
  @import url("../style/layers.css");
2
2
  @import url("../style/Color.module.css");
3
3
  @import url("../style/Space.module.css");
4
- @import url("../style/Shadow.module.css");
5
4
  @import url("../style/Tint.module.css");
6
5
  @import url("../style/Width.module.css");
7
6
 
@@ -27,7 +26,7 @@
27
26
 
28
27
  /* Style */
29
28
  color: var(--dialog-color, var(--tint-100));
30
- background: var(--dialog-background, var(--shadow-color));
29
+ background: var(--dialog-background, var(--color-backdrop));
31
30
 
32
31
  /* Flex only to centre `.content`, its one in-flow child. */
33
32
  &[open] {
@@ -33,7 +33,7 @@ export interface ModalProps extends ModalVariants, PaddingVariants, IndentVarian
33
33
  * Styled `<aside>` panel for content inside a `<Dialog>`, with dark text on a light surface.
34
34
  *
35
35
  * - Centred by default. It fades in and out with its `<Dialog>`.
36
- * - Has a `--shadow-normal` drop shadow by default. Set `shadow="none"`, `shadow="small"` or `shadow="large"` to change it.
36
+ * - Has a `--shadow-large` drop shadow by default. Set `shadow="none"`, `shadow="small"` or `shadow="normal"` to change it.
37
37
  * - `top`, `right`, `bottom`, or `left` pins it to that edge. It then takes its own layer in the `<Dialog>` view transition, and slides in from that edge and out to it.
38
38
  *
39
39
  * @kind component
@@ -9,7 +9,7 @@ import styles from "./Modal.module.css";
9
9
  * Styled `<aside>` panel for content inside a `<Dialog>`, with dark text on a light surface.
10
10
  *
11
11
  * - Centred by default. It fades in and out with its `<Dialog>`.
12
- * - Has a `--shadow-normal` drop shadow by default. Set `shadow="none"`, `shadow="small"` or `shadow="large"` to change it.
12
+ * - Has a `--shadow-large` drop shadow by default. Set `shadow="none"`, `shadow="small"` or `shadow="normal"` to change it.
13
13
  * - `top`, `right`, `bottom`, or `left` pins it to that edge. It then takes its own layer in the `<Dialog>` view transition, and slides in from that edge and out to it.
14
14
  *
15
15
  * @kind component
@@ -11,7 +11,7 @@ The panel inside a `<Dialog>`. `<Dialog>` dims the page; `Modal` gives the conte
11
11
  - A centred `Modal` fills the width of its `<Dialog>`, so set `--dialog-width` to change it. `--modal-width` sets the width of a `left` or `right` panel, and the maximum width of a `top` or `bottom` panel.
12
12
  - The `padding` variant (for example `padding="large"`) sets the top and bottom padding, and the `indent` variant sets the left and right padding, the same as on `<Panel>`.
13
13
  - The `radius` variant sets the corner radius. On a pinned panel, corners that touch a screen edge stay square.
14
- - It has a `--shadow-normal` drop shadow by default. Set `shadow="none"`, `shadow="small"` or `shadow="large"` to change it, the same as on `<Card>`.
14
+ - It has a `--shadow-large` drop shadow by default. Set `shadow="none"`, `shadow="small"` or `shadow="normal"` to change it, the same as on `<Card>`.
15
15
  - Set `top`, `right`, `bottom`, or `left` to pin the panel to that edge of the screen. A top or bottom panel is full width up to `--modal-width`, and centred on a wider screen. A left or right panel is full height. Use these for mobile menus, bottom sheets, and side menus.
16
16
  - A centred panel fades in and out with its `<Dialog>`. A pinned panel slides in from its edge and out to it, in its own view-transition layer. With reduced motion, a pinned panel fades in place.
17
17
 
@@ -67,8 +67,8 @@ function DeleteButton({ onConfirm }: { onConfirm: () => void }) {
67
67
  ### Shadow
68
68
 
69
69
  ```tsx
70
- <Modal shadow="large">
71
- <p>Raised above the overlay.</p>
70
+ <Modal shadow="small">
71
+ <p>Sits closer to the page.</p>
72
72
  </Modal>
73
73
  ```
74
74
 
@@ -110,6 +110,6 @@ A link click inside a `<Dialog>` closes it, so the menu slides out as the page c
110
110
  | `--modal-color` | Text colour | `var(--tint-00)` |
111
111
  | `--modal-max-height` | Maximum height of a `top` or `bottom` panel (it scrolls past this) | `100%` |
112
112
  | `--modal-transition-duration` | Length of the slide for a pinned panel. Keep it the same as `--fade-transition-duration`, so the panel and the `<Dialog>` overlay finish together | `var(--duration-fast)` (150ms) |
113
- | `--modal-shadow` | Drop shadow (the `shadow` variant wins over it) | `var(--shadow-normal)` |
113
+ | `--modal-shadow` | Drop shadow (the `shadow` variant wins over it) | `var(--shadow-large)` |
114
114
 
115
- **Global tokens it reads** — move these to retheme broadly: the tint ladder `--tint-00` / `--tint-80` / `--tint-100`, plus `--width-narrow`, `--space-normal`, `--radius-normal`, `--shadow-normal`, and `--duration-fast`.
115
+ **Global tokens it reads** — move these to retheme broadly: the tint ladder `--tint-00` / `--tint-80` / `--tint-100`, plus `--width-narrow`, `--space-normal`, `--radius-normal`, `--shadow-large`, and `--duration-fast`.
@@ -21,7 +21,7 @@
21
21
 
22
22
  /* Style */
23
23
  color: var(--modal-color, var(--tint-00));
24
- box-shadow: var(--modal-shadow, var(--shadow-normal));
24
+ box-shadow: var(--modal-shadow, var(--shadow-large));
25
25
 
26
26
  /* Pinned to an edge: fixed to the viewport, flush with the edge, and scrolls when its content is too tall. */
27
27
  &.top,
@@ -44,7 +44,7 @@ export interface ModalProps
44
44
  * Styled `<aside>` panel for content inside a `<Dialog>`, with dark text on a light surface.
45
45
  *
46
46
  * - Centred by default. It fades in and out with its `<Dialog>`.
47
- * - Has a `--shadow-normal` drop shadow by default. Set `shadow="none"`, `shadow="small"` or `shadow="large"` to change it.
47
+ * - Has a `--shadow-large` drop shadow by default. Set `shadow="none"`, `shadow="small"` or `shadow="normal"` to change it.
48
48
  * - `top`, `right`, `bottom`, or `left` pins it to that edge. It then takes its own layer in the `<Dialog>` view transition, and slides in from that edge and out to it.
49
49
  *
50
50
  * @kind component
@@ -44,7 +44,8 @@ Layouts compose naturally as `<Router>` route values — wrap a group of routes
44
44
  | `--sidebar-layout-sidebar-background` | Sidebar column fill | `var(--tint-90)` (one shade darker than the page) |
45
45
  | `--sidebar-layout-sidebar-color` | Sidebar column text colour | `var(--tint-00)` (black) |
46
46
  | `--sidebar-layout-border` | Divider between sidebar and content, e.g. `1px solid var(--tint-80)` | `none` |
47
+ | `--sidebar-layout-shadow` | Drop shadow of the open drawer on a narrow screen | `var(--shadow-large)` |
47
48
 
48
49
  The sidebar and content columns own their own scroll behaviour directly (this layout no longer composes a shared `.layout` class).
49
50
 
50
- **Global tokens it reads** — `--tint-00` / `--tint-90` / `--tint-100`, plus `--space-normal`, `--duration-normal`, and `--color-shadow`.
51
+ **Global tokens it reads** — `--tint-00` / `--tint-90` / `--tint-100`, plus `--space-normal`, `--duration-normal`, `--shadow-large`, and `--color-backdrop`.
@@ -159,7 +159,7 @@
159
159
 
160
160
  .sidebar.open {
161
161
  transform: translateX(0);
162
- box-shadow: 0 0 1.5rem #0006;
162
+ box-shadow: var(--sidebar-layout-shadow, var(--shadow-large));
163
163
  }
164
164
 
165
165
  /* Right variant: dock the drawer to the right edge and slide it in from the right instead. */
@@ -194,7 +194,7 @@
194
194
  border: 0;
195
195
 
196
196
  /* Style */
197
- background: var(--shadow-color);
197
+ background: var(--color-backdrop);
198
198
  cursor: pointer;
199
199
 
200
200
  /* Hidden and non-interactive until open. Transition `visibility` alongside `opacity` so the overlay stays in the a11y tree (and clickable) only while shown, then flips hidden at the end of the fade-out. */
@@ -36,6 +36,7 @@ import { LOADING_NOTICE } from "shelving/ui";
36
36
  | `--notice-color` | Text colour | `var(--tint-50)` |
37
37
  | `--notice-border` | Border shorthand | `var(--notice-stroke) solid var(--tint-80)` |
38
38
  | `--notice-stroke` | Border thickness | `var(--stroke-normal)` (2px) |
39
+ | `--notice-shadow` | Drop shadow, for example `var(--shadow-small)` | `none` |
39
40
  | `--notice-radius` | Corner radius | `var(--radius-xsmall)` |
40
41
  | `--notice-padding` | Inner top and bottom padding (one length) | `var(--space-small)` (12px) |
41
42
  | `--notice-indent` | Inner left and right padding (one length) | `var(--space-small)` (12px) |
@@ -15,6 +15,7 @@
15
15
 
16
16
  /* Style */
17
17
  background: var(--notice-background, var(--tint-90));
18
+ box-shadow: var(--notice-shadow, none);
18
19
  color: var(--notice-color, var(--tint-50));
19
20
 
20
21
  /* Text */
@@ -3,19 +3,31 @@ import { type FlexVariants } from "../style/Flex.js";
3
3
  import type { ClassProps } from "../util/props.js";
4
4
  import "./NoticesTransition.css";
5
5
  /**
6
- * Props for `<Notices>` — flex styling variants for the notices container.
6
+ * Corner of the screen where `<Notices>` shows the list of notices.
7
+ *
8
+ * @see https://shelving.cc/ui/NoticesPosition
9
+ */
10
+ export type NoticesPosition = "top-left" | "top-right" | "bottom-left" | "bottom-right";
11
+ /**
12
+ * Props for `<Notices>` — the corner for the list, and flex styling variants for the notices container.
7
13
  *
8
14
  * @see https://shelving.cc/ui/NoticesProps
9
15
  */
10
16
  export interface NoticesProps extends FlexVariants, ClassProps {
17
+ /**
18
+ * Corner of the screen for the list. New notices slide in from this side.
19
+ * @default "bottom-right"
20
+ */
21
+ position?: NoticesPosition | undefined;
11
22
  }
12
23
  /**
13
24
  * Render the global list of notices and subscribe to incoming `"notice"` events.
14
25
  * - Listens for `"notice"` events on `window` (or that bubble up to `window`) and shows them in the global notice list.
15
26
  * - This is how e.g. `<Button>` and `<FormNotify>` components send notices into the global list.
16
- * - Each notice slides in and out in its own view transition. The other notices move to their new places in the same transition.
27
+ * - Shows the list in the bottom-right corner, or in the corner that `position` sets.
28
+ * - Each notice slides in and out in its own view transition, from the side of its corner. The other notices move to their new places in the same transition.
17
29
  *
18
30
  * @kind component
19
31
  * @see https://shelving.cc/ui/Notices
20
32
  */
21
- export declare function Notices({ className, ...props }: NoticesProps): ReactElement;
33
+ export declare function Notices({ position, className, ...props }: NoticesProps): ReactElement;
@@ -13,24 +13,28 @@ const NOTICES_CLASS = getModuleClass(NOTICES_CSS, "notices");
13
13
  * Render the global list of notices and subscribe to incoming `"notice"` events.
14
14
  * - Listens for `"notice"` events on `window` (or that bubble up to `window`) and shows them in the global notice list.
15
15
  * - This is how e.g. `<Button>` and `<FormNotify>` components send notices into the global list.
16
- * - Each notice slides in and out in its own view transition. The other notices move to their new places in the same transition.
16
+ * - Shows the list in the bottom-right corner, or in the corner that `position` sets.
17
+ * - Each notice slides in and out in its own view transition, from the side of its corner. The other notices move to their new places in the same transition.
17
18
  *
18
19
  * @kind component
19
20
  * @see https://shelving.cc/ui/Notices
20
21
  */
21
- export function Notices({ className, ...props }) {
22
+ export function Notices({ position = "bottom-right", className, ...props }) {
22
23
  const notices = useTransitionValue(NOTICES);
23
24
  useEffect(() => {
24
25
  // Subscribe to global notices.
25
26
  return subscribeNotices((message, status) => NOTICES.show(message, status));
26
27
  });
27
- return (_jsx("aside", { className: getClass(NOTICES_CLASS, getFlexClass(props), className), children: notices.map(notice => (_jsx(NoticeItem, { notice: notice }, notice.key))) }));
28
+ const [vertical, horizontal] = position.split("-");
29
+ return (_jsx("aside", { className: getClass(NOTICES_CLASS, getModuleClass(NOTICES_CSS, vertical, horizontal), getFlexClass(props), className), children: notices.map(notice => (_jsx(NoticeItem, { notice: notice, position: position }, notice.key))) }));
28
30
  }
29
31
  /**
30
32
  * Render one notice in its own view transition, and re-render when the notice changes in place.
31
33
  * - Module-private, but named without the `_` prefix: React and the hooks lint rule only treat a capitalised name as a component.
32
34
  */
33
- function NoticeItem({ notice }) {
35
+ function NoticeItem({ notice, position }) {
34
36
  const { children, status } = useTransitionValue(notice);
35
- return (_jsx(ViewTransition, { enter: "notice", exit: "notice", update: "notice-update", children: _jsx(Notice, { status: status, children: children }) }));
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
+ const side = position.endsWith("left") ? "left" : "right";
39
+ return (_jsx(ViewTransition, { enter: `notice-${side}`, exit: `notice-${side}`, update: `notice-update-${position}`, children: _jsx(Notice, { status: status, children: children }) }));
36
40
  }
@@ -7,7 +7,8 @@ Renders the global list of active notices and subscribes to incoming `"notice"`
7
7
  - Mount `<Notices>` once near the root of your app. It renders at that point in the DOM and listens automatically — no context required.
8
8
  - Notices auto-dismiss after a short delay unless they carry a `"loading"` status.
9
9
  - Backed by the `NOTICES` store singleton; for advanced use you can keep a reference to a notice to update or close it manually.
10
- - Notices animate with [view transitions](https://developer.mozilla.org/en-US/docs/Web/API/View_Transition_API). A new notice slides in from the right, and a closed notice slides out to the right. The other notices move to their new places. A notice that changes in place (for example from loading to success) changes at once, with no animation.
10
+ - The list shows in the bottom-right corner. Set `position` to `"top-left"`, `"top-right"`, `"bottom-left"`, or `"bottom-right"` to choose a different corner.
11
+ - Notices animate with [view transitions](https://developer.mozilla.org/en-US/docs/Web/API/View_Transition_API). A new notice slides in from the side of its corner, and a closed notice slides out to that side. The other notices move to their new places. A notice that changes in place (for example from loading to success) changes at once, with no animation.
11
12
  - With reduced motion, notices fade in and out in place, and the others move at once. A browser without view transitions shows the changes at once.
12
13
 
13
14
  ## Usage
@@ -27,6 +28,12 @@ export function AppLayout({ children }) {
27
28
  }
28
29
  ```
29
30
 
31
+ Show the list in the top-left corner:
32
+
33
+ ```tsx
34
+ <Notices position="top-left" />
35
+ ```
36
+
30
37
  Dispatch notices from anywhere — no context required:
31
38
 
32
39
  ```tsx
@@ -56,13 +63,14 @@ notice.close(); // Or close it immediately.
56
63
 
57
64
  ## Styling
58
65
 
59
- `Notices` positions the list in the bottom-right corner. Each notice is only as wide as its content and is right-aligned. The list is never wider than `--notices-width`, and keeps `--notices-offset` clear at both sides on a narrow screen. Clicks pass through the gaps between notices to the page. Each item is a `<Notice>`, which has its own hooks. Override these hooks at `:root` (or any ancestor scope) to retheme.
66
+ `Notices` positions the list in the corner that `position` sets. Each notice is only as wide as its content and is aligned to the side of that corner. The list is never wider than `--notices-width`, and keeps `--notices-offset` clear at both sides on a narrow screen. The offset also adds the safe area of the device (`env(safe-area-inset-*)`). Clicks pass through the gaps between notices to the page. Each item is a `<Notice>`, which has its own hooks. Override these hooks at `:root` (or any ancestor scope) to retheme.
60
67
 
61
68
  | Variable | Styles | Default |
62
69
  |---|---|---|
63
- | `--notices-offset` | Distance of the list from the bottom, right, and left edges | `var(--space-normal)` (16px) |
70
+ | `--notices-offset` | Distance of the list from the top or bottom edge, and from the left and right edges | `var(--space-normal)` (16px) |
64
71
  | `--notices-width` | Maximum width of the list and of each notice | `var(--width-narrow)` |
72
+ | `--notices-shadow` | Drop shadow under each notice in the list (sets `--notice-shadow`) | `var(--shadow-normal)` |
65
73
  | `--notices-gap` | Gap between notices | `var(--space-small)` (12px) |
66
74
  | `--notices-transition-duration` | Length of the slide in, slide out, and move | `var(--duration-fast)` (150ms) |
67
75
 
68
- **Global tokens it reads** — move these to retheme broadly: `--space-normal`, `--space-small`, `--width-narrow`, and `--duration-fast`.
76
+ **Global tokens it reads** — move these to retheme broadly: `--space-normal`, `--space-small`, `--shadow-normal`, `--width-narrow`, and `--duration-fast`.
@@ -1,29 +1,49 @@
1
1
  @import url("../style/layers.css");
2
+ @import url("../style/Shadow.module.css");
2
3
  @import url("../style/Space.module.css");
3
4
  @import url("../style/Width.module.css");
4
5
 
5
6
  @layer components {
6
7
  .notices {
7
8
  position: fixed;
8
- right: var(--notices-offset, var(--space-normal));
9
- bottom: var(--notices-offset, var(--space-normal));
10
- left: var(--notices-offset, var(--space-normal));
9
+ right: calc(var(--notices-offset, var(--space-normal)) + env(safe-area-inset-right, 0px));
10
+ left: calc(var(--notices-offset, var(--space-normal)) + env(safe-area-inset-left, 0px));
11
11
  z-index: 1000;
12
12
  display: flex;
13
- margin-left: auto;
14
13
  max-width: var(--notices-width, var(--width-narrow));
15
14
  flex-direction: column;
16
- align-items: flex-end;
17
15
  gap: var(--notices-gap, var(--space-small));
18
16
 
19
17
  /* The list is as wide as `--notices-width`, so let clicks pass through the gaps to the page. */
20
18
  pointer-events: none;
21
19
 
22
- /* Each notice is only as wide as its content, and stays on the right. */
20
+ /* Each notice is only as wide as its content, and stays on the side of the list's corner. */
23
21
  & > * {
24
22
  inline-size: auto;
25
23
  max-width: 100%;
26
24
  pointer-events: auto;
25
+
26
+ /* Floating notices sit above the page, so give each one a shadow. */
27
+ --notice-shadow: var(--notices-shadow, var(--shadow-normal));
27
28
  }
28
29
  }
30
+
31
+ /* Corners. The list keeps `--notices-offset` clear of the edges, plus the safe area of the device. */
32
+ .top {
33
+ top: calc(var(--notices-offset, var(--space-normal)) + env(safe-area-inset-top, 0px));
34
+ }
35
+
36
+ .bottom {
37
+ bottom: calc(var(--notices-offset, var(--space-normal)) + env(safe-area-inset-bottom, 0px));
38
+ }
39
+
40
+ .left {
41
+ margin-right: auto;
42
+ align-items: flex-start;
43
+ }
44
+
45
+ .right {
46
+ margin-left: auto;
47
+ align-items: flex-end;
48
+ }
29
49
  }
@@ -14,31 +14,46 @@ import { NOTICES } from "./NoticesStore.js";
14
14
  const NOTICES_CLASS = getModuleClass(NOTICES_CSS, "notices");
15
15
 
16
16
  /**
17
- * Props for `<Notices>` — flex styling variants for the notices container.
17
+ * Corner of the screen where `<Notices>` shows the list of notices.
18
+ *
19
+ * @see https://shelving.cc/ui/NoticesPosition
20
+ */
21
+ export type NoticesPosition = "top-left" | "top-right" | "bottom-left" | "bottom-right";
22
+
23
+ /**
24
+ * Props for `<Notices>` — the corner for the list, and flex styling variants for the notices container.
18
25
  *
19
26
  * @see https://shelving.cc/ui/NoticesProps
20
27
  */
21
- export interface NoticesProps extends FlexVariants, ClassProps {}
28
+ export interface NoticesProps extends FlexVariants, ClassProps {
29
+ /**
30
+ * Corner of the screen for the list. New notices slide in from this side.
31
+ * @default "bottom-right"
32
+ */
33
+ position?: NoticesPosition | undefined;
34
+ }
22
35
 
23
36
  /**
24
37
  * Render the global list of notices and subscribe to incoming `"notice"` events.
25
38
  * - Listens for `"notice"` events on `window` (or that bubble up to `window`) and shows them in the global notice list.
26
39
  * - This is how e.g. `<Button>` and `<FormNotify>` components send notices into the global list.
27
- * - Each notice slides in and out in its own view transition. The other notices move to their new places in the same transition.
40
+ * - Shows the list in the bottom-right corner, or in the corner that `position` sets.
41
+ * - Each notice slides in and out in its own view transition, from the side of its corner. The other notices move to their new places in the same transition.
28
42
  *
29
43
  * @kind component
30
44
  * @see https://shelving.cc/ui/Notices
31
45
  */
32
- export function Notices({ className, ...props }: NoticesProps): ReactElement {
46
+ export function Notices({ position = "bottom-right", className, ...props }: NoticesProps): ReactElement {
33
47
  const notices = useTransitionValue(NOTICES);
34
48
  useEffect(() => {
35
49
  // Subscribe to global notices.
36
50
  return subscribeNotices((message, status) => NOTICES.show(message, status));
37
51
  });
52
+ const [vertical, horizontal] = position.split("-");
38
53
  return (
39
- <aside className={getClass(NOTICES_CLASS, getFlexClass(props), className)}>
54
+ <aside className={getClass(NOTICES_CLASS, getModuleClass(NOTICES_CSS, vertical, horizontal), getFlexClass(props), className)}>
40
55
  {notices.map(notice => (
41
- <NoticeItem key={notice.key} notice={notice} />
56
+ <NoticeItem key={notice.key} notice={notice} position={position} />
42
57
  ))}
43
58
  </aside>
44
59
  );
@@ -48,10 +63,12 @@ export function Notices({ className, ...props }: NoticesProps): ReactElement {
48
63
  * Render one notice in its own view transition, and re-render when the notice changes in place.
49
64
  * - Module-private, but named without the `_` prefix: React and the hooks lint rule only treat a capitalised name as a component.
50
65
  */
51
- function NoticeItem({ notice }: { notice: NoticeStore<Status> }): ReactElement {
66
+ function NoticeItem({ notice, position }: { notice: NoticeStore<Status>; position: NoticesPosition }): ReactElement {
52
67
  const { children, status } = useTransitionValue(notice);
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
+ const side = position.endsWith("left") ? "left" : "right";
53
70
  return (
54
- <ViewTransition enter="notice" exit="notice" update="notice-update">
71
+ <ViewTransition enter={`notice-${side}`} exit={`notice-${side}`} update={`notice-update-${position}`}>
55
72
  <Notice status={status}>{children}</Notice>
56
73
  </ViewTransition>
57
74
  );
@@ -9,6 +9,13 @@
9
9
  }
10
10
 
11
11
  /* Only `from` is set, so the keyframe ends at the snapshot's own position. The exit plays it in reverse. */
12
+ @keyframes notice-from-left {
13
+ from {
14
+ opacity: 0;
15
+ transform: translateX(-100%);
16
+ }
17
+ }
18
+
12
19
  @keyframes notice-from-right {
13
20
  from {
14
21
  opacity: 0;
@@ -22,46 +29,85 @@
22
29
  }
23
30
  }
24
31
 
25
- /* A new notice slides in from the right. `:only-child` stops Safari from also starting the animation on the missing image, which stops it later on the real one (see `FadeTransition.css`). */
26
- ::view-transition-new(.notice):only-child {
32
+ /*
33
+ * A new notice slides in from the side of its corner, and a closed notice slides out to that side.
34
+ * - `:only-child` stops Safari from also starting the animation on the missing image, which stops it later on the real one (see `FadeTransition.css`).
35
+ */
36
+ ::view-transition-new(.notice-left):only-child {
37
+ animation: notice-from-left var(--notices-transition-duration) ease-out both;
38
+ }
39
+
40
+ ::view-transition-old(.notice-left):only-child {
41
+ animation: notice-from-left var(--notices-transition-duration) ease-in reverse both;
42
+ }
43
+
44
+ ::view-transition-new(.notice-right):only-child {
27
45
  animation: notice-from-right var(--notices-transition-duration) ease-out both;
28
46
  }
29
47
 
30
- /* A closed notice slides out to the right. */
31
- ::view-transition-old(.notice):only-child {
48
+ ::view-transition-old(.notice-right):only-child {
32
49
  animation: notice-from-right var(--notices-transition-duration) ease-in reverse both;
33
50
  }
34
51
 
35
52
  /* The other notices move to their new places (the default group morph). */
36
- ::view-transition-group(.notice-update) {
53
+ ::view-transition-group(.notice-update-top-left),
54
+ ::view-transition-group(.notice-update-top-right),
55
+ ::view-transition-group(.notice-update-bottom-left),
56
+ ::view-transition-group(.notice-update-bottom-right) {
37
57
  animation-duration: var(--notices-transition-duration);
38
58
  }
39
59
 
40
60
  /*
41
61
  * A notice that changes in place does not animate: hide the old image, and show the new image at once at its own size.
42
- * - The group still morphs between the old and new size, so the new image is drawn unscaled from the bottom-right corner, which does not move.
62
+ * - The group still morphs between the old and new size, so the new image is drawn unscaled from the corner of the list, which does not move.
43
63
  * - For a notice that only moves, the old and new images are the same, so this changes nothing.
44
64
  */
45
- ::view-transition-old(.notice-update) {
65
+ ::view-transition-old(.notice-update-top-left),
66
+ ::view-transition-old(.notice-update-top-right),
67
+ ::view-transition-old(.notice-update-bottom-left),
68
+ ::view-transition-old(.notice-update-bottom-right) {
46
69
  animation: none;
47
70
  opacity: 0;
48
71
  }
49
72
 
50
- ::view-transition-new(.notice-update) {
73
+ ::view-transition-new(.notice-update-top-left),
74
+ ::view-transition-new(.notice-update-top-right),
75
+ ::view-transition-new(.notice-update-bottom-left),
76
+ ::view-transition-new(.notice-update-bottom-right) {
51
77
  animation: none;
52
- inset: auto 0 0 auto;
53
78
  width: auto;
54
79
  height: auto;
55
80
  }
56
81
 
82
+ ::view-transition-new(.notice-update-top-left) {
83
+ inset: 0 auto auto 0;
84
+ }
85
+
86
+ ::view-transition-new(.notice-update-top-right) {
87
+ inset: 0 0 auto auto;
88
+ }
89
+
90
+ ::view-transition-new(.notice-update-bottom-left) {
91
+ inset: auto auto 0 0;
92
+ }
93
+
94
+ ::view-transition-new(.notice-update-bottom-right) {
95
+ inset: auto 0 0 auto;
96
+ }
97
+
57
98
  /* Reduced motion: fade new and closed notices in place, and move the others at once. */
58
99
  @media (prefers-reduced-motion: reduce) {
59
- ::view-transition-new(.notice):only-child,
60
- ::view-transition-old(.notice):only-child {
100
+ ::view-transition-new(.notice-left):only-child,
101
+ ::view-transition-new(.notice-right):only-child,
102
+ ::view-transition-old(.notice-left):only-child,
103
+ ::view-transition-old(.notice-right):only-child {
61
104
  animation-name: notice-fade;
62
105
  }
63
106
 
64
- ::view-transition-group(.notice-update) {
107
+ ::view-transition-group(.notice-update-top-left),
108
+ ::view-transition-group(.notice-update-top-right),
109
+ ::view-transition-group(.notice-update-bottom-left),
110
+ ::view-transition-group(.notice-update-bottom-right) {
65
111
  animation: none;
66
112
  }
67
113
  }
@@ -20,6 +20,7 @@
20
20
  --color-success: var(--color-green);
21
21
  --color-warning: var(--color-orange);
22
22
  --color-failure: var(--color-red);
23
+ --color-backdrop: #0006; /* Dims the page behind a dialog or an open sidebar drawer. */
23
24
 
24
25
  /* Brand colors */
25
26
  --color-primary: var(--color-blue); /* Primary brand color */
@@ -3,12 +3,12 @@
3
3
  @layer defaults {
4
4
  :root {
5
5
  /* Colors */
6
- --shadow-color: #0006;
6
+ --shadow-color: #0003;
7
7
 
8
- /* Shadows — elevation drop-shadows. */
9
- --shadow-small: 0 0.375rem 1.5rem -0.75rem var(--shadow-color);
10
- --shadow-normal: 0 0.5rem 2rem -1rem var(--shadow-color);
11
- --shadow-large: 0 0.75rem 3rem -1.5rem var(--shadow-color);
8
+ /* Shadows — elevation drop-shadows. Each has two layers with a negative spread, so no dark line shows under the bottom edge. The Y offset is small enough that a sliver of shadow also shows at the top. */
9
+ --shadow-small: 0 0.125rem 0.375rem -0.0625rem var(--shadow-color), 0 0.0625rem 0.25rem -0.125rem var(--shadow-color);
10
+ --shadow-normal: 0 0.3125rem 0.9375rem -0.1875rem var(--shadow-color), 0 0.125rem 0.375rem -0.25rem var(--shadow-color);
11
+ --shadow-large: 0 0.625rem 1.5625rem -0.3125rem var(--shadow-color), 0 0.25rem 0.625rem -0.375rem var(--shadow-color);
12
12
  }
13
13
  }
14
14
 
@@ -31,6 +31,7 @@ The following `:root` variables are defined by this module and can be overridden
31
31
  | `--color-success` | `var(--color-green)` | `status="success"`. |
32
32
  | `--color-warning` | `var(--color-orange)` | `status="warning"`. |
33
33
  | `--color-failure` | `var(--color-red)` | `status="error"` / `status="danger"`. |
34
+ | `--color-backdrop` | `#0006` | The backdrop that dims the page behind `<Dialog>` and an open `<SidebarLayout>` drawer. |
34
35
 
35
36
  ### Brand
36
37
 
@@ -4,12 +4,15 @@ This module's main job is to **define and document the elevation drop-shadow des
4
4
 
5
5
  ## Theme variables
6
6
 
7
- The following `:root` variables are defined by this module and can be overridden in a theme file to adjust default styling across the whole app. Each step deepens both blur and offset for a consistent elevation ramp.
7
+ The following `:root` variables are defined by this module and can be overridden in a theme file to adjust default styling across the whole app. The scale is [Tailwind's](https://tailwindcss.com/docs/box-shadow) `shadow-md`, `shadow-lg` and `shadow-xl` with half the Y offset, so a sliver of shadow always shows at the top. Each shadow has two layers of `--shadow-color`. Both layers have a negative spread, so no dark line shows under the bottom edge.
8
8
 
9
- | Variable | Default |
10
- |---|---|
11
- | `--shadow-small` | `0 0.375rem 1.5rem -0.75rem #0006` |
12
- | `--shadow-normal` | `0 0.5rem 2rem -1rem #0006` |
13
- | `--shadow-large` | `0 0.75rem 3rem -1.5rem #0006` |
9
+ | Variable | Default | Used by |
10
+ |---|---|---|
11
+ | `--shadow-color` | `#0003` (20% black) | Every layer of every shadow below. |
12
+ | `--shadow-small` | `0 2px 6px -1px`, `0 1px 4px -2px` | `<Popover>` |
13
+ | `--shadow-normal` | `0 5px 15px -3px`, `0 2px 6px -4px` | Floating `<Notices>` |
14
+ | `--shadow-large` | `0 10px 25px -5px`, `0 4px 10px -6px` | `<Modal>`, the open `<SidebarLayout>` drawer |
15
+
16
+ The table shows the values in pixels. The source uses `rem`.
14
17
 
15
18
  The `shadow=` variant prop accepts `"none"`, `"small"`, `"normal"`, or `"large"` — `"none"` removes a component's default shadow rather than mapping to a token.