shelving 1.317.1 → 1.318.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.
@@ -20302,7 +20302,7 @@ The components below are listed in the index following this page; this is the sh
20302
20302
  - [EmptyProps](ui/EmptyProps.md): Props for <Empty> — the message content plus an optional className.
20303
20303
  - [MessageProps](ui/MessageProps.md): Props for <Message> — paragraph props plus colour and status styling variants.
20304
20304
  - [NoticeProps](ui/NoticeProps.md): Props for <Notice> — flex/colour/status styling variants, optional children, and an optional icon.
20305
- - [NoticesProps](ui/NoticesProps.md): Props for <Notices> — the corner for the list, and flex styling variants for the notices container.
20305
+ - [NoticesProps](ui/NoticesProps.md): Props for <Notices> — the place for the list, and flex styling variants for the notices container.
20306
20306
  - [HTMLProps](ui/HTMLProps.md): Props for <HTML> — initial Meta (language/root/app) plus the page children.
20307
20307
  - [PageProps](ui/PageProps.md): Props for <Page> — per-page Meta (title, description, etc.) plus the page children.
20308
20308
  - [NavigationProps](ui/NavigationProps.md): Props for <Navigation> — initial Meta (url/base) plus optional children.
@@ -20360,7 +20360,7 @@ The components below are listed in the index following this page; this is the sh
20360
20360
  - [PopoverChildren](ui/PopoverChildren.md): Children tuple for Popover: a leading trigger node followed by the popover's contents.
20361
20361
  - [TextFormatter](ui/TextFormatter.md): Formats a string for display in a text input.
20362
20362
  - [Mapping](ui/Mapping.md): Dispatch table from a JSX.IntrinsicElements key to a renderer component.
20363
- - [NoticesPosition](ui/NoticesPosition.md): Corner of the screen where <Notices> shows the list of notices.
20363
+ - [NoticesPosition](ui/NoticesPosition.md): Place on the screen where <Notices> shows the list of notices: a corner, or the centre of the top or bottom edge.
20364
20364
  - [RouteProps](ui/RouteProps.md): Props for a component that works as a route in the router.
20365
20365
  - [RouteComponent](ui/RouteComponent.md): React component usable as a route value — a function or class component accepting RouteProps.
20366
20366
  - [Route](ui/Route.md): Valid route values:
@@ -31270,12 +31270,12 @@ Shared loading `<Notice>` element showing the loading spinner.
31270
31270
  - Kind: type
31271
31271
  - Import: `import { NoticesPosition } from "shelving/ui";`
31272
31272
 
31273
- Corner of the screen where `<Notices>` shows the list of notices.
31273
+ Place on the screen where `<Notices>` shows the list of notices: a corner, or the centre of the top or bottom edge.
31274
31274
 
31275
31275
  ## Signatures
31276
31276
 
31277
31277
  ```ts
31278
- "top-left" | "top-right" | "bottom-left" | "bottom-right"
31278
+ `${"top" | "bottom"}-${"left" | "center" | "right"}`
31279
31279
  ```
31280
31280
 
31281
31281
 
@@ -31287,7 +31287,7 @@ Corner of the screen where `<Notices>` shows the list of notices.
31287
31287
  - Import: `import { NoticesProps } from "shelving/ui";`
31288
31288
  - Extends: `FlexVariants`
31289
31289
 
31290
- Props for `<Notices>` — the corner for the list, and flex styling variants for the notices container.
31290
+ Props for `<Notices>` — the place for the list, and flex styling variants for the notices container.
31291
31291
 
31292
31292
  ## Signatures
31293
31293
 
@@ -31301,7 +31301,7 @@ Props for `<Notices>` — the corner for the list, and flex styling variants for
31301
31301
 
31302
31302
  | Property | Type | Description |
31303
31303
  | --- | --- | --- |
31304
- | `position` | `NoticesPosition \| undefined` | Corner of the screen for the list. New notices slide in from this side. Defaults to `"bottom-right"`. |
31304
+ | `position` | `NoticesPosition \| undefined` | Place on the screen for the list. New notices slide in from this side, or from the top or bottom edge for a centred list. Defaults to `"bottom-right"`. |
31305
31305
 
31306
31306
 
31307
31307
  ---
