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
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
// src/satellites/orbits.ts
|
|
2
|
+
/** The same orbit moved by `dx`, `dy` with its electron (the arc and everything on it). */
|
|
3
|
+
const movedOrbit = (orbit, dx, dy) => ({
|
|
4
|
+
...orbit,
|
|
5
|
+
x: orbit.x + dx,
|
|
6
|
+
y: orbit.y + dy,
|
|
7
|
+
spots: orbit.spots.map((spot) => ({
|
|
8
|
+
...spot,
|
|
9
|
+
x: spot.x + dx,
|
|
10
|
+
y: spot.y + dy
|
|
11
|
+
}))
|
|
12
|
+
});
|
|
2
13
|
/** How far a wheel can turn: from 0 to this many orbitals. */
|
|
3
14
|
const wheelEnd = (orbit) => Math.max(0, orbit.count - orbit.visible);
|
|
4
15
|
/** Orbital `index`'s slot on the arc (0 to visible − 1 on it), mirrored in a right-to-left page. */
|
|
@@ -167,6 +178,7 @@ function orbitalAt(orbit, size, electronRadius, px, py, turn = 0) {
|
|
|
167
178
|
}
|
|
168
179
|
|
|
169
180
|
exports.hiddenPast = hiddenPast;
|
|
181
|
+
exports.movedOrbit = movedOrbit;
|
|
170
182
|
exports.orbitalAt = orbitalAt;
|
|
171
183
|
exports.pastEnd = pastEnd;
|
|
172
184
|
exports.planOrbit = planOrbit;
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
// src/satellites/orbits.ts
|
|
2
|
+
/** The same orbit moved by `dx`, `dy` with its electron (the arc and everything on it). */
|
|
3
|
+
const movedOrbit = (orbit, dx, dy) => ({
|
|
4
|
+
...orbit,
|
|
5
|
+
x: orbit.x + dx,
|
|
6
|
+
y: orbit.y + dy,
|
|
7
|
+
spots: orbit.spots.map((spot) => ({
|
|
8
|
+
...spot,
|
|
9
|
+
x: spot.x + dx,
|
|
10
|
+
y: spot.y + dy
|
|
11
|
+
}))
|
|
12
|
+
});
|
|
2
13
|
/** How far a wheel can turn: from 0 to this many orbitals. */
|
|
3
14
|
const wheelEnd = (orbit) => Math.max(0, orbit.count - orbit.visible);
|
|
4
15
|
/** Orbital `index`'s slot on the arc (0 to visible − 1 on it), mirrored in a right-to-left page. */
|
|
@@ -166,4 +177,4 @@ function orbitalAt(orbit, size, electronRadius, px, py, turn = 0) {
|
|
|
166
177
|
return bestGap <= Math.max(orbit.step / 2 + 8, 30) ? best : -1;
|
|
167
178
|
}
|
|
168
179
|
|
|
169
|
-
export { hiddenPast, orbitalAt, pastEnd, planOrbit, spotOn, wheelEnd };
|
|
180
|
+
export { hiddenPast, movedOrbit, orbitalAt, pastEnd, planOrbit, spotOn, wheelEnd };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ComponentType, RefObject } from "react";
|
|
1
|
+
import { CSSProperties, ComponentType, RefObject } from "react";
|
|
2
2
|
import { LinkComponent, PillPlacement, PillTheme, PillVariant } from "../Pill/types.mjs";
|
|
3
3
|
import { PillStore } from "../store/store.mjs";
|
|
4
4
|
/** Where electrons go: further along the edge, before the pill, or one row towards the page. */
|
|
@@ -36,6 +36,12 @@ export interface SatelliteHost {
|
|
|
36
36
|
linkComponent?: LinkComponent;
|
|
37
37
|
variant?: PillVariant;
|
|
38
38
|
theme?: PillTheme;
|
|
39
|
+
/**
|
|
40
|
+
* The tokens (`--mp-*`) set in the host's own `style`: its satellites take them too (they're pills of
|
|
41
|
+
* their own beside it, not inside it, so they don't inherit them). The adaptive glass, the light
|
|
42
|
+
* following the pointer, the readability veil… applied to the main pill only
|
|
43
|
+
*/
|
|
44
|
+
tokens?: CSSProperties;
|
|
39
45
|
electronSide: ElectronSide;
|
|
40
46
|
electronLine: ElectronLine;
|
|
41
47
|
keepElectronsOut: boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ComponentType, RefObject } from "react";
|
|
1
|
+
import { CSSProperties, ComponentType, RefObject } from "react";
|
|
2
2
|
import { LinkComponent, PillPlacement, PillTheme, PillVariant } from "../Pill/types.js";
|
|
3
3
|
import { PillStore } from "../store/store.js";
|
|
4
4
|
/** Where electrons go: further along the edge, before the pill, or one row towards the page. */
|
|
@@ -36,6 +36,12 @@ export interface SatelliteHost {
|
|
|
36
36
|
linkComponent?: LinkComponent;
|
|
37
37
|
variant?: PillVariant;
|
|
38
38
|
theme?: PillTheme;
|
|
39
|
+
/**
|
|
40
|
+
* The tokens (`--mp-*`) set in the host's own `style`: its satellites take them too (they're pills of
|
|
41
|
+
* their own beside it, not inside it, so they don't inherit them). The adaptive glass, the light
|
|
42
|
+
* following the pointer, the readability veil… applied to the main pill only
|
|
43
|
+
*/
|
|
44
|
+
tokens?: CSSProperties;
|
|
39
45
|
electronSide: ElectronSide;
|
|
40
46
|
electronLine: ElectronLine;
|
|
41
47
|
keepElectronsOut: boolean;
|
package/dist/styles.css
CHANGED
|
@@ -29,11 +29,44 @@
|
|
|
29
29
|
visibility: hidden;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
/* A wheel of orbitals on a touchscreen (satellites/Orbitals.tsx): a finger
|
|
33
|
+
turns it from anywhere on its track, between the orbitals too, and
|
|
34
|
+
neither it nor the orbitals scroll the page. With a mouse, the page
|
|
35
|
+
around them stays within reach (the mouse wheel turns it) */
|
|
36
|
+
[data-mp="orbital-track"] {
|
|
37
|
+
pointer-events: none;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@media (pointer: coarse) {
|
|
41
|
+
[data-mp="orbital-track"] {
|
|
42
|
+
pointer-events: auto;
|
|
43
|
+
touch-action: none;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
[data-mp="orbitals"][data-wheel] [data-satellite="orbital"] {
|
|
47
|
+
touch-action: none;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/* A copy measured where the pill is going (Pill/morph.ts): as it ends up */
|
|
52
|
+
[data-mp-measure],
|
|
53
|
+
[data-mp-measure] * {
|
|
54
|
+
transition: none !important;
|
|
55
|
+
animation: none !important;
|
|
56
|
+
}
|
|
57
|
+
|
|
32
58
|
/* A closed <dialog> stays closed, whatever display the pill uses */
|
|
33
59
|
dialog[data-mp="pill"]:not([open]) {
|
|
34
60
|
display: none;
|
|
35
61
|
}
|
|
36
62
|
|
|
63
|
+
/* The dialog takes the focus as it opens, so the keyboard starts inside
|
|
64
|
+
it: no ring around the whole pill. Important, so an app's own global
|
|
65
|
+
:focus-visible rule (unlayered, so it would win) doesn't draw one */
|
|
66
|
+
dialog[data-mp="pill"] {
|
|
67
|
+
outline: 0 !important;
|
|
68
|
+
}
|
|
69
|
+
|
|
37
70
|
/* Resting circle: only the leading icon remains, for everyone */
|
|
38
71
|
[data-mp="pill"][data-presence="rest"] > :not([data-mp="icon"]) {
|
|
39
72
|
visibility: hidden;
|
|
@@ -129,8 +162,11 @@
|
|
|
129
162
|
/* Half the one-line pill's height: round ends on a one-line pill, a
|
|
130
163
|
rounded rectangle when it grows taller (a wrapped message, a panel).
|
|
131
164
|
The browser shrinks it while the pill is smaller, so the size
|
|
132
|
-
animation (morph.ts) keeps the corners right at every frame
|
|
133
|
-
|
|
165
|
+
animation (morph.ts) keeps the corners right at every frame.
|
|
166
|
+
--mp-radius makes them smaller: a rounded rectangle at any size (a
|
|
167
|
+
sidebar, a toolbox). The circle at rest stays a circle (see below) */
|
|
168
|
+
--_mp-radius: var(--mp-radius, calc(var(--_mp-rest-size) / 2));
|
|
169
|
+
border-radius: var(--_mp-radius);
|
|
134
170
|
background: var(--_mp-surface);
|
|
135
171
|
color: var(--_mp-on-surface);
|
|
136
172
|
box-shadow: var(--mp-shadow, 0 0.5rem 0.5rem rgb(20 20 20 / 0.45));
|
|
@@ -201,6 +237,7 @@
|
|
|
201
237
|
/* A circle: both axes clamped, whatever the hidden content would need.
|
|
202
238
|
It shrinks once the content has faded out */
|
|
203
239
|
&[data-presence="rest"] {
|
|
240
|
+
--_mp-radius: calc(var(--_mp-rest-size) / 2);
|
|
204
241
|
inline-size: var(--_mp-rest-size);
|
|
205
242
|
max-inline-size: var(--_mp-rest-size);
|
|
206
243
|
max-block-size: var(--_mp-rest-size);
|
|
@@ -308,6 +345,11 @@
|
|
|
308
345
|
}
|
|
309
346
|
}
|
|
310
347
|
|
|
348
|
+
/* An electron and its orbitals are circles whatever --mp-radius says */
|
|
349
|
+
&:is([data-satellite="electron"], [data-satellite="orbital"]) {
|
|
350
|
+
--_mp-radius: calc(var(--_mp-rest-size) / 2);
|
|
351
|
+
}
|
|
352
|
+
|
|
311
353
|
/* An electron's orbitals: small round pills, the size of an action. The
|
|
312
354
|
one under the finger, the pointer or the focus takes the actions'
|
|
313
355
|
colours and grows a little */
|
|
@@ -575,9 +617,11 @@
|
|
|
575
617
|
/* A notification in rows (layout="rows"): the message and the actions
|
|
576
618
|
wrap in a body beside the icon. The actions stay on the message's
|
|
577
619
|
line while they fit, go under it when it wraps (the body is as wide
|
|
578
|
-
as a message can be
|
|
579
|
-
|
|
580
|
-
|
|
620
|
+
as a message can be, then as its longest line: PillNotification/
|
|
621
|
+
RowsBody.tsx), and always with two of them; under it, they take a
|
|
622
|
+
line as wide as the pill, from under the icon, and sit in its middle
|
|
623
|
+
(--mp-rows-actions-align: start, center or end). The icon and the
|
|
624
|
+
divider stay with the first line */
|
|
581
625
|
&:has(> [data-mp="body"]) {
|
|
582
626
|
align-items: flex-start;
|
|
583
627
|
|
|
@@ -600,11 +644,24 @@
|
|
|
600
644
|
padding-block: max(0px, (var(--_mp-action-size) - 1lh) / 2);
|
|
601
645
|
}
|
|
602
646
|
|
|
603
|
-
|
|
647
|
+
/* No effect beside the message, where the actions are only as wide as they are */
|
|
648
|
+
& > [data-mp="actions"]:not([data-wheel]) {
|
|
649
|
+
justify-content: var(--mp-rows-actions-align, center);
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
& > [data-mp="actions"]:has(> :nth-child(2)),
|
|
653
|
+
&[data-under] > [data-mp="actions"] {
|
|
604
654
|
flex-basis: 100%;
|
|
605
655
|
}
|
|
606
656
|
}
|
|
607
657
|
|
|
658
|
+
/* Under the message, past the icon, its divider and their gaps, on a line of their own */
|
|
659
|
+
&:has(> [data-mp="icon"]) > [data-mp="body"][data-under] > [data-mp="actions"] {
|
|
660
|
+
--_mp-under: calc(var(--_mp-action-size) + 2 * var(--_mp-gap) + 1px);
|
|
661
|
+
flex-basis: calc(100% + var(--_mp-under));
|
|
662
|
+
margin-inline-start: calc(-1 * var(--_mp-under));
|
|
663
|
+
}
|
|
664
|
+
|
|
608
665
|
/* The <a>/<button> stays neutral and the look lives on its inner body:
|
|
609
666
|
an app's global resets (a { color: inherit }, button { background:
|
|
610
667
|
none; padding: 0 }…) are unlayered, so they'd beat this layer on
|
|
@@ -652,9 +709,13 @@
|
|
|
652
709
|
--_mp-action-rim: var(--mp-close-rim, color-mix(in srgb, var(--_mp-on-surface) 48%, transparent));
|
|
653
710
|
}
|
|
654
711
|
|
|
712
|
+
/* Keyboard focus rings (--mp-focus-ring: their colour). Important, so an
|
|
713
|
+
app's own global :focus-visible rule (unlayered, so it would win)
|
|
714
|
+
doesn't replace them: drawn in its colour outside the item, the ring
|
|
715
|
+
was the pill's colour or clipped by it (an electron's, in the demo) */
|
|
655
716
|
& [data-mp="action"]:focus-visible {
|
|
656
|
-
outline: 2px solid var(--_mp-on-surface);
|
|
657
|
-
outline-offset: 2px;
|
|
717
|
+
outline: 2px solid var(--mp-focus-ring, var(--_mp-on-surface)) !important;
|
|
718
|
+
outline-offset: 2px !important;
|
|
658
719
|
}
|
|
659
720
|
|
|
660
721
|
/* An electron: all of the circle is a link back to where it came from.
|
|
@@ -706,13 +767,13 @@
|
|
|
706
767
|
}
|
|
707
768
|
|
|
708
769
|
& [data-mp="orbital"]:focus-visible {
|
|
709
|
-
outline: 2px solid currentColor;
|
|
710
|
-
outline-offset: -4px;
|
|
770
|
+
outline: 2px solid var(--mp-focus-ring, currentColor) !important;
|
|
771
|
+
outline-offset: -4px !important;
|
|
711
772
|
}
|
|
712
773
|
|
|
713
774
|
& [data-mp="electron"]:focus-visible {
|
|
714
|
-
outline: 2px solid var(--_mp-on-surface);
|
|
715
|
-
outline-offset: -5px;
|
|
775
|
+
outline: 2px solid var(--mp-focus-ring, var(--_mp-on-surface)) !important;
|
|
776
|
+
outline-offset: -5px !important;
|
|
716
777
|
}
|
|
717
778
|
|
|
718
779
|
& [data-mp="electron-value"] {
|
|
@@ -978,8 +1039,10 @@
|
|
|
978
1039
|
|
|
979
1040
|
/* No room for two labels (PillNavbar/room.ts): the one that was open
|
|
980
1041
|
folds while another is pointed at or focused. Folded at rest too with
|
|
981
|
-
labels="closed", or "auto" while the current one has no room
|
|
982
|
-
|
|
1042
|
+
labels="closed", or "auto" while the current one has no room.
|
|
1043
|
+
[data-pointed]: on a copy measured by script, the one under the
|
|
1044
|
+
pointer or focused on the pill itself (Pill/morph.ts) */
|
|
1045
|
+
& [data-mp="navbar"]:is([data-tight], [data-folded]) [data-mp="action"]:not(:hover, :focus-visible, [data-pointed]) {
|
|
983
1046
|
& [data-mp="action-body"] {
|
|
984
1047
|
padding-inline-end: calc((var(--_mp-action-size) - 1.25rem) / 2);
|
|
985
1048
|
}
|
|
@@ -994,7 +1057,7 @@
|
|
|
994
1057
|
/* The same on hover, only where the device really hovers: a tap on a
|
|
995
1058
|
touchscreen leaves a "sticky" hover behind until the next tap (L20) */
|
|
996
1059
|
@media (hover: hover) {
|
|
997
|
-
& [data-mp="action"]:hover {
|
|
1060
|
+
& [data-mp="action"]:is(:hover, [data-pointed]) {
|
|
998
1061
|
& [data-mp="action-body"] {
|
|
999
1062
|
padding-inline-end: calc(var(--_mp-action-size) / 2.5);
|
|
1000
1063
|
transition-delay: 0s;
|