magic-pill 9.3.0 → 9.4.0-next.2
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 +29 -0
- package/README.md +114 -3
- package/dist/MagicPill/MagicPill.d.mts +51 -1
- package/dist/MagicPill/MagicPill.d.ts +51 -1
- package/dist/MagicPill/MagicPill.js +53 -4
- package/dist/MagicPill/MagicPill.mjs +55 -6
- package/dist/MagicPill/flag.js +1 -59
- package/dist/MagicPill/flag.mjs +1 -58
- package/dist/Pill/PillProgress.d.mts +12 -0
- package/dist/Pill/PillProgress.d.ts +12 -0
- package/dist/Pill/PillProgress.js +42 -0
- package/dist/Pill/PillProgress.mjs +42 -0
- package/dist/Pill/goo.js +576 -0
- package/dist/Pill/goo.mjs +566 -0
- package/dist/Pill/morph.js +11 -4
- package/dist/Pill/morph.mjs +10 -5
- package/dist/PillNavbar/PillNavbar.d.mts +8 -0
- package/dist/PillNavbar/PillNavbar.d.ts +8 -0
- package/dist/PillNavbar/PillNavbar.js +3 -2
- package/dist/PillNavbar/PillNavbar.mjs +3 -2
- package/dist/PillNavbar/room.d.mts +3 -0
- package/dist/PillNavbar/room.d.ts +2 -0
- package/dist/PillNavbar/room.js +89 -17
- package/dist/PillNavbar/room.mjs +89 -18
- package/dist/index.d.mts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +2 -0
- package/dist/index.mjs +2 -1
- package/dist/satellites/Actions.d.mts +12 -0
- package/dist/satellites/Actions.d.ts +11 -0
- package/dist/satellites/Actions.js +181 -0
- package/dist/satellites/Actions.mjs +177 -0
- package/dist/satellites/Orbitals.js +585 -0
- package/dist/satellites/Orbitals.mjs +585 -0
- package/dist/satellites/Satellites.js +634 -0
- package/dist/satellites/Satellites.mjs +634 -0
- package/dist/satellites/layout.js +209 -0
- package/dist/satellites/layout.mjs +209 -0
- package/dist/satellites/measure.js +25 -0
- package/dist/satellites/measure.mjs +24 -0
- package/dist/satellites/orbits.js +139 -0
- package/dist/satellites/orbits.mjs +136 -0
- package/dist/satellites/types.d.mts +58 -0
- package/dist/satellites/types.d.ts +58 -0
- package/dist/satellites.d.mts +5 -0
- package/dist/satellites.d.ts +5 -0
- package/dist/satellites.js +14 -0
- package/dist/satellites.mjs +12 -0
- package/dist/store/store.d.mts +103 -0
- package/dist/store/store.d.ts +103 -0
- package/dist/store/store.js +52 -1
- package/dist/store/store.mjs +52 -2
- package/dist/styles.css +322 -8
- package/package.json +11 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,35 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
### Added
|
|
6
|
+
- **Beta:** the Electron, in an optional entry, `magic-pill/satellites`: a small round pill that splits out of the host to keep a background activity in reach. `pill().electron()`, `updateElectron()` and `endElectron()`; on `<MagicPill>`, `satellites`, `pathname`, `electronSide`, `electronLine`, `keepElectronsOut`, `electronEnding` and `arrange`. It's tucked into the pill on the page that started it and while a notification has the pill, a tap goes back to that page, and the pill and its electrons stay centred as a group
|
|
7
|
+
- **Beta:** an electron's orbitals, its quick actions fanned out around it (`orbitals` on `pill().electron()`): opened by a long press (slide to one and release to run it), hovering with a mouse, or a tap (`orbitalsOpenOn`, with a first orbital going back), and the keyboard as a menu. On an arc away from the screen's edge, clear of the pill and the other electrons; when they don't all fit, a wheel that turns with the mouse wheel, a drag along it or the arrow keys, and stays open until a tap away. `orbitalLabels`, `orbitalsStayOpen`, `backLabel`, and the tokens `--mp-orbital-size`, `--mp-orbital-distance`, `--mp-orbital-spread`, `--mp-orbital-stagger`, `--mp-hover-delay` and `--mp-long-press`
|
|
8
|
+
- **Beta:** the page's actions, the design's wide atom: `usePillActions()` (from `magic-pill/satellites`) and `pill().setActions()` set one or more actions for the current page, next to the pill. `actionsStyle` (`"detached"`, a pill of their own that comes out of the host with the goo, or `"inside"`, after a divider), `actionsSide` (`"start"`, `"end"` or `"beside"`), `actionsOrientation` (`"auto"`, turning across when room runs out, `"horizontal"`, `"vertical"`) and `actionsLabel` on `<MagicPill>`
|
|
9
|
+
- **Beta:** `actionsWheel` on `<MagicPill>`: short of room, the page's actions show what fits and the others turn in, like the orbitals' wheel (a mouse wheel, a drag, a swipe or the arrow keys, each one snapping into place, the ends that hide some fading out), instead of turning across; in the pill, the cut starts right at the divider. And `nearestToPill` (`"actions"`, the default, or `"electrons"`): which are nearer the pill on a side they share
|
|
10
|
+
- `labels` on `<PillNavbar>`: which labels show at rest. `"auto"` (the default) shows the current page's while the pill has room for it and folds it when it doesn't, `"current"` always shows it, `"closed"` shows none. An electron stays in the pill's row when the navbar can fold to make room, and only goes above it when it still doesn't fit
|
|
11
|
+
- `PillProgress`: a progress ring around a value or an icon, in the text colour (`--mp-progress-size`, `--mp-progress-width`)
|
|
12
|
+
- The split's tokens, for a sidebar's flag: `--mp-duration-split` and `--mp-duration-join` (the enter and exit durations by default), `--mp-ease-split` (`bouncy`, the default, `pop`, `smooth` or any CSS easing), `--mp-goo` (`12`; `0` for no neck) and `--mp-electron-start` (`1`)
|
|
13
|
+
|
|
14
|
+
### Fixed
|
|
15
|
+
- Opening an electron's orbitals no longer stutters: each orbital's goo ran an SVG filter over the whole screen; it now only covers the two pills it joins (60 frames a second where it fell to about 30, with frames of up to 180 ms)
|
|
16
|
+
- Two electrons given an empty `id` are two electrons, instead of one flickering between them
|
|
17
|
+
- The page's actions grow away from the pill when an action's label opens on hover, instead of over it
|
|
18
|
+
- When the host changes placement or turns, its electrons and actions tuck in while it travels and come out at its new place; one that changes side or row (or actions that turn) goes back into the pill and out again, instead of sliding across it or jumping
|
|
19
|
+
- An electron's orbitals bulge out of its centre one after the other and fold back into it, quicker than they came and in the other order, as the design drew them. Next to another electron, two of them used to slide sideways into each other above it, merge and vanish; the electron's shadow flickered as they opened, and on the glass themes they switched colour at the end. On their way back, they're out of reach (a pointer over them can't hold them); when their electron ends from one of them, they're in at once; on their way out, one under the pointer doesn't light up
|
|
20
|
+
- With the orbitals open (they stay open after an action), a press on the electron slides onto one at once, instead of waiting for a long press again: it only worked once until a tap away
|
|
21
|
+
- For a notification, the electrons and the actions go into the pill with it, once their content has faded, instead of staying out while it closes and then chasing it; back from the notification, they come out once the pill has grown back, not out of a half-grown pill
|
|
22
|
+
- Beside the pill, the actions and the electrons make a row of their own, clear of each other and kept on the screen (on a phone, four actions covered the second electron and could run off the screen); automatic actions turn across there when the row is too long, and a row that still doesn't fit wraps into a further one
|
|
23
|
+
- The actions slide with the group (gathered to spread, another satellite coming or going), instead of jumping; and whether they turn across is decided again once a resize settles, not only after a render
|
|
24
|
+
- An orbital's label is a small pill of the electron's look (its theme and colours), instead of always light on dark
|
|
25
|
+
- A navbar too long for its pill scrolls inside it, instead of its last items being cut off: a sidebar's, and a horizontal one once its labels have folded; where the browser has scroll-driven animations, the ends that hide some fade out
|
|
26
|
+
- An electron and the page's actions come out of the pill and go back into it as the orbitals do, drawing themselves the whole way: on the glass themes they no longer switch colour at the end; changing sides, they no longer flicker between going in and coming out. For a notification, they go into the pill's centre as it closes to a circle
|
|
27
|
+
- The actions go into the pill and come out of it with the goo when `actionsStyle` changes, instead of disappearing; turned while they were in, they come out turned, instead of at their old shape first. Two satellites passing each other (`nearestToPill` changed) melt together as they meet
|
|
28
|
+
- An electron's orbitals keep clear of the page's actions, as they do of the other electrons
|
|
29
|
+
|
|
30
|
+
### Changed
|
|
31
|
+
- A navbar whose current page's label has no room folds it (`labels="auto"`, the new default), instead of the pill cutting its last items off. `labels="current"` keeps the old behaviour
|
|
32
|
+
- A sidebar's flag comes out of the sidebar's edge as a droplet, with goo: a neck forms between them, stretches and snaps, on a bouncy curve, and it goes back into the sidebar the same way. It no longer pops in at its spot with a short bridge, nor scales in and out. With reduced motion it still fades. On the glass themes, its blur waits until it's clear of the sidebar
|
|
33
|
+
|
|
5
34
|
## [9.3.0] - 2026-11-27
|
|
6
35
|
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
36
|
|
package/README.md
CHANGED
|
@@ -24,12 +24,13 @@ On top of it come ready-made **templates** (a notification, a navbar, a form pan
|
|
|
24
24
|
- [X] Anything inside: messages, icons and panels are React content; build your own templates from the same parts
|
|
25
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
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
|
|
27
|
+
- [X] **Beta:** the Electron, a small round pill that splits out of the main one to keep a background activity (a timer, an upload) in reach anywhere in the app (optional)
|
|
27
28
|
- [X] Forms: fields on native controls, in a panel or in the pill, validated by the browser, and a calendar (optional)
|
|
28
29
|
- [X] Themes (optional): glass and Liquid Glass, with refraction, a pointer light and adaptive tinting, or a theme of your own from the tokens
|
|
29
30
|
- [X] Accessible: screen reader announcements, keyboard focus pauses the countdown, focus handling for panels and modals
|
|
30
31
|
- [X] Works in any React 18+ app, including React Server Components (Next.js App Router), with any router
|
|
31
32
|
- [X] Styles you can override without `!important`, design tokens, no fonts loaded behind your back
|
|
32
|
-
- [X] Tiny: the quick start adds about **
|
|
33
|
+
- [X] Tiny: the quick start adds about **19 kB gzipped** to your app (15.5 kB of JavaScript + 3.7 kB of CSS, minified by your bundler), checked in CI. Unused parts are tree-shaken.
|
|
33
34
|
- [X] Written in TypeScript, zero runtime dependencies
|
|
34
35
|
|
|
35
36
|
## Installation
|
|
@@ -232,7 +233,7 @@ export function AppPill() {
|
|
|
232
233
|
</MagicPill>
|
|
233
234
|
```
|
|
234
235
|
|
|
235
|
-
- **The active link** shows its label and gets `aria-current="page"`.
|
|
236
|
+
- **The active link** shows its label and gets `aria-current="page"`. `labels` says which labels show at rest: `"auto"` (the default) shows the current page's while the pill has room for it, and folds it when it doesn't (next to an electron on a phone, or on a very narrow screen, where the pill used to cut its last items off); `"current"` always shows it; `"closed"` shows none. An item pointed at or focused shows its label in every case. A folded navbar has `data-folded`.
|
|
236
237
|
- **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.
|
|
237
238
|
- **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.
|
|
238
239
|
- **`aria-label`** defaults to `"Main"`.
|
|
@@ -266,7 +267,111 @@ pill("assistant").notify({ icon: <HelpIcon />, message: "Need a hand?", duration
|
|
|
266
267
|
```
|
|
267
268
|
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
|
|
|
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.
|
|
270
|
+
**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. It comes out of the sidebar's edge as a droplet (a neck forms between them, stretches and snaps) and goes back into it the same way: `--mp-duration-split` and `--mp-duration-join` time it, `--mp-ease-split` picks its curve (`bouncy`, the default, `pop`, `smooth` or any CSS easing), `--mp-goo` how sticky it is (`0`: no neck), `--mp-electron-start` the size it starts at.
|
|
271
|
+
|
|
272
|
+
## The Electron (beta)
|
|
273
|
+
A small round pill that splits out of the host to keep a background activity in reach while the person goes elsewhere in the app: a timer, a call, an upload. It's tucked into the pill on the page that started it, and comes out as a droplet (with the goo, like a sidebar's flag) anywhere else; a tap goes back to that page. **Beta:** it ships in `9.4.0-next` releases, and its API may still change.
|
|
274
|
+
|
|
275
|
+
It's optional: import `satellites` and give it to the host, with the current path.
|
|
276
|
+
|
|
277
|
+
```tsx
|
|
278
|
+
"use client";
|
|
279
|
+
import { MagicPill, PillNavbar } from "magic-pill";
|
|
280
|
+
import { satellites } from "magic-pill/satellites";
|
|
281
|
+
|
|
282
|
+
<MagicPill pathname={pathname} satellites={satellites} linkComponent={Link}>
|
|
283
|
+
<PillNavbar items={items} pathname={pathname} linkComponent={Link} />
|
|
284
|
+
</MagicPill>
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
```ts
|
|
288
|
+
// Anywhere in the app
|
|
289
|
+
const id = pill().electron({ label: "Focus timer", value: "25:00", valueText: "25 minutes left", progress: 0 });
|
|
290
|
+
pill().updateElectron(id, { value: "24:59", progress: 1 / 1500 }); // every second
|
|
291
|
+
pill().endElectron(id); // it goes back into the pill
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
| Option | Type | Notes |
|
|
295
|
+
|---|---|---|
|
|
296
|
+
| `label` | `string` | Required: its accessible name ("Focus timer"). |
|
|
297
|
+
| `value` / `valueText` | `string` | A short live text ("4:34", "64%"), and what screen readers read for it ("5 minutes left", default: `value`). Round `valueText`, so the name doesn't change every second. |
|
|
298
|
+
| `progress` | `number` (0 to 1) | Draws a progress ring around its content (`PillProgress`, which you can use in any pill). |
|
|
299
|
+
| `icon` | `ReactNode` | With `progress` and no `value`, it sits inside the ring. |
|
|
300
|
+
| `render` | `() => ReactNode` | Your own content instead of the ring, the value and the icon. |
|
|
301
|
+
| `href` | `string` | Where a tap goes back to (with the host's `linkComponent`). Default: the path it was started on. |
|
|
302
|
+
| `onClick` | `(event) => void` | Instead of going back: a button. |
|
|
303
|
+
| `hideOnOrigin` | `boolean` | Tucked into the pill while the current path is its `href` (or a page under it). Default `true`. |
|
|
304
|
+
| `variant` | as a pill's | Default: the host's. |
|
|
305
|
+
| `ending` | `"join"` · `"pop"` | How it leaves when it ends: back into the pill, or scaling out like any pill. Default: the host's `electronEnding` (`"join"`). |
|
|
306
|
+
| `announce` | `string` | Said once by screen readers whenever it changes, for a milestone ("Break time"). Its value is never announced on its own. |
|
|
307
|
+
| `orbitals` | `{ icon, label, onClick?, href?, id? }[]` | Its quick actions, fanned out around it (see below). |
|
|
308
|
+
| `backLabel` | `string` | With `orbitalsOpenOn="tap"`: the label of the first orbital, which goes back. Default `"Back"`. |
|
|
309
|
+
| `id` | `string` | Starting an electron with an id that's there updates it in place. |
|
|
310
|
+
|
|
311
|
+
| Host prop | Default | Notes |
|
|
312
|
+
|---|---|---|
|
|
313
|
+
| `satellites` | none | `satellites` from `magic-pill/satellites`. Without it, `pill().electron()` warns in development and shows nothing. |
|
|
314
|
+
| `pathname` | none | The current path, as for the navbar: an electron tucks in on its page. |
|
|
315
|
+
| `electronSide` | `"after"` | `"after"` (further along the edge), `"before"`, or `"beside"` (one row towards the page: above a bottom pill, next to a sidebar). |
|
|
316
|
+
| `electronLine` | `"along"` | Several electrons line up `"along"` the pill or stack `"across"` it. |
|
|
317
|
+
| `keepElectronsOut` | `false` | They tuck in while a notification has the pill (and come back once it has its base layer again); `true` keeps them out. |
|
|
318
|
+
| `electronEnding` | `"join"` | `"join"` or `"pop"`. |
|
|
319
|
+
| `arrange` | `"gather"` | `"gather"`: the pill and its electrons are centred as a group (or at the edge, for a `-start` or `-end` placement). `"spread"`: the pill stays where it is, the electrons go to the screen's edge (under the thumb on a tablet). |
|
|
320
|
+
| `orbitalsOpenOn` | `"press-hover"` | What opens an electron's orbitals: a long press, or hovering it with a mouse; `"press"`, a long press only; `"tap"`, a tap, with a first orbital going back. |
|
|
321
|
+
| `orbitalLabels` | `true` | The orbital under the finger, the pointer or the focus shows its label next to it. |
|
|
322
|
+
| `orbitalsStayOpen` | `true` | They stay open after one of them runs (Pause becomes Resume in place). |
|
|
323
|
+
|
|
324
|
+
**Orbitals** are an electron's quick actions, small round pills that bulge out of it with the goo:
|
|
325
|
+
|
|
326
|
+
```ts
|
|
327
|
+
pill().electron({
|
|
328
|
+
label: "Focus timer",
|
|
329
|
+
value: "4:34",
|
|
330
|
+
orbitals: [
|
|
331
|
+
{ icon: <PlusIcon />, label: "+1 min", onClick: addMinute },
|
|
332
|
+
{ icon: <PauseIcon />, label: "Pause", onClick: pause },
|
|
333
|
+
{ icon: <SkipIcon />, label: "Skip to the break", onClick: skip },
|
|
334
|
+
],
|
|
335
|
+
});
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
- A long press opens them. Keep pressing, slide to one (it's picked by its angle from the electron) and release to run it; released on none, they stay open until a tap away. With a mouse, hovering opens them too, and they close once the pointer leaves them.
|
|
339
|
+
- They fan out on an arc away from the screen's edge, clear of the pill, the other electrons and the screen's edges, moving out a little if they must. **When they don't all fit, they're a wheel:** the arc shows what fits and turns to show the others, with the mouse wheel, a drag along it, or the arrow keys (it brings the focused one into view). One past an end fades out (it peeks out faintly where its spot is clear). A wheel stays open until a tap away or Escape. `--mp-orbital-size` (an action's size), `--mp-orbital-distance` (`0.875rem`), `--mp-orbital-spread` (`auto`, or an angle such as `120deg`), `--mp-orbital-stagger` (`30ms`), `--mp-hover-delay` (`300ms`) and `--mp-long-press` (`450ms`) tune them.
|
|
340
|
+
- The keyboard opens them with the arrow pointing away from the edge, Shift+F10 or the context-menu key, and goes round them with the arrows, Home and End; Escape closes them and gives the focus back. An ARIA menu named after the electron.
|
|
341
|
+
|
|
342
|
+
**How it behaves:**
|
|
343
|
+
- **Short of room** (the pill and its electrons wider than the screen), a navbar folds its labels first (`labels="auto"`, its default); if they still don't fit, the last ones go beside the pill, one row towards the page, like the ladder.
|
|
344
|
+
- It splits and joins with the goo, on the split's tokens (`--mp-duration-split`, `--mp-duration-join`, `--mp-ease-split`, `--mp-goo`, `--mp-electron-start`, see [Styling](#styling)); `--mp-electron-gap` (`--mp-gap` by default) keeps it apart from the pill. With reduced motion, it fades.
|
|
345
|
+
- It's a link (or a button, or an image for neither) named after its `label` and `valueText`, with its own focus ring.
|
|
346
|
+
|
|
347
|
+
### The page's actions (beta)
|
|
348
|
+
The design's wide atom: one or more actions for the current page, next to the pill. A page sets them while it's mounted, and they go with it:
|
|
349
|
+
|
|
350
|
+
```tsx
|
|
351
|
+
"use client";
|
|
352
|
+
import { usePillActions } from "magic-pill/satellites";
|
|
353
|
+
|
|
354
|
+
const ACTIONS = [
|
|
355
|
+
{ icon: <PenIcon />, label: "Write", onClick: compose },
|
|
356
|
+
{ icon: <CheckIcon />, label: "Mark all as read", href: "/inbox/read" },
|
|
357
|
+
];
|
|
358
|
+
|
|
359
|
+
export function InboxPage() {
|
|
360
|
+
usePillActions(ACTIONS); // a stable array: a constant, or useMemo
|
|
361
|
+
return …;
|
|
362
|
+
}
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
`pill().setActions(items)` does the same from anywhere (`null` or none: they go). Each one is `{ icon, label, onClick?, href?, expanded?, id? }`, shown like the pill's own actions: the label on hover and focus, or all the time with `expanded`.
|
|
366
|
+
|
|
367
|
+
| Host prop | Default | Notes |
|
|
368
|
+
|---|---|---|
|
|
369
|
+
| `actionsStyle` | `"detached"` | `"detached"`: a pill of their own, which comes out of the host with the goo and goes back into it when the page has none (or while a notification has the pill). `"inside"`: in the pill itself, after a divider. |
|
|
370
|
+
| `actionsSide` | `"start"` | `"start"` or `"end"` (following the text direction: under the thumb you want), or `"beside"` (one row towards the page). |
|
|
371
|
+
| `actionsOrientation` | `"auto"` | `"auto"`: like the pill, turning across it when they'd leave the pill too little room (a column next to a bottom pill), and back once they're beside it. `"horizontal"` or `"vertical"`, always. |
|
|
372
|
+
| `actionsLabel` | `"Page actions"` | Their accessible name. |
|
|
373
|
+
|
|
374
|
+
Short of room, the actions turn across first (`"auto"`), then the last electrons, the actions and the first electron go beside the pill, in that order.
|
|
270
375
|
|
|
271
376
|
## The primitive
|
|
272
377
|
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.
|
|
@@ -554,6 +659,12 @@ An `<img>` keeps its file's colours: `currentColor` only reaches inline SVGs and
|
|
|
554
659
|
| `--mp-backdrop` / `--mp-backdrop-blur` | the overlay's backdrop: `rgb(20 20 20 / 0.4)` / no blur |
|
|
555
660
|
| `--mp-duration-enter` / `--mp-duration-change` / `--mp-duration-exit` | `500ms` / `250ms` / `300ms` |
|
|
556
661
|
| `--mp-duration-fade` | `150ms`: the content fades out before the pill shrinks, and in once it has grown |
|
|
662
|
+
| `--mp-duration-split` / `--mp-duration-join` | `--mp-duration-enter` / `--mp-duration-exit`: a sidebar's flag coming out of the sidebar and going back |
|
|
663
|
+
| `--mp-ease-split` | `bouncy`: the split's curve, `bouncy`, `pop`, `smooth` or any CSS easing (the join is always smooth) |
|
|
664
|
+
| `--mp-goo` | `12`: how sticky the split is, the blur behind the neck in px. `0`: a plain split, no neck |
|
|
665
|
+
| `--mp-electron-start` | `1`: the size a flag or an electron starts at as it comes out. `1`: full size, hidden behind the pill's edge. Lower: it starts small and grows on its way out |
|
|
666
|
+
| `--mp-electron-gap` | `--mp-gap`: between the pill and its electrons (beta) |
|
|
667
|
+
| `--mp-progress-size` / `--mp-progress-width` | `3.375rem` / `3.5`: `PillProgress`'s ring, and its stroke |
|
|
557
668
|
| `--mp-scale-origin` | `center`: where the pill pops in from and scales out to (e.g. `bottom` to come out of the edge) |
|
|
558
669
|
| `--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 |
|
|
559
670
|
|
|
@@ -2,6 +2,7 @@ import { ReactNode } from "react";
|
|
|
2
2
|
import { LinkComponent, PillProps } from "../Pill/types.mjs";
|
|
3
3
|
import { NotificationLayout, PillNotificationClassNames } from "../PillNotification/PillNotification.mjs";
|
|
4
4
|
import { SwapMode } from "./choreography.mjs";
|
|
5
|
+
import { ActionsOrientation, ActionsSide, ActionsStyle, ElectronEnding, ElectronLine, ElectronSide, NearestToPill, OrbitalsOpenOn, PillSatellites, SatelliteArrangement } from "../satellites/types.mjs";
|
|
5
6
|
export interface MagicPillProps extends Omit<PillProps, "presence" | "defaultPresence" | "onPresenceChange" | "children" | "scene" | "sceneChange"> {
|
|
6
7
|
/** Default "main". Two hosts with the same name warn in development. */
|
|
7
8
|
name?: string;
|
|
@@ -36,9 +37,58 @@ export interface MagicPillProps extends Omit<PillProps, "presence" | "defaultPre
|
|
|
36
37
|
* in one row. A notification's own `layout` wins.
|
|
37
38
|
*/
|
|
38
39
|
notificationLayout?: NotificationLayout;
|
|
39
|
-
/** Passed to notification actions that have an `href
|
|
40
|
+
/** Passed to notification actions that have an `href`, and to electrons going back. */
|
|
40
41
|
linkComponent?: LinkComponent;
|
|
41
42
|
classNames?: PillNotificationClassNames;
|
|
43
|
+
/**
|
|
44
|
+
* The current path, as for the navbar: an electron is tucked in while the
|
|
45
|
+
* person is on its page (beta).
|
|
46
|
+
*/
|
|
47
|
+
pathname?: string;
|
|
48
|
+
/**
|
|
49
|
+
* The electrons and the other satellites (beta): `satellites` from
|
|
50
|
+
* `magic-pill/satellites`. Without it, `pill().electron()` does nothing.
|
|
51
|
+
*/
|
|
52
|
+
satellites?: PillSatellites;
|
|
53
|
+
/** Where electrons go: further along the edge (default), before the pill, or beside it, one row towards the page (beta). */
|
|
54
|
+
electronSide?: ElectronSide;
|
|
55
|
+
/** Several electrons line up along the pill (default) or stack across it (beta). */
|
|
56
|
+
electronLine?: ElectronLine;
|
|
57
|
+
/** Electrons stay out while a notification shows. Default false: they tuck in (beta). */
|
|
58
|
+
keepElectronsOut?: boolean;
|
|
59
|
+
/** How an electron leaves when it ends: back into the pill (default) or scaling out (beta). */
|
|
60
|
+
electronEnding?: ElectronEnding;
|
|
61
|
+
/** Satellites gathered around the pill (default) or spread to the screen's edges (beta). */
|
|
62
|
+
arrange?: SatelliteArrangement;
|
|
63
|
+
/**
|
|
64
|
+
* What opens an electron's orbitals: a long press, or hovering it with a
|
|
65
|
+
* mouse (default); a long press only; or a tap, which then adds a first
|
|
66
|
+
* orbital going back (beta).
|
|
67
|
+
*/
|
|
68
|
+
orbitalsOpenOn?: OrbitalsOpenOn;
|
|
69
|
+
/** The label of the orbital under the finger, the pointer or the focus shows next to it. Default true (beta). */
|
|
70
|
+
orbitalLabels?: boolean;
|
|
71
|
+
/** Orbitals stay open after one of them runs. Default true (beta). */
|
|
72
|
+
orbitalsStayOpen?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* The current page's actions (`usePillActions()`): a pill of their own
|
|
75
|
+
* (default), or in the pill itself, after a divider (beta).
|
|
76
|
+
*/
|
|
77
|
+
actionsStyle?: ActionsStyle;
|
|
78
|
+
/** Where the page's actions go: the start side (default), the end side, or beside the pill (beta). */
|
|
79
|
+
actionsSide?: ActionsSide;
|
|
80
|
+
/** The page's actions run like the pill, turning across when room runs out (default), or horizontal, or vertical (beta). */
|
|
81
|
+
actionsOrientation?: ActionsOrientation;
|
|
82
|
+
/**
|
|
83
|
+
* Short of room, the page's actions show what fits and turn the rest in a
|
|
84
|
+
* wheel (a mouse wheel, a drag, the arrow keys), instead of turning across.
|
|
85
|
+
* Default false (beta).
|
|
86
|
+
*/
|
|
87
|
+
actionsWheel?: boolean;
|
|
88
|
+
/** On a side they share, the page's actions are nearer the pill (default), or the electrons (beta). */
|
|
89
|
+
nearestToPill?: NearestToPill;
|
|
90
|
+
/** The page's actions' accessible name. Default "Page actions" (beta). */
|
|
91
|
+
actionsLabel?: string;
|
|
42
92
|
}
|
|
43
93
|
/**
|
|
44
94
|
* The batteries-included pill: a <Pill> with a base layer, a queue of
|
|
@@ -2,6 +2,7 @@ import { ReactNode } from "react";
|
|
|
2
2
|
import { LinkComponent, PillProps } from "../Pill/types.js";
|
|
3
3
|
import { NotificationLayout, PillNotificationClassNames } from "../PillNotification/PillNotification.js";
|
|
4
4
|
import { SwapMode } from "./choreography.js";
|
|
5
|
+
import { ActionsOrientation, ActionsSide, ActionsStyle, ElectronEnding, ElectronLine, ElectronSide, NearestToPill, OrbitalsOpenOn, PillSatellites, SatelliteArrangement } from "../satellites/types.js";
|
|
5
6
|
export interface MagicPillProps extends Omit<PillProps, "presence" | "defaultPresence" | "onPresenceChange" | "children" | "scene" | "sceneChange"> {
|
|
6
7
|
/** Default "main". Two hosts with the same name warn in development. */
|
|
7
8
|
name?: string;
|
|
@@ -36,9 +37,58 @@ export interface MagicPillProps extends Omit<PillProps, "presence" | "defaultPre
|
|
|
36
37
|
* in one row. A notification's own `layout` wins.
|
|
37
38
|
*/
|
|
38
39
|
notificationLayout?: NotificationLayout;
|
|
39
|
-
/** Passed to notification actions that have an `href
|
|
40
|
+
/** Passed to notification actions that have an `href`, and to electrons going back. */
|
|
40
41
|
linkComponent?: LinkComponent;
|
|
41
42
|
classNames?: PillNotificationClassNames;
|
|
43
|
+
/**
|
|
44
|
+
* The current path, as for the navbar: an electron is tucked in while the
|
|
45
|
+
* person is on its page (beta).
|
|
46
|
+
*/
|
|
47
|
+
pathname?: string;
|
|
48
|
+
/**
|
|
49
|
+
* The electrons and the other satellites (beta): `satellites` from
|
|
50
|
+
* `magic-pill/satellites`. Without it, `pill().electron()` does nothing.
|
|
51
|
+
*/
|
|
52
|
+
satellites?: PillSatellites;
|
|
53
|
+
/** Where electrons go: further along the edge (default), before the pill, or beside it, one row towards the page (beta). */
|
|
54
|
+
electronSide?: ElectronSide;
|
|
55
|
+
/** Several electrons line up along the pill (default) or stack across it (beta). */
|
|
56
|
+
electronLine?: ElectronLine;
|
|
57
|
+
/** Electrons stay out while a notification shows. Default false: they tuck in (beta). */
|
|
58
|
+
keepElectronsOut?: boolean;
|
|
59
|
+
/** How an electron leaves when it ends: back into the pill (default) or scaling out (beta). */
|
|
60
|
+
electronEnding?: ElectronEnding;
|
|
61
|
+
/** Satellites gathered around the pill (default) or spread to the screen's edges (beta). */
|
|
62
|
+
arrange?: SatelliteArrangement;
|
|
63
|
+
/**
|
|
64
|
+
* What opens an electron's orbitals: a long press, or hovering it with a
|
|
65
|
+
* mouse (default); a long press only; or a tap, which then adds a first
|
|
66
|
+
* orbital going back (beta).
|
|
67
|
+
*/
|
|
68
|
+
orbitalsOpenOn?: OrbitalsOpenOn;
|
|
69
|
+
/** The label of the orbital under the finger, the pointer or the focus shows next to it. Default true (beta). */
|
|
70
|
+
orbitalLabels?: boolean;
|
|
71
|
+
/** Orbitals stay open after one of them runs. Default true (beta). */
|
|
72
|
+
orbitalsStayOpen?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* The current page's actions (`usePillActions()`): a pill of their own
|
|
75
|
+
* (default), or in the pill itself, after a divider (beta).
|
|
76
|
+
*/
|
|
77
|
+
actionsStyle?: ActionsStyle;
|
|
78
|
+
/** Where the page's actions go: the start side (default), the end side, or beside the pill (beta). */
|
|
79
|
+
actionsSide?: ActionsSide;
|
|
80
|
+
/** The page's actions run like the pill, turning across when room runs out (default), or horizontal, or vertical (beta). */
|
|
81
|
+
actionsOrientation?: ActionsOrientation;
|
|
82
|
+
/**
|
|
83
|
+
* Short of room, the page's actions show what fits and turn the rest in a
|
|
84
|
+
* wheel (a mouse wheel, a drag, the arrow keys), instead of turning across.
|
|
85
|
+
* Default false (beta).
|
|
86
|
+
*/
|
|
87
|
+
actionsWheel?: boolean;
|
|
88
|
+
/** On a side they share, the page's actions are nearer the pill (default), or the electrons (beta). */
|
|
89
|
+
nearestToPill?: NearestToPill;
|
|
90
|
+
/** The page's actions' accessible name. Default "Page actions" (beta). */
|
|
91
|
+
actionsLabel?: string;
|
|
42
92
|
}
|
|
43
93
|
/**
|
|
44
94
|
* The batteries-included pill: a <Pill> with a base layer, a queue of
|
|
@@ -12,6 +12,7 @@ const require_timing = require("../utils/timing.js");
|
|
|
12
12
|
const require_visuallyHidden = require("../utils/visuallyHidden.js");
|
|
13
13
|
const require_choreography = require("./choreography.js");
|
|
14
14
|
const require_flag = require("./flag.js");
|
|
15
|
+
const require_goo = require("../Pill/goo.js");
|
|
15
16
|
const require_useChoreography = require("./useChoreography.js");
|
|
16
17
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
17
18
|
|
|
@@ -82,13 +83,29 @@ const notificationIn = ({ scene, presence }) => scene.kind === "notification" &&
|
|
|
82
83
|
* The batteries-included pill: a <Pill> with a base layer, a queue of
|
|
83
84
|
* notifications fed by pill(name), and a live region that announces them.
|
|
84
85
|
*/
|
|
85
|
-
const MagicPill = (0, react.forwardRef)(function MagicPill({ name = "main", children, scene, duration = DEFAULT_DURATION, idle = "hidden", idleIcon, swap = "queue", notificationLayout = "pill", linkComponent, classNames, placement = "bottom", orientation, moveThroughCircle, variant, onPointerEnter, onPointerLeave, onFocus, onBlur, ...rest }, forwardedRef) {
|
|
86
|
+
const MagicPill = (0, react.forwardRef)(function MagicPill({ name = "main", children, scene, duration = DEFAULT_DURATION, idle = "hidden", idleIcon, swap = "queue", notificationLayout = "pill", linkComponent, classNames, pathname, satellites, electronSide = "after", electronLine = "along", keepElectronsOut = false, electronEnding = "join", arrange = "gather", orbitalsOpenOn = "press-hover", orbitalLabels = true, orbitalsStayOpen = true, actionsStyle = "detached", actionsSide = "start", actionsOrientation = "auto", actionsWheel = false, nearestToPill = "actions", actionsLabel = "Page actions", placement = "bottom", orientation, moveThroughCircle, variant, onPointerEnter, onPointerLeave, onFocus, onBlur, ...rest }, forwardedRef) {
|
|
86
87
|
const store = require_store.getStore(name);
|
|
87
88
|
const { current } = require_usePillQueue.usePillQueue(name);
|
|
88
89
|
const rootRef = (0, react.useRef)(null);
|
|
89
90
|
const ref = (0, react.useMemo)(() => require_react.mergeRefs(rootRef, forwardedRef), [forwardedRef]);
|
|
90
91
|
const flagRef = (0, react.useRef)(null);
|
|
91
92
|
(0, react.useEffect)(() => store.registerHost(), [store]);
|
|
93
|
+
(0, react.useEffect)(() => {
|
|
94
|
+
if (satellites) return;
|
|
95
|
+
const check = () => {
|
|
96
|
+
if (store.getElectrons().length > 0) {
|
|
97
|
+
require_react.devWarn(`pill("${name}").electron() needs the satellites: <MagicPill satellites={satellites}>, from "magic-pill/satellites".`);
|
|
98
|
+
unsubscribe();
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
const unsubscribe = store.subscribe(check);
|
|
102
|
+
check();
|
|
103
|
+
return unsubscribe;
|
|
104
|
+
}, [
|
|
105
|
+
store,
|
|
106
|
+
satellites,
|
|
107
|
+
name
|
|
108
|
+
]);
|
|
92
109
|
(0, react.useEffect)(require_inputModality.trackInputModality, []);
|
|
93
110
|
const hasBase = hasContent(children);
|
|
94
111
|
const lastBase = (0, react.useRef)(children);
|
|
@@ -182,11 +199,11 @@ const MagicPill = (0, react.forwardRef)(function MagicPill({ name = "main", chil
|
|
|
182
199
|
const flag = flagRef.current;
|
|
183
200
|
if (!sidebar || !flag || previous === flagDisplayed.presence) return;
|
|
184
201
|
const { enter, fade, change, exit } = require_choreography.readTimings(flag);
|
|
185
|
-
if (previous === "hidden" && flagDisplayed.presence === "rest")
|
|
202
|
+
if (previous === "hidden" && flagDisplayed.presence === "rest") require_goo.playSplit(sidebar, flag, "split", {
|
|
186
203
|
delay: 0,
|
|
187
204
|
duration: enter
|
|
188
205
|
});
|
|
189
|
-
else if (flagDisplayed.presence === "hidden")
|
|
206
|
+
else if (flagDisplayed.presence === "hidden") require_goo.playSplit(sidebar, flag, "join", {
|
|
190
207
|
delay: fade + change,
|
|
191
208
|
duration: exit
|
|
192
209
|
});
|
|
@@ -235,9 +252,40 @@ const MagicPill = (0, react.forwardRef)(function MagicPill({ name = "main", chil
|
|
|
235
252
|
presence: next
|
|
236
253
|
});
|
|
237
254
|
};
|
|
255
|
+
const satelliteHost = satellites ? {
|
|
256
|
+
name,
|
|
257
|
+
store,
|
|
258
|
+
rootRef,
|
|
259
|
+
placement,
|
|
260
|
+
vertical: isVertical,
|
|
261
|
+
pathname,
|
|
262
|
+
notifying: target.kind === "notification" || displayed.scene.kind === "notification" || hasBase && !require_choreography.isOpen(displayed.presence),
|
|
263
|
+
linkComponent,
|
|
264
|
+
variant,
|
|
265
|
+
theme: rest.theme,
|
|
266
|
+
electronSide,
|
|
267
|
+
electronLine,
|
|
268
|
+
keepElectronsOut,
|
|
269
|
+
electronEnding,
|
|
270
|
+
arrange,
|
|
271
|
+
orbitalsOpenOn,
|
|
272
|
+
orbitalLabels,
|
|
273
|
+
orbitalsStayOpen,
|
|
274
|
+
actionsStyle,
|
|
275
|
+
actionsSide,
|
|
276
|
+
actionsOrientation,
|
|
277
|
+
actionsWheel,
|
|
278
|
+
nearestToPill,
|
|
279
|
+
actionsLabel
|
|
280
|
+
} : void 0;
|
|
281
|
+
const inside = satellites && satelliteHost && actionsStyle === "inside" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(satellites.Inside, { host: satelliteHost }) : null;
|
|
238
282
|
const renderScene = (shownScene) => {
|
|
239
283
|
switch (shownScene.kind) {
|
|
240
|
-
case "base": return /* @__PURE__ */ (0, react_jsx_runtime.
|
|
284
|
+
case "base": return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react.Fragment, { children: [
|
|
285
|
+
actionsSide !== "end" && inside,
|
|
286
|
+
lastScenes.current.get(shownScene.key)?.children ?? lastBase.current,
|
|
287
|
+
actionsSide === "end" && inside
|
|
288
|
+
] }, shownScene.key);
|
|
241
289
|
case "idle": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_parts.PillIcon, { children: idleIcon });
|
|
242
290
|
case "notification": {
|
|
243
291
|
const { id, input } = shownScene.item;
|
|
@@ -319,6 +367,7 @@ const MagicPill = (0, react.forwardRef)(function MagicPill({ name = "main", chil
|
|
|
319
367
|
...flagPause.handlers,
|
|
320
368
|
children: renderScene(flagDisplayed.scene)
|
|
321
369
|
}),
|
|
370
|
+
satellites && satelliteHost && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(satellites.Layer, { host: satelliteHost }),
|
|
322
371
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
323
372
|
role: "status",
|
|
324
373
|
"aria-live": "polite",
|
|
@@ -7,11 +7,12 @@ import { NotificationContent } from "../PillNotification/PillNotification.mjs";
|
|
|
7
7
|
import { getStore } from "../store/store.mjs";
|
|
8
8
|
import { getInputModality, trackInputModality } from "../utils/inputModality.mjs";
|
|
9
9
|
import { usePillQueue } from "../store/usePillQueue.mjs";
|
|
10
|
-
import { mergeRefs, useIsomorphicLayoutEffect } from "../utils/react.mjs";
|
|
10
|
+
import { devWarn, mergeRefs, useIsomorphicLayoutEffect } from "../utils/react.mjs";
|
|
11
11
|
import { prefersReducedMotion } from "../utils/timing.mjs";
|
|
12
12
|
import { VISUALLY_HIDDEN } from "../utils/visuallyHidden.mjs";
|
|
13
13
|
import { BASE, IDLE, NONE, isOpen, readTimings } from "./choreography.mjs";
|
|
14
|
-
import { flagStyle, measureFlagSpot
|
|
14
|
+
import { flagStyle, measureFlagSpot } from "./flag.mjs";
|
|
15
|
+
import { playSplit } from "../Pill/goo.mjs";
|
|
15
16
|
import { useChoreography } from "./useChoreography.mjs";
|
|
16
17
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
17
18
|
|
|
@@ -82,13 +83,29 @@ const notificationIn = ({ scene, presence }) => scene.kind === "notification" &&
|
|
|
82
83
|
* The batteries-included pill: a <Pill> with a base layer, a queue of
|
|
83
84
|
* notifications fed by pill(name), and a live region that announces them.
|
|
84
85
|
*/
|
|
85
|
-
const MagicPill = forwardRef(function MagicPill({ name = "main", children, scene, duration = DEFAULT_DURATION, idle = "hidden", idleIcon, swap = "queue", notificationLayout = "pill", linkComponent, classNames, placement = "bottom", orientation, moveThroughCircle, variant, onPointerEnter, onPointerLeave, onFocus, onBlur, ...rest }, forwardedRef) {
|
|
86
|
+
const MagicPill = forwardRef(function MagicPill({ name = "main", children, scene, duration = DEFAULT_DURATION, idle = "hidden", idleIcon, swap = "queue", notificationLayout = "pill", linkComponent, classNames, pathname, satellites, electronSide = "after", electronLine = "along", keepElectronsOut = false, electronEnding = "join", arrange = "gather", orbitalsOpenOn = "press-hover", orbitalLabels = true, orbitalsStayOpen = true, actionsStyle = "detached", actionsSide = "start", actionsOrientation = "auto", actionsWheel = false, nearestToPill = "actions", actionsLabel = "Page actions", placement = "bottom", orientation, moveThroughCircle, variant, onPointerEnter, onPointerLeave, onFocus, onBlur, ...rest }, forwardedRef) {
|
|
86
87
|
const store = getStore(name);
|
|
87
88
|
const { current } = usePillQueue(name);
|
|
88
89
|
const rootRef = useRef(null);
|
|
89
90
|
const ref = useMemo(() => mergeRefs(rootRef, forwardedRef), [forwardedRef]);
|
|
90
91
|
const flagRef = useRef(null);
|
|
91
92
|
useEffect(() => store.registerHost(), [store]);
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
if (satellites) return;
|
|
95
|
+
const check = () => {
|
|
96
|
+
if (store.getElectrons().length > 0) {
|
|
97
|
+
devWarn(`pill("${name}").electron() needs the satellites: <MagicPill satellites={satellites}>, from "magic-pill/satellites".`);
|
|
98
|
+
unsubscribe();
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
const unsubscribe = store.subscribe(check);
|
|
102
|
+
check();
|
|
103
|
+
return unsubscribe;
|
|
104
|
+
}, [
|
|
105
|
+
store,
|
|
106
|
+
satellites,
|
|
107
|
+
name
|
|
108
|
+
]);
|
|
92
109
|
useEffect(trackInputModality, []);
|
|
93
110
|
const hasBase = hasContent(children);
|
|
94
111
|
const lastBase = useRef(children);
|
|
@@ -182,11 +199,11 @@ const MagicPill = forwardRef(function MagicPill({ name = "main", children, scene
|
|
|
182
199
|
const flag = flagRef.current;
|
|
183
200
|
if (!sidebar || !flag || previous === flagDisplayed.presence) return;
|
|
184
201
|
const { enter, fade, change, exit } = readTimings(flag);
|
|
185
|
-
if (previous === "hidden" && flagDisplayed.presence === "rest")
|
|
202
|
+
if (previous === "hidden" && flagDisplayed.presence === "rest") playSplit(sidebar, flag, "split", {
|
|
186
203
|
delay: 0,
|
|
187
204
|
duration: enter
|
|
188
205
|
});
|
|
189
|
-
else if (flagDisplayed.presence === "hidden")
|
|
206
|
+
else if (flagDisplayed.presence === "hidden") playSplit(sidebar, flag, "join", {
|
|
190
207
|
delay: fade + change,
|
|
191
208
|
duration: exit
|
|
192
209
|
});
|
|
@@ -235,9 +252,40 @@ const MagicPill = forwardRef(function MagicPill({ name = "main", children, scene
|
|
|
235
252
|
presence: next
|
|
236
253
|
});
|
|
237
254
|
};
|
|
255
|
+
const satelliteHost = satellites ? {
|
|
256
|
+
name,
|
|
257
|
+
store,
|
|
258
|
+
rootRef,
|
|
259
|
+
placement,
|
|
260
|
+
vertical: isVertical,
|
|
261
|
+
pathname,
|
|
262
|
+
notifying: target.kind === "notification" || displayed.scene.kind === "notification" || hasBase && !isOpen(displayed.presence),
|
|
263
|
+
linkComponent,
|
|
264
|
+
variant,
|
|
265
|
+
theme: rest.theme,
|
|
266
|
+
electronSide,
|
|
267
|
+
electronLine,
|
|
268
|
+
keepElectronsOut,
|
|
269
|
+
electronEnding,
|
|
270
|
+
arrange,
|
|
271
|
+
orbitalsOpenOn,
|
|
272
|
+
orbitalLabels,
|
|
273
|
+
orbitalsStayOpen,
|
|
274
|
+
actionsStyle,
|
|
275
|
+
actionsSide,
|
|
276
|
+
actionsOrientation,
|
|
277
|
+
actionsWheel,
|
|
278
|
+
nearestToPill,
|
|
279
|
+
actionsLabel
|
|
280
|
+
} : void 0;
|
|
281
|
+
const inside = satellites && satelliteHost && actionsStyle === "inside" ? /* @__PURE__ */ jsx(satellites.Inside, { host: satelliteHost }) : null;
|
|
238
282
|
const renderScene = (shownScene) => {
|
|
239
283
|
switch (shownScene.kind) {
|
|
240
|
-
case "base": return /* @__PURE__ */
|
|
284
|
+
case "base": return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
285
|
+
actionsSide !== "end" && inside,
|
|
286
|
+
lastScenes.current.get(shownScene.key)?.children ?? lastBase.current,
|
|
287
|
+
actionsSide === "end" && inside
|
|
288
|
+
] }, shownScene.key);
|
|
241
289
|
case "idle": return /* @__PURE__ */ jsx(PillIcon, { children: idleIcon });
|
|
242
290
|
case "notification": {
|
|
243
291
|
const { id, input } = shownScene.item;
|
|
@@ -319,6 +367,7 @@ const MagicPill = forwardRef(function MagicPill({ name = "main", children, scene
|
|
|
319
367
|
...flagPause.handlers,
|
|
320
368
|
children: renderScene(flagDisplayed.scene)
|
|
321
369
|
}),
|
|
370
|
+
satellites && satelliteHost && /* @__PURE__ */ jsx(satellites.Layer, { host: satelliteHost }),
|
|
322
371
|
/* @__PURE__ */ jsx("div", {
|
|
323
372
|
role: "status",
|
|
324
373
|
"aria-live": "polite",
|
package/dist/MagicPill/flag.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
const require_matchPath = require("../PillNavbar/matchPath.js");
|
|
2
|
-
const require_timing = require("../utils/timing.js");
|
|
3
2
|
|
|
4
3
|
// src/MagicPill/flag.ts
|
|
5
4
|
/** Measures the sidebar, and the navbar item whose `href` matches `at`, if any. */
|
|
@@ -31,63 +30,6 @@ function flagStyle({ shift, y }) {
|
|
|
31
30
|
}
|
|
32
31
|
return style;
|
|
33
32
|
}
|
|
34
|
-
/**
|
|
35
|
-
* The bridge between the sidebar and its flag: it stretches out of the
|
|
36
|
-
* sidebar as the flag pops out of it, then thins away as they part
|
|
37
|
-
* (`split`), or the other way round as the flag goes back (`join`).
|
|
38
|
-
*/
|
|
39
|
-
function playBridge(sidebar, flag, y, kind, timing) {
|
|
40
|
-
if (timing.duration <= 0 || require_timing.prefersReducedMotion() || typeof document.body.animate !== "function") return;
|
|
41
|
-
const rect = sidebar.getBoundingClientRect();
|
|
42
|
-
const flagStyles = getComputedStyle(flag);
|
|
43
|
-
const gap = (Number.parseFloat(flagStyles.columnGap) || 16) * .75;
|
|
44
|
-
const onRight = flag.dataset.placement === "right";
|
|
45
|
-
const overlap = 8;
|
|
46
|
-
const thickness = 22;
|
|
47
|
-
const centre = y ?? rect.top + rect.height / 2;
|
|
48
|
-
const bridge = document.createElement("div");
|
|
49
|
-
bridge.setAttribute("data-mp", "flag-bridge");
|
|
50
|
-
bridge.setAttribute("aria-hidden", "true");
|
|
51
|
-
const from = getComputedStyle(sidebar).backgroundColor;
|
|
52
|
-
const to = flagStyles.backgroundColor;
|
|
53
|
-
bridge.style.cssText = [
|
|
54
|
-
"position:fixed",
|
|
55
|
-
"pointer-events:none",
|
|
56
|
-
`z-index:${(Number.parseInt(flagStyles.zIndex, 10) || 50) - 1}`,
|
|
57
|
-
`top:${centre - thickness / 2}px`,
|
|
58
|
-
`left:${onRight ? rect.left - gap - overlap : rect.right - overlap}px`,
|
|
59
|
-
`width:${gap + 16}px`,
|
|
60
|
-
`height:${thickness}px`,
|
|
61
|
-
`border-radius:${thickness / 2}px`,
|
|
62
|
-
`background:linear-gradient(to ${onRight ? "left" : "right"}, ${from}, ${to})`,
|
|
63
|
-
`transform-origin:${onRight ? "right" : "left"} center`,
|
|
64
|
-
"transform:scaleX(0)"
|
|
65
|
-
].join(";");
|
|
66
|
-
document.body.append(bridge);
|
|
67
|
-
const out = [
|
|
68
|
-
{ transform: "scaleX(0)" },
|
|
69
|
-
{
|
|
70
|
-
transform: "scaleX(1)",
|
|
71
|
-
offset: .35
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
transform: "scaleX(1) scaleY(0.35)",
|
|
75
|
-
offset: .7
|
|
76
|
-
},
|
|
77
|
-
{ transform: "scaleX(1) scaleY(0)" }
|
|
78
|
-
];
|
|
79
|
-
const remove = () => bridge.remove();
|
|
80
|
-
bridge.animate(kind === "split" ? out : [...out].reverse().map((frame, index, all) => ({
|
|
81
|
-
...frame,
|
|
82
|
-
offset: index / (all.length - 1)
|
|
83
|
-
})), {
|
|
84
|
-
delay: timing.delay,
|
|
85
|
-
duration: timing.duration,
|
|
86
|
-
easing: "ease-out",
|
|
87
|
-
fill: "both"
|
|
88
|
-
}).finished.then(remove, remove);
|
|
89
|
-
}
|
|
90
33
|
|
|
91
34
|
exports.flagStyle = flagStyle;
|
|
92
|
-
exports.measureFlagSpot = measureFlagSpot;
|
|
93
|
-
exports.playBridge = playBridge;
|
|
35
|
+
exports.measureFlagSpot = measureFlagSpot;
|