magic-pill 9.1.1 → 9.3.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 (72) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/MIGRATING.md +2 -0
  3. package/README.md +55 -17
  4. package/dist/MagicPill/MagicPill.d.mts +9 -1
  5. package/dist/MagicPill/MagicPill.d.ts +9 -1
  6. package/dist/MagicPill/MagicPill.js +208 -107
  7. package/dist/MagicPill/MagicPill.mjs +211 -110
  8. package/dist/MagicPill/flag.js +93 -0
  9. package/dist/MagicPill/flag.mjs +91 -0
  10. package/dist/MagicPill/useChoreography.js +66 -0
  11. package/dist/MagicPill/useChoreography.mjs +66 -0
  12. package/dist/Pill/Pill.js +20 -9
  13. package/dist/Pill/Pill.mjs +21 -10
  14. package/dist/Pill/modal.js +2 -1
  15. package/dist/Pill/modal.mjs +3 -2
  16. package/dist/Pill/morph.js +178 -26
  17. package/dist/Pill/morph.mjs +178 -28
  18. package/dist/Pill/travel.js +77 -0
  19. package/dist/Pill/travel.mjs +76 -0
  20. package/dist/Pill/types.d.mts +8 -0
  21. package/dist/Pill/types.d.ts +8 -0
  22. package/dist/Pill/zone.js +3 -2
  23. package/dist/Pill/zone.mjs +4 -3
  24. package/dist/PillForm/PillField.js +16 -1
  25. package/dist/PillForm/PillField.mjs +17 -2
  26. package/dist/PillForm/PillSubmit.js +1 -1
  27. package/dist/PillForm/PillSubmit.mjs +3 -3
  28. package/dist/PillForm/popover.js +2 -1
  29. package/dist/PillForm/popover.mjs +3 -2
  30. package/dist/PillNavbar/PillNavbar.js +2 -1
  31. package/dist/PillNavbar/PillNavbar.mjs +2 -1
  32. package/dist/PillNotification/PillNotification.d.mts +16 -1
  33. package/dist/PillNotification/PillNotification.d.ts +16 -1
  34. package/dist/PillNotification/PillNotification.js +41 -30
  35. package/dist/PillNotification/PillNotification.mjs +41 -30
  36. package/dist/PillOptics/PillOptics.js +2 -1
  37. package/dist/PillOptics/PillOptics.mjs +3 -2
  38. package/dist/forms.css +40 -27
  39. package/dist/index.d.mts +29 -15
  40. package/dist/index.d.ts +29 -15
  41. package/dist/index.js +38 -12
  42. package/dist/index.mjs +38 -12
  43. package/dist/store/store.d.mts +9 -1
  44. package/dist/store/store.d.ts +9 -1
  45. package/dist/styles.css +91 -3
  46. package/dist/utils/react.js +8 -1
  47. package/dist/utils/react.mjs +8 -2
  48. package/package.json +2 -2
  49. package/dist/icons/ArrowIcon.d.mts +0 -4
  50. package/dist/icons/ArrowIcon.d.ts +0 -4
  51. package/dist/icons/BoxIcon.d.mts +0 -4
  52. package/dist/icons/BoxIcon.d.ts +0 -4
  53. package/dist/icons/CheckIcon.d.mts +0 -4
  54. package/dist/icons/CheckIcon.d.ts +0 -4
  55. package/dist/icons/CloseIcon.d.mts +0 -4
  56. package/dist/icons/CloseIcon.d.ts +0 -4
  57. package/dist/icons/CouponIcon.d.mts +0 -4
  58. package/dist/icons/CouponIcon.d.ts +0 -4
  59. package/dist/icons/DocumentIcon.d.mts +0 -4
  60. package/dist/icons/DocumentIcon.d.ts +0 -4
  61. package/dist/icons/HelpIcon.d.mts +0 -4
  62. package/dist/icons/HelpIcon.d.ts +0 -4
  63. package/dist/icons/InfoIcon.d.mts +0 -4
  64. package/dist/icons/InfoIcon.d.ts +0 -4
  65. package/dist/icons/MailIcon.d.mts +0 -4
  66. package/dist/icons/MailIcon.d.ts +0 -4
  67. package/dist/icons/PhoneIcon.d.mts +0 -4
  68. package/dist/icons/PhoneIcon.d.ts +0 -4
  69. package/dist/icons/PlusIcon.d.mts +0 -4
  70. package/dist/icons/PlusIcon.d.ts +0 -4
  71. package/dist/icons/UndoIcon.d.mts +0 -4
  72. package/dist/icons/UndoIcon.d.ts +0 -4