@@ -31314,8 +31314,8 @@ Props for `<Notices>` — the corner for the list, and flex styling variants for
31314
31314
  Render the global list of notices and subscribe to incoming `"notice"` events.
31315
31315
  - Listens for `"notice"` events on `window` (or that bubble up to `window`) and shows them in the global notice list.
31316
31316
  - This is how e.g. `<Button>` and `<FormNotify>` components send notices into the global list.
31317
- - Shows the list in the bottom-right corner, or in the corner that `position` sets.
31318
- - 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.
31317
+ - Shows the list in the bottom-right corner, or in the place that `position` sets.
31318
+ - Each notice slides in and out in its own view transition, from the side of its corner, or from the edge for a centred list. The other notices move to their new places in the same transition.
31319
31319
 
31320
31320
  Renders the global list of active notices and subscribes to incoming `"notice"` events. It listens for `"notice"` events on `window` (dispatched by the `notify()` helpers) and shows each one as a `<Notice>` — this is how components like `<Button>` and `<FormNotify>` send notices into the global list.
31321
31321
 
@@ -31324,8 +31324,8 @@ Renders the global list of active notices and subscribes to incoming `"notice"`
31324
31324
  - Mount `<Notices>` once near the root of your app. It renders at that point in the DOM and listens automatically — no context required.
31325
31325
  - Notices auto-dismiss after a short delay unless they carry a `"loading"` status.
31326
31326
  - Backed by the `NOTICES` store singleton; for advanced use you can keep a reference to a notice to update or close it manually.
31327
- - 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.
31328
- - 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.
31327
+ - The list shows in the bottom-right corner. Set `position` to `"top-left"`, `"top-center"`, `"top-right"`, `"bottom-left"`, `"bottom-center"`, or `"bottom-right"` to choose a different place.
31328
+ - 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. In a centred list, notices slide in and out from the top or bottom edge. 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.
31329
31329
  - 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.
31330
31330
 
31331
31331
  ## Usage
@@ -31351,6 +31351,12 @@ Show the list in the top-left corner:
31351
31351
  <Notices position="top-left" />
31352
31352
  ```
31353
31353
 
31354
+ Show the list at the top of the screen, in the centre:
31355
+
31356
+ ```tsx
31357
+ <Notices position="top-center" />
31358
+ ```
31359
+
31354
31360
  Dispatch notices from anywhere — no context required:
31355
31361
 
31356
31362
  ```tsx
@@ -31380,7 +31386,7 @@ notice.close(); // Or close it immediately.
31380
31386
 
31381
31387
  ## Styling
31382
31388
 
31383
- `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.
31389
+ `Notices` positions the list in the place that `position` sets. Each notice is only as wide as its content and is aligned to the side of that corner, or to the centre. 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.
31384
31390
 
31385
31391
  | Variable | Styles | Default |
31386
31392
  |---|---|---|
@@ -31404,7 +31410,7 @@ Notices({ position = "bottom-right", className, ...props }: NoticesProps): React
31404
31410
  | Param | Type | Description |
31405
31411
  | --- | --- | --- |
31406
31412
  | `props` | `NoticesProps` | |
31407
- | `.position` | `NoticesPosition \| undefined` | Corner of the screen for the list. New notices slide in from this side. Defaults to `"bottom-right"`. |
31413
+ | `.position` | `NoticesPosition \| undefined` | Place on the screen for the list. New notices slide in from this side, or from the top or bottom edge for a centred list. Defaults to `"bottom-right"`. |
31408
31414
 
31409
31415
  ## Returns
31410
31416
 
@@ -6,8 +6,8 @@
6
6
  Render the global list of notices and subscribe to incoming `"notice"` events.
7
7
  - Listens for `"notice"` events on `window` (or that bubble up to `window`) and shows them in the global notice list.
8
8
  - This is how e.g. `<Button>` and `<FormNotify>` components send notices into the global list.
9
- - Shows the list in the bottom-right corner, or in the corner that `position` sets.
10
- - 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.
9
+ - Shows the list in the bottom-right corner, or in the place that `position` sets.
10
+ - Each notice slides in and out in its own view transition, from the side of its corner, or from the edge for a centred list. The other notices move to their new places in the same transition.
11
11
 
12
12
  Renders the global list of active notices and subscribes to incoming `"notice"` events. It listens for `"notice"` events on `window` (dispatched by the `notify()` helpers) and shows each one as a `<Notice>` — this is how components like `<Button>` and `<FormNotify>` send notices into the global list.
13
13
 
@@ -16,8 +16,8 @@ Renders the global list of active notices and subscribes to incoming `"notice"`
16
16
  - Mount `<Notices>` once near the root of your app. It renders at that point in the DOM and listens automatically — no context required.
17
17
  - Notices auto-dismiss after a short delay unless they carry a `"loading"` status.
18
18
  - Backed by the `NOTICES` store singleton; for advanced use you can keep a reference to a notice to update or close it manually.
19
- - 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.
20
- - 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.
19
+ - The list shows in the bottom-right corner. Set `position` to `"top-left"`, `"top-center"`, `"top-right"`, `"bottom-left"`, `"bottom-center"`, or `"bottom-right"` to choose a different place.
20
+ - 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. In a centred list, notices slide in and out from the top or bottom edge. 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.
21
21
  - 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.
22
22
 
23
23
  ## Usage
@@ -43,6 +43,12 @@ Show the list in the top-left corner:
43
43
  <Notices position="top-left" />
44
44
  ```
