dsh-plan-steps 0.1.2 → 0.1.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/client.js +34 -5
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -15,6 +15,26 @@ window.__ModuleLoader__.load({
|
|
|
15
15
|
radius: 'var(--dsw-radius-lg, 12px)',
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Glass themes (dsh-catppuccin and siblings) expose their look as body
|
|
20
|
+
* variables and mark the document with `data-dsh-glass`; they only blur the
|
|
21
|
+
* surfaces listed in their own seam table, which does not know this panel.
|
|
22
|
+
* Reading the same variables keeps the panel visually identical without
|
|
23
|
+
* patching the theme.
|
|
24
|
+
* @returns extra styles for the panel root, empty when no glass theme is on.
|
|
25
|
+
*/
|
|
26
|
+
function glassSurface() {
|
|
27
|
+
if (typeof document === 'undefined' || !document.documentElement.hasAttribute('data-dsh-glass')) return {}
|
|
28
|
+
const blur = 'blur(var(--dsh-glass-blur, 14px))'
|
|
29
|
+
return {
|
|
30
|
+
background: 'var(--dsh-glass-card, var(--dsw-specific-menu, transparent))',
|
|
31
|
+
border: '1px solid var(--dsh-glass-rim-soft, transparent)',
|
|
32
|
+
backdropFilter: blur,
|
|
33
|
+
WebkitBackdropFilter: blur,
|
|
34
|
+
borderRadius: '14px',
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
18
38
|
// Material Symbols (google/material-design-icons, Apache-2.0), inlined as
|
|
19
39
|
// path data so the panel renders offline.
|
|
20
40
|
const ICONS = {
|
|
@@ -109,6 +129,16 @@ window.__ModuleLoader__.load({
|
|
|
109
129
|
// inside the content as a zero-width marker and is stripped here.
|
|
110
130
|
const todos = (useProjection('todos') ?? []).map(readItem)
|
|
111
131
|
const [open, setOpen] = React.useState(false)
|
|
132
|
+
// A glass theme can be switched on while the panel is mounted.
|
|
133
|
+
const [glass, setGlass] = React.useState(() => glassSurface())
|
|
134
|
+
React.useEffect(() => {
|
|
135
|
+
const observer = new MutationObserver(() => setGlass(glassSurface()))
|
|
136
|
+
observer.observe(document.documentElement, {
|
|
137
|
+
attributes: true,
|
|
138
|
+
attributeFilter: ['data-dsh-glass', 'data-dsh-glass-float'],
|
|
139
|
+
})
|
|
140
|
+
return () => observer.disconnect()
|
|
141
|
+
}, [])
|
|
112
142
|
if (todos.length === 0) return null
|
|
113
143
|
const { done, total, index, current } = positionOf(todos)
|
|
114
144
|
const label = '计划 · 第 ' + String(index) + ' / ' + String(total) + ' 步'
|
|
@@ -127,6 +157,7 @@ window.__ModuleLoader__.load({
|
|
|
127
157
|
color: TOKENS.title,
|
|
128
158
|
fontSize: '13px',
|
|
129
159
|
overflow: 'hidden',
|
|
160
|
+
...glass,
|
|
130
161
|
},
|
|
131
162
|
},
|
|
132
163
|
h(
|
|
@@ -301,10 +332,9 @@ window.__ModuleLoader__.load({
|
|
|
301
332
|
if (position.done === true) {
|
|
302
333
|
return h('div', { style: { padding: '6px 2px', fontSize: '13px', fontWeight: 600 } }, '计划 · 全部完成')
|
|
303
334
|
}
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
}))
|
|
335
|
+
// No bar here: one linear bar cannot show a two-level list truthfully — a
|
|
336
|
+
// phase can be current while completed sub-steps sit after it — so the row
|
|
337
|
+
// states the position and the panel, which knows every status, draws it.
|
|
308
338
|
return h(
|
|
309
339
|
'div',
|
|
310
340
|
{ style: { padding: '6px 2px', fontSize: '13px', display: 'flex', alignItems: 'center', gap: '10px' } },
|
|
@@ -314,7 +344,6 @@ window.__ModuleLoader__.load({
|
|
|
314
344
|
{ style: { minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } },
|
|
315
345
|
position.current,
|
|
316
346
|
),
|
|
317
|
-
h(Bar, { items, index: done + 1 }),
|
|
318
347
|
)
|
|
319
348
|
} catch (error) {
|
|
320
349
|
return h('div', { style: { padding: '6px 2px', fontSize: '12px', opacity: 0.7 } }, '完成一步')
|