magic-pill 9.4.0-next.3 → 9.4.0-next.4
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 +26 -0
- package/README.md +10 -7
- package/dist/MagicPill/MagicPill.d.mts +2 -1
- package/dist/MagicPill/MagicPill.d.ts +2 -1
- package/dist/MagicPill/MagicPill.js +10 -3
- package/dist/MagicPill/MagicPill.mjs +10 -3
- package/dist/Pill/Pill.js +1 -0
- package/dist/Pill/Pill.mjs +1 -0
- package/dist/Pill/goo.js +60 -28
- package/dist/Pill/goo.mjs +60 -28
- package/dist/Pill/modal.js +3 -1
- package/dist/Pill/modal.mjs +3 -1
- package/dist/Pill/morph.js +56 -2
- package/dist/Pill/morph.mjs +56 -3
- package/dist/PillForm/PillForm.js +6 -1
- package/dist/PillForm/PillForm.mjs +7 -2
- package/dist/PillForm/dates.js +14 -3
- package/dist/PillForm/dates.mjs +14 -3
- package/dist/PillForm/room.js +46 -0
- package/dist/PillForm/room.mjs +46 -0
- package/dist/PillNavbar/PillNavbar.js +3 -1
- package/dist/PillNavbar/PillNavbar.mjs +4 -2
- package/dist/PillNavbar/room.js +65 -11
- package/dist/PillNavbar/room.mjs +65 -12
- package/dist/PillNotification/PillNotification.js +2 -4
- package/dist/PillNotification/PillNotification.mjs +2 -4
- package/dist/PillNotification/RowsBody.js +77 -0
- package/dist/PillNotification/RowsBody.mjs +77 -0
- package/dist/forms.css +14 -0
- package/dist/satellites/Actions.js +181 -6
- package/dist/satellites/Actions.mjs +182 -7
- package/dist/satellites/Orbitals.js +67 -17
- package/dist/satellites/Orbitals.mjs +69 -19
- package/dist/satellites/Satellites.js +197 -84
- package/dist/satellites/Satellites.mjs +198 -86
- package/dist/satellites/handoff.js +36 -0
- package/dist/satellites/handoff.mjs +34 -0
- package/dist/satellites/measure.js +22 -0
- package/dist/satellites/measure.mjs +22 -1
- package/dist/satellites/orbits.js +12 -0
- package/dist/satellites/orbits.mjs +12 -1
- package/dist/satellites/types.d.mts +7 -1
- package/dist/satellites/types.d.ts +7 -1
- package/dist/styles.css +78 -15
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
5
|
### Added
|
|
6
|
+
- `--mp-focus-ring`: the keyboard focus ring's colour on the pill's actions, electrons and orbitals
|
|
7
|
+
- `--mp-radius`: the pill's corners (half the one-line pill's height by default). Smaller gives a rounded rectangle at any size, a sidebar or a toolbox included; a pill closed to a circle, an electron and its orbitals stay round
|
|
8
|
+
- `--mp-rows-actions-align`: where a notification in rows (`layout="rows"`) puts its actions under the message: `start`, `center` (the default) or `end`, following the text direction
|
|
6
9
|
- **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
10
|
- **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
11
|
- **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>`
|
|
@@ -14,6 +17,27 @@
|
|
|
14
17
|
- 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` (`0.15`, a droplet)
|
|
15
18
|
|
|
16
19
|
### Fixed
|
|
20
|
+
- An electron coming out next to a navbar that folds its label for it (`labels="auto"`, on a phone) stays in the pill's row again, the label folding as the electron grows out of it: the pill used to jump shorter before the electron was there (its room capped it before the label had folded), and since the satellites plan from the pill open or folded, an electron that would fit beside the folded pill went above it instead
|
|
21
|
+
- Switching the page's actions into the pill (`actionsStyle`) no longer shows them twice: their own pill goes back into the host as when they hide, then they open in the pill. Out of it, they fold away in the pill before their own pill comes out of it, from the pill's edge (it showed at full size at once). In the pill, they open out of nothing as they come and fold away before they go, the pill following its content: it used to jump to its new length at once, and the navbar takes their room back as they fold away
|
|
22
|
+
- An electron's orbitals follow it while they're out: when it moves with the pill (on a phone, Safari's toolbar folding as the page scrolls; the group re-centring), they stayed where they had opened, apart from it, and went back in towards where it had been. They move with it at every frame, on the same arc, their opening or closing going on
|
|
23
|
+
- Placement changes run lighter: as the pill closed and opened, a navbar that folds by itself and the satellites laid out up to three hidden copies of it at every frame, for answers that don't change while it morphs (125 copies per change in the demo, now 27). The navbar checks again only when something it depends on changed (the pill's markup, the screen's size, the page's root, fonts loading); the satellites measure the host's open size once per placement and screen size on its way
|
|
24
|
+
- Turning a phone sideways, the satellites come out of the host in one go: they came out as the host slid to its new spot, followed it one way, then went back the other way to theirs (the electron 642 → 491 → 675 px). Out of a host that slides against their way out, they now wait for it to get there, then come out of its edge
|
|
25
|
+
- The satellites re-plan sooner once the window stops changing size: they waited 200 ms after its last change, a pause you could feel once you let go; now 120 ms, still after a drag (one change per frame)
|
|
26
|
+
- A sidebar's flag comes out with lighter goo: its overlay covered the whole sidebar (as tall as the screen) and its filter worked on four times that, at every frame, slow on a phone. It now covers the flag and the part of the sidebar a neck can reach (about nine times fewer pixels filtered), and every goo filter works on its overlay, not twice its width and height
|
|
27
|
+
- A wheel of orbitals turns from anywhere on its track on a phone: a finger had to land on an orbital (44 px) to turn it, and a swipe starting between two of them closed them, or scrolled the page. A finger now turns it from anywhere on the arc, between the orbitals and a little outside them, and neither the track nor the orbitals scroll the page; a tap on the track, off the orbitals, still closes them. With a mouse, nothing changes
|
|
28
|
+
- A form in the pill itself keeps its field usable on a phone: its submit button's label took the room, and the field was squeezed to a few letters (an e-mail subscription, 60 px on a 393 px screen, nothing at all in a narrow card). Short of room, the button folds its label to its icon, still its name; the field gets it back (184 px). Not while the pill is still growing (out of a circle)
|
|
29
|
+
- A notification in rows (`layout="rows"`) is as wide as what it shows: a wrapped message kept its box as wide as a message can be (`--mp-message-width`), so the pill looked too wide for it, with a gap after its lines. The message fits its longest line, measured on a copy of the pill as it ends up. The actions under it are centred in the pill, instead of lining up with the text; `--mp-rows-actions-align` (`start`, `center` or `end`) lines them up elsewhere
|
|
30
|
+
- The calendar's and `PillDate`'s labels start with a capital in languages that write days and months in lowercase: "Jeudi 24 décembre 2026", "Décembre 2026", "Déc." (was all lowercase in French)
|
|
31
|
+
- A modal no longer shows a focus ring on its first button as it opens after a click or a tap ("Delete", in a question about deleting): the dialog itself takes the focus, as a panel does, and the first Tab reaches the button, with its ring
|
|
32
|
+
- The page's actions in the pill, with their wheel, leave the navbar its room first: they show what fits next to it with its label open (or, when not even one does, next to it folded), the rest in their wheel. A navbar now folds its label when what's beside it in the pill leaves it no room, instead of being squeezed
|
|
33
|
+
- An electron, its orbitals and the page's actions take the tokens set in the host's `style`: the adaptive glass, the light following the pointer, the readability veil and the rest applied to the main pill only (they're pills of their own beside it, so they didn't inherit them)
|
|
34
|
+
- A navbar with `labels="auto"` and satellites could fold and unfold its label every frame, the satellites moving back and forth with it until a phone's page crashed (two electrons and four actions with a wheel, next to the docs' sidebar): they now plan from the host open, if they fit beside it so, or folded, never from the length it has as the label moves
|
|
35
|
+
- Another list of page actions resizes their pill where it is, sliding with the host as the group re-centres: it used to close to a circle, open with the new list, then close again to follow the host. A column of actions next to a bottom pill grows up from the pill's level, instead of jumping up and growing down; actions that turn for a new list close to a circle from where they were, not off to one side over the host
|
|
36
|
+
- Scrolling on a phone no longer sends the electrons back into the pill and out again: Safari's toolbar shrinking moves the pill and every satellite's row with it, which was taken for a new spot
|
|
37
|
+
- An electron that ends as a notification comes (an upload that ends with "Your file is uploaded") goes back into the pill's centre with the others as the pill closes, instead of shrinking on its own next to it as if it popped
|
|
38
|
+
- An electron and the page's actions come out from behind the pill and go back in behind it: they were drawn over it, so an electron's face (its ring, its time) showed on top of the pill as it joined. Their orbitals stay under them, and the goo's necks under them all. An electron's face fades once as it goes back in, instead of fading, showing again and fading a second time
|
|
39
|
+
- An electron shows its keyboard focus ring in apps with their own global `:focus-visible` rule: the app's ring was drawn outside it, in its colour, and the pill hid it. The rings on the pill's actions, electrons and orbitals now stay the library's, and `--mp-focus-ring` sets their colour
|
|
40
|
+
- A pill closing its panel goes to its size in one motion when its navbar folds its labels for the room it has: it shrank, then jumped as the labels folded. The navbar decides as the pill's presence changes, and the pill measures where it's going as it ends up (on a copy with no transitions); if its content still changes size meanwhile (a label opening under the pointer), it gets there smoothly instead of jumping
|
|
17
41
|
- 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)
|
|
18
42
|
- Two electrons given an empty `id` are two electrons, instead of one flickering between them
|
|
19
43
|
- The page's actions grow away from the pill when an action's label opens on hover, instead of over it
|
|
@@ -28,6 +52,7 @@
|
|
|
28
52
|
- 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
|
|
29
53
|
- 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
|
|
30
54
|
- An electron's orbitals keep clear of the page's actions, as they do of the other electrons
|
|
55
|
+
- With `avoidPills`, an electron's orbitals also keep clear of the other pills on the screen, as the electrons and the actions do: on a phone, the timer's orbitals no longer open over the docs' sidebar
|
|
31
56
|
- When the group gathers again (an electron coming or going, the actions changing), the satellites no longer slide across whole: the page's actions close to a circle where they are, move, and open at their new spot; an electron goes down to a droplet, moves, and grows back (a nudge of a few pixels still slides)
|
|
32
57
|
- An electron and the page's actions come out of the pill as a droplet, as the design drew it: drawn out small on the goo's neck (following the pill as it slides to make room), growing to their size as they come free, then showing their content; going back in, the same played backwards. A sidebar's flag does the same, out of the sidebar's edge. `--mp-electron-start` is now `0.15` (a droplet); `--mp-ease-split`, when set, still picks the curve
|
|
33
58
|
- An electron's orbitals come out from behind it and go back in behind it, instead of over what it shows
|
|
@@ -38,6 +63,7 @@
|
|
|
38
63
|
- With electrons or actions out, a pill changing placement goes there through the circle in one movement, from and to any placement: it used to jump across the screen as it closed (to or from the top and bottom, the start and end placements, between the bottom and a side), laid out for its new placement while still at its old one. Next to another pill of the same side, it no longer flashes aside as it sets off
|
|
39
64
|
|
|
40
65
|
### Changed
|
|
66
|
+
- **Beta:** `actionsWheel` is on by default for the page's actions in the pill (`actionsStyle="inside"`): short of room, they show what fits next to the navbar and turn the rest in their wheel; `false` shows them all. Still off by default for a pill of their own
|
|
41
67
|
- 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
|
|
42
68
|
- 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
|
|
43
69
|
|
package/README.md
CHANGED
|
@@ -119,7 +119,7 @@ const id = pill().notify({
|
|
|
119
119
|
| `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). |
|
|
120
120
|
| `variant` | `"neutral"` · `"success"` · `"danger"` · any string | Defaults to the host's variant. |
|
|
121
121
|
| `duration` | `number` (ms) | Defaults to the host's (5000). `Infinity` keeps it until dismissed. |
|
|
122
|
-
| `layout` | `"pill"` · `"rows"` · `"card"` · `"flag"` | Defaults to the host's `notificationLayout`. `"rows"` puts the actions under the message when they need the room: when the message wraps, or with an action and a panel. Under it, they
|
|
122
|
+
| `layout` | `"pill"` · `"rows"` · `"card"` · `"flag"` | Defaults to the host's `notificationLayout`. `"rows"` puts the actions under the message when they need the room: when the message wraps, or with an action and a panel. Under it, they're centred in the pill (`--mp-rows-actions-align` lines them up at the `start` or the `end` instead), and the pill is as wide as the message's longest line. `"card"`, in a sidebar: a column of the sidebar's width (at least `--mp-card-width`, `12.5rem`), the icon on top, the actions full width with their labels; a horizontal host shows it in one row. `"flag"`, in a `left` or `right` sidebar with a base layer: a pill of its own out of the sidebar's edge, while the sidebar stays (see below). |
|
|
123
123
|
| `at` | `string` | `"flag"` only: the `href` of the navbar item it's about, to come out next to it (matched as the navbar matches the current page). Default: the middle of the sidebar. |
|
|
124
124
|
| `id` | `string` | Notifying again with the same id updates the notification in place. |
|
|
125
125
|
| `announce` | `string` · `false` | What screen readers hear. Defaults to the message's text. |
|
|
@@ -337,7 +337,7 @@ pill().electron({
|
|
|
337
337
|
```
|
|
338
338
|
|
|
339
339
|
- 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. While they're open, a press slides onto one at once. With a mouse, hovering opens them too, and they close once the pointer leaves them; on their way back in, they're out of reach.
|
|
340
|
-
- They fan out on an arc away from the screen's edge, clear of the pill, the other electrons, the page's actions 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
|
+
- They fan out on an arc away from the screen's edge, clear of the pill, the other electrons, the page's actions 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). On a touchscreen, a finger turns it from anywhere on its track, between the orbitals and a little outside them too, and the page doesn't scroll under it; a tap on the track, off the orbitals, closes them. 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.
|
|
341
341
|
- 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.
|
|
342
342
|
|
|
343
343
|
**How it behaves:**
|
|
@@ -368,12 +368,12 @@ export function InboxPage() {
|
|
|
368
368
|
|
|
369
369
|
| Host prop | Default | Notes |
|
|
370
370
|
|---|---|---|
|
|
371
|
-
| `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. Changing it,
|
|
371
|
+
| `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, opening out of nothing as they come and folding away before they go. Changing it, their own pill goes back into the host before they open in it; the other way, they fold away in the pill before their own pill comes out of it. |
|
|
372
372
|
| `actionsSide` | `"start"` | `"start"` or `"end"` (following the text direction: under the thumb you want), or `"beside"` (one row towards the page). |
|
|
373
373
|
| `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), in its row or in the row beside it; decided again once a resize settles. `"horizontal"` or `"vertical"`, always. Turning, they close to a circle where they are and open again the other way, as the pill does when it changes placement. |
|
|
374
|
-
| `actionsWheel` | `false` | Short of room, they show what fits (two at least in the pill's row) 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 (`"inside"`), the cut starts at the divider. |
|
|
374
|
+
| `actionsWheel` | `true` in the pill, `false` in a pill of their own | Short of room, they show what fits (two at least in the pill's row) 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 (`"inside"`), the cut starts at the divider, and the navbar keeps its room first: `false` there shows them all. |
|
|
375
375
|
| `nearestToPill` | `"actions"` | On a side they share, the page's actions are nearer the pill, or `"electrons"` are. |
|
|
376
|
-
| `avoidPills` | `true` | The satellites keep clear of the other pills on the screen (a sidebar, a help pill): over one, the actions go to the other side, then turn across, then (with `actionsWheel`) show fewer; the layout that covers them least when none is clear. `false`: they go where the props say. |
|
|
376
|
+
| `avoidPills` | `true` | The satellites keep clear of the other pills on the screen (a sidebar, a help pill): over one, the actions go to the other side, then turn across, then (with `actionsWheel`) show fewer; the layout that covers them least when none is clear. An electron's orbitals turn away from them too (a wheel shows what fits clear of them). `false`: they go where the props say. |
|
|
377
377
|
| `actionsLabel` | `"Page actions"` | Their accessible name. |
|
|
378
378
|
|
|
379
379
|
Short of room, the actions turn across first (`"auto"`, or show what fits with `actionsWheel`), then the farthest ones go beside the pill: the last electrons, then the first electron and the actions, the nearer of them last. They slide with the group as it changes (gathered or spread, another one coming or going).
|
|
@@ -542,7 +542,7 @@ async function send(data: FormData) {
|
|
|
542
542
|
| `disabled` / `busy` | `false` | Disables every field (`busy`: while something is being sent; `onSend` does it for you) |
|
|
543
543
|
|
|
544
544
|
- **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.
|
|
545
|
-
- **In the pill itself**, a `<PillForm>` is a row, with fields as tall as the actions: one field, one action.
|
|
545
|
+
- **In the pill itself**, a `<PillForm>` is a row, with fields as tall as the actions: one field, one action. Short of room (a phone), its `expanded` submit button folds its label to its icon (still its name, read out), so the field keeps room to type in.
|
|
546
546
|
- **On phones**, the pill stays above the keyboard while one of its fields has the focus.
|
|
547
547
|
- **Escape** closes an open list, not the panel.
|
|
548
548
|
- **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.
|
|
@@ -658,8 +658,11 @@ An `<img>` keeps its file's colours: `currentColor` only reaches inline SVGs and
|
|
|
658
658
|
| `--mp-text-size` / `--mp-title-size` | fluid, about 1rem / 1.5–2rem |
|
|
659
659
|
| `--mp-padding` / `--mp-gap` / `--mp-action-size` | `0.875rem` / `1rem` / `2.75rem` |
|
|
660
660
|
| `--mp-max-width` / `--mp-message-width` / `--mp-panel-width` | `48rem` / `24rem` / `32rem` |
|
|
661
|
+
| `--mp-rows-actions-align` | `center`: where a notification in `rows` puts its actions on their own line under the message: `start`, `center` or `end` (following the text direction) |
|
|
661
662
|
| `--mp-card-width` | `12.5rem`: a sidebar's notification card, at the least (it keeps the sidebar's width if that's wider) |
|
|
663
|
+
| `--mp-radius` | Half the one-line pill's height: the pill's corners. Smaller makes a rounded rectangle at any size (a sidebar, a toolbox); a pill closed to a circle, an electron and its orbitals stay round |
|
|
662
664
|
| `--mp-radius-panel` / `--mp-shadow` | `2.5rem` / a soft drop shadow |
|
|
665
|
+
| `--mp-focus-ring` | The keyboard focus ring's colour on the pill's actions, an electron and its orbitals: the text's colour by default. Drawn by the stylesheet even over an app's own global `:focus-visible` rule, which would draw it outside the item, where the pill hides it |
|
|
663
666
|
| `--mp-offset` / `--mp-z-index` | `1.5rem` from the viewport edges (plus safe areas) / `50` |
|
|
664
667
|
| `--mp-backdrop` / `--mp-backdrop-blur` | the overlay's backdrop: `rgb(20 20 20 / 0.4)` / no blur |
|
|
665
668
|
| `--mp-duration-enter` / `--mp-duration-change` / `--mp-duration-exit` | `500ms` / `250ms` / `300ms` |
|
|
@@ -677,7 +680,7 @@ The pill fits small screens: sizes are in `rem`, fixed pills stay inside the vie
|
|
|
677
680
|
|
|
678
681
|
**Sidebars:** a `left` or `right` pill lines its items up along the screen edge, and on the right-hand side its labels open towards the middle of the screen, so the icons stay in line (mirrored in right-to-left pages). Set `--mp-align` to change the alignment.
|
|
679
682
|
|
|
680
|
-
**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`.
|
|
683
|
+
**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 (`--mp-radius` makes them smaller), so a taller pill, such as a wrapped message, is a rounded rectangle; a panel's corners are `--mp-radius-panel`.
|
|
681
684
|
|
|
682
685
|
### Themes
|
|
683
686
|
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`:
|
|
@@ -89,7 +89,8 @@ export interface MagicPillProps extends Omit<PillProps, "presence" | "defaultPre
|
|
|
89
89
|
/**
|
|
90
90
|
* Short of room, the page's actions show what fits and turn the rest in a
|
|
91
91
|
* wheel (a mouse wheel, a drag, the arrow keys), instead of turning across.
|
|
92
|
-
* Default
|
|
92
|
+
* Default: true in the pill (`actionsStyle="inside"`: the navbar keeps its
|
|
93
|
+
* room), false in a pill of their own (beta).
|
|
93
94
|
*/
|
|
94
95
|
actionsWheel?: boolean;
|
|
95
96
|
/** On a side they share, the page's actions are nearer the pill (default), or the electrons (beta). */
|
|
@@ -89,7 +89,8 @@ export interface MagicPillProps extends Omit<PillProps, "presence" | "defaultPre
|
|
|
89
89
|
/**
|
|
90
90
|
* Short of room, the page's actions show what fits and turn the rest in a
|
|
91
91
|
* wheel (a mouse wheel, a drag, the arrow keys), instead of turning across.
|
|
92
|
-
* Default
|
|
92
|
+
* Default: true in the pill (`actionsStyle="inside"`: the navbar keeps its
|
|
93
|
+
* room), false in a pill of their own (beta).
|
|
93
94
|
*/
|
|
94
95
|
actionsWheel?: boolean;
|
|
95
96
|
/** On a side they share, the page's actions are nearer the pill (default), or the electrons (beta). */
|
|
@@ -83,7 +83,7 @@ const notificationIn = ({ scene, presence }) => scene.kind === "notification" &&
|
|
|
83
83
|
* The batteries-included pill: a <Pill> with a base layer, a queue of
|
|
84
84
|
* notifications fed by pill(name), and a live region that announces them.
|
|
85
85
|
*/
|
|
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, orbitalsMore = "peek", orbitalsStayOpen = true, actionsStyle = "detached", actionsSide = "start", actionsOrientation = "auto", actionsWheel
|
|
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, orbitalsMore = "peek", orbitalsStayOpen = true, actionsStyle = "detached", actionsSide = "start", actionsOrientation = "auto", actionsWheel: actionsWheelProp, nearestToPill = "actions", avoidPills = true, actionsLabel = "Page actions", placement = "bottom", orientation, moveThroughCircle, variant, onPointerEnter, onPointerLeave, onFocus, onBlur, ...rest }, forwardedRef) {
|
|
87
87
|
const store = require_store.getStore(name);
|
|
88
88
|
const { current } = require_usePillQueue.usePillQueue(name);
|
|
89
89
|
const rootRef = (0, react.useRef)(null);
|
|
@@ -263,6 +263,7 @@ const MagicPill = (0, react.forwardRef)(function MagicPill({ name = "main", chil
|
|
|
263
263
|
linkComponent,
|
|
264
264
|
variant,
|
|
265
265
|
theme: rest.theme,
|
|
266
|
+
tokens: hostTokens(rest.style),
|
|
266
267
|
electronSide,
|
|
267
268
|
electronLine,
|
|
268
269
|
keepElectronsOut,
|
|
@@ -275,12 +276,12 @@ const MagicPill = (0, react.forwardRef)(function MagicPill({ name = "main", chil
|
|
|
275
276
|
actionsStyle,
|
|
276
277
|
actionsSide,
|
|
277
278
|
actionsOrientation,
|
|
278
|
-
actionsWheel,
|
|
279
|
+
actionsWheel: actionsWheelProp ?? actionsStyle === "inside",
|
|
279
280
|
nearestToPill,
|
|
280
281
|
avoidPills,
|
|
281
282
|
actionsLabel
|
|
282
283
|
} : void 0;
|
|
283
|
-
const inside = satellites && satelliteHost
|
|
284
|
+
const inside = satellites && satelliteHost ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(satellites.Inside, { host: satelliteHost }) : null;
|
|
284
285
|
const renderScene = (shownScene) => {
|
|
285
286
|
switch (shownScene.kind) {
|
|
286
287
|
case "base": return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react.Fragment, { children: [
|
|
@@ -380,5 +381,11 @@ const MagicPill = (0, react.forwardRef)(function MagicPill({ name = "main", chil
|
|
|
380
381
|
})
|
|
381
382
|
] });
|
|
382
383
|
});
|
|
384
|
+
/** The tokens (`--mp-*`) in a style, for the satellites: undefined when there are none. */
|
|
385
|
+
function hostTokens(style) {
|
|
386
|
+
if (!style) return void 0;
|
|
387
|
+
const entries = Object.entries(style).filter(([name]) => name.startsWith("--mp-"));
|
|
388
|
+
return entries.length > 0 ? Object.fromEntries(entries) : void 0;
|
|
389
|
+
}
|
|
383
390
|
|
|
384
391
|
module.exports = MagicPill;
|
|
@@ -83,7 +83,7 @@ const notificationIn = ({ scene, presence }) => scene.kind === "notification" &&
|
|
|
83
83
|
* The batteries-included pill: a <Pill> with a base layer, a queue of
|
|
84
84
|
* notifications fed by pill(name), and a live region that announces them.
|
|
85
85
|
*/
|
|
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, orbitalsMore = "peek", orbitalsStayOpen = true, actionsStyle = "detached", actionsSide = "start", actionsOrientation = "auto", actionsWheel
|
|
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, orbitalsMore = "peek", orbitalsStayOpen = true, actionsStyle = "detached", actionsSide = "start", actionsOrientation = "auto", actionsWheel: actionsWheelProp, nearestToPill = "actions", avoidPills = true, actionsLabel = "Page actions", placement = "bottom", orientation, moveThroughCircle, variant, onPointerEnter, onPointerLeave, onFocus, onBlur, ...rest }, forwardedRef) {
|
|
87
87
|
const store = getStore(name);
|
|
88
88
|
const { current } = usePillQueue(name);
|
|
89
89
|
const rootRef = useRef(null);
|
|
@@ -263,6 +263,7 @@ const MagicPill = forwardRef(function MagicPill({ name = "main", children, scene
|
|
|
263
263
|
linkComponent,
|
|
264
264
|
variant,
|
|
265
265
|
theme: rest.theme,
|
|
266
|
+
tokens: hostTokens(rest.style),
|
|
266
267
|
electronSide,
|
|
267
268
|
electronLine,
|
|
268
269
|
keepElectronsOut,
|
|
@@ -275,12 +276,12 @@ const MagicPill = forwardRef(function MagicPill({ name = "main", children, scene
|
|
|
275
276
|
actionsStyle,
|
|
276
277
|
actionsSide,
|
|
277
278
|
actionsOrientation,
|
|
278
|
-
actionsWheel,
|
|
279
|
+
actionsWheel: actionsWheelProp ?? actionsStyle === "inside",
|
|
279
280
|
nearestToPill,
|
|
280
281
|
avoidPills,
|
|
281
282
|
actionsLabel
|
|
282
283
|
} : void 0;
|
|
283
|
-
const inside = satellites && satelliteHost
|
|
284
|
+
const inside = satellites && satelliteHost ? /* @__PURE__ */ jsx(satellites.Inside, { host: satelliteHost }) : null;
|
|
284
285
|
const renderScene = (shownScene) => {
|
|
285
286
|
switch (shownScene.kind) {
|
|
286
287
|
case "base": return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -380,5 +381,11 @@ const MagicPill = forwardRef(function MagicPill({ name = "main", children, scene
|
|
|
380
381
|
})
|
|
381
382
|
] });
|
|
382
383
|
});
|
|
384
|
+
/** The tokens (`--mp-*`) in a style, for the satellites: undefined when there are none. */
|
|
385
|
+
function hostTokens(style) {
|
|
386
|
+
if (!style) return void 0;
|
|
387
|
+
const entries = Object.entries(style).filter(([name]) => name.startsWith("--mp-"));
|
|
388
|
+
return entries.length > 0 ? Object.fromEntries(entries) : void 0;
|
|
389
|
+
}
|
|
383
390
|
|
|
384
391
|
export { MagicPill as default };
|
package/dist/Pill/Pill.js
CHANGED
|
@@ -140,6 +140,7 @@ const Pill = (0, react.forwardRef)(function Pill({ presence: presenceProp, defau
|
|
|
140
140
|
...require_react.inertProps(!isVisible),
|
|
141
141
|
onKeyDown: handleKeyDown,
|
|
142
142
|
...isOverlay && {
|
|
143
|
+
tabIndex: -1,
|
|
143
144
|
onCancel: handleCancel,
|
|
144
145
|
onClose: handleClose,
|
|
145
146
|
...closeOnBackdropClick && {
|
package/dist/Pill/Pill.mjs
CHANGED
|
@@ -140,6 +140,7 @@ const Pill = forwardRef(function Pill({ presence: presenceProp, defaultPresence
|
|
|
140
140
|
...inertProps(!isVisible),
|
|
141
141
|
onKeyDown: handleKeyDown,
|
|
142
142
|
...isOverlay && {
|
|
143
|
+
tabIndex: -1,
|
|
143
144
|
onCancel: handleCancel,
|
|
144
145
|
onClose: handleClose,
|
|
145
146
|
...closeOnBackdropClick && {
|
package/dist/Pill/goo.js
CHANGED
|
@@ -111,26 +111,43 @@ function dropShadow(boxShadow) {
|
|
|
111
111
|
const running = /* @__PURE__ */ new WeakMap();
|
|
112
112
|
let overlays = 0;
|
|
113
113
|
const SVG = "http://www.w3.org/2000/svg";
|
|
114
|
+
/**
|
|
115
|
+
* The z-index a pill is drawn at: its own, or the one of the nearest element around it that has one
|
|
116
|
+
* (an orbital's menu). 50 (the library's default) when none says.
|
|
117
|
+
*/
|
|
118
|
+
function stackLevel(element) {
|
|
119
|
+
for (let node = element; node; node = node.parentElement) {
|
|
120
|
+
const level = Number.parseInt(getComputedStyle(node).zIndex, 10);
|
|
121
|
+
if (Number.isFinite(level)) return level;
|
|
122
|
+
}
|
|
123
|
+
return 50;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* The area a goo filter works on: its layer, a little past it. The layer leaves room for the blur and
|
|
127
|
+
* the shadow already (`margin`); the filter worked on twice its width and height, four times its area,
|
|
128
|
+
* at every frame, and filters cost by the pixel (WebKit's most of all)
|
|
129
|
+
*/
|
|
130
|
+
const FILTER_REGION = {
|
|
131
|
+
x: "-10%",
|
|
132
|
+
y: "-10%",
|
|
133
|
+
width: "120%",
|
|
134
|
+
height: "120%",
|
|
135
|
+
"color-interpolation-filters": "sRGB"
|
|
136
|
+
};
|
|
114
137
|
/** The overlay: a filter (blur, threshold, the anchor's inside cut out, a fill, a shadow) and two shapes. */
|
|
115
138
|
function createOverlay(zIndex, color, shadow) {
|
|
116
139
|
const id = `mp-goo-${++overlays}`;
|
|
117
140
|
const root = document.createElement("div");
|
|
118
141
|
root.setAttribute("data-mp", "goo");
|
|
119
142
|
root.setAttribute("aria-hidden", "true");
|
|
120
|
-
root.style.cssText = `position:fixed;left:0;top:0;width:0;height:0;pointer-events:none;z-index:${zIndex};`;
|
|
143
|
+
root.style.cssText = `position:fixed;left:0;top:0;width:0;height:0;overflow:hidden;pointer-events:none;z-index:${zIndex};`;
|
|
121
144
|
const svg = document.createElementNS(SVG, "svg");
|
|
122
145
|
svg.setAttribute("width", "0");
|
|
123
146
|
svg.setAttribute("height", "0");
|
|
124
147
|
svg.style.position = "absolute";
|
|
125
148
|
const filter = document.createElementNS(SVG, "filter");
|
|
126
149
|
filter.id = id;
|
|
127
|
-
for (const [name, value] of Object.entries(
|
|
128
|
-
x: "-50%",
|
|
129
|
-
y: "-50%",
|
|
130
|
-
width: "200%",
|
|
131
|
-
height: "200%",
|
|
132
|
-
"color-interpolation-filters": "sRGB"
|
|
133
|
-
})) filter.setAttribute(name, value);
|
|
150
|
+
for (const [name, value] of Object.entries(FILTER_REGION)) filter.setAttribute(name, value);
|
|
134
151
|
filter.innerHTML = `
|
|
135
152
|
<feGaussianBlur in="SourceAlpha" stdDeviation="0" result="blur"/>
|
|
136
153
|
<feComponentTransfer in="blur" result="goo"><feFuncA type="linear" slope="24" intercept="-12"/></feComponentTransfer>
|
|
@@ -173,16 +190,24 @@ function createOverlay(zIndex, color, shadow) {
|
|
|
173
190
|
* Puts the overlay around the two pills (with `margin` for the blur and the
|
|
174
191
|
* shadow), and each shape where its pill is, with its rounded corners at its
|
|
175
192
|
* current scale (`radius`: read once, at its full size).
|
|
193
|
+
*
|
|
194
|
+
* Around the moving pill only, as far as a neck can reach: a sidebar a flag
|
|
195
|
+
* comes out of is as tall as the screen, and the filter ran over all of it at
|
|
196
|
+
* every frame (slow on a phone). Its shape still runs past the overlay, which
|
|
197
|
+
* clips it, so its ends (rounded by the blur) never show.
|
|
176
198
|
*/
|
|
177
199
|
function placeAll(overlay, pills, radii, margin) {
|
|
178
200
|
const a = pills.anchor.getBoundingClientRect();
|
|
179
201
|
const m = pills.moving.getBoundingClientRect();
|
|
180
|
-
const
|
|
181
|
-
const
|
|
202
|
+
const reach = margin;
|
|
203
|
+
const left = Math.max(Math.min(a.left, m.left), m.left - reach) - margin;
|
|
204
|
+
const top = Math.max(Math.min(a.top, m.top), m.top - reach) - margin;
|
|
205
|
+
const right = Math.min(Math.max(a.right, m.right), m.right + reach) + margin;
|
|
206
|
+
const bottom = Math.min(Math.max(a.bottom, m.bottom), m.bottom + reach) + margin;
|
|
182
207
|
const root = overlay.root.style;
|
|
183
208
|
root.transform = `translate(${left}px, ${top}px)`;
|
|
184
|
-
root.width = `${
|
|
185
|
-
root.height = `${
|
|
209
|
+
root.width = `${right - left}px`;
|
|
210
|
+
root.height = `${bottom - top}px`;
|
|
186
211
|
const put = (shape, rect, element, radius) => {
|
|
187
212
|
const scale = element.offsetWidth > 0 ? rect.width / element.offsetWidth : 1;
|
|
188
213
|
shape.style.width = `${rect.width}px`;
|
|
@@ -420,6 +445,21 @@ function playOrbit(electron, items, kind, timing) {
|
|
|
420
445
|
const cx = centre.left + centre.width / 2;
|
|
421
446
|
const cy = centre.top + centre.height / 2;
|
|
422
447
|
const longest = Math.max(...items.map(({ delay }) => delay)) + timing.duration;
|
|
448
|
+
const anchorLevel = stackLevel(electron);
|
|
449
|
+
const lowered = [];
|
|
450
|
+
for (const { element } of items) {
|
|
451
|
+
if (stackLevel(element) < anchorLevel) continue;
|
|
452
|
+
lowered.push([element, element.style.zIndex]);
|
|
453
|
+
element.style.zIndex = String(anchorLevel - 1);
|
|
454
|
+
}
|
|
455
|
+
let restored = false;
|
|
456
|
+
const restore = () => {
|
|
457
|
+
if (restored) return;
|
|
458
|
+
restored = true;
|
|
459
|
+
clearTimeout(timer);
|
|
460
|
+
for (const [element, zIndex] of lowered) element.style.zIndex = zIndex;
|
|
461
|
+
};
|
|
462
|
+
const timer = lowered.length > 0 ? setTimeout(restore, longest) : void 0;
|
|
423
463
|
for (const { element, delay, shown = 1, from = atPoint(cx, cy), droplet = false, opaque = droplet } of items) {
|
|
424
464
|
if (shown <= 0) continue;
|
|
425
465
|
const start = from(element.getBoundingClientRect(), element);
|
|
@@ -497,14 +537,10 @@ function playOrbit(electron, items, kind, timing) {
|
|
|
497
537
|
offset: .7
|
|
498
538
|
},
|
|
499
539
|
{ opacity: 1 }
|
|
500
|
-
] : [
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
offset: .3
|
|
505
|
-
},
|
|
506
|
-
{ opacity: 0 }
|
|
507
|
-
];
|
|
540
|
+
] : [{
|
|
541
|
+
opacity: 0,
|
|
542
|
+
offset: .3
|
|
543
|
+
}, { opacity: 0 }];
|
|
508
544
|
for (const child of element.children) child.animate(content, {
|
|
509
545
|
...options,
|
|
510
546
|
easing: "linear"
|
|
@@ -514,6 +550,7 @@ function playOrbit(electron, items, kind, timing) {
|
|
|
514
550
|
const stop = playNecks([electron, ...items.filter(({ shown = 1 }) => shown > 0).map(({ element }) => element)], longest);
|
|
515
551
|
const stopAll = () => {
|
|
516
552
|
stop();
|
|
553
|
+
restore();
|
|
517
554
|
for (const { element } of items) if (budding.get(element) === stopAll) budding.delete(element);
|
|
518
555
|
};
|
|
519
556
|
for (const { element } of items) budding.set(element, stopAll);
|
|
@@ -535,20 +572,15 @@ function playNecks(pills, duration) {
|
|
|
535
572
|
const root = document.createElement("div");
|
|
536
573
|
root.setAttribute("data-mp", "goo");
|
|
537
574
|
root.setAttribute("aria-hidden", "true");
|
|
538
|
-
|
|
575
|
+
const level = Math.min(...pills.map(stackLevel)) - 1;
|
|
576
|
+
root.style.cssText = `position:fixed;left:0;top:0;width:0;height:0;pointer-events:none;z-index:${level};`;
|
|
539
577
|
const svg = document.createElementNS(SVG, "svg");
|
|
540
578
|
svg.setAttribute("width", "0");
|
|
541
579
|
svg.setAttribute("height", "0");
|
|
542
580
|
svg.style.position = "absolute";
|
|
543
581
|
const filter = document.createElementNS(SVG, "filter");
|
|
544
582
|
filter.id = id;
|
|
545
|
-
for (const [name, value] of Object.entries(
|
|
546
|
-
x: "-50%",
|
|
547
|
-
y: "-50%",
|
|
548
|
-
width: "200%",
|
|
549
|
-
height: "200%",
|
|
550
|
-
"color-interpolation-filters": "sRGB"
|
|
551
|
-
})) filter.setAttribute(name, value);
|
|
583
|
+
for (const [name, value] of Object.entries(FILTER_REGION)) filter.setAttribute(name, value);
|
|
552
584
|
filter.innerHTML = `
|
|
553
585
|
<feGaussianBlur in="SourceAlpha" stdDeviation="0" result="blur"/>
|
|
554
586
|
<feComponentTransfer in="blur" result="goo"><feFuncA type="linear" slope="24" intercept="-12"/></feComponentTransfer>
|
package/dist/Pill/goo.mjs
CHANGED
|
@@ -111,26 +111,43 @@ function dropShadow(boxShadow) {
|
|
|
111
111
|
const running = /* @__PURE__ */ new WeakMap();
|
|
112
112
|
let overlays = 0;
|
|
113
113
|
const SVG = "http://www.w3.org/2000/svg";
|
|
114
|
+
/**
|
|
115
|
+
* The z-index a pill is drawn at: its own, or the one of the nearest element around it that has one
|
|
116
|
+
* (an orbital's menu). 50 (the library's default) when none says.
|
|
117
|
+
*/
|
|
118
|
+
function stackLevel(element) {
|
|
119
|
+
for (let node = element; node; node = node.parentElement) {
|
|
120
|
+
const level = Number.parseInt(getComputedStyle(node).zIndex, 10);
|
|
121
|
+
if (Number.isFinite(level)) return level;
|
|
122
|
+
}
|
|
123
|
+
return 50;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* The area a goo filter works on: its layer, a little past it. The layer leaves room for the blur and
|
|
127
|
+
* the shadow already (`margin`); the filter worked on twice its width and height, four times its area,
|
|
128
|
+
* at every frame, and filters cost by the pixel (WebKit's most of all)
|
|
129
|
+
*/
|
|
130
|
+
const FILTER_REGION = {
|
|
131
|
+
x: "-10%",
|
|
132
|
+
y: "-10%",
|
|
133
|
+
width: "120%",
|
|
134
|
+
height: "120%",
|
|
135
|
+
"color-interpolation-filters": "sRGB"
|
|
136
|
+
};
|
|
114
137
|
/** The overlay: a filter (blur, threshold, the anchor's inside cut out, a fill, a shadow) and two shapes. */
|
|
115
138
|
function createOverlay(zIndex, color, shadow) {
|
|
116
139
|
const id = `mp-goo-${++overlays}`;
|
|
117
140
|
const root = document.createElement("div");
|
|
118
141
|
root.setAttribute("data-mp", "goo");
|
|
119
142
|
root.setAttribute("aria-hidden", "true");
|
|
120
|
-
root.style.cssText = `position:fixed;left:0;top:0;width:0;height:0;pointer-events:none;z-index:${zIndex};`;
|
|
143
|
+
root.style.cssText = `position:fixed;left:0;top:0;width:0;height:0;overflow:hidden;pointer-events:none;z-index:${zIndex};`;
|
|
121
144
|
const svg = document.createElementNS(SVG, "svg");
|
|
122
145
|
svg.setAttribute("width", "0");
|
|
123
146
|
svg.setAttribute("height", "0");
|
|
124
147
|
svg.style.position = "absolute";
|
|
125
148
|
const filter = document.createElementNS(SVG, "filter");
|
|
126
149
|
filter.id = id;
|
|
127
|
-
for (const [name, value] of Object.entries(
|
|
128
|
-
x: "-50%",
|
|
129
|
-
y: "-50%",
|
|
130
|
-
width: "200%",
|
|
131
|
-
height: "200%",
|
|
132
|
-
"color-interpolation-filters": "sRGB"
|
|
133
|
-
})) filter.setAttribute(name, value);
|
|
150
|
+
for (const [name, value] of Object.entries(FILTER_REGION)) filter.setAttribute(name, value);
|
|
134
151
|
filter.innerHTML = `
|
|
135
152
|
<feGaussianBlur in="SourceAlpha" stdDeviation="0" result="blur"/>
|
|
136
153
|
<feComponentTransfer in="blur" result="goo"><feFuncA type="linear" slope="24" intercept="-12"/></feComponentTransfer>
|
|
@@ -173,16 +190,24 @@ function createOverlay(zIndex, color, shadow) {
|
|
|
173
190
|
* Puts the overlay around the two pills (with `margin` for the blur and the
|
|
174
191
|
* shadow), and each shape where its pill is, with its rounded corners at its
|
|
175
192
|
* current scale (`radius`: read once, at its full size).
|
|
193
|
+
*
|
|
194
|
+
* Around the moving pill only, as far as a neck can reach: a sidebar a flag
|
|
195
|
+
* comes out of is as tall as the screen, and the filter ran over all of it at
|
|
196
|
+
* every frame (slow on a phone). Its shape still runs past the overlay, which
|
|
197
|
+
* clips it, so its ends (rounded by the blur) never show.
|
|
176
198
|
*/
|
|
177
199
|
function placeAll(overlay, pills, radii, margin) {
|
|
178
200
|
const a = pills.anchor.getBoundingClientRect();
|
|
179
201
|
const m = pills.moving.getBoundingClientRect();
|
|
180
|
-
const
|
|
181
|
-
const
|
|
202
|
+
const reach = margin;
|
|
203
|
+
const left = Math.max(Math.min(a.left, m.left), m.left - reach) - margin;
|
|
204
|
+
const top = Math.max(Math.min(a.top, m.top), m.top - reach) - margin;
|
|
205
|
+
const right = Math.min(Math.max(a.right, m.right), m.right + reach) + margin;
|
|
206
|
+
const bottom = Math.min(Math.max(a.bottom, m.bottom), m.bottom + reach) + margin;
|
|
182
207
|
const root = overlay.root.style;
|
|
183
208
|
root.transform = `translate(${left}px, ${top}px)`;
|
|
184
|
-
root.width = `${
|
|
185
|
-
root.height = `${
|
|
209
|
+
root.width = `${right - left}px`;
|
|
210
|
+
root.height = `${bottom - top}px`;
|
|
186
211
|
const put = (shape, rect, element, radius) => {
|
|
187
212
|
const scale = element.offsetWidth > 0 ? rect.width / element.offsetWidth : 1;
|
|
188
213
|
shape.style.width = `${rect.width}px`;
|
|
@@ -420,6 +445,21 @@ function playOrbit(electron, items, kind, timing) {
|
|
|
420
445
|
const cx = centre.left + centre.width / 2;
|
|
421
446
|
const cy = centre.top + centre.height / 2;
|
|
422
447
|
const longest = Math.max(...items.map(({ delay }) => delay)) + timing.duration;
|
|
448
|
+
const anchorLevel = stackLevel(electron);
|
|
449
|
+
const lowered = [];
|
|
450
|
+
for (const { element } of items) {
|
|
451
|
+
if (stackLevel(element) < anchorLevel) continue;
|
|
452
|
+
lowered.push([element, element.style.zIndex]);
|
|
453
|
+
element.style.zIndex = String(anchorLevel - 1);
|
|
454
|
+
}
|
|
455
|
+
let restored = false;
|
|
456
|
+
const restore = () => {
|
|
457
|
+
if (restored) return;
|
|
458
|
+
restored = true;
|
|
459
|
+
clearTimeout(timer);
|
|
460
|
+
for (const [element, zIndex] of lowered) element.style.zIndex = zIndex;
|
|
461
|
+
};
|
|
462
|
+
const timer = lowered.length > 0 ? setTimeout(restore, longest) : void 0;
|
|
423
463
|
for (const { element, delay, shown = 1, from = atPoint(cx, cy), droplet = false, opaque = droplet } of items) {
|
|
424
464
|
if (shown <= 0) continue;
|
|
425
465
|
const start = from(element.getBoundingClientRect(), element);
|
|
@@ -497,14 +537,10 @@ function playOrbit(electron, items, kind, timing) {
|
|
|
497
537
|
offset: .7
|
|
498
538
|
},
|
|
499
539
|
{ opacity: 1 }
|
|
500
|
-
] : [
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
offset: .3
|
|
505
|
-
},
|
|
506
|
-
{ opacity: 0 }
|
|
507
|
-
];
|
|
540
|
+
] : [{
|
|
541
|
+
opacity: 0,
|
|
542
|
+
offset: .3
|
|
543
|
+
}, { opacity: 0 }];
|
|
508
544
|
for (const child of element.children) child.animate(content, {
|
|
509
545
|
...options,
|
|
510
546
|
easing: "linear"
|
|
@@ -514,6 +550,7 @@ function playOrbit(electron, items, kind, timing) {
|
|
|
514
550
|
const stop = playNecks([electron, ...items.filter(({ shown = 1 }) => shown > 0).map(({ element }) => element)], longest);
|
|
515
551
|
const stopAll = () => {
|
|
516
552
|
stop();
|
|
553
|
+
restore();
|
|
517
554
|
for (const { element } of items) if (budding.get(element) === stopAll) budding.delete(element);
|
|
518
555
|
};
|
|
519
556
|
for (const { element } of items) budding.set(element, stopAll);
|
|
@@ -535,20 +572,15 @@ function playNecks(pills, duration) {
|
|
|
535
572
|
const root = document.createElement("div");
|
|
536
573
|
root.setAttribute("data-mp", "goo");
|
|
537
574
|
root.setAttribute("aria-hidden", "true");
|
|
538
|
-
|
|
575
|
+
const level = Math.min(...pills.map(stackLevel)) - 1;
|
|
576
|
+
root.style.cssText = `position:fixed;left:0;top:0;width:0;height:0;pointer-events:none;z-index:${level};`;
|
|
539
577
|
const svg = document.createElementNS(SVG, "svg");
|
|
540
578
|
svg.setAttribute("width", "0");
|
|
541
579
|
svg.setAttribute("height", "0");
|
|
542
580
|
svg.style.position = "absolute";
|
|
543
581
|
const filter = document.createElementNS(SVG, "filter");
|
|
544
582
|
filter.id = id;
|
|
545
|
-
for (const [name, value] of Object.entries(
|
|
546
|
-
x: "-50%",
|
|
547
|
-
y: "-50%",
|
|
548
|
-
width: "200%",
|
|
549
|
-
height: "200%",
|
|
550
|
-
"color-interpolation-filters": "sRGB"
|
|
551
|
-
})) filter.setAttribute(name, value);
|
|
583
|
+
for (const [name, value] of Object.entries(FILTER_REGION)) filter.setAttribute(name, value);
|
|
552
584
|
filter.innerHTML = `
|
|
553
585
|
<feGaussianBlur in="SourceAlpha" stdDeviation="0" result="blur"/>
|
|
554
586
|
<feComponentTransfer in="blur" result="goo"><feFuncA type="linear" slope="24" intercept="-12"/></feComponentTransfer>
|
package/dist/Pill/modal.js
CHANGED
|
@@ -21,6 +21,7 @@ function useModal(rootRef, isOverlay, presence, lastSize) {
|
|
|
21
21
|
const show = () => {
|
|
22
22
|
const dialog = rootRef.current;
|
|
23
23
|
if (!isOverlay || !isVisible || !dialog?.isConnected || typeof dialog.showModal !== "function") return;
|
|
24
|
+
let opening = false;
|
|
24
25
|
if (!dialog.open) {
|
|
25
26
|
dialog.dataset.presence = "hidden";
|
|
26
27
|
dialog.showModal();
|
|
@@ -29,8 +30,9 @@ function useModal(rootRef, isOverlay, presence, lastSize) {
|
|
|
29
30
|
height: dialog.offsetHeight
|
|
30
31
|
};
|
|
31
32
|
dialog.dataset.presence = presence;
|
|
33
|
+
opening = true;
|
|
32
34
|
}
|
|
33
|
-
if (presence === "rest" || !dialog.contains(document.activeElement)) dialog.focus();
|
|
35
|
+
if (opening || presence === "rest" || !dialog.contains(document.activeElement)) dialog.focus();
|
|
34
36
|
};
|
|
35
37
|
require_react.useIsomorphicLayoutEffect(() => {
|
|
36
38
|
show();
|
package/dist/Pill/modal.mjs
CHANGED
|
@@ -21,6 +21,7 @@ function useModal(rootRef, isOverlay, presence, lastSize) {
|
|
|
21
21
|
const show = () => {
|
|
22
22
|
const dialog = rootRef.current;
|
|
23
23
|
if (!isOverlay || !isVisible || !dialog?.isConnected || typeof dialog.showModal !== "function") return;
|
|
24
|
+
let opening = false;
|
|
24
25
|
if (!dialog.open) {
|
|
25
26
|
dialog.dataset.presence = "hidden";
|
|
26
27
|
dialog.showModal();
|
|
@@ -29,8 +30,9 @@ function useModal(rootRef, isOverlay, presence, lastSize) {
|
|
|
29
30
|
height: dialog.offsetHeight
|
|
30
31
|
};
|
|
31
32
|
dialog.dataset.presence = presence;
|
|
33
|
+
opening = true;
|
|
32
34
|
}
|
|
33
|
-
if (presence === "rest" || !dialog.contains(document.activeElement)) dialog.focus();
|
|
35
|
+
if (opening || presence === "rest" || !dialog.contains(document.activeElement)) dialog.focus();
|
|
34
36
|
};
|
|
35
37
|
useIsomorphicLayoutEffect(() => {
|
|
36
38
|
show();
|