package/CHANGELOG.md CHANGED
@@ -2,6 +2,38 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [9.3.0] - 2026-11-27
6
+ A token for the content's fade, the built-in icons deprecated, and two fixes. Nothing to change in your code: the icons still work as before, and leaving them can wait until the next major version.
7
+
8
+ ### Added
9
+ - `--mp-duration-fade` (`150ms`): how long the content takes to fade out before the pill shrinks, and in once it has grown, like the other duration tokens
10
+
11
+ ### Deprecated
12
+ - The twelve built-in icons (`ArrowIcon`, `BoxIcon`, `CheckIcon`, `CloseIcon`, `CouponIcon`, `DocumentIcon`, `HelpIcon`, `InfoIcon`, `MailIcon`, `PhoneIcon`, `PlusIcon`, `UndoIcon`) and `IconProps`: bring your own icons, any React content fits an icon slot (README, "Icons"). They still work, unchanged, and go in the next major version. The defaults the library draws itself stay
13
+
14
+ ### Fixed
15
+ - React 18 no longer warns about `useLayoutEffect` when the pills render on the server (L31)
16
+ - An `<img>` in an icon slot (a notification's, an action's, a field's) is sized like an `<svg>`, 1em square, instead of its file's own size
17
+
18
+ ## [9.2.0] - 2026-11-26
19
+ Placement changes through the circle, and new layouts for notifications: in rows on any host, and as cards or flags in a sidebar. One default changes: a pill whose placement changes now closes to a circle, travels, and opens at its new place; `moveThroughCircle={false}` keeps the old travel at full size. Nothing else to change in your code.
20
+
21
+ ### Added
22
+ - `moveThroughCircle` on `<Pill>` and `<MagicPill>` (default `true`), see Changed
23
+ - Notifications in rows: `notificationLayout="rows"` on `<MagicPill>`, `layout: "rows"` on a notification (it wins over the host's), or `layout="rows"` on `<PillNotification>`. The actions go under the message when they need the room (the message wraps, or there's an action and a panel's trigger), lined up with it; one action beside a short message stays on its line. On every host. A sidebar slides to and from a notification in rows with `swap="always"`, turning as it goes
24
+ - Notifications as cards, in a sidebar: `notificationLayout="card"` or `layout: "card"`. A column of the sidebar's width, at least `--mp-card-width` (`12.5rem`): the icon on top, the divider across, the message centred, the actions full width with their labels. The sidebar stays vertical, through the circle, or sliding with `swap="always"`. A horizontal host shows it in one row
25
+ - A sidebar's flag: `notificationLayout="flag"` or `layout: "flag"`, on a `left` or `right` host with a base layer. The sidebar stays, usable, and the notification comes out of its edge as a pill of its own (`data-layout="flag"`), next to the navbar item it's about (`at`, its `href`) or in the middle. It pauses while pointed at or focused, slides to the next one and moves to its section, and opens its panel beside the sidebar. Its motion, a pop out of the sidebar with a short bridge while they part, will follow the Electron's once it's designed. Elsewhere, a flag shows in the pill itself
26
+ - Navbar links carry `data-href`, their item's `href` as given (the rendered one may carry the app's base path)
27
+
28
+ ### Changed
29
+ - A pill whose placement (or orientation) changes goes there through the circle: it closes to a circle where it is, the circle travels, and it opens at its new place, instead of travelling at full size while its content is laid out for the new place. Nothing jumps, even from the bottom of the screen to a side, where it turns vertical inside the circle. `moveThroughCircle={false}` travels at full size as before; with reduced motion it still changes place at once
30
+ - A sidebar host (`placement="left"` or `"right"`) shows its notifications as horizontal pills, like any other host: it turns horizontal while it's a circle, and back once they're gone. Between its base layer and a notification, it goes through the circle even with `swap="always"`, unless the notification is in rows or a card
31
+
32
+ ### Fixed
33
+ - A vertical pill at rest is a circle: it kept the width of its hidden content (an oval as wide as the sidebar's labels)
34
+ - A pill that hides plays its whole exit on iOS: when the page scrolled and Safari's toolbar folded away at the same time, the viewport's change restyled the page and cut the exit's transitions short, so the pill vanished at once. The exit (the content fading, the scale and the visibility) is now played by script on top of the stylesheet, with the same timings; a pill asked back mid-way grows back from where it was, as before
35
+ - Form fields draw their focus ring for the keyboard only: browsers matched `:focus-visible` on text fields, lists, steppers and code fields even after a click or a tap. A field focused with a pointer now gets `data-pointer-focus`, and `forms.css` leaves it without a ring (the caret shows where typing goes). Tabbing to a field still draws it. An app's own global `:focus-visible` outline no longer shows on the bare controls either (text fields, the stepper's value, a list's options): browsers drew it after a click, and with the keyboard it doubled the field's ring
36
+
5
37
  ## [9.1.1] - 2026-11-26
6
38
  A fix for Next.js apps. Nothing to change in your code.
7
39
 
package/MIGRATING.md CHANGED
@@ -139,6 +139,8 @@ The active item also changes: an item is active on its own path and below, on wh
139
139
  ## 4. Icons
140
140
  Icons are components now, and any React content works as an icon.
141
141
 
142
+ > **The built-in icons below are deprecated since 9.3** (they still work, and go in the next major version): you can also pass your own icons right away, any SVG, image or icon component ([README, "Icons"](./README.md#icons)). The table is the quickest way off 8.x.
143
+
142
144
  | 8.x name | 9 component |
143
145
  |---|---|
144
146
  | `info` | `InfoIcon` |
package/README.md CHANGED
@@ -3,10 +3,7 @@ Let it empower you.
3
3
 
4
4
  > **9.0.0 is the first stable release of Magic Pill**; earlier versions are deprecated. Upgrading from 8.x? Read the [migration guide](./MIGRATING.md). 8.x is documented in the [8.1.0 README](https://github.com/CedricTheveneau/Magic-Pill/tree/v8.1.0#readme).
5
5
 
6
- **[Try it on the live demo](https://cedrictheveneau.github.io/Magic-Pill/)**: the playground, the templates and the building blocks.
7
-
8
- #### Thank you !!
9
- Thank you for your patience and to all people who already have shown interest in Magic Pill, it's my very first npm package and I couldn't ask for a better reception of my package after only a few days after its initial release.
6
+ **[Try it on the live demo](https://cedrictheveneau.github.io/Magic-Pill/)**: the playground, the templates, the building blocks, and [the docs](https://cedrictheveneau.github.io/Magic-Pill/docs/) with live examples.
10
7
 
11
8
  ## Badges
12
9
  ![npm version](https://img.shields.io/npm/v/magic-pill?color=blue)
@@ -18,7 +15,7 @@ Thank you for your patience and to all people who already have shown interest in
18
15
  ## Introduction
19
16
  Magic Pill is **a design primitive, not just a notification library.** At its core is *the pill*: a dark, fully rounded, elevated container with a strong design language, and you can put anything inside it.
20
17
 
21
- On top of it come ready-made **templates** (a notification, a navbar) and a **controller** you can call from anywhere: `pill().notify(...)`. Use one pill as a discreet assistant at the bottom of the page, or several pills together (a sidebar, a navbar, a modal) to build a whole interface.
18
+ On top of it come ready-made **templates** (a notification, a navbar, a form panel) and a **controller** you can call from anywhere: `pill().notify(...)`. Use one pill as a discreet assistant at the bottom of the page, or several pills together (a sidebar, a navbar, a modal) to build a whole interface.
22
19
 
23
20
  ## Features
24
21
  - [X] Two lines to get started: mount `<MagicPill />`, then call `pill().notify(...)` from anywhere, even outside React
@@ -26,11 +23,13 @@ On top of it come ready-made **templates** (a notification, a navbar) and a **co
26
23
  - [X] Several named pills on one page, at any edge or corner, inline, or as a modal; pills that share a spot line up instead of overlapping
27
24
  - [X] Anything inside: messages, icons and panels are React content; build your own templates from the same parts
28
25
  - [X] Shape-changing animations (circle ↔ pill ↔ panel) at the pill's real size, notifications that slide into each other, a pill that travels when its placement changes, all respecting reduced motion
26
+ - [X] Notifications laid out the way the pill is: in one row, in rows, and in a sidebar as cards or as a flag out of its edge
29
27
  - [X] Forms: fields on native controls, in a panel or in the pill, validated by the browser, and a calendar (optional)
28
+ - [X] Themes (optional): glass and Liquid Glass, with refraction, a pointer light and adaptive tinting, or a theme of your own from the tokens
30
29
  - [X] Accessible: screen reader announcements, keyboard focus pauses the countdown, focus handling for panels and modals
31
30
  - [X] Works in any React 18+ app, including React Server Components (Next.js App Router), with any router
32
31
  - [X] Styles you can override without `!important`, design tokens, no fonts loaded behind your back
33
- - [X] Tiny: the quick start adds about **13.3 kB gzipped** to your app (10.2 kB of JavaScript + 3.1 kB of CSS, minified by your bundler), checked in CI. Unused parts are tree-shaken.
32
+ - [X] Tiny: the quick start adds about **16.5 kB gzipped** to your app (13.1 kB of JavaScript + 3.4 kB of CSS, minified by your bundler), checked in CI. Unused parts are tree-shaken.
34
33
  - [X] Written in TypeScript, zero runtime dependencies
35
34
 
36
35
  ## Installation
@@ -74,6 +73,8 @@ pill().notify({ icon: <CheckIcon />, message: "Saved!", variant: "success" });
74
73
 
75
74
  That's it. The pill pops in at the bottom of the page, stays for 5 seconds, then goes away.
76
75
 
76
+ > **Icons:** the examples use the built-in icons (`CheckIcon`…), which are **deprecated**: they still work, and go in the next major version. Any icon works instead, from your own SVGs to Lucide or Font Awesome: see [Icons](#icons).
77
+
77
78
  ### Fonts
78
79
  Magic Pill loads no fonts: it uses your page's fonts. For the signature look, an italic serif for messages (**Overlock**) and a bold sans for action labels (**Lexend**), point the two font tokens at them.
79
80
 
@@ -117,6 +118,8 @@ const id = pill().notify({
117
118
  | `panel` | `{ title?, titleAction?, content, footer?, trigger?, closeLabel?, closeExpanded? }` | A "Learn more" action that grows the pill into a panel. `trigger` defaults to `{ icon: <PlusIcon />, label: "Learn more" }` and takes `expanded` too, `closeLabel` to `"Close"`: like the other labels, it shows on hover and focus, or all the time with `closeExpanded`. `titleAction` and `footer`: see [the panel](#the-primitive). |
118
119
  | `variant` | `"neutral"` · `"success"` · `"danger"` · any string | Defaults to the host's variant. |
119
120
  | `duration` | `number` (ms) | Defaults to the host's (5000). `Infinity` keeps it until dismissed. |
121
+ | `layout` | `"pill"` · `"rows"` · `"card"` · `"flag"` | Defaults to the host's `notificationLayout`. `"rows"` puts the actions under the message when they need the room: when the message wraps, or with an action and a panel. Under it, they line up with the message. `"card"`, in a sidebar: a column of the sidebar's width (at least `--mp-card-width`, `12.5rem`), the icon on top, the actions full width with their labels; a horizontal host shows it in one row. `"flag"`, in a `left` or `right` sidebar with a base layer: a pill of its own out of the sidebar's edge, while the sidebar stays (see below). |
122
+ | `at` | `string` | `"flag"` only: the `href` of the navbar item it's about, to come out next to it (matched as the navbar matches the current page). Default: the middle of the sidebar. |
120
123
  | `id` | `string` | Notifying again with the same id updates the notification in place. |
121
124
  | `announce` | `string` · `false` | What screen readers hear. Defaults to the message's text. |
122
125
  | `onDismiss` | `(id, reason) => void` | `reason` is `"timeout"`, `"action"`, `"dismissed"` or `"cleared"`. |
@@ -182,6 +185,7 @@ pill().notify({
182
185
  | `duration` | `5000` | Default display time for notifications. |
183
186
  | `idle` | `"hidden"` | With no base layer and nothing queued: `"hidden"`, or `"rest"` for a small resting circle showing `idleIcon`. |
184
187
  | `idleIcon` | none | The icon of the resting circle. |
188
+ | `notificationLayout` | `"pill"` | How notifications are laid out: in one row, `"rows"` (the actions under the message when they need the room), or, in a sidebar, `"card"` or `"flag"` (see `layout` above). A notification's own `layout` wins. |
185
189
  | `swap` | `"queue"` | Where new content slides into the open pill (out through the top, in from the bottom, the other way round for a top pill) instead of closing it to a circle and growing back: `"queue"` between notifications, `"always"` also between the base layer and notifications, `"never"` nowhere. |
186
190
  | `linkComponent` | `<a>` | Renders notification actions that have an `href`, e.g. Next's `Link`. |
187
191
  | `classNames` | none | Classes for the notification's parts: `icon`, `divider`, `message`, `actions`, `action`, `panel`. |
@@ -260,6 +264,9 @@ Give each host a name, and target it with `pill(name)`:
260
264
  pill("sidebar").notify({ message: "3 new posts" });
261
265
  pill("assistant").notify({ icon: <HelpIcon />, message: "Need a hand?", duration: Infinity });
262
266
  ```
267
+ A sidebar's notifications are pills like the others: it turns horizontal for them while it's a circle, and back once they're gone. Between its base layer and a notification it goes through the circle, even with `swap="always"`, unless the notification is in `rows` (it slides, turning as it goes) or a `card`: a card stays in the sidebar's column, and slides like any other content.
268
+
269
+ **A flag** (`notificationLayout="flag"`, `left`/`right` sidebars) leaves the sidebar where it is, usable: the notification comes out of its edge as a pill of its own (`[data-layout="flag"]`), next to the section it's about (`at`), and goes back into it. Pointing at it or focusing it pauses it; the next one slides in it, and it moves to its own section. Its panel opens beside the sidebar, in the middle of the screen. Its motion (a pop out of the sidebar, with a short bridge while they part) will follow the Electron's once it's designed.
263
270
 
264
271
  ## The primitive
265
272
  Everything above is built from `<Pill>` and its parts, and you can use them directly. A `<Pill>` you write yourself isn't connected to `pill()`: you control it with props.
@@ -279,11 +286,12 @@ import { Pill, PillActions, PillAction, PhoneIcon, MailIcon, DocumentIcon } from
279
286
 
280
287
  | `<Pill>` prop | Values | Default |
281
288
  |---|---|---|
282
- | `placement` | `"inline"` (in the page flow), `"top"`, `"bottom"`, `"left"`, `"right"`, `"top-start"`, `"top-end"`, `"bottom-start"`, `"bottom-end"` (fixed; `start`/`end` follow the text direction), `"overlay"` (a modal `<dialog>`). Change it and the pill travels to its new place (e.g. with the scroll, or for a guided tour), except to or from `"overlay"`. | `"inline"` |
289
+ | `placement` | `"inline"` (in the page flow), `"top"`, `"bottom"`, `"left"`, `"right"`, `"top-start"`, `"top-end"`, `"bottom-start"`, `"bottom-end"` (fixed; `start`/`end` follow the text direction), `"overlay"` (a modal `<dialog>`). Change it and the pill travels to its new place (e.g. with the scroll, or for a guided tour), through the circle (see `moveThroughCircle`), except to or from `"overlay"`. | `"inline"` |
283
290
  | `presence` / `defaultPresence` / `onPresenceChange` | `"hidden"`, `"rest"` (a circle with the icon only), `"compact"`, `"expanded"` (every action label shown), `"panel"` | `"compact"` |
284
291
  | `closeOnBackdropClick` | `boolean`, for the `"overlay"` placement: a click outside the modal does what Escape does (closes its panel if it's open, the modal otherwise). Call `event.preventDefault()` in your `onClick` to keep it open | `false` |
285
292
  | `backdrop` | `"plain"`, `"glow"`, or any string, for the `"overlay"` placement: what's behind the modal (see below) | `"plain"` |
286
293
  | `ladder` | `boolean`, for the fixed placements: pills with the same placement line up like the rungs of a ladder (see below). `false` leaves this one out: it stays in its spot and the others ignore it | `true` |
294
+ | `moveThroughCircle` | `boolean`, for the fixed placements: when the placement (or the orientation) changes, the pill closes to a circle where it is, the circle travels, and the pill opens at its new place, so its content never jumps on the way (from the bottom to a side, it turns vertical inside the circle). `false` travels at full size. At once with reduced motion | `true` |
287
295
  | `scene` / `sceneChange` | A name for what the pill shows: when it changes, the pill goes from one content to the other instead of jumping (see below). `"circle"`, `"slide"` or `"none"` | none / `"circle"` |
288
296
  | `orientation` | `"horizontal"`, `"vertical"` | `"vertical"` for `left`/`right` |
289
297
  | `variant` | `"neutral"`, `"success"`, `"danger"`, or any string (see [Styling](#styling)) | `"neutral"` |
@@ -473,12 +481,38 @@ import "magic-pill/calendar.css";
473
481
 
474
482
  With the keyboard: the arrows, Home and End (the week), Page Up and Page Down (the month; the year with Shift), Enter, and Escape, which closes it alone. The title goes up to the months, then to the years. It looks like open lists do (`--mp-list`, `--mp-on-list`): made of the fields, of the form's `look`, or of the pill's glass; of the pill itself when it's `inline`; `--mp-calendar-cell` (`2.25rem`) is its days' size. Weeks start on Monday.
475
483
 
476
- > **Your app's resets:** CSS like `input { border: 1px solid }` that isn't in a layer also reaches the pill's fields. Their look is on what surrounds the controls, so they only need to stay bare: scope such rules, or put them in a layer.
484
+ > **Your app's resets:** CSS like `input { border: 1px solid }` that isn't in a layer also reaches the pill's fields. Their look is on what surrounds the controls, so they only need to stay bare: scope such rules, or put them in a layer. A global `:focus-visible` outline is the exception, already handled: the focus ring is drawn around the field, for the keyboard only (not after a click or a tap), and the bare control never draws one of its own.
477
485
 
478
486
  ## Icons
479
- Twelve built-in icons, drawn in `currentColor` and decorative by default (`aria-hidden`). Any other icon or SVG works too: icons are just React content.
487
+ Bring your own: every `icon` (a notification's, an action's, a navbar item's, a field's, `idleIcon`, a panel's `trigger`) and `<PillIcon>` take any React content. The slot sizes and colours it for you:
488
+
489
+ - an `<svg>` or an `<img>` is drawn 1em square, whatever its own `width` and `height` (1.25rem in an action, larger as the leading icon);
490
+ - a font icon (Font Awesome's `<i>`, an emoji) takes the slot's font size;
491
+ - it's in the pill's text colour: draw your SVGs in `currentColor` to follow it (most icon libraries do);
492
+ - it's decorative (`aria-hidden`): the action's label or the message says what it means. Give `<PillIcon>` a `label` when the icon carries meaning of its own.
493
+
494
+ ```tsx
495
+ import { ShoppingCart } from "lucide-react"; // or Heroicons, Phosphor, Material…
496
+ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
497
+ import { faTruck } from "@fortawesome/free-solid-svg-icons";
498
+
499
+ pill().notify({ icon: <ShoppingCart />, message: "Added to your cart" });
500
+ pill().notify({ icon: <FontAwesomeIcon icon={faTruck} />, message: "Shipped today" });
501
+ pill().notify({ icon: <i className="fa-solid fa-truck" />, message: "Shipped today" }); // Font Awesome's web font
502
+ pill().notify({ icon: <img src="/icons/cart.svg" alt="" />, message: "Added to your cart" });
503
+ pill().notify({
504
+ icon: (
505
+ <svg viewBox="0 0 24 24" fill="currentColor">
506
+ <path d="M12 2 2 22h20L12 2Z" />
507
+ </svg>
508
+ ),
509
+ message: "Your own SVG",
510
+ });
511
+ ```
512
+
513
+ An `<img>` keeps its file's colours: `currentColor` only reaches inline SVGs and font icons.
480
514
 
481
- `ArrowIcon` · `BoxIcon` · `CheckIcon` · `CloseIcon` · `CouponIcon` · `DocumentIcon` · `HelpIcon` · `InfoIcon` · `MailIcon` · `PhoneIcon` · `PlusIcon` · `UndoIcon`
515
+ **The twelve built-in icons are deprecated** (`ArrowIcon` · `BoxIcon` · `CheckIcon` · `CloseIcon` · `CouponIcon` · `DocumentIcon` · `HelpIcon` · `InfoIcon` · `MailIcon` · `PhoneIcon` · `PlusIcon` · `UndoIcon`, and `IconProps`). They still work, unchanged, and editors strike them through; they go in the next major version. The library keeps the three it uses as defaults (the panel's trigger, its close button, the submit's tick), so nothing changes when you don't pass your own. To keep one of them, copy its SVG from `src/icons/` (MIT).
482
516
 
483
517
  ## Styling
484
518
  - **Easy to override:** every rule sits in a `magic-pill` cascade layer. Any CSS of yours that isn't in a layer wins, whatever its specificity, with no `!important`.
@@ -514,10 +548,12 @@ Twelve built-in icons, drawn in `currentColor` and decorative by default (`aria-
514
548
  | `--mp-text-size` / `--mp-title-size` | fluid, about 1rem / 1.5–2rem |
515
549
  | `--mp-padding` / `--mp-gap` / `--mp-action-size` | `0.875rem` / `1rem` / `2.75rem` |
516
550
  | `--mp-max-width` / `--mp-message-width` / `--mp-panel-width` | `48rem` / `24rem` / `32rem` |
551
+ | `--mp-card-width` | `12.5rem`: a sidebar's notification card, at the least (it keeps the sidebar's width if that's wider) |
517
552
  | `--mp-radius-panel` / `--mp-shadow` | `2.5rem` / a soft drop shadow |
518
553
  | `--mp-offset` / `--mp-z-index` | `1.5rem` from the viewport edges (plus safe areas) / `50` |
519
554
  | `--mp-backdrop` / `--mp-backdrop-blur` | the overlay's backdrop: `rgb(20 20 20 / 0.4)` / no blur |
520
555
  | `--mp-duration-enter` / `--mp-duration-change` / `--mp-duration-exit` | `500ms` / `250ms` / `300ms` |
556
+ | `--mp-duration-fade` | `150ms`: the content fades out before the pill shrinks, and in once it has grown |
521
557
  | `--mp-scale-origin` | `center`: where the pill pops in from and scales out to (e.g. `bottom` to come out of the edge) |
522
558
  | `--mp-align` | How a vertical pill lines up its items: `start`, `center` or `end` (following the text direction). By default, along the screen edge for a `left` or `right` pill, centred otherwise |
523
559
 
@@ -607,7 +643,7 @@ import { MagicPill, PillOptics } from "magic-pill";
607
643
  - **Safe links:** links only render relative, `http(s):`, `mailto:` and `tel:` URLs. Anything else, such as `javascript:`, renders without a link (with a warning in development). React 18 doesn't block those URLs by itself.
608
644
 
609
645
  ## TypeScript
610
- Everything is typed. The main types are `NotifyOptions`, `NotifyInput`, `PillController`, `MagicPillProps`, `PillProps`, `PillPresence`, `PillPlacement`, `PillVariant`, `PillTheme`, `NavItem` and `LinkComponent`.
646
+ Everything is typed, and every component's props are exported as `<Component>Props` (`MagicPillProps`, `PillProps`, `PillFormPanelProps`, `PillInputProps`…). The other main types are `NotifyOptions`, `NotifyInput`, `PillController`, `PillPresence`, `PillPlacement`, `PillVariant`, `PillTheme`, `NotificationLayout`, `NavItem`, `LinkComponent` and `SendHandler`.
611
647
 
612
648
  ## Build your own
613
649
  Maybe what I brought to the table wasn't enough but you like the idea behind it, that's why Magic Pill is under [MIT License](https://www.tldrlegal.com/license/mit-license), which means you can pretty much do whatever you want and build upon my own version of Magic Pill to bring it to new heights or just make it your own.
@@ -652,10 +688,12 @@ You can also send me emails anytime at [theveneaucedricpro@gmail.com](mailto:the
652
688
  Magic Pill is distributed under the [MIT License](https://www.tldrlegal.com/license/mit-license).
653
689
 
654
690
  ## What's next?
655
- | Coming next | Done in 9.0 |
691
+ | Coming next | Done in 9.x |
656
692
  |-----------|-----------|
657
- | A documentation site with live examples | Custom icons (any React content) |
658
- | Themes (glass, custom) | Animated morphing between contents, panels and placements |
659
- | Forms, toolbox and carousel indicator templates | Transitions between the navbar and notifications |
660
- | More built-in icons | Function triggers on actions (`onClick`) |
661
- | | Responsive styles, full documentation, tests |
693
+ | The Electron: a small circle that splits off the pill to keep an activity (a timer, a call, an upload) within reach | A documentation site with live examples |
694
+ | Toolbox and carousel indicator templates | Themes: glass, Liquid Glass, your own |
695
+ | More layouts for vertical pills | Forms and a calendar |
696
+ | Performance presets for the glass | Notification layouts: rows, cards, flags |
697
+ | Usage from a CDN | Pills that share a spot line up instead of overlapping |
698
+ | | Animated morphing between contents, panels and placements, through the circle |
699
+ | | Any icon (any React content), actions with `onClick` or `href`, full documentation, tests |
@@ -1,6 +1,6 @@
1
1
  import { ReactNode } from "react";
2
2
  import { LinkComponent, PillProps } from "../Pill/types.mjs";
3
- import { PillNotificationClassNames } from "../PillNotification/PillNotification.mjs";
3
+ import { NotificationLayout, PillNotificationClassNames } from "../PillNotification/PillNotification.mjs";
4
4
  import { SwapMode } from "./choreography.mjs";
5
5
  export interface MagicPillProps extends Omit<PillProps, "presence" | "defaultPresence" | "onPresenceChange" | "children" | "scene" | "sceneChange"> {
6
6
  /** Default "main". Two hosts with the same name warn in development. */
@@ -28,6 +28,14 @@ export interface MagicPillProps extends Omit<PillProps, "presence" | "defaultPre
28
28
  * between the base layer and notifications ("always"), or nowhere ("never").
29
29
  */
30
30
  swap?: SwapMode;
31
+ /**
32
+ * How notifications are laid out: in one row (default), with their actions
33
+ * under the message when they need the room (`rows`), or, in a sidebar
34
+ * (`left`/`right`), as a card in its column (`card`) or in a flag out of its
35
+ * edge, while the sidebar stays (`flag`). Elsewhere, a card and a flag show
36
+ * in one row. A notification's own `layout` wins.
37
+ */
38
+ notificationLayout?: NotificationLayout;
31
39
  /** Passed to notification actions that have an `href`. */
32
40
  linkComponent?: LinkComponent;
33
41
  classNames?: PillNotificationClassNames;
@@ -1,6 +1,6 @@
1
1
  import { ReactNode } from "react";
2
2
  import { LinkComponent, PillProps } from "../Pill/types.js";
3
- import { PillNotificationClassNames } from "../PillNotification/PillNotification.js";
3
+ import { NotificationLayout, PillNotificationClassNames } from "../PillNotification/PillNotification.js";
4
4
  import { SwapMode } from "./choreography.js";
5
5
  export interface MagicPillProps extends Omit<PillProps, "presence" | "defaultPresence" | "onPresenceChange" | "children" | "scene" | "sceneChange"> {
6
6
  /** Default "main". Two hosts with the same name warn in development. */
@@ -28,6 +28,14 @@ export interface MagicPillProps extends Omit<PillProps, "presence" | "defaultPre
28
28
  * between the base layer and notifications ("always"), or nowhere ("never").
29
29
  */
30
30
  swap?: SwapMode;
31
+ /**
32
+ * How notifications are laid out: in one row (default), with their actions
33
+ * under the message when they need the room (`rows`), or, in a sidebar
34
+ * (`left`/`right`), as a card in its column (`card`) or in a flag out of its
35
+ * edge, while the sidebar stays (`flag`). Elsewhere, a card and a flag show
36
+ * in one row. A notification's own `layout` wins.
37
+ */
38
+ notificationLayout?: NotificationLayout;
31
39
  /** Passed to notification actions that have an `href`. */
32
40
  linkComponent?: LinkComponent;
33
41
  classNames?: PillNotificationClassNames;