45
45
 
46
+ Show the list at the top of the screen, in the centre:
47
+
48
+ ```tsx
49
+ <Notices position="top-center" />
50
+ ```
51
+
46
52
  Dispatch notices from anywhere — no context required:
47
53
 
48
54
  ```tsx
@@ -72,7 +78,7 @@ notice.close(); // Or close it immediately.
72
78
 
73
79
  ## Styling
74
80
 
75
- `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.
81
+ `Notices` positions the list in the place that `position` sets. Each notice is only as wide as its content and is aligned to the side of that corner, or to the centre. 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.
76
82
 
77
83
  | Variable | Styles | Default |
78
84
  |---|---|---|
@@ -96,7 +102,7 @@ Notices({ position = "bottom-right", className, ...props }: NoticesProps): React
96
102
  | Param | Type | Description |
97
103
  | --- | --- | --- |
98
104
  | `props` | `NoticesProps` | |
99
- | `.position` | `NoticesPosition \| undefined` | Corner of the screen for the list. New notices slide in from this side. Defaults to `"bottom-right"`. |
105
+ | `.position` | `NoticesPosition \| undefined` | Place on the screen for the list. New notices slide in from this side, or from the top or bottom edge for a centred list. Defaults to `"bottom-right"`. |
100
106
 
101
107
  ## Returns
102
108
 
@@ -3,10 +3,10 @@
3
3
  - Kind: type
4
4
  - Import: `import { NoticesPosition } from "shelving/ui";`
5
5
 
6
- Corner of the screen where `<Notices>` shows the list of notices.
6
+ Place on the screen where `<Notices>` shows the list of notices: a corner, or the centre of the top or bottom edge.
7
7
 
8
8
  ## Signatures
9
9
 
10
10
  ```ts
11
- "top-left" | "top-right" | "bottom-left" | "bottom-right"
11
+ `${"top" | "bottom"}-${"left" | "center" | "right"}`
12
12
  ```
@@ -4,7 +4,7 @@
4
4
  - Import: `import { NoticesProps } from "shelving/ui";`
5
5
  - Extends: `FlexVariants`
6
6
 
7
- Props for `<Notices>` — the corner for the list, and flex styling variants for the notices container.
7
+ Props for `<Notices>` — the place for the list, and flex styling variants for the notices container.
8
8
 
9
9
  ## Signatures
10
10
 
@@ -18,4 +18,4 @@ Props for `<Notices>` — the corner for the list, and flex styling variants for
18
18
 
19
19
  | Property | Type | Description |
20
20
  | --- | --- | --- |
21
- | `position` | `NoticesPosition \| undefined` | Corner of the screen for the list. New notices slide in from this side. Defaults to `"bottom-right"`. |
21
+ | `position` | `NoticesPosition \| undefined` | Place on the screen for the list. New notices slide in from this side, or from the top or bottom edge for a centred list. Defaults to `"bottom-right"`. |
package/docs/ui.md CHANGED
@@ -433,7 +433,7 @@ The components below are listed in the index following this page; this is the sh
433
433
  - [EmptyProps](ui/EmptyProps.md): Props for <Empty> — the message content plus an optional className.
