@threadlabs/looma 0.51.3 → 0.51.5
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/components/ui-disclosure/ui-disclosure.html +3 -0
- package/components/ui-disclosure/ui-disclosure.js +42 -1
- package/dist/index.js +1 -1
- package/docs/catalog.json +1 -1
- package/editor/components.css +3 -0
- package/editor/index.js +44 -1
- package/package.json +1 -1
- package/styles/ui-disclosure.css +3 -0
- package/theme-system.css +4 -0
- package/tokens.css +9 -0
|
@@ -214,6 +214,9 @@
|
|
|
214
214
|
background: var(--ui-nav-hover-surface);
|
|
215
215
|
color: var(--ui-text-primary);
|
|
216
216
|
}
|
|
217
|
+
:host([variant="navigation"]:state(internalOpen)) .panel-inner {
|
|
218
|
+
padding-block: 0 !important;
|
|
219
|
+
}
|
|
217
220
|
:host([variant="navigation"]) :is(.leading, .indicator) {
|
|
218
221
|
inline-size: var(--ui-nav-icon-size);
|
|
219
222
|
font-size: var(--ui-nav-icon-size);
|
|
@@ -42,18 +42,52 @@ export function connect(host) {
|
|
|
42
42
|
host.state.internalOpen = Boolean(external);
|
|
43
43
|
let groupName = "";
|
|
44
44
|
let disposed = false;
|
|
45
|
+
let motionFrame = 0;
|
|
46
|
+
let takeoverMotion;
|
|
47
|
+
const view = document.defaultView;
|
|
48
|
+
const reducedMotion = view?.matchMedia?.("(prefers-reduced-motion: reduce)");
|
|
49
|
+
const stopTakeoverMotion = () => {
|
|
50
|
+
view?.cancelAnimationFrame(motionFrame);
|
|
51
|
+
motionFrame = 0;
|
|
52
|
+
takeoverMotion?.cancel();
|
|
53
|
+
};
|
|
54
|
+
const onMotionPreferenceChange = () => { if (reducedMotion.matches) stopTakeoverMotion(); };
|
|
55
|
+
reducedMotion?.addEventListener("change", onMotionPreferenceChange);
|
|
56
|
+
// A consumer may hide a sibling when this panel takes over the remaining space.
|
|
57
|
+
// Flex interpolation alone cannot animate the resulting change of position.
|
|
58
|
+
const animateFillTakeover = () => {
|
|
59
|
+
if (motionFrame || !host.props.fill.value || !view || !host.element.animate) return;
|
|
60
|
+
const previousTop = host.refs.heading.getBoundingClientRect().top;
|
|
61
|
+
takeoverMotion?.cancel();
|
|
62
|
+
if (reducedMotion?.matches) return;
|
|
63
|
+
motionFrame = view.requestAnimationFrame(() => {
|
|
64
|
+
motionFrame = 0;
|
|
65
|
+
if (disposed || !host.element.isConnected) return;
|
|
66
|
+
const delta = previousTop - host.refs.heading.getBoundingClientRect().top;
|
|
67
|
+
if (Math.abs(delta) < 1) return;
|
|
68
|
+
const style = view.getComputedStyle(host.element);
|
|
69
|
+
const duration = style.transitionDuration.split(",")[0].trim();
|
|
70
|
+
const milliseconds = parseFloat(duration) * (duration.endsWith("ms") ? 1 : 1000);
|
|
71
|
+
if (!(milliseconds > 0)) return;
|
|
72
|
+
takeoverMotion = host.element.animate([{ translate: `0 ${delta}px` }, { translate: "0 0" }], {
|
|
73
|
+
duration: milliseconds, easing: style.transitionTimingFunction, fill: "none",
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
};
|
|
45
77
|
const member = {
|
|
46
78
|
isOpen: () => Boolean(host.state.internalOpen),
|
|
47
79
|
required: () => Boolean(host.props.requiredOpen.value),
|
|
48
80
|
disabled: () => Boolean(host.props.disabled.value),
|
|
49
81
|
open() {
|
|
50
82
|
if (disposed || host.state.internalOpen) return;
|
|
83
|
+
animateFillTakeover();
|
|
51
84
|
host.state.internalOpen = true;
|
|
52
85
|
syncGroup("programmatic", "programmatic");
|
|
53
86
|
host.dispatch("open", { open: true, reason: "programmatic", trigger: "programmatic" });
|
|
54
87
|
},
|
|
55
88
|
close(reason, how) {
|
|
56
89
|
if (!host.state.internalOpen) return;
|
|
90
|
+
animateFillTakeover();
|
|
57
91
|
host.state.internalOpen = false;
|
|
58
92
|
host.dispatch("close", { open: false, reason, trigger: how });
|
|
59
93
|
},
|
|
@@ -78,7 +112,10 @@ export function connect(host) {
|
|
|
78
112
|
const stop = host.effect(() => {
|
|
79
113
|
if (host.props.open.value !== external) {
|
|
80
114
|
external = host.props.open.value;
|
|
81
|
-
if (external || mayClose())
|
|
115
|
+
if (external || mayClose()) {
|
|
116
|
+
animateFillTakeover();
|
|
117
|
+
host.state.internalOpen = Boolean(external);
|
|
118
|
+
}
|
|
82
119
|
}
|
|
83
120
|
const level = Number(host.props.headingLevel.value);
|
|
84
121
|
host.state.headingRole = Number.isInteger(level) && level >= 2 && level <= 6 ? "heading" : null;
|
|
@@ -92,12 +129,14 @@ export function connect(host) {
|
|
|
92
129
|
const open = !host.state.internalOpen;
|
|
93
130
|
if (!open && !mayClose()) return;
|
|
94
131
|
const how = trigger();
|
|
132
|
+
animateFillTakeover();
|
|
95
133
|
host.state.internalOpen = open;
|
|
96
134
|
if (open) syncGroup("action", how);
|
|
97
135
|
host.dispatch(open ? "open" : "close", { open, reason: "action", trigger: how });
|
|
98
136
|
};
|
|
99
137
|
const onBeforematch = () => queueMicrotask(() => {
|
|
100
138
|
if (disposed || host.state.internalOpen) return;
|
|
139
|
+
animateFillTakeover();
|
|
101
140
|
host.state.internalOpen = true;
|
|
102
141
|
syncGroup("programmatic", "programmatic");
|
|
103
142
|
host.dispatch("open", { open: true, reason: "programmatic", trigger: "programmatic" });
|
|
@@ -111,6 +150,8 @@ export function connect(host) {
|
|
|
111
150
|
measureHeading();
|
|
112
151
|
return () => {
|
|
113
152
|
disposed = true;
|
|
153
|
+
stopTakeoverMotion();
|
|
154
|
+
reducedMotion?.removeEventListener("change", onMotionPreferenceChange);
|
|
114
155
|
headingObserver?.disconnect();
|
|
115
156
|
stop();
|
|
116
157
|
stopTracking();
|