magic-pill 9.0.0-next.3 → 9.1.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/CHANGELOG.md +54 -25
- package/README.md +261 -17
- package/dist/MagicPill/MagicPill.d.mts +7 -1
- package/dist/MagicPill/MagicPill.d.ts +7 -1
- package/dist/MagicPill/MagicPill.js +40 -17
- package/dist/MagicPill/MagicPill.mjs +42 -19
- package/dist/MagicPill/choreography.js +1 -1
- package/dist/MagicPill/choreography.mjs +1 -1
- package/dist/Pill/Pill.js +53 -17
- package/dist/Pill/Pill.mjs +54 -18
- package/dist/Pill/PillContext.js +3 -1
- package/dist/Pill/PillContext.mjs +3 -1
- package/dist/Pill/PillPanel.d.mts +5 -5
- package/dist/Pill/PillPanel.d.ts +5 -5
- package/dist/Pill/PillPanel.js +28 -20
- package/dist/Pill/PillPanel.mjs +28 -20
- package/dist/Pill/morph.js +25 -7
- package/dist/Pill/morph.mjs +22 -8
- package/dist/Pill/scene.js +90 -0
- package/dist/Pill/scene.mjs +89 -0
- package/dist/Pill/themed.js +36 -0
- package/dist/Pill/themed.mjs +34 -0
- package/dist/Pill/types.d.mts +50 -0
- package/dist/Pill/types.d.ts +50 -0
- package/dist/Pill/zone.js +160 -0
- package/dist/Pill/zone.mjs +159 -0
- package/dist/PillForm/Calendar.d.mts +15 -0
- package/dist/PillForm/Calendar.d.ts +16 -0
- package/dist/PillForm/Calendar.js +371 -0
- package/dist/PillForm/Calendar.mjs +370 -0
- package/dist/PillForm/FormContext.d.mts +2 -0
- package/dist/PillForm/FormContext.d.ts +2 -0
- package/dist/PillForm/FormContext.js +8 -0
- package/dist/PillForm/FormContext.mjs +8 -0
- package/dist/PillForm/PillCheckbox.d.mts +8 -0
- package/dist/PillForm/PillCheckbox.d.ts +8 -0
- package/dist/PillForm/PillCheckbox.js +45 -0
- package/dist/PillForm/PillCheckbox.mjs +45 -0
- package/dist/PillForm/PillChoices.d.mts +39 -0
- package/dist/PillForm/PillChoices.d.ts +39 -0
- package/dist/PillForm/PillChoices.js +103 -0
- package/dist/PillForm/PillChoices.mjs +103 -0
- package/dist/PillForm/PillCode.d.mts +12 -0
- package/dist/PillForm/PillCode.d.ts +12 -0
- package/dist/PillForm/PillCode.js +60 -0
- package/dist/PillForm/PillCode.mjs +60 -0
- package/dist/PillForm/PillColor.d.mts +10 -0
- package/dist/PillForm/PillColor.d.ts +10 -0
- package/dist/PillForm/PillColor.js +56 -0
- package/dist/PillForm/PillColor.mjs +56 -0
- package/dist/PillForm/PillDate.d.mts +44 -0
- package/dist/PillForm/PillDate.d.ts +44 -0
- package/dist/PillForm/PillDate.js +193 -0
- package/dist/PillForm/PillDate.mjs +193 -0
- package/dist/PillForm/PillField.d.mts +38 -0
- package/dist/PillForm/PillField.d.ts +38 -0
- package/dist/PillForm/PillField.js +81 -0
- package/dist/PillForm/PillField.mjs +80 -0
- package/dist/PillForm/PillFields.d.mts +11 -0
- package/dist/PillForm/PillFields.d.ts +11 -0
- package/dist/PillForm/PillFields.js +21 -0
- package/dist/PillForm/PillFields.mjs +21 -0
- package/dist/PillForm/PillFile.d.mts +8 -0
- package/dist/PillForm/PillFile.d.ts +8 -0
- package/dist/PillForm/PillFile.js +55 -0
- package/dist/PillForm/PillFile.mjs +55 -0
- package/dist/PillForm/PillForm.d.mts +29 -0
- package/dist/PillForm/PillForm.d.ts +29 -0
- package/dist/PillForm/PillForm.js +66 -0
- package/dist/PillForm/PillForm.mjs +65 -0
- package/dist/PillForm/PillFormPanel.d.mts +24 -0
- package/dist/PillForm/PillFormPanel.d.ts +24 -0
- package/dist/PillForm/PillFormPanel.js +53 -0
- package/dist/PillForm/PillFormPanel.mjs +53 -0
- package/dist/PillForm/PillInput.d.mts +20 -0
- package/dist/PillForm/PillInput.d.ts +20 -0
- package/dist/PillForm/PillInput.js +84 -0
- package/dist/PillForm/PillInput.mjs +84 -0
- package/dist/PillForm/PillSelect.d.mts +23 -0
- package/dist/PillForm/PillSelect.d.ts +23 -0
- package/dist/PillForm/PillSelect.js +87 -0
- package/dist/PillForm/PillSelect.mjs +87 -0
- package/dist/PillForm/PillSlider.d.mts +17 -0
- package/dist/PillForm/PillSlider.d.ts +17 -0
- package/dist/PillForm/PillSlider.js +61 -0
- package/dist/PillForm/PillSlider.mjs +61 -0
- package/dist/PillForm/PillStepper.d.mts +13 -0
- package/dist/PillForm/PillStepper.d.ts +13 -0
- package/dist/PillForm/PillStepper.js +84 -0
- package/dist/PillForm/PillStepper.mjs +84 -0
- package/dist/PillForm/PillSubmit.d.mts +14 -0
- package/dist/PillForm/PillSubmit.d.ts +14 -0
- package/dist/PillForm/PillSubmit.js +90 -0
- package/dist/PillForm/PillSubmit.mjs +89 -0
- package/dist/PillForm/PillSwitch.d.mts +5 -0
- package/dist/PillForm/PillSwitch.d.ts +5 -0
- package/dist/PillForm/PillSwitch.js +38 -0
- package/dist/PillForm/PillSwitch.mjs +38 -0
- package/dist/PillForm/PillTextarea.d.mts +5 -0
- package/dist/PillForm/PillTextarea.d.ts +5 -0
- package/dist/PillForm/PillTextarea.js +49 -0
- package/dist/PillForm/PillTextarea.mjs +49 -0
- package/dist/PillForm/dates.d.mts +1 -0
- package/dist/PillForm/dates.d.ts +1 -0
- package/dist/PillForm/dates.js +155 -0
- package/dist/PillForm/dates.mjs +139 -0
- package/dist/PillForm/glyphs.js +65 -0
- package/dist/PillForm/glyphs.mjs +56 -0
- package/dist/PillForm/keyboard.js +34 -0
- package/dist/PillForm/keyboard.mjs +34 -0
- package/dist/PillForm/popover.js +84 -0
- package/dist/PillForm/popover.mjs +83 -0
- package/dist/PillForm/send.d.mts +6 -0
- package/dist/PillForm/send.d.ts +6 -0
- package/dist/PillForm/send.js +44 -0
- package/dist/PillForm/send.mjs +44 -0
- package/dist/PillForm/validity.js +74 -0
- package/dist/PillForm/validity.mjs +72 -0
- package/dist/PillNavbar/PillNavbar.d.mts +29 -6
- package/dist/PillNavbar/PillNavbar.d.ts +29 -6
- package/dist/PillNavbar/PillNavbar.js +35 -11
- package/dist/PillNavbar/PillNavbar.mjs +36 -12
- package/dist/PillNavbar/room.js +84 -0
- package/dist/PillNavbar/room.mjs +83 -0
- package/dist/PillNotification/PillNotification.d.mts +6 -0
- package/dist/PillNotification/PillNotification.d.ts +6 -0
- package/dist/PillNotification/PillNotification.js +3 -0
- package/dist/PillNotification/PillNotification.mjs +3 -0
- package/dist/PillOptics/PillOptics.d.mts +8 -0
- package/dist/PillOptics/PillOptics.d.ts +8 -0
- package/dist/PillOptics/PillOptics.js +195 -0
- package/dist/PillOptics/PillOptics.mjs +195 -0
- package/dist/PillOptics/adaptive.js +212 -0
- package/dist/PillOptics/adaptive.mjs +208 -0
- package/dist/PillOptics/lens.js +77 -0
- package/dist/PillOptics/lens.mjs +73 -0
- package/dist/PillOptics/light.js +37 -0
- package/dist/PillOptics/light.mjs +36 -0
- package/dist/calendar.css +499 -0
- package/dist/forms.css +1452 -0
- package/dist/index.d.mts +24 -3
- package/dist/index.d.ts +24 -3
- package/dist/index.js +36 -0
- package/dist/index.mjs +19 -1
- package/dist/styles.css +169 -19
- package/dist/themes.css +449 -0
- package/dist/utils/visuallyHidden.js +18 -0
- package/dist/utils/visuallyHidden.mjs +18 -0
- package/package.json +4 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,7 +1,51 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
## [9.1.0] - 2026-11-25
|
|
6
|
+
Themes (frosted glass, Liquid Glass, yours), forms and a calendar, scenes, and pills that make room for each other. Nothing to change in your code: forms, themes and the calendar are optional, each with its own stylesheet.
|
|
7
|
+
|
|
8
|
+
### Added
|
|
9
|
+
- Pills with the same fixed placement make room for each other instead of overlapping: the first one set up keeps its spot, the next ones line up after it (below it at the top of the screen, above it at the bottom, further in from the edge on the sides), and take its place when it hides or unmounts. An open panel covers the others. On by default, for `<MagicPill>` hosts too; `ladder={false}` leaves a pill out
|
|
10
|
+
- Themes: the `theme` prop on `<Pill>` and `<MagicPill>`, written to `data-theme`. `glass` and `liquid` come in an optional stylesheet, `magic-pill/themes.css`; any other name is yours to style, on the same glass if you like
|
|
11
|
+
- Set through tokens: `--mp-tint`, `--mp-status-tint`, `--mp-frost`, `--mp-panel-frost`, `--mp-rays`, `--mp-light`, `--mp-light-angle`, `--mp-light-color`, `--mp-vibrancy`, `--mp-readable`
|
|
12
|
+
- Text stays readable whatever the page shows behind the pill, with no script: a veil worked out from the pill's own colour. `--mp-readable: 0` opts out
|
|
13
|
+
- `<PillOptics />`, rendered once, for what CSS can't do: refraction (`--mp-refraction`, `--mp-edge`, `--mp-fringe`; Chromium only), a light that follows the pointer (`--mp-light-follow`), and adaptive tinting, which takes the colours of the page behind the pill and turns it light over light pages (`--mp-adaptive`, `--mp-adaptive-surface`, `--mp-adaptive-on-surface`)
|
|
14
|
+
- `--mp-action-glass: 1` makes the actions of the same glass as the pill: the light on their edges and, with `<PillOptics>`, their own refraction and frosting
|
|
15
|
+
- Solid when the system asks for less transparency, more contrast or forced colours, and where the browser can't draw it
|
|
16
|
+
- The modal's backdrop: `--mp-backdrop-blur` blurs the page behind it, and `backdrop="glow"` (with `magic-pill/themes.css`) adds two soft lights drifting over it (`--mp-glow-1`, `--mp-glow-2`, `--mp-glow-duration`), still with reduced motion. Any other `backdrop` is written to `data-backdrop`, for one of your own
|
|
17
|
+
- `--mp-action-rim`, `--mp-action-current` and `--mp-on-action-current`: an outline for the actions, and the current page's own colours. Together with `--mp-action`, they make actions solid or see-through on any theme
|
|
18
|
+
- Text and action colours for each variant: `--mp-on-neutral`, `--mp-on-success`, `--mp-on-danger` (the text), `--mp-neutral-action`, `--mp-success-action`, `--mp-danger-action` (the actions) and `--mp-on-neutral-action`, `--mp-on-success-action`, `--mp-on-danger-action` (the actions' text), on every theme. They default to `--mp-on-surface`, `--mp-action` and `--mp-on-action`, so nothing changes without them
|
|
19
|
+
- Panels: `titleAction`, an action at the end of the title's row, and `footer`, actions before the close button, which is then an outline. In notifications' `panel` too. Tokens: `--mp-accent`, `--mp-on-accent`, `--mp-close`, `--mp-on-close`, `--mp-close-rim`
|
|
20
|
+
- Several panels in one pill: a `name` on `<PillPanel>`, the same `panel` on `<PillPanelTrigger>`, and `openPanel(name?)` and `closePanel()` from `usePill()`
|
|
21
|
+
- Navbar items that are actions (`{ onClick, label }`) or that open a panel (`{ panel, label }`), next to links. `NavItem` is now one of `NavLinkItem`, `NavActionItem` and `NavPanelItem`
|
|
22
|
+
- Scenes: `scene` on `<Pill>`, or on `<MagicPill>` for its base layer, names what it shows. When it changes, the pill goes from one content to the other through the circle, or sliding (`sceneChange="slide"`; `swap="always"` on the host), instead of jumping
|
|
23
|
+
- Forms, in an optional `magic-pill/forms.css`: fields on native controls, with no dependency, for panels and for the pill itself. The browser's validation shows under them, and the pill stays above the on-screen keyboard
|
|
24
|
+
- `PillForm` (`look`: solid, soft or outline, for every kind of field, open lists and calendars included, which are of the same glass as the pill on the glass themes; `layout`; `errors`; `disabled`; `busy`), `PillInput` (12 types, icons, suffixes, suggestions), `PillTextarea`, `PillSelect`, and `PillField` for a control of yours
|
|
25
|
+
- Tokens that follow the actions by default: `--mp-field`, `--mp-on-field`, `--mp-field-rim`, `--mp-field-size`, `--mp-field-radius`, `--mp-field-gap`, `--mp-field-scheme`, `--mp-placeholder`, `--mp-label-font`, `--mp-label-style`, `--mp-label-weight`, `--mp-error`, `--mp-list`, `--mp-on-list`, `--mp-picker`
|
|
26
|
+
- `PillSlider`, `PillSwitch`, `PillCheckbox`, `PillChoices` (a list, one bar where the choice slides, chips; one or several), `PillStepper` and `PillFields`. Tokens: `--mp-track`, `--mp-track-size`, `--mp-thumb`
|
|
27
|
+
- `PillCode` (a one-time code), `PillFile` and `PillColor`
|
|
28
|
+
- `PillDate`, with an optional `magic-pill/calendar.css`: a calendar in the pill's language for dates, months, weeks, times, and dates and times, in a popover or `inline`, with the native inputs' values, in the reader's language and with the keyboard
|
|
29
|
+
- `PillFormPanel`: a panel that is a form. It sends, waits, closes, or says what went wrong
|
|
30
|
+
- `PillSubmit`, the action that sends a form and says so meanwhile: `busyLabel`, one label or several that follow one another, also on `PillFormPanel`. `onSend` on `PillForm` gets the data, waits, and says what went wrong
|
|
31
|
+
- A form of the base layer that's being filled in isn't replaced by a notification, which waits for its panel to close
|
|
32
|
+
|
|
33
|
+
### Changed
|
|
34
|
+
- A pill's open panel sits one level above the other pills (`--mp-z-index` + 1) until it has closed
|
|
35
|
+
- A panel's close button shows its icon, and its label on hover and focus, like the other actions. `closeExpanded`, on `<PillPanel>` or in a notification's `panel`, always shows it
|
|
36
|
+
- Colours change together: the text's and the actions' now fade like the pill's
|
|
37
|
+
- TypeScript: `NavItem` is a union now, so an `interface` can't extend it: extend `NavLinkItem` instead
|
|
38
|
+
- Size, measured and checked in CI: the quick start (`MagicPill` + `pill()`) adds about 10.2 kB of gzipped JavaScript and 3.1 kB of gzipped CSS to an app; a hand-written `Pill` with its parts, about 6.2 kB of JavaScript. A form panel adds about 3.2 kB to the quick start, and the calendar about 5 kB, only for apps that use them
|
|
39
|
+
|
|
40
|
+
### Fixed
|
|
41
|
+
- A notification triggered with the keyboard from inside the pill (an action of the base layer, for instance) never timed out: the pill thought it still had the focus
|
|
42
|
+
- A panel's footer changed colour at once when the variant changed, ahead of the pill
|
|
43
|
+
- An action with no icon had more space after its label than before it
|
|
44
|
+
- A scrolled panel's text showed again under its close button
|
|
45
|
+
- A navbar too wide for its pill (a narrow screen, a long label) pushed its last items out of it: the open label folds while another item is pointed at or focused with the keyboard, and a label that still has no room ends with an ellipsis
|
|
46
|
+
|
|
47
|
+
## [9.0.0] - 2026-11-23
|
|
48
|
+
9.0.0 is the first stable release of Magic Pill; earlier versions are deprecated (upgrading from 8.x: [MIGRATING.md](./MIGRATING.md)). It's a breaking release with a new API, but most apps get shorter.
|
|
5
49
|
|
|
6
50
|
### Added
|
|
7
51
|
- The pill primitive: `Pill` with its parts `PillIcon`, `PillDivider`, `PillMessage`, `PillActions`, `PillAction`, `PillPanel` and `PillPanelTrigger`, plus the `usePill()` hook to write your own templates
|
|
@@ -10,7 +54,7 @@ Work towards 9.0.0, the first release with a stable API. It's a breaking release
|
|
|
10
54
|
- Horizontal or vertical orientation, and `neutral`, `success`, `danger` or custom variants
|
|
11
55
|
- Stateless parts and `PillAction` can be rendered by React Server Components without becoming client code
|
|
12
56
|
- The pill animates its real size, width and height together: a message that wraps to several lines, a panel opening or closing, a sidebar's labels unfolding. Its corners stay right at every frame: half the one-line pill's height, so a taller pill is a rounded rectangle, up to `--mp-radius-panel` for a panel
|
|
13
|
-
- Vertical pills line their items up along the screen edge they sit on (`left` or `right`), and a right-hand sidebar opens its labels towards the middle of the screen, so the icons stay in line; mirrored in right-to-left pages. The
|
|
57
|
+
- Vertical pills line their items up along the screen edge they sit on (`left` or `right`), and a right-hand sidebar opens its labels towards the middle of the screen, so the icons stay in line; mirrored in right-to-left pages. The `--mp-align` token (`start`, `center`, `end`) changes the alignment; an inline vertical pill stays centred
|
|
14
58
|
- When its `placement` changes, the pill travels to its new place from where it was, resizing on the way (e.g. into a sidebar), instead of jumping there: handy for a pill that follows the scroll, or a guided tour
|
|
15
59
|
- The overlay pops in and scales out like any other pill, and its backdrop fades in and out, in every browser. The dialog closes once its exit has played; its actions stop responding at once. With reduced motion, it all fades briefly
|
|
16
60
|
- `closeOnBackdropClick` closes the overlay (or its panel first, like Escape) with a click outside it. Off by default
|
|
@@ -18,50 +62,35 @@ Work towards 9.0.0, the first release with a stable API. It's a breaking release
|
|
|
18
62
|
- Link actions take a `linkComponent` (e.g. Next's `Link`) and only render relative, `http(s):`, `mailto:` and `tel:` URLs. Any other scheme, such as `javascript:`, renders no link
|
|
19
63
|
- Templates built from those parts:
|
|
20
64
|
- `PillNotification`: icon, message, an action (`onClick` or `href`) and an optional expandable panel. Every content is a React node, so nothing is parsed as HTML any more
|
|
21
|
-
- `PillNavbar`: a `<nav>` of icon links for any router (`pathname`, `linkComponent`). Items match whole path segments, the longest match wins, and the active link gets `aria-current="page"`
|
|
65
|
+
- `PillNavbar`: a `<nav>` of icon links for any router (`pathname`, `linkComponent`). Items match whole path segments (in linear time, whatever the URL), the longest match wins, and the active link gets `aria-current="page"`
|
|
22
66
|
- `<MagicPill>` and `pill(name)`: mount the host once, then call `pill().notify({...})` from anywhere, including outside React. This replaces the 8.x Context, Provider and Initializer (about 135 lines of user code)
|
|
23
67
|
- Notifications queue first in, first out, take the pill over, then hand it back to the host's **base layer** (its children, e.g. a `PillNavbar`), so navbar and notifications are no longer exclusive
|
|
24
68
|
- `update(id, patch)`, `dismiss(id?)`, `clear()`, and `notify()` with an existing `id` to update in place
|
|
25
|
-
- `duration` per notification or on the host (`Infinity` keeps it). The countdown pauses
|
|
69
|
+
- `duration` per notification or on the host (`Infinity` keeps it). The countdown pauses while a mouse or pen hovers the pill, on keyboard focus, with an open panel and in a hidden browser tab. A tap doesn't pause it
|
|
26
70
|
- Action clicks dismiss the notification unless the handler calls `event.preventDefault()`; `onDismiss(id, reason)` reports `timeout`, `action`, `dismissed` or `cleared`
|
|
27
71
|
- `render` for your own template, which keeps the queue, timing and animation
|
|
28
72
|
- `expanded: true` on a notification's action (or its panel trigger) keeps its label open, not only on hover and focus, so phones show it too
|
|
29
73
|
- Several named hosts per page (`<MagicPill name="sidebar">`), and `idle="rest"` for a discreet resting circle
|
|
30
|
-
- Shape changes: the next notification in the queue replaces the current one in one movement, without closing the pill: the current one slides out through the top while the pill resizes, and the next one comes in from the bottom (the other way round for a pill at the top of the screen). Other changes (the navbar and a notification) collapse to a circle, swap the content there and grow back. `swap="always"` slides between the base layer and notifications too, so it all feels like one pill; `swap="never"` uses the circle everywhere. With reduced motion, the pill fades instead
|
|
74
|
+
- Shape changes: the next notification in the queue replaces the current one in one movement, without closing the pill: the current one slides out through the top while the pill resizes, and the next one comes in from the bottom (the other way round for a pill at the top of the screen). Other changes (the navbar and a notification) collapse to a circle, swap the content there and grow back: the content fades out before the pill shrinks, and in once it has grown, so text never rewraps or gets cut off along the way. `swap="always"` slides between the base layer and notifications too, so it all feels like one pill; `swap="never"` uses the circle everywhere. With reduced motion, the pill fades instead
|
|
31
75
|
- Announcements go through a separate live region, so a hidden pill can leave the accessibility tree
|
|
32
76
|
- On the server, `pill()` does nothing (it warns in development), so requests never share notifications
|
|
33
77
|
- `usePillQueue(name)`: the queue as a hook, to build your own host
|
|
34
78
|
- Twelve icons as components (`ArrowIcon`, `BoxIcon`, `CheckIcon`, `CloseIcon`, `CouponIcon`, `DocumentIcon`, `HelpIcon`, `InfoIcon`, `MailIcon`, `PhoneIcon`, `PlusIcon`, `UndoIcon`): drawn in `currentColor`, decorative by default
|
|
35
79
|
- A new stylesheet, `magic-pill/styles.css`:
|
|
36
80
|
- every rule sits in a `magic-pill` cascade layer and targets `data-mp` attributes, so your own CSS overrides it without `!important` and no class names collide;
|
|
81
|
+
- global resets on links and buttons, such as `a { color: inherit }` or `button { background: none }`, leave the actions alone: their look lives on an inner `[data-mp="action-body"]`;
|
|
37
82
|
- it loads no fonts (it uses your page's fonts unless you set `--mp-font-text`/`--mp-font-accent`);
|
|
38
|
-
- it's sized in `rem`, fits phone screens and safe areas, and supports reduced motion and forced colours
|
|
83
|
+
- it's sized in `rem`, fits phone screens and safe areas, and supports reduced motion and forced colours;
|
|
84
|
+
- labels open on hover only on devices that can hover, so a tapped action doesn't stay open on touchscreens;
|
|
39
85
|
- the pill pops in and scales out from its centre; `--mp-scale-origin` changes that (e.g. `bottom` to come out of the edge a bottom pill sits on)
|
|
40
|
-
|
|
41
86
|
- A migration guide from 8.x, [MIGRATING.md](./MIGRATING.md), shipped in the package
|
|
42
87
|
- The README is rewritten for v9: quick start, notifications, the host and its base layer, the primitive, React Server Components, styling and tokens, accessibility and security
|
|
43
88
|
|
|
44
89
|
### Changed
|
|
45
|
-
- The published JavaScript is readable (not minified) and has no source maps
|
|
90
|
+
- The published JavaScript is readable (not minified) and has no source maps: your bundler minifies it, so it doesn't change what your app ships. The package is about 253 kB unpacked (201 kB for 8.1.0, minified and with source maps)
|
|
91
|
+
- The danger colour is darker (`#c2303e` instead of `#fc5d6a`), so the light text on it meets WCAG AA contrast
|
|
46
92
|
- Size, measured and checked in CI: the quick start (`MagicPill` + `pill()`) adds about 8.25 kB of gzipped JavaScript and 2.45 kB of gzipped CSS to an app (both minified, as your bundler does); a hand-written `Pill` with its parts, about 3.8 kB of JavaScript, most of it the size animation
|
|
47
93
|
|
|
48
|
-
### Fixed (since 9.0.0-next.0)
|
|
49
|
-
- Global resets on links and buttons, such as `a { color: inherit }` or `button { background: none }`, no longer blank out the pill's actions: their look now lives on an inner `[data-mp="action-body"]`
|
|
50
|
-
- In a narrow container, an inline pill wraps its message instead of cutting off its action
|
|
51
|
-
- On touchscreens, a tapped action no longer stays open: labels open on hover only on devices that can really hover. Keyboard focus, an expanded panel and the current page still open them everywhere
|
|
52
|
-
- When a notification takes the pill over (from the navbar, or the next one in the queue), its message no longer wraps one word per line while the pill grows: `<MagicPill>` shows new content closed first, then the pill opens around it
|
|
53
|
-
- Long text no longer looks clipped while the pill changes size. When the pill closes, its content fades out first, then the pill shrinks; when it opens, the pill grows first, then the content fades in
|
|
54
|
-
- When the app removes the host's base layer (e.g. `{showNavbar && <PillNavbar … />}`), the pill closes around it into a circle, then scales out, instead of losing its content at once and collapsing into a narrow oval
|
|
55
|
-
- The pill scales from its centre instead of the edge it sits on (see `--mp-scale-origin`)
|
|
56
|
-
- When the pill grows out of the circle (the navbar giving way to a notification, or the first notification), its message no longer shows on two lines for a moment before settling on one: it's laid out at its final width while the pill grows
|
|
57
|
-
- When a pill closes, its message no longer wraps onto one more line as it fades out: the size it closes from is measured to the fraction of a pixel
|
|
58
|
-
- A notification whose message wraps to two or three lines (e.g. on a phone) no longer jumps in height when it opens and closes: the pill animates to its measured size
|
|
59
|
-
- A panel's corners no longer snap from fully round to their radius at the end of the opening animation
|
|
60
|
-
- In a vertical pill, a label folds once the next one has unfolded, so the pill widens or narrows smoothly when the active item changes instead of narrowing in between. Labels now unfold at their real width
|
|
61
|
-
- A sidebar's panel keeps the panel width cap (`--mp-panel-width`) instead of running to the edge of the screen
|
|
62
|
-
- Security: `PillNavbar` matches paths in linear time. Stripping trailing slashes used a regular expression that could take seconds on a crafted URL made of many slashes (ReDoS)
|
|
63
|
-
- On touchscreens, a notification whose panel was opened and closed no longer stays until the next tap elsewhere. The countdown pauses for keyboard focus and for a mouse or pen hovering, not for a tap, and after a tap the panel gives the focus back without showing it as keyboard focus
|
|
64
|
-
|
|
65
94
|
### Removed
|
|
66
95
|
- The 8.x API: the `pillData` prop and `mode`, the types (`MagicPillType`, `Mode`, `NotificationIcon`, `CTAIcon`, `MagicPillNotification*`, `MagicPillNavbar*`), the 15 handlers (`updateMode` … `handleActiveNavItem`), `Icons`, `CTAIcons`, `getIconComponent` and `defaultPillData`
|
|
67
96
|
- The 8.x stylesheet: its `.magicPill`/`.CTA`/… classes, the `--mp__*` variables and the Google Fonts `@import`. The `magic-pill/magicpill.css` and `magic-pill/dist/magicpill.css` paths now serve the new stylesheet
|
package/README.md
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
# Magic Pill
|
|
2
2
|
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
|
+
|
|
6
|
+
**[Try it on the live demo](https://cedrictheveneau.github.io/Magic-Pill/)**: the playground, the templates and the building blocks.
|
|
5
7
|
|
|
6
8
|
#### Thank you !!
|
|
7
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.
|
|
@@ -21,18 +23,19 @@ On top of it come ready-made **templates** (a notification, a navbar) and a **co
|
|
|
21
23
|
## Features
|
|
22
24
|
- [X] Two lines to get started: mount `<MagicPill />`, then call `pill().notify(...)` from anywhere, even outside React
|
|
23
25
|
- [X] A notification queue on top of a **base layer** (e.g. a navbar): notifications take the pill over, then hand it back
|
|
24
|
-
- [X] Several named pills on one page, at any edge or corner, inline, or as a modal
|
|
26
|
+
- [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
|
|
25
27
|
- [X] Anything inside: messages, icons and panels are React content; build your own templates from the same parts
|
|
26
28
|
- [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
|
|
29
|
+
- [X] Forms: fields on native controls, in a panel or in the pill, validated by the browser, and a calendar (optional)
|
|
27
30
|
- [X] Accessible: screen reader announcements, keyboard focus pauses the countdown, focus handling for panels and modals
|
|
28
31
|
- [X] Works in any React 18+ app, including React Server Components (Next.js App Router), with any router
|
|
29
32
|
- [X] Styles you can override without `!important`, design tokens, no fonts loaded behind your back
|
|
30
|
-
- [X] Tiny: the quick start adds about **
|
|
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.
|
|
31
34
|
- [X] Written in TypeScript, zero runtime dependencies
|
|
32
35
|
|
|
33
36
|
## Installation
|
|
34
37
|
```bash
|
|
35
|
-
npm install magic-pill
|
|
38
|
+
npm install magic-pill
|
|
36
39
|
```
|
|
37
40
|
|
|
38
41
|
### Requirements
|
|
@@ -111,7 +114,7 @@ const id = pill().notify({
|
|
|
111
114
|
| `message` | `ReactNode` | Required (unless you use `render`). Any content, e.g. `<>Total: <strong>768.99$</strong></>`. Never parsed as HTML. |
|
|
112
115
|
| `icon` | `ReactNode` | The leading icon, followed by the divider. |
|
|
113
116
|
| `action` | `{ icon?, label, onClick }` or `{ icon?, label, href }`, plus `expanded?` | The round button. Its label shows on hover and focus, or all the time with `expanded: true` (phones don't hover). Clicking it dismisses the notification; call `event.preventDefault()` in `onClick` to keep it open. |
|
|
114
|
-
| `panel` | `{ title?, content, trigger?, closeLabel? }` | 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"`. |
|
|
117
|
+
| `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). |
|
|
115
118
|
| `variant` | `"neutral"` · `"success"` · `"danger"` · any string | Defaults to the host's variant. |
|
|
116
119
|
| `duration` | `number` (ms) | Defaults to the host's (5000). `Infinity` keeps it until dismissed. |
|
|
117
120
|
| `id` | `string` | Notifying again with the same id updates the notification in place. |
|
|
@@ -175,6 +178,7 @@ pill().notify({
|
|
|
175
178
|
|---|---|---|
|
|
176
179
|
| `name` | `"main"` | Which `pill(name)` controls it. Mount one host per name. |
|
|
177
180
|
| `children` | none | The **base layer**: shown whenever no notification is. Without it, the pill hides between notifications. |
|
|
181
|
+
| `scene` | none | A name for what the base layer shows: when it changes, the pill goes from one to the other (through the circle, or sliding with `swap="always"`) instead of jumping. |
|
|
178
182
|
| `duration` | `5000` | Default display time for notifications. |
|
|
179
183
|
| `idle` | `"hidden"` | With no base layer and nothing queued: `"hidden"`, or `"rest"` for a small resting circle showing `idleIcon`. |
|
|
180
184
|
| `idleIcon` | none | The icon of the resting circle. |
|
|
@@ -209,8 +213,24 @@ export function AppPill() {
|
|
|
209
213
|
```
|
|
210
214
|
|
|
211
215
|
- **Matching:** an item is active on its own path and below it, on whole segments: `/blog` is active on `/blog/my-post`, not on `/blogroll`. `/` is only active on `/`. When several items match, the longest `href` wins. Override with `match: "exact"` or `match: (pathname) => boolean`.
|
|
216
|
+
- **Items can be actions**, or open a panel of the same pill: `{ onClick, label, icon }` and `{ panel: "settings", label, icon }`, with `expanded: true` to always show their label. The panels sit next to the navbar:
|
|
217
|
+
|
|
218
|
+
```tsx
|
|
219
|
+
<MagicPill>
|
|
220
|
+
<PillNavbar
|
|
221
|
+
items={[
|
|
222
|
+
{ href: "/", label: "Home", icon: <BoxIcon /> },
|
|
223
|
+
{ onClick: skipSession, label: "Skip session", icon: <ArrowIcon />, expanded: true },
|
|
224
|
+
{ panel: "settings", label: "Timer settings", icon: <InfoIcon /> },
|
|
225
|
+
]}
|
|
226
|
+
/>
|
|
227
|
+
<PillPanel name="settings" title="Timer settings">…</PillPanel>
|
|
228
|
+
</MagicPill>
|
|
229
|
+
```
|
|
230
|
+
|
|
212
231
|
- **The active link** shows its label and gets `aria-current="page"`.
|
|
213
232
|
- **Without `pathname`**, the navbar reads `window.location.pathname` after mounting and on back/forward navigation. That misses client-side navigations, so pass `pathname` when you use a client-side router.
|
|
233
|
+
- **On a narrow screen**, when there's no room for the current page's label and the one you point at (or focus), the current one folds meanwhile. A label that still has no room ends with an ellipsis.
|
|
214
234
|
- **`aria-label`** defaults to `"Main"`.
|
|
215
235
|
|
|
216
236
|
**React Router:** its `Link` takes `to` instead of `href`. Wrap it once:
|
|
@@ -262,8 +282,12 @@ import { Pill, PillActions, PillAction, PhoneIcon, MailIcon, DocumentIcon } from
|
|
|
262
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"` |
|
|
263
283
|
| `presence` / `defaultPresence` / `onPresenceChange` | `"hidden"`, `"rest"` (a circle with the icon only), `"compact"`, `"expanded"` (every action label shown), `"panel"` | `"compact"` |
|
|
264
284
|
| `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
|
+
| `backdrop` | `"plain"`, `"glow"`, or any string, for the `"overlay"` placement: what's behind the modal (see below) | `"plain"` |
|
|
286
|
+
| `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` |
|
|
287
|
+
| `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"` |
|
|
265
288
|
| `orientation` | `"horizontal"`, `"vertical"` | `"vertical"` for `left`/`right` |
|
|
266
289
|
| `variant` | `"neutral"`, `"success"`, `"danger"`, or any string (see [Styling](#styling)) | `"neutral"` |
|
|
290
|
+
| `theme` | `"plain"`, `"glass"`, `"liquid"`, or any string (see [Themes](#themes)). The variant picks the colour, the theme the material | `"plain"` |
|
|
267
291
|
| `unstyled` | `boolean`: keep the behaviour, drop the look | `false` |
|
|
268
292
|
|
|
269
293
|
Any other prop (`className`, `aria-label`, `ref`…) goes to the element.
|
|
@@ -273,7 +297,19 @@ Any other prop (`className`, `aria-label`, `ref`…) goes to the element.
|
|
|
273
297
|
- `PillDivider`: the thin line after the icon.
|
|
274
298
|
- `PillMessage`: the message, in the italic serif.
|
|
275
299
|
- `PillActions` and `PillAction`: round buttons. `label` is required: it's the accessible name, and it shows on hover, on focus, with `expanded`, or at the `expanded` level. A `PillAction` is a `<button>` with `onClick`, or a link with `href` (through `linkComponent` if you pass one).
|
|
276
|
-
- `PillPanel` and `PillPanelTrigger`: content shown at the `panel` level, and the action that opens it. The panel takes the focus when it opens, closes on Escape or with its close button, and gives the focus back to the trigger.
|
|
300
|
+
- `PillPanel` and `PillPanelTrigger`: content shown at the `panel` level, and the action that opens it. The panel takes the focus when it opens, closes on Escape or with its close button (`closeLabel`, `closeIcon`, and `closeExpanded` to always show the label), and gives the focus back to the trigger. `titleAction` goes at the end of the title's row and `footer` before the close button, which is then quieter (an outline, `--mp-close`). **Several panels in one pill:** give each a `name`, and its trigger the same `panel`.
|
|
301
|
+
|
|
302
|
+
**Scenes:** when what a pill shows changes altogether, name it. The pill closes to a circle on the old content and opens on the new one, as a host does between its navbar and a notification; `sceneChange="slide"` slides one out and the other in, as between two notifications. The colour follows, each scene starts anew, and a focus that leaves with the old content goes to the pill. At once with reduced motion.
|
|
303
|
+
```tsx
|
|
304
|
+
<Pill scene={isIn ? "done" : "form"} variant={isIn ? "success" : "neutral"}>
|
|
305
|
+
{isIn ? <PillMessage>You're in!</PillMessage> : <PillForm onSend={subscribe}>…</PillForm>}
|
|
306
|
+
</Pill>
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
**Pills in the same spot:** pills with the same fixed `placement` make room for each other, `<MagicPill>` hosts included. The first one set up keeps its spot, and the next ones line up after it: below it at the top of the screen, above it at the bottom, further in from the edge on the `left` and `right`. Each one keeps its own `--mp-gap` from the one before it.
|
|
310
|
+
- When a pill hides or unmounts, the ones after it take its place. A hidden pill keeps its turn, and takes its spot back when it shows again; one that unmounts comes back last.
|
|
311
|
+
- An open panel covers the other pills instead of pushing them.
|
|
312
|
+
- The order is the one the pills mount in. For a layout's pill to stay ahead of its pages' pills, render it before them.
|
|
277
313
|
|
|
278
314
|
**A modal:** `placement="overlay"` renders a native modal `<dialog>`, which brings a focus trap, Escape and an inert page with it. It pops in and scales out like any other pill, while its backdrop fades in and out: the dialog closes, and gives the focus back, once the exit has played. Add `closeOnBackdropClick` to also close it with a click outside (off by default, so a confirmation isn't dismissed by accident).
|
|
279
315
|
```tsx
|
|
@@ -286,8 +322,10 @@ Any other prop (`className`, `aria-label`, `ref`…) goes to the element.
|
|
|
286
322
|
</Pill>
|
|
287
323
|
```
|
|
288
324
|
|
|
325
|
+
Its backdrop is `--mp-backdrop`: a colour, or any CSS background. `--mp-backdrop-blur: 10px` also blurs the page. `backdrop="glow"` adds two soft lights drifting over them: import `magic-pill/themes.css`, and set `--mp-glow-1`, `--mp-glow-2` (their colours) and `--mp-glow-duration` (a full turn, `14s`). They stand still with reduced motion. Any other string is written to `data-backdrop`, for a backdrop of your own: `[data-mp="pill"][data-backdrop="dots"]::backdrop { … }`.
|
|
326
|
+
|
|
289
327
|
### Your own templates
|
|
290
|
-
Templates are plain arrangements of the parts, so yours work the same way. `usePill()` gives a part access to its pill (`presence`, `setPresence`, `placement`, `orientation`, `variant`). Inside a `<MagicPill>`, the `render` option puts your arrangement in the queue:
|
|
328
|
+
Templates are plain arrangements of the parts, so yours work the same way. `usePill()` gives a part access to its pill (`presence`, `setPresence`, `openPanel(name?)`, `closePanel()`, `placement`, `orientation`, `variant`). Inside a `<MagicPill>`, the `render` option puts your arrangement in the queue:
|
|
291
329
|
|
|
292
330
|
```tsx
|
|
293
331
|
pill().notify({
|
|
@@ -309,12 +347,134 @@ pill().notify({
|
|
|
309
347
|
|
|
310
348
|
### React Server Components
|
|
311
349
|
- The parts, `PillAction`, `PillNotification`, the icons and `pill()` have no `"use client"`. A Server Component can render them (and pass `linkComponent={Link}`) without shipping them to the browser.
|
|
312
|
-
- `Pill`, `MagicPill`, `PillPanel`, `PillPanelTrigger`, `PillNavbar`, `usePill` and `usePillQueue` are
|
|
350
|
+
- `Pill`, `MagicPill`, `PillPanel`, `PillPanelTrigger`, `PillNavbar`, `PillOptics`, the fields, `PillForm`, `PillSubmit`, `PillFormPanel`, `usePill` and `usePillQueue` are for the client. You can still render them from a Server Component.
|
|
313
351
|
- Call `pill()` from client code: event handlers, effects, client-side stores.
|
|
314
352
|
|
|
315
353
|
### Headless: `usePillQueue`
|
|
316
354
|
To build your own display on the same store: `const { current, queued } = usePillQueue("main");`.
|
|
317
355
|
|
|
356
|
+
## Forms
|
|
357
|
+
Fields for a panel, or for the pill itself, on native controls: phones keep their keyboards and date pickers, and autofill, `FormData` and form libraries work as usual. Their look comes in a third stylesheet, so other apps don't load it:
|
|
358
|
+
|
|
359
|
+
```tsx
|
|
360
|
+
import "magic-pill/styles.css";
|
|
361
|
+
import "magic-pill/forms.css"; // in any order
|
|
362
|
+
|
|
363
|
+
<MagicPill>
|
|
364
|
+
<PillNavbar items={[{ href: "/", label: "Home", icon: <BoxIcon /> }, { panel: "contact", label: "Write to us", icon: <MailIcon /> }]} />
|
|
365
|
+
<PillFormPanel name="contact" title="Write to us" submitLabel="Send" onSubmit={send}>
|
|
366
|
+
<PillInput name="email" label="Email" type="email" required />
|
|
367
|
+
<PillSelect name="about" label="About" options={["An order", "A return", "Something else"]} />
|
|
368
|
+
<PillTextarea name="message" label="Message" required maxLength={400} />
|
|
369
|
+
</PillFormPanel>
|
|
370
|
+
</MagicPill>;
|
|
371
|
+
|
|
372
|
+
async function send(data: FormData) {
|
|
373
|
+
await api.send(Object.fromEntries(data)); // the panel waits, then closes; if this throws, it stays open and says why
|
|
374
|
+
pill().notify({ message: "Sent", variant: "success" });
|
|
375
|
+
}
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
**`<PillFormPanel>`** is a `<PillPanel>` that is a form. It takes the panel's `name`, `title`, `titleAction`, `closeLabel`, `closeIcon` and `closeExpanded`, the form's `look`, `layout`, `errors` and `disabled`, and:
|
|
379
|
+
|
|
380
|
+
| Prop | |
|
|
381
|
+
|---|---|
|
|
382
|
+
| `onSubmit(data, event)` | Called once every field is valid. The panel closes after it, unless it returns `false`. While the promise it returns is pending, the fields wait; if it's rejected, the panel stays open, keeps what was typed and shows the error's message |
|
|
383
|
+
| `submitLabel` / `submitIcon` | The main action. Without a label there's none: for settings that apply at once |
|
|
384
|
+
| `busyLabel` / `busyInterval` | Its label while it waits: one, or several that follow one another (every 2500 ms; the last one stays). Default "Just a moment…" |
|
|
385
|
+
| `resetLabel` | An action in the title's row that resets the fields |
|
|
386
|
+
| `errorLabel` | Shown when the error has no message. Default "Something went wrong." |
|
|
387
|
+
|
|
388
|
+
**The fields.** Any other prop goes to the native control (`name`, `value`, `defaultValue`, `required`, `onChange`, `ref`…).
|
|
389
|
+
|
|
390
|
+
| Component | |
|
|
391
|
+
|---|---|
|
|
392
|
+
| `PillInput` | `type`: `text`, `email`, `password` (with a button that shows it), `search`, `tel`, `url`, `number`, `date`, `time`, `datetime-local`, `month`, `week`. Also `icon`, `suffix` (`"kg"`), `suggestions` (a list), `revealLabel` |
|
|
393
|
+
| `PillTextarea` | Grows with its text, and counts it with `maxLength` |
|
|
394
|
+
| `PillSelect` | `options`: strings, `{ value, label, disabled? }`, or groups (`{ label, options }`). `placeholder`, `icon`, and `layout="inline"` for a chip at the end of the row |
|
|
395
|
+
| `PillSlider` | A range, with its value at the end of the label's line: `format={(v) => `${v} min`}` |
|
|
396
|
+
| `PillSwitch` | On or off, at once |
|
|
397
|
+
| `PillCheckbox` | Something to agree to, sent with the form. `indeterminate` |
|
|
398
|
+
| `PillChoices` | One of several (radios), or several with `multiple` (checkboxes). `look`: `"list"`, `"segmented"` (one bar, where the choice slides) or `"chips"`. `options`: strings or `{ value, label, icon?, hint?, disabled? }`. `onChange(value)` |
|
|
399
|
+
| `PillStepper` | A number, one step at a time, with a `unit` |
|
|
400
|
+
| `PillCode` | A one-time code of `length` digits (6): one input, drawn as slots, so pasting and SMS autofill work. `onComplete(code)` |
|
|
401
|
+
| `PillFile` | Files: an area to click or drop them on, which names them. `multiple`, `accept`, `prompt` |
|
|
402
|
+
| `PillColor` | A colour |
|
|
403
|
+
| `PillDate` | A date, a month, a week, a time, or a date and time, in a calendar of the pill's instead of the browser's: see below |
|
|
404
|
+
| `PillFields` | Fields that go together: a `label`, `columns={2}`, `separators` |
|
|
405
|
+
| `PillSubmit` | The action that sends the form: a `PillAction` that says so meanwhile (`busyLabel`, `busyInterval`) |
|
|
406
|
+
| `PillField` | The label, the hint and the error, wired to a control of yours: `{(control) => <input {...control} />}` |
|
|
407
|
+
|
|
408
|
+
| Every field's props | |
|
|
409
|
+
|---|---|
|
|
410
|
+
| `label` | Required: it's the accessible name. `hideLabel` keeps it for assistive technology |
|
|
411
|
+
| `hint` | Under the control, and read with it |
|
|
412
|
+
| `error` | Your own error, e.g. from the server. It wins over the browser's |
|
|
413
|
+
| `optional` | Writes "optional" after the label, or your own word |
|
|
414
|
+
| `layout` | For text: the label above (`"stacked"`) or beside (`"inline"`) |
|
|
415
|
+
|
|
416
|
+
**`<PillForm>`** is a `<form>`, with:
|
|
417
|
+
|
|
418
|
+
| Prop | Default | |
|
|
419
|
+
|---|---|---|
|
|
420
|
+
| `look` | `"solid"` | Of every field, switches and choices included: `"solid"` (like the actions), `"soft"` (a hint of the pill's text), `"outline"`, or any string (written to `data-look`) |
|
|
421
|
+
| `layout` | `"stacked"` | Its text fields' labels: above, or beside (`"inline"`) |
|
|
422
|
+
| `errors` | `"inline"` | The browser's validation messages: under the fields, or in its bubbles (`"native"`) |
|
|
423
|
+
| `onSend(data, event)` | none | Instead of `onSubmit`: called once every field is valid, with no page load. While the promise it returns is pending, the form is busy; if it's rejected, the error's message shows (`errorLabel` if it has none) |
|
|
424
|
+
| `disabled` / `busy` | `false` | Disables every field (`busy`: while something is being sent; `onSend` does it for you) |
|
|
425
|
+
|
|
426
|
+
- **Validation** is the browser's own (`required`, `type`, `pattern`, `min`…), in the reader's language: on an attempt to submit, which focuses the first wrong field, or on leaving a field that was changed and is wrong. A message goes as soon as the value is right.
|
|
427
|
+
- **In the pill itself**, a `<PillForm>` is a row, with fields as tall as the actions: one field, one action.
|
|
428
|
+
- **On phones**, the pill stays above the keyboard while one of its fields has the focus.
|
|
429
|
+
- **Escape** closes an open list, not the panel.
|
|
430
|
+
- **Notifications wait** while a form of the base layer is open, so what's being typed isn't taken away. The base layer unmounts while a notification shows: keep what must last in your own state.
|
|
431
|
+
|
|
432
|
+
```tsx
|
|
433
|
+
<Pill>
|
|
434
|
+
<PillForm onSend={subscribe}>
|
|
435
|
+
<PillInput label="Your email" hideLabel type="email" name="email" required />
|
|
436
|
+
<PillSubmit icon={<ArrowIcon />} label="Subscribe" expanded busyLabel={["Adding you…", "Nearly there…"]} />
|
|
437
|
+
</PillForm>
|
|
438
|
+
</Pill>
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
| Token | Default |
|
|
442
|
+
|---|---|
|
|
443
|
+
| `--mp-field` / `--mp-on-field` / `--mp-field-rim` | the actions' colours and outline (the variant's, the theme's) |
|
|
444
|
+
| `--mp-placeholder` | `--mp-on-field` at 70% (92% on glass) |
|
|
445
|
+
| `--mp-field-size` / `--mp-field-radius` / `--mp-field-gap` | an action's height / half of it / 1.25 times `--mp-gap` |
|
|
446
|
+
| `--mp-field-scheme` | `light` (`dark` on glass, `soft` and `outline`): what the browser draws, such as a calendar |
|
|
447
|
+
| `--mp-label-font` / `--mp-label-style` / `--mp-label-weight` | `--mp-font-accent` / `normal` / `400` |
|
|
448
|
+
| `--mp-error` | `--mp-danger` mixed with the pill's text (its text alone on `success`, `danger` and glass) |
|
|
449
|
+
| `--mp-list` / `--mp-on-list` / `--mp-picker` | what opens over the page (a calendar, and a list where the browser lets it be drawn, Chromium): the fields' colours, the pill's own with the `soft` and `outline` looks, and the same glass as the pill on `glass` and `liquid`. What's chosen takes the accent, if you set one. `--mp-picker: none` keeps the system's lists |
|
|
450
|
+
| `--mp-accent` / `--mp-on-accent` | the pill's text / its surface: switches, sliders, ticks, the submit action |
|
|
451
|
+
| `--mp-track` / `--mp-track-size` / `--mp-thumb` | the pill's text at 48% / `4px` / `1.25rem`: what's off; a slider's thickness and thumb |
|
|
452
|
+
|
|
453
|
+
### The calendar
|
|
454
|
+
`PillInput type="date"` opens the browser's own calendar: the one people know on their device, and it costs nothing. `PillDate` draws one in the pill's language instead, with the same values, so one can replace the other. It's optional, with a stylesheet of its own:
|
|
455
|
+
|
|
456
|
+
```tsx
|
|
457
|
+
import "magic-pill/forms.css";
|
|
458
|
+
import "magic-pill/calendar.css";
|
|
459
|
+
|
|
460
|
+
<PillDate name="when" label="When" defaultValue="2026-12-24" min="2026-12-01" onChange={(value) => {}} />
|
|
461
|
+
<PillDate name="slot" label="Slot" type="datetime-local" step={900} />
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
| Prop | |
|
|
465
|
+
|---|---|
|
|
466
|
+
| `type` | `"date"`, `"month"`, `"week"`, `"time"`, `"datetime-local"` |
|
|
467
|
+
| `value` / `defaultValue` / `onChange(value)` | As the native input of that type writes it: `2026-12-24`, `2026-12`, `2026-W52`, `19:30`, `2026-12-24T19:30`. It's sent with the form the same way |
|
|
468
|
+
| `min` / `max` / `step` / `required` / `disabled` | As on the native input (`step` in seconds: how far apart the times are, five minutes by default) |
|
|
469
|
+
| `disabledDate(day)` | Days that can't be chosen, e.g. weekends |
|
|
470
|
+
| `inline` | Always there, in the form, instead of in a popover |
|
|
471
|
+
| `locale` / `firstDay` / `format` | The reader's by default: the language, the first day of the week, how the value is written (`Intl.DateTimeFormat` options) |
|
|
472
|
+
| `labels` / `placeholder` | Its own words (`today`, `now`, `clear`, `done`, `previous`, `next`, `hours`, `minutes`…) |
|
|
473
|
+
|
|
474
|
+
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
|
+
|
|
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.
|
|
477
|
+
|
|
318
478
|
## Icons
|
|
319
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.
|
|
320
480
|
|
|
@@ -322,18 +482,33 @@ Twelve built-in icons, drawn in `currentColor` and decorative by default (`aria-
|
|
|
322
482
|
|
|
323
483
|
## Styling
|
|
324
484
|
- **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`.
|
|
325
|
-
- **No collisions:** parts are selected by `data-mp` attributes (`[data-mp="pill"]`, `"icon"`, `"divider"`, `"message"`, `"actions"`, `"action"`, `"action-body"`, `"action-icon"`, `"label"`, `"panel"`, `"panel-title"`, `"panel-body"`, `"panel-footer"`, `"navbar"`), and states by `data-presence`, `data-placement`, `data-orientation` and `data-
|
|
485
|
+
- **No collisions:** parts are selected by `data-mp` attributes (`[data-mp="pill"]`, `"icon"`, `"divider"`, `"message"`, `"actions"`, `"action"`, `"action-body"`, `"action-icon"`, `"label"`, `"panel"`, `"panel-head"`, `"panel-title"`, `"panel-title-action"`, `"panel-body"`, `"panel-footer"`, `"navbar"`), and states by `data-presence`, `data-placement`, `data-orientation`, `data-variant`, `data-theme`, `data-backdrop` and `data-scheme`. There are no class names of ours to clash with yours.
|
|
326
486
|
- **Classes:** every part takes a `className`; templates and `<MagicPill>` take `classNames`.
|
|
327
487
|
- **Global resets are safe:** an action's look lives on its inner `[data-mp="action-body"]`, so app-wide rules such as `a { color: inherit }` or `button { background: none }` don't break it. To restyle an action, target `[data-mp="action-body"]`.
|
|
328
488
|
- **Tailwind CSS v4:** declare the layer order once, before your imports, so utilities win: `@layer theme, base, magic-pill, components, utilities;`.
|
|
329
|
-
- **Your own variants:** `variant="brand"` gives `data-variant="brand"`, so you can write `[data-variant="brand"] { --mp-surface: #4b2bd6; }
|
|
489
|
+
- **Your own variants:** `variant="brand"` gives `data-variant="brand"`, so you can write `[data-variant="brand"] { --mp-surface: #4b2bd6; }` (and `--mp-on-surface`, `--mp-action`… for its text and actions).
|
|
490
|
+
|
|
491
|
+
**Tokens:** set them on `:root`, on one pill, or anywhere in between. The text and action colours can be set for every pill at once, or for one variant:
|
|
330
492
|
|
|
331
|
-
|
|
493
|
+
```css
|
|
494
|
+
:root {
|
|
495
|
+
--mp-surface: #fffaf0; --mp-on-neutral: #2b2118; /* a light neutral pill, with dark text… */
|
|
496
|
+
--mp-neutral-action: #2b2118; --mp-on-neutral-action: #fffaf0; /* …and dark actions: success and danger stay as they are */
|
|
497
|
+
--mp-danger-action: #ffd7db; --mp-on-danger-action: #7a1420; /* pink actions on danger pills */
|
|
498
|
+
}
|
|
499
|
+
```
|
|
332
500
|
|
|
333
501
|
| Token | Default |
|
|
334
502
|
|---|---|
|
|
335
503
|
| `--mp-surface` / `--mp-on-surface` | `#141414` / `#f9f9f9` |
|
|
336
504
|
| `--mp-action` / `--mp-on-action` | `#f9f9f9` / `#141414` |
|
|
505
|
+
| `--mp-on-neutral` / `--mp-on-success` / `--mp-on-danger` | `--mp-on-surface`: the text of one variant |
|
|
506
|
+
| `--mp-neutral-action` / `--mp-success-action` / `--mp-danger-action` | `--mp-action`: the actions of one variant |
|
|
507
|
+
| `--mp-on-neutral-action` / `--mp-on-success-action` / `--mp-on-danger-action` | `--mp-on-action`: the text of one variant's actions |
|
|
508
|
+
| `--mp-action-rim` | `transparent`: a thin outline on the actions |
|
|
509
|
+
| `--mp-action-current` / `--mp-on-action-current` | the action's own colours: the action with `aria-current` (a navbar's current page) |
|
|
510
|
+
| `--mp-accent` / `--mp-on-accent` | the pill's text / its surface: what stands out, such as a panel's `titleAction` |
|
|
511
|
+
| `--mp-close` / `--mp-on-close` / `--mp-close-rim` | `transparent` / the pill's text / the same at 48%: the close button next to a panel's `footer` |
|
|
337
512
|
| `--mp-success` / `--mp-danger` | `#3f7253` / `#c2303e` |
|
|
338
513
|
| `--mp-font-text` / `--mp-font-accent` | `inherit` (see [Fonts](#fonts)) |
|
|
339
514
|
| `--mp-text-size` / `--mp-title-size` | fluid, about 1rem / 1.5–2rem |
|
|
@@ -341,7 +516,7 @@ Twelve built-in icons, drawn in `currentColor` and decorative by default (`aria-
|
|
|
341
516
|
| `--mp-max-width` / `--mp-message-width` / `--mp-panel-width` | `48rem` / `24rem` / `32rem` |
|
|
342
517
|
| `--mp-radius-panel` / `--mp-shadow` | `2.5rem` / a soft drop shadow |
|
|
343
518
|
| `--mp-offset` / `--mp-z-index` | `1.5rem` from the viewport edges (plus safe areas) / `50` |
|
|
344
|
-
| `--mp-backdrop` | the overlay's backdrop |
|
|
519
|
+
| `--mp-backdrop` / `--mp-backdrop-blur` | the overlay's backdrop: `rgb(20 20 20 / 0.4)` / no blur |
|
|
345
520
|
| `--mp-duration-enter` / `--mp-duration-change` / `--mp-duration-exit` | `500ms` / `250ms` / `300ms` |
|
|
346
521
|
| `--mp-scale-origin` | `center`: where the pill pops in from and scales out to (e.g. `bottom` to come out of the edge) |
|
|
347
522
|
| `--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 |
|
|
@@ -352,19 +527,87 @@ The pill fits small screens: sizes are in `rem`, fixed pills stay inside the vie
|
|
|
352
527
|
|
|
353
528
|
**Shape and motion:** the pill animates its real size whenever its presence changes (a script measures it; with `unstyled` or reduced motion it doesn't). Its corners are half the one-line pill's height, so a taller pill, such as a wrapped message, is a rounded rectangle; a panel's corners are `--mp-radius-panel`.
|
|
354
529
|
|
|
530
|
+
### Themes
|
|
531
|
+
A theme is the pill's material. `glass` (frosted glass) and `liquid` (clearer, thicker Liquid Glass) come in a second stylesheet, so plain pills don't load them. Import it once, before or after `styles.css`:
|
|
532
|
+
|
|
533
|
+
```tsx
|
|
534
|
+
import "magic-pill/styles.css";
|
|
535
|
+
import "magic-pill/themes.css";
|
|
536
|
+
|
|
537
|
+
<MagicPill theme="glass" />
|
|
538
|
+
```
|
|
539
|
+
|
|
540
|
+
Set these tokens like the others, on `:root`, on one pill, or anywhere in between. Booleans are `1` and `0`.
|
|
541
|
+
|
|
542
|
+
| Token | What it does | `glass` | `liquid` |
|
|
543
|
+
|---|---|---|---|
|
|
544
|
+
| `--mp-tint` | How much of the surface's colour stays, from 0 (clear) to 1 (solid) | `0.35` | `0.18` |
|
|
545
|
+
| `--mp-status-tint` | The least a `success` or `danger` pill keeps, so it still reads as one | `0.75` | `0.75` |
|
|
546
|
+
| `--mp-frost` | The blur of what's behind | `14px` | `3px` |
|
|
547
|
+
| `--mp-panel-frost` | The least blur behind an open panel (more text, more frosting); `0px` for none | `12px` | `12px` |
|
|
548
|
+
| `--mp-rays` | Ray casting: `0` turns refraction, the light and the tinting (vibrancy, adaptive) off | `1` | `1` |
|
|
549
|
+
| `--mp-light` | The strength of the light on the edges, 0 to 1 | `0.7` | `0.7` |
|
|
550
|
+
| `--mp-light-angle` / `--mp-light-color` | Where the light comes from, and its colour | `235deg` (top left) / `#fff` | same |
|
|
551
|
+
| `--mp-vibrancy` | How much the page's colours glow through (`1` is off) | `1.9` | `1.9` |
|
|
552
|
+
| `--mp-refraction` | With `<PillOptics>`: how much the edge bends what's behind, 0 to 1 | `0.16` | `0.55` |
|
|
553
|
+
| `--mp-edge` / `--mp-fringe` | With `<PillOptics>`: how wide that edge is, and how much it splits colours, 0 to 1 | `10px` / `0` | `22px` / `0.15` |
|
|
554
|
+
| `--mp-action-glass` | `1` makes the actions little lenses of the same glass: the light on their edges, and with `<PillOptics>`, their own refraction and frosting | `0` | `0` |
|
|
555
|
+
| `--mp-light-follow` | With `<PillOptics>`: `1` has the light follow the pointer | `0` | `0` |
|
|
556
|
+
| `--mp-adaptive` | With `<PillOptics>`: `1` tints the pill after the page behind it, and turns a neutral pill light over light pages | `0` | `0` |
|
|
557
|
+
| `--mp-adaptive-surface` / `--mp-adaptive-on-surface` | The colours of that light pill | `#f9f9f9` / `#141414` | same |
|
|
558
|
+
| `--mp-readable` | Keeps the text readable over any page: see below | `1` | `1` |
|
|
559
|
+
|
|
560
|
+
- **Readable by default:** a veil, worked out in CSS from the surface's colour and tint, keeps Magic Pill's colours at 4.5:1 or more over any page. `--mp-readable: 0` turns it off; the contrast is then yours to check, as it is for your own `--mp-action` colours.
|
|
561
|
+
- **Actions** are see-through on `glass` and `liquid`, solid on the others. Any action works on any theme:
|
|
562
|
+
|
|
563
|
+
```css
|
|
564
|
+
/* Solid actions on glass */
|
|
565
|
+
.my-pill { --mp-action: #f4c542; --mp-on-action: #141414; }
|
|
566
|
+
|
|
567
|
+
/* See-through actions on a plain pill, with less white on the status colours to keep 4.5:1 */
|
|
568
|
+
.my-pill { --mp-action: rgb(249 249 249 / 0.12); --mp-on-action: #f9f9f9; --mp-action-rim: rgb(249 249 249 / 0.2); }
|
|
569
|
+
.my-pill:is([data-variant="success"], [data-variant="danger"]) { --mp-action: rgb(249 249 249 / 0.06); }
|
|
570
|
+
```
|
|
571
|
+
|
|
572
|
+
- **Your own theme:** any other name. With colours only, `themes.css` isn't needed. With `--mp-tint` below 1, it's built on the same glass:
|
|
573
|
+
|
|
574
|
+
```css
|
|
575
|
+
[data-mp="pill"][data-theme="paper"] {
|
|
576
|
+
--mp-tint: 0.8; --mp-frost: 24px; --mp-light: 0;
|
|
577
|
+
--mp-surface: #fffaf0;
|
|
578
|
+
--mp-on-neutral: #2b2118; /* --mp-on-surface would also darken the text of success and danger */
|
|
579
|
+
}
|
|
580
|
+
```
|
|
581
|
+
|
|
582
|
+
- **Refraction and adaptive tinting** need a script: render `<PillOptics />` once, anywhere, e.g. in your root layout. It has no props: each pill's tokens decide, and it costs nothing to the pills that don't use it.
|
|
583
|
+
|
|
584
|
+
```tsx
|
|
585
|
+
import { MagicPill, PillOptics } from "magic-pill";
|
|
586
|
+
|
|
587
|
+
<MagicPill theme="liquid" style={{ "--mp-adaptive": 1 } as React.CSSProperties} />
|
|
588
|
+
<PillOptics />
|
|
589
|
+
```
|
|
590
|
+
|
|
591
|
+
- **Refraction** is drawn by Chromium browsers (Chrome, Edge, Arc, Dia…) that use the GPU. Safari and Firefox show the same glass without the bending. A Content Security Policy needs `img-src data:` for it.
|
|
592
|
+
- **Adaptive** reads colours, gradients, images, videos and canvases behind the pill. It can't read `url()` backgrounds, pictures from other sites (without CORS), or elements that ignore the pointer. It writes `data-scheme="light"` or `"dark"` on the pill. Status pills keep their colours.
|
|
593
|
+
- **Cost:** the graphics card does the work. With three Liquid Glass pills on a MacBook Pro (M2 Pro, 1440 × 900 at 2x), a frame takes about 1.1 ms, 1.4 ms with `--mp-action-glass: 1`. The colour fringe is most of it: with `--mp-fringe: 0`, 0.5 ms, glass actions included.
|
|
594
|
+
- Glass actions aren't refracted in an open panel, nor with reduced motion (pills fade then, which hides the page from them).
|
|
595
|
+
- The light doesn't follow a finger, nor anything with reduced motion.
|
|
596
|
+
- **Where the glass can't be drawn** (a browser without relative colours or `pow()` in CSS, less transparency, more contrast, forced colours), the pill has its plain look.
|
|
597
|
+
|
|
355
598
|
## Accessibility
|
|
356
599
|
- **Announcements:** each `<MagicPill>` has a polite live region that reads notifications out (or your `announce` text). A hidden pill leaves the accessibility tree.
|
|
357
600
|
- **Time to act:** the countdown pauses while a mouse hovers the pill, on keyboard focus, and while a panel is open. A tap doesn't pause it.
|
|
358
601
|
- **Panels and modals:** they take and give back the focus, and close on Escape. The overlay is a native modal `<dialog>`.
|
|
359
602
|
- **Accessible names:** every action has one (`label` is required), and icons are hidden from assistive technology.
|
|
360
|
-
- **Motion and contrast:** with `prefers-reduced-motion`, shape changes become short fades. In forced-colours mode, the shapes keep visible outlines.
|
|
603
|
+
- **Motion and contrast:** with `prefers-reduced-motion`, shape changes become short fades. In forced-colours mode, the shapes keep visible outlines. The glass [themes](#themes) keep text at 4.5:1 or more by default, and become solid when the system asks for less transparency or more contrast.
|
|
361
604
|
|
|
362
605
|
## Security
|
|
363
606
|
- **No HTML strings:** contents are React nodes and never parsed as HTML, so text from your users can't inject markup.
|
|
364
607
|
- **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.
|
|
365
608
|
|
|
366
609
|
## TypeScript
|
|
367
|
-
Everything is typed. The main types are `NotifyOptions`, `NotifyInput`, `PillController`, `MagicPillProps`, `PillProps`, `PillPresence`, `PillPlacement`, `PillVariant`, `NavItem` and `LinkComponent`.
|
|
610
|
+
Everything is typed. The main types are `NotifyOptions`, `NotifyInput`, `PillController`, `MagicPillProps`, `PillProps`, `PillPresence`, `PillPlacement`, `PillVariant`, `PillTheme`, `NavItem` and `LinkComponent`.
|
|
368
611
|
|
|
369
612
|
## Build your own
|
|
370
613
|
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.
|
|
@@ -411,7 +654,8 @@ Magic Pill is distributed under the [MIT License](https://www.tldrlegal.com/lice
|
|
|
411
654
|
## What's next?
|
|
412
655
|
| Coming next | Done in 9.0 |
|
|
413
656
|
|-----------|-----------|
|
|
414
|
-
|
|
|
415
|
-
|
|
|
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 |
|
|
416
660
|
| More built-in icons | Function triggers on actions (`onClick`) |
|
|
417
|
-
|
|
|
661
|
+
| | Responsive styles, full documentation, tests |
|
|
@@ -2,7 +2,7 @@ import { ReactNode } from "react";
|
|
|
2
2
|
import { LinkComponent, PillProps } from "../Pill/types.mjs";
|
|
3
3
|
import { PillNotificationClassNames } from "../PillNotification/PillNotification.mjs";
|
|
4
4
|
import { SwapMode } from "./choreography.mjs";
|
|
5
|
-
export interface MagicPillProps extends Omit<PillProps, "presence" | "defaultPresence" | "onPresenceChange" | "children"> {
|
|
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. */
|
|
7
7
|
name?: string;
|
|
8
8
|
/**
|
|
@@ -10,6 +10,12 @@ export interface MagicPillProps extends Omit<PillProps, "presence" | "defaultPre
|
|
|
10
10
|
* Notifications take the pill over, then it returns to this content.
|
|
11
11
|
*/
|
|
12
12
|
children?: ReactNode;
|
|
13
|
+
/**
|
|
14
|
+
* A name for what the base layer shows. When it changes, the pill goes from
|
|
15
|
+
* the old content to the new one as it does to a notification (see `swap`),
|
|
16
|
+
* instead of jumping.
|
|
17
|
+
*/
|
|
18
|
+
scene?: string | number;
|
|
13
19
|
/** Default display time for notifications, in ms. Default 5000. */
|
|
14
20
|
duration?: number;
|
|
15
21
|
/** With no base layer and nothing queued: hide (default) or rest as a circle. */
|
|
@@ -2,7 +2,7 @@ import { ReactNode } from "react";
|
|
|
2
2
|
import { LinkComponent, PillProps } from "../Pill/types.js";
|
|
3
3
|
import { PillNotificationClassNames } from "../PillNotification/PillNotification.js";
|
|
4
4
|
import { SwapMode } from "./choreography.js";
|
|
5
|
-
export interface MagicPillProps extends Omit<PillProps, "presence" | "defaultPresence" | "onPresenceChange" | "children"> {
|
|
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. */
|
|
7
7
|
name?: string;
|
|
8
8
|
/**
|
|
@@ -10,6 +10,12 @@ export interface MagicPillProps extends Omit<PillProps, "presence" | "defaultPre
|
|
|
10
10
|
* Notifications take the pill over, then it returns to this content.
|
|
11
11
|
*/
|
|
12
12
|
children?: ReactNode;
|
|
13
|
+
/**
|
|
14
|
+
* A name for what the base layer shows. When it changes, the pill goes from
|
|
15
|
+
* the old content to the new one as it does to a notification (see `swap`),
|
|
16
|
+
* instead of jumping.
|
|
17
|
+
*/
|
|
18
|
+
scene?: string | number;
|
|
13
19
|
/** Default display time for notifications, in ms. Default 5000. */
|
|
14
20
|
duration?: number;
|
|
15
21
|
/** With no base layer and nothing queued: hide (default) or rest as a circle. */
|