434
434
  - [MessageProps](ui/MessageProps.md): Props for <Message> — paragraph props plus colour and status styling variants.
435
435
  - [NoticeProps](ui/NoticeProps.md): Props for <Notice> — flex/colour/status styling variants, optional children, and an optional icon.
436
- - [NoticesProps](ui/NoticesProps.md): Props for <Notices> — the corner for the list, and flex styling variants for the notices container.
436
+ - [NoticesProps](ui/NoticesProps.md): Props for <Notices> — the place for the list, and flex styling variants for the notices container.
437
437
  - [HTMLProps](ui/HTMLProps.md): Props for <HTML> — initial Meta (language/root/app) plus the page children.
438
438
  - [PageProps](ui/PageProps.md): Props for <Page> — per-page Meta (title, description, etc.) plus the page children.
439
439
  - [NavigationProps](ui/NavigationProps.md): Props for <Navigation> — initial Meta (url/base) plus optional children.
@@ -491,7 +491,7 @@ The components below are listed in the index following this page; this is the sh
491
491
  - [PopoverChildren](ui/PopoverChildren.md): Children tuple for Popover: a leading trigger node followed by the popover's contents.
492
492
  - [TextFormatter](ui/TextFormatter.md): Formats a string for display in a text input.
493
493
  - [Mapping](ui/Mapping.md): Dispatch table from a JSX.IntrinsicElements key to a renderer component.
494
- - [NoticesPosition](ui/NoticesPosition.md): Corner of the screen where <Notices> shows the list of notices.
494
+ - [NoticesPosition](ui/NoticesPosition.md): Place on the screen where <Notices> shows the list of notices: a corner, or the centre of the top or bottom edge.
495
495
  - [RouteProps](ui/RouteProps.md): Props for a component that works as a route in the router.
496
496
  - [RouteComponent](ui/RouteComponent.md): React component usable as a route value — a function or class component accepting RouteProps.
497
497
  - [Route](ui/Route.md): Valid route values:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shelving",
3
- "version": "1.317.1",
3
+ "version": "1.318.0",
4
4
  "author": "Dave Houlbrooke <dave@shax.com>",
5
5
  "repository": {
6
6
  "type": "git",
@@ -2,19 +2,19 @@ import { type ReactElement } from "react";
2
2
  import { type FlexVariants } from "../style/Flex.js";
3
3
  import type { ClassProps } from "../util/props.js";
4
4
  /**
5
- * Corner of the screen where `<Notices>` shows the list of notices.
5
+ * Place on the screen where `<Notices>` shows the list of notices: a corner, or the centre of the top or bottom edge.
6
6
  *
7
7
  * @see https://shelving.cc/ui/NoticesPosition
8
8
  */
9
- export type NoticesPosition = "top-left" | "top-right" | "bottom-left" | "bottom-right";
9
+ export type NoticesPosition = `${"top" | "bottom"}-${"left" | "center" | "right"}`;
10
10
  /**
11
- * Props for `<Notices>` — the corner for the list, and flex styling variants for the notices container.
11
+ * Props for `<Notices>` — the place for the list, and flex styling variants for the notices container.
12
12
  *
13
13
  * @see https://shelving.cc/ui/NoticesProps
14
14
  */
15
15
  export interface NoticesProps extends FlexVariants, ClassProps {
16
16
  /**
17
- * Corner of the screen for the list. New notices slide in from this side.
17
+ * Place on the screen for the list. New notices slide in from this side, or from the top or bottom edge for a centred list.
18
18
  * @default "bottom-right"
19
19
  */
20
20
  position?: NoticesPosition | undefined;
@@ -23,8 +23,8 @@ export interface NoticesProps extends FlexVariants, ClassProps {
23
23
  * Render the global list of notices and subscribe to incoming `"notice"` events.
24
24
  * - Listens for `"notice"` events on `window` (or that bubble up to `window`) and shows them in the global notice list.
25
25
  * - This is how e.g. `<Button>` and `<FormNotify>` components send notices into the global list.
26
- * - Shows the list in the bottom-right corner, or in the corner that `position` sets.
27
- * - 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.
26
+ * - Shows the list in the bottom-right corner, or in the place that `position` sets.
27
+ * - Each notice slides in and out in its own view transition, from the side of its corner, or from the edge for a centred list. The other notices move to their new places in the same transition.
28
28
  *
29
29
  * @kind component
30
30
  * @see https://shelving.cc/ui/Notices
@@ -13,8 +13,8 @@ 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
- * - 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.
16
+ * - Shows the list in the bottom-right corner, or in the place that `position` sets.
17
+ * - Each notice slides in and out in its own view transition, from the side of its corner, or from the edge for a centred list. The other notices move to their new places in the same transition.
18
18
  *
19
19
  * @kind component
20
20
  * @see https://shelving.cc/ui/Notices
@@ -34,7 +34,8 @@ export function Notices({ position = "bottom-right", className, ...props }) {
34
34
  */
35
35
  function NoticeItem({ notice, position }) {
36
36
  const { children, status } = useTransitionValue(notice);
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";
37
+ // New and closed notices slide from the side of the corner, or from the edge when centred. A notice that changes in place is drawn from the corner itself.
38
+ const [vertical, horizontal] = position.split("-");
39
+ const side = horizontal === "center" ? vertical : horizontal;
39
40
  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
41
  }
@@ -7,8 +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
- - 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.
10
+ - The list shows in the bottom-right corner. Set `position` to `"top-left"`, `"top-center"`, `"top-right"`, `"bottom-left"`, `"bottom-center"`, or `"bottom-right"` to choose a different place.
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. In a centred list, notices slide in and out from the top or bottom edge. 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.
12
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.
13
13
 
14
14
  ## Usage
@@ -34,6 +34,12 @@ Show the list in the top-left corner:
34
34
  <Notices position="top-left" />
35
35
  ```
36
36
 
37
+ Show the list at the top of the screen, in the centre:
38
+
39
+ ```tsx
40
+ <Notices position="top-center" />
41
+ ```
42
+
37
43
  Dispatch notices from anywhere — no context required:
38
44
 
39
45
  ```tsx
@@ -63,7 +69,7 @@ notice.close(); // Or close it immediately.
63
69
 
64
70
  ## Styling
65
71
 
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.
72
+ `Notices` positions the list in the place that `position` sets. Each notice is only as wide as its content and is aligned to the side of that corner, or to the centre. 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.
67
73
 
68
74
  | Variable | Styles | Default |
69
75
  |---|---|---|
@@ -17,7 +17,7 @@
17
17
  /* The list is as wide as `--notices-width`, so let clicks pass through the gaps to the page. */
18
18
  pointer-events: none;
19
19
 
20
- /* Each notice is only as wide as its content, and stays on the side of the list's corner. */
20
+ /* Each notice is only as wide as its content, and stays on the side of the list's corner, or in the centre. */
21
21
  & > * {
22
22
  inline-size: auto;
23
23
  max-width: 100%;
@@ -28,7 +28,7 @@
28
28
  }
29
29
  }
30
30
 
31
- /* Corners. The list keeps `--notices-offset` clear of the edges, plus the safe area of the device. */
31
+ /* Places. The list keeps `--notices-offset` clear of the edges, plus the safe area of the device. */
32
32
  .top {
33
33
  top: calc(var(--notices-offset, var(--space-normal)) + env(safe-area-inset-top, 0px));
34
34
  }
@@ -46,4 +46,9 @@
46
46
  margin-left: auto;
47
47
  align-items: flex-end;
48
48
  }
49
+
50
+ .center {
51
+ margin-inline: auto;
52
+ align-items: center;
53
+ }
49
54
  }
@@ -14,20 +14,20 @@ import NOTICES_TRANSITION_CSS from "./NoticesTransition.module.css";
14
14
  const NOTICES_CLASS = getModuleClass(NOTICES_CSS, "notices");
15
15
 
16
16
  /**
17
- * Corner of the screen where `<Notices>` shows the list of notices.
17
+ * Place on the screen where `<Notices>` shows the list of notices: a corner, or the centre of the top or bottom edge.
18
18
  *
19
19
  * @see https://shelving.cc/ui/NoticesPosition
20
20
  */
21
- export type NoticesPosition = "top-left" | "top-right" | "bottom-left" | "bottom-right";
21
+ export type NoticesPosition = `${"top" | "bottom"}-${"left" | "center" | "right"}`;
22
22
 
23
23
  /**
24
- * Props for `<Notices>` — the corner for the list, and flex styling variants for the notices container.
24
+ * Props for `<Notices>` — the place for the list, and flex styling variants for the notices container.
25
25
  *
26
26
  * @see https://shelving.cc/ui/NoticesProps
27
27
  */
28
28
  export interface NoticesProps extends FlexVariants, ClassProps {
29
29
  /**
30
- * Corner of the screen for the list. New notices slide in from this side.
30
+ * Place on the screen for the list. New notices slide in from this side, or from the top or bottom edge for a centred list.
31
31
  * @default "bottom-right"
32
32
  */
33
33
  position?: NoticesPosition | undefined;
@@ -37,8 +37,8 @@ export interface NoticesProps extends FlexVariants, ClassProps {
37
37
  * Render the global list of notices and subscribe to incoming `"notice"` events.
38
38
  * - Listens for `"notice"` events on `window` (or that bubble up to `window`) and shows them in the global notice list.
39
39
  * - This is how e.g. `<Button>` and `<FormNotify>` components send notices into the global list.
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.
40
+ * - Shows the list in the bottom-right corner, or in the place that `position` sets.
41
+ * - Each notice slides in and out in its own view transition, from the side of its corner, or from the edge for a centred list. The other notices move to their new places in the same transition.
42
42
  *
43
43
  * @kind component
44
44
  * @see https://shelving.cc/ui/Notices
@@ -65,8 +65,9 @@ export function Notices({ position = "bottom-right", className, ...props }: Noti
65
65
  */
66
66
  function NoticeItem({ notice, position }: { notice: NoticeStore<Status>; position: NoticesPosition }): ReactElement {
67
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";
68
+ // New and closed notices slide from the side of the corner, or from the edge when centred. A notice that changes in place is drawn from the corner itself.
69
+ const [vertical, horizontal] = position.split("-");
70
+ const side = horizontal === "center" ? vertical : horizontal;
70
71
  return (
71
72
  <ViewTransition
72
73
  enter={getModuleClass(NOTICES_TRANSITION_CSS, `notice-${side}`)}
@@ -22,6 +22,20 @@
22
22
  }
23
23
  }
24
24
 
25
+ @keyframes notice-from-top {
26
+ from {
27
+ opacity: 0;
28
+ transform: translateY(-100%);
29
+ }
30
+ }
31
+
32
+ @keyframes notice-from-bottom {
33
+ from {
34
+ opacity: 0;
35
+ transform: translateY(100%);
36
+ }
37
+ }
38
+
25
39
  @keyframes notice-fade {
26
40
  from {
27
41
  opacity: 0;
@@ -29,7 +43,7 @@
29
43
  }
30
44
 
31
45
  /*
32
- * A new notice slides in from the side of its corner, and a closed notice slides out to that side.
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.
33
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`).
34
48
  * - Longhands, not the `animation` shorthand: Bun rewrites `animation-name` to the hashed keyframes name but leaves a shorthand that holds a `var()` untouched.
35
49
  */
@@ -63,30 +77,66 @@
63
77
  animation-fill-mode: both;
64
78
  }
65
79
 
80
+ ::view-transition-new(.notice-top):only-child {
81
+ animation-name: notice-from-top;
82
+ animation-duration: var(--notices-transition-duration);
83
+ animation-timing-function: ease-out;
84
+ animation-fill-mode: both;
85
+ }
86
+
87
+ ::view-transition-old(.notice-top):only-child {
88
+ animation-name: notice-from-top;
89
+ animation-duration: var(--notices-transition-duration);
90
+ animation-timing-function: ease-in;
91
+ animation-direction: reverse;
92
+ animation-fill-mode: both;
93
+ }
94
+
95
+ ::view-transition-new(.notice-bottom):only-child {
96
+ animation-name: notice-from-bottom;
97
+ animation-duration: var(--notices-transition-duration);
98
+ animation-timing-function: ease-out;
99
+ animation-fill-mode: both;
100
+ }
101
+
102
+ ::view-transition-old(.notice-bottom):only-child {
103
+ animation-name: notice-from-bottom;
104
+ animation-duration: var(--notices-transition-duration);
105
+ animation-timing-function: ease-in;
106
+ animation-direction: reverse;
107
+ animation-fill-mode: both;
108
+ }
109
+
66
110
  /* The other notices move to their new places (the default group morph). */
67
111
  ::view-transition-group(.notice-update-top-left),
112
+ ::view-transition-group(.notice-update-top-center),
68
113
  ::view-transition-group(.notice-update-top-right),
69
114
  ::view-transition-group(.notice-update-bottom-left),
115
+ ::view-transition-group(.notice-update-bottom-center),
70
116
  ::view-transition-group(.notice-update-bottom-right) {
71
117
  animation-duration: var(--notices-transition-duration);
72
118
  }
73
119
 
74
120
  /*
75
121
  * A notice that changes in place does not animate: hide the old image, and show the new image at once at its own size.
76
- * - 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.
122
+ * - The group still morphs between the old and new size, so the new image is drawn unscaled from the corner (or the centre of the edge) of the list, which does not move.
77
123
  * - For a notice that only moves, the old and new images are the same, so this changes nothing.
78
124
  */
79
125
  ::view-transition-old(.notice-update-top-left),
126
+ ::view-transition-old(.notice-update-top-center),
80
127
  ::view-transition-old(.notice-update-top-right),
81
128
  ::view-transition-old(.notice-update-bottom-left),
129
+ ::view-transition-old(.notice-update-bottom-center),
82
130
  ::view-transition-old(.notice-update-bottom-right) {
83
131
  animation: none;
84
132
  opacity: 0;
85
133
  }
86
134
 
87
135
  ::view-transition-new(.notice-update-top-left),
136
+ ::view-transition-new(.notice-update-top-center),
88
137
  ::view-transition-new(.notice-update-top-right),
89
138
  ::view-transition-new(.notice-update-bottom-left),
139
+ ::view-transition-new(.notice-update-bottom-center),
90
140
  ::view-transition-new(.notice-update-bottom-right) {
91
141
  animation: none;
92
142
  width: auto;
@@ -97,6 +147,11 @@
97
147
  inset: 0 auto auto 0;
98
148
  }
99
149
 
150
+ ::view-transition-new(.notice-update-top-center) {
151
+ inset: 0 0 auto;
152
+ margin-inline: auto;
153
+ }
154
+
100
155
  ::view-transition-new(.notice-update-top-right) {
101
156
  inset: 0 0 auto auto;
102
157
  }
@@ -105,6 +160,11 @@
105
160
  inset: auto auto 0 0;
106
161
  }
107
162
 
163
+ ::view-transition-new(.notice-update-bottom-center) {
164
+ inset: auto 0 0;
165
+ margin-inline: auto;
166
+ }
167
+
108
168
  ::view-transition-new(.notice-update-bottom-right) {
109
169
  inset: auto 0 0 auto;
110
170
  }
@@ -114,13 +174,19 @@
114
174
  ::view-transition-new(.notice-left):only-child,
115
175
  ::view-transition-new(.notice-right):only-child,
116
176
  ::view-transition-old(.notice-left):only-child,
117
- ::view-transition-old(.notice-right):only-child {
177
+ ::view-transition-old(.notice-right):only-child,
178
+ ::view-transition-new(.notice-top):only-child,
179
+ ::view-transition-new(.notice-bottom):only-child,
180
+ ::view-transition-old(.notice-top):only-child,
181
+ ::view-transition-old(.notice-bottom):only-child {
118
182
  animation-name: notice-fade;
119
183
  }
120
184
 
121
185
  ::view-transition-group(.notice-update-top-left),
186
+ ::view-transition-group(.notice-update-top-center),
122
187
  ::view-transition-group(.notice-update-top-right),
123
188
  ::view-transition-group(.notice-update-bottom-left),
189
+ ::view-transition-group(.notice-update-bottom-center),
124
190
  ::view-transition-group(.notice-update-bottom-right) {
125
191
  animation: none;
126
192
  }