@celestia-island/hikari 0.55.356 → 0.55.358
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/package.json +1 -1
- package/src/components/HkBlockingToast.scss +5 -8
- package/src/components/HkCardList.scss +8 -0
- package/src/components/HkCardList.tsx +35 -2
- package/src/components/HkColorSchemeEditor.tsx +22 -3
- package/src/components/HkThemePanelContent.tsx +106 -55
- package/src/components/HkThemeToggle.contract.test.ts +77 -39
- package/src/components/HkThemeToggle.scss +94 -113
- package/src/components/HkThemeToggle.test.ts +193 -33
- package/src/components/HkThemeToggle.tsx +23 -5
- package/src/components/HkTimePicker.scss +439 -0
- package/src/components/HkTimePicker.test.ts +486 -0
- package/src/components/HkTimePicker.tsx +595 -0
- package/src/components/HkTimeZonePicker.scss +269 -0
- package/src/components/HkTimeZonePicker.test.tsx +444 -0
- package/src/components/HkTimeZonePicker.tsx +337 -0
- package/src/components/HkToast.scss +43 -34
- package/src/components/HkWeekdayPicker.scss +350 -0
- package/src/components/HkWeekdayPicker.test.tsx +398 -0
- package/src/components/HkWeekdayPicker.tsx +303 -0
- package/src/components/calendarGrid.test.ts +186 -0
- package/src/components/calendarGrid.ts +132 -0
- package/src/components/pickerFamily.barrel.test.ts +35 -0
- package/src/i18n/locales/ar/components.json +18 -1
- package/src/i18n/locales/ar/platform.json +1 -0
- package/src/i18n/locales/de/components.json +18 -1
- package/src/i18n/locales/de/platform.json +1 -0
- package/src/i18n/locales/en/components.json +18 -1
- package/src/i18n/locales/en/platform.json +1 -0
- package/src/i18n/locales/es/components.json +18 -1
- package/src/i18n/locales/es/platform.json +1 -0
- package/src/i18n/locales/fr/components.json +18 -1
- package/src/i18n/locales/fr/platform.json +1 -0
- package/src/i18n/locales/ja/components.json +18 -1
- package/src/i18n/locales/ja/platform.json +1 -0
- package/src/i18n/locales/ko/components.json +18 -1
- package/src/i18n/locales/ko/platform.json +1 -0
- package/src/i18n/locales/pt/components.json +18 -1
- package/src/i18n/locales/pt/platform.json +1 -0
- package/src/i18n/locales/ru/components.json +18 -1
- package/src/i18n/locales/ru/platform.json +1 -0
- package/src/i18n/locales/zh-Hans/components.json +18 -1
- package/src/i18n/locales/zh-Hans/platform.json +1 -0
- package/src/i18n/locales/zh-Hant/components.json +18 -1
- package/src/i18n/locales/zh-Hant/platform.json +1 -0
- package/src/index.ts +3 -0
- package/src/plugins/bootLandingCss.mjs +1 -1
- package/src/styles/theme/channels.scss +16 -0
- package/src/theme/presets.ts +62 -0
- package/src/theme/solidInk.contract.test.ts +194 -0
- package/src/tokens.scss +16 -0
- package/src/components/HkToast.onSolidInk.contract.test.ts +0 -95
package/package.json
CHANGED
|
@@ -83,20 +83,17 @@
|
|
|
83
83
|
gap: var(--space-8, 8px);
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
// Variant backgrounds follow the HkToast conventions
|
|
87
|
-
//
|
|
86
|
+
// Variant backgrounds follow the HkToast conventions: each tinted band inks
|
|
87
|
+
// itself from its OWN fill via --hi-color-text-on-<tone> (the theme derives
|
|
88
|
+
// it per tone: white on saturated fills, black on the light ones).
|
|
88
89
|
.hk-blocking-toast-info {
|
|
89
90
|
background: var(--hi-color-info, #6abed6);
|
|
90
|
-
|
|
91
|
-
* #fff fallback so themeless hosts render as before. */
|
|
92
|
-
color: var(--hi-color-text-on-solid, #fff);
|
|
91
|
+
color: var(--hi-color-text-on-info, #fff);
|
|
93
92
|
}
|
|
94
93
|
|
|
95
94
|
.hk-blocking-toast-warning {
|
|
96
95
|
background: var(--hi-color-warning, #eed677);
|
|
97
|
-
|
|
98
|
-
* the on-solid slot is white — a white glyph here would be unreadable. */
|
|
99
|
-
color: #1c1c1e;
|
|
96
|
+
color: var(--hi-color-text-on-warning, #1c1c1e);
|
|
100
97
|
}
|
|
101
98
|
|
|
102
99
|
.hk-blocking-toast-danger {
|
|
@@ -67,6 +67,14 @@
|
|
|
67
67
|
gap: var(--space-8, 0.5rem);
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
/* The touch action lane parks in the same flex line and owns the auto
|
|
71
|
+
margin; a trailing column beside it yields its own (the class the TSX
|
|
72
|
+
binds), so the row's free space never splits between the two right
|
|
73
|
+
edges. */
|
|
74
|
+
.hk-list-row-trailing--parked {
|
|
75
|
+
margin-left: 0;
|
|
76
|
+
}
|
|
77
|
+
|
|
70
78
|
/* ── Option-control array (HkListRow's `actions`) ───────────────────────
|
|
71
79
|
* The row's last lane: named icon buttons in one of two layouts (see
|
|
72
80
|
* HkListRowActionsMode). "persistent" keeps the lane in the flow — it
|
|
@@ -138,7 +138,17 @@ export function hkListRowMenuItems(actions: readonly HkListRowAction[]): HkMenuI
|
|
|
138
138
|
*
|
|
139
139
|
* The row is a list item, not a button — set `clickable` when the whole
|
|
140
140
|
* row drills through, which adds the cursor/focus/hover contract the
|
|
141
|
-
* stat cards use.
|
|
141
|
+
* stat cards use. Clicks inside the trailing column and the action lane
|
|
142
|
+
* STOP at their wrapper (the HkStatCard action-wrapper rule): an
|
|
143
|
+
* affordance nested in a clickable row owns its click and never
|
|
144
|
+
* double-fires the row's — the synthesized click a keyboard Enter
|
|
145
|
+
* produces on a lane button bubbles exactly like a pointer click, so
|
|
146
|
+
* the guard lives on the containers, not on individual buttons. The
|
|
147
|
+
* touch trigger's named menu teleports (HkMenu popup panels are
|
|
148
|
+
* siblings of the row, not children), so menu selections don't bubble
|
|
149
|
+
* either. When the touch lane owns the right edge, the trailing column
|
|
150
|
+
* gives up its auto margin (`--parked` below) so the two never split
|
|
151
|
+
* the row's free space.
|
|
142
152
|
*/
|
|
143
153
|
export const HkListRow = defineComponent({
|
|
144
154
|
name: "HkListRow",
|
|
@@ -188,6 +198,15 @@ export const HkListRow = defineComponent({
|
|
|
188
198
|
onMounted(() => document.addEventListener("pointerdown", onDocumentPointerDown, true));
|
|
189
199
|
onBeforeUnmount(() => document.removeEventListener("pointerdown", onDocumentPointerDown, true));
|
|
190
200
|
const menuItems = computed<HkMenuItem[]>(() => hkListRowMenuItems(props.actions ?? []));
|
|
201
|
+
/** Clicks inside an interactive wrapper (trailing column, action
|
|
202
|
+
* lane) stop here: the row's clickable handler must never see
|
|
203
|
+
* them — a per-row delete button that also selected the row was
|
|
204
|
+
* the 2026-11-13 theme-panel field report. Covers pointer clicks
|
|
205
|
+
* AND the click a keyboard Enter synthesizes on the focused
|
|
206
|
+
* button (same bubbling path). */
|
|
207
|
+
function stopRowClick(e: MouseEvent) {
|
|
208
|
+
e.stopPropagation();
|
|
209
|
+
}
|
|
191
210
|
return () => (
|
|
192
211
|
<div
|
|
193
212
|
ref={rowEl}
|
|
@@ -217,7 +236,20 @@ export const HkListRow = defineComponent({
|
|
|
217
236
|
{props.subtitle ? <div class="hk-list-row-subtitle">{props.subtitle}</div> : null}
|
|
218
237
|
{slots.default?.()}
|
|
219
238
|
</div>
|
|
220
|
-
{slots.trailing ?
|
|
239
|
+
{slots.trailing ? (
|
|
240
|
+
<div
|
|
241
|
+
class={[
|
|
242
|
+
"hk-list-row-trailing",
|
|
243
|
+
// The touch lane parks in the same flex line and owns the
|
|
244
|
+
// auto margin; the trailing column yields (see class doc
|
|
245
|
+
// above) so the two never split the free space.
|
|
246
|
+
hasActions() && touchFirst.value && "hk-list-row-trailing--parked",
|
|
247
|
+
]}
|
|
248
|
+
onClick={stopRowClick}
|
|
249
|
+
>
|
|
250
|
+
{slots.trailing()}
|
|
251
|
+
</div>
|
|
252
|
+
) : null}
|
|
221
253
|
{hasActions() && (
|
|
222
254
|
<div
|
|
223
255
|
class={[
|
|
@@ -231,6 +263,7 @@ export const HkListRow = defineComponent({
|
|
|
231
263
|
data-revealed={revealed.value ? "" : undefined}
|
|
232
264
|
role={touchFirst.value ? undefined : "toolbar"}
|
|
233
265
|
aria-label={touchFirst.value ? undefined : props.actionsLabel}
|
|
266
|
+
onClick={stopRowClick}
|
|
234
267
|
>
|
|
235
268
|
{touchFirst.value ? (
|
|
236
269
|
<button
|
|
@@ -60,13 +60,25 @@ function seedScheme(mode: "dark" | "light"): ThemeSchemeTokens {
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
type ColorTokenKey = keyof ThemeSchemeTokens;
|
|
63
|
-
/**
|
|
64
|
-
|
|
63
|
+
/**
|
|
64
|
+
* Required (always-present) token slots — excludes the optional content
|
|
65
|
+
* colors: the on-solid brand pair and the per-tone on-fill inks
|
|
66
|
+
* (danger/success/warning/info), which a theme may leave to solidInk.
|
|
67
|
+
*/
|
|
68
|
+
type OptionalTokenKey = "onSolidText" | "onSolidIcon" | "onDanger" | "onSuccess" | "onWarning" | "onInfo";
|
|
69
|
+
type RequiredTokenKey = Exclude<ColorTokenKey, OptionalTokenKey>;
|
|
65
70
|
|
|
66
71
|
const editableTokens: RequiredTokenKey[] = ["primary", "secondary", "accent", "success", "error", "warning", "info"];
|
|
67
72
|
const derivedTokens: RequiredTokenKey[] = ["background", "surface", "text", "muted", "border", "focusedBorder", "selectedBackground", "selectedText", "statusBarBackground"];
|
|
68
73
|
/** Content colors ON solid brand fills: user-choosable, never derived. */
|
|
69
|
-
const contentTokens:
|
|
74
|
+
const contentTokens: OptionalTokenKey[] = ["onSolidText", "onSolidIcon"];
|
|
75
|
+
/** Per-tone on-fill inks: optional too, so legacy prefills may omit them. */
|
|
76
|
+
const toneInkTokens: Array<"onDanger" | "onSuccess" | "onWarning" | "onInfo"> = [
|
|
77
|
+
"onDanger",
|
|
78
|
+
"onSuccess",
|
|
79
|
+
"onWarning",
|
|
80
|
+
"onInfo",
|
|
81
|
+
];
|
|
70
82
|
const WHITE: ThemeTokenRGB = { r: 255, g: 255, b: 255 };
|
|
71
83
|
|
|
72
84
|
function clamp(v: number): number {
|
|
@@ -209,6 +221,13 @@ export const HkColorSchemeEditor = defineComponent({
|
|
|
209
221
|
dark[k] = props.initialDark?.[k] ?? WHITE;
|
|
210
222
|
light[k] = props.initialLight?.[k] ?? WHITE;
|
|
211
223
|
}
|
|
224
|
+
// Per-tone on-fill inks: same optional-slot treatment. Omitted ones
|
|
225
|
+
// fall back to the tone fill's own judgement (see solidInk), so a
|
|
226
|
+
// legacy prefill keeps deriving instead of freezing a stale value.
|
|
227
|
+
for (const k of toneInkTokens) {
|
|
228
|
+
dark[k] = props.initialDark?.[k];
|
|
229
|
+
light[k] = props.initialLight?.[k];
|
|
230
|
+
}
|
|
212
231
|
seedGroups(groupDark, "dark", props.initialGroups?.dark);
|
|
213
232
|
seedGroups(groupLight, "light", props.initialGroups?.light);
|
|
214
233
|
rederiveSurface();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import HkIconButton from "./HkIconButton";
|
|
2
1
|
import HkAddTile from "./HkAddTile";
|
|
2
|
+
import { HkListRow, type HkListRowAction } from "./HkCardList";
|
|
3
3
|
|
|
4
4
|
import { computed, defineComponent, onUnmounted, ref, watch, type PropType } from "vue";
|
|
5
5
|
import { Monitor, MoonStar, Sun, Trash as Trash2 } from "lucide-vue-next";
|
|
@@ -45,8 +45,13 @@ export interface ThemeItemScope {
|
|
|
45
45
|
*
|
|
46
46
|
* Everything between the popover's padding lives here: the color-mode
|
|
47
47
|
* group (HTabs segmented with the solar-altitude merged cell), the
|
|
48
|
-
* `mode-extra` host strip, the preset/custom theme rows (
|
|
49
|
-
*
|
|
48
|
+
* `mode-extra` host strip, the preset/custom theme rows (the STANDARD
|
|
49
|
+
* list row — HkListRow, 2026-11-13 user direction — with four scoped
|
|
50
|
+
* host slots), the customize entry and the `menu-extra` slot. The rows
|
|
51
|
+
* read as list items (role="listitem" + aria-current), not buttons —
|
|
52
|
+
* selection is the row's wash plus its click/Enter contract; lane and
|
|
53
|
+
* trailing clicks stop at their wrappers (HkListRow's clickable-row
|
|
54
|
+
* rule), so per-row affordances never double-fire a selection. The
|
|
50
55
|
* built-in HColorSchemeDialog rides along when `externalCustomize` is
|
|
51
56
|
* false — dialogs teleport, so hosting this inside any surface is safe.
|
|
52
57
|
*
|
|
@@ -67,6 +72,26 @@ export const HkThemePanelContent = defineComponent({
|
|
|
67
72
|
* dialog is not rendered in this mode.
|
|
68
73
|
*/
|
|
69
74
|
externalCustomize: { type: Boolean, default: false },
|
|
75
|
+
/**
|
|
76
|
+
* Per-row option-control builder (2026-11-13 user direction: the
|
|
77
|
+
* theme rows ride the standard list row, and the host owns the
|
|
78
|
+
* affordances on its lane). Returns the row's `HkListRowAction[]`.
|
|
79
|
+
* The grammar follows HkCardList's `actions` prop: a PRESENT
|
|
80
|
+
* builder owns the row's lane — an EMPTY array means "no actions",
|
|
81
|
+
* while a per-row `undefined` declines and falls back to the
|
|
82
|
+
* built-in anatomy (custom rows get the standard delete, unless an
|
|
83
|
+
* `item-trailing` slot is rendered — its suppression contract
|
|
84
|
+
* stands). A
|
|
85
|
+
* CALLBACK PROP, not a slot, deliberately: slot returns are
|
|
86
|
+
* normalized into vnodes by Vue, and plain action objects would be
|
|
87
|
+
* silently destroyed in transit (the name/onSelect payload is
|
|
88
|
+
* data, not render output — the same grammar as HkCardList's own
|
|
89
|
+
* `actions` prop).
|
|
90
|
+
*/
|
|
91
|
+
itemActions: {
|
|
92
|
+
type: Function as PropType<(scope: ThemeItemScope) => HkListRowAction[] | undefined>,
|
|
93
|
+
default: undefined,
|
|
94
|
+
},
|
|
70
95
|
},
|
|
71
96
|
emits: {
|
|
72
97
|
"update:scheme": (_theme: HCustomTheme) => true,
|
|
@@ -227,19 +252,28 @@ export const HkThemePanelContent = defineComponent({
|
|
|
227
252
|
<HDivider spacing="md" />
|
|
228
253
|
|
|
229
254
|
<div class="s-theme-menu-label">{t("hikari::theme.themes")}</div>
|
|
255
|
+
{/* The rows are a real list (role="list") so HkListRow's
|
|
256
|
+
role="listitem" anatomy reads correctly to assistive tech. */}
|
|
257
|
+
<div class="s-theme-item-list" role="list">
|
|
230
258
|
{allThemeList.value.map((th) => {
|
|
231
|
-
// Host-customizable row anatomy
|
|
232
|
-
//
|
|
233
|
-
//
|
|
234
|
-
//
|
|
235
|
-
//
|
|
236
|
-
//
|
|
237
|
-
//
|
|
238
|
-
//
|
|
239
|
-
//
|
|
240
|
-
// renders
|
|
241
|
-
//
|
|
242
|
-
//
|
|
259
|
+
// Host-customizable row anatomy, on the STANDARD list row
|
|
260
|
+
// (2026-11-13 user direction: the theme list rides hikari's
|
|
261
|
+
// standard list component so its right-side control facility
|
|
262
|
+
// — the hover-revealed action lane on pointer devices, the
|
|
263
|
+
// ⋯ named menu on touch — comes for free). `item-leading`
|
|
264
|
+
// renders for EVERY row (fixed icon cell, so names stay
|
|
265
|
+
// aligned); `item-name-suffix` renders right after the name,
|
|
266
|
+
// so a host mark (e.g. a provenance/sync glyph) reads as
|
|
267
|
+
// part of the name instead of as an affordance;
|
|
268
|
+
// `item-trailing` renders quiet trailing CONTENT (badges) —
|
|
269
|
+
// it is what the action lane covers while engaged, so
|
|
270
|
+
// affordances do not belong there anymore; the `itemActions`
|
|
271
|
+
// prop supplies the row's option-control array
|
|
272
|
+
// (HkListRowAction[] — named, localized by the host's own
|
|
273
|
+
// translator; a callback PROP, see the prop's doc). Without
|
|
274
|
+
// them the rows behave exactly as before: the active row's
|
|
275
|
+
// wash marks selection, and custom rows carry the built-in
|
|
276
|
+
// delete on the standard lane.
|
|
243
277
|
const scope: ThemeItemScope = {
|
|
244
278
|
id: th.id,
|
|
245
279
|
name: th.name,
|
|
@@ -256,59 +290,76 @@ export const HkThemePanelContent = defineComponent({
|
|
|
256
290
|
// key, so literal display names pass through unchanged, and the
|
|
257
291
|
// reactive message lookup re-renders rows on locale switches.
|
|
258
292
|
const displayName = t(th.name);
|
|
293
|
+
const isActive = currentTheme.value === th.id;
|
|
294
|
+
// Default lane anatomy: the host's `itemActions` builder wins;
|
|
295
|
+
// a host that renders `item-trailing` owns the affordance
|
|
296
|
+
// column (the suppression contract the old overlay button
|
|
297
|
+
// honored) and gets no built-in lane; fully default rows put
|
|
298
|
+
// the custom delete on the standard lane.
|
|
299
|
+
const actions: HkListRowAction[] | undefined =
|
|
300
|
+
props.itemActions?.(scope) ??
|
|
301
|
+
(trailingSlot
|
|
302
|
+
? undefined
|
|
303
|
+
: th.isCustom
|
|
304
|
+
? [
|
|
305
|
+
{
|
|
306
|
+
name: t("hikari::theme.deleteTheme"),
|
|
307
|
+
icon: Trash2,
|
|
308
|
+
danger: true,
|
|
309
|
+
onSelect: () => removeCustomTheme(th.id),
|
|
310
|
+
},
|
|
311
|
+
]
|
|
312
|
+
: undefined);
|
|
259
313
|
return (
|
|
260
|
-
<
|
|
314
|
+
<HkListRow
|
|
261
315
|
key={th.id}
|
|
262
316
|
class="s-theme-item-row"
|
|
317
|
+
clickable
|
|
263
318
|
data-custom={th.isCustom || undefined}
|
|
319
|
+
// Deliberate DOM hook (no stylesheet consumer since the
|
|
320
|
+
// name-clearance cancellation retired): hosts and tests
|
|
321
|
+
// key off the trailing-slot mode without re-deriving it.
|
|
264
322
|
data-trailing={trailingSlot ? "slot" : undefined}
|
|
265
323
|
data-name-suffix={nameSuffixSlot ? "slot" : undefined}
|
|
266
324
|
// The ROW is the pill: the highlight state lives here so
|
|
267
325
|
// the hover/active wash spans the full row width — a
|
|
268
326
|
// trailing slot column must not shrink it (2026-10-01
|
|
269
327
|
// user report: theme rows and the 自定义 row hovered at
|
|
270
|
-
// different widths). The
|
|
271
|
-
//
|
|
272
|
-
|
|
328
|
+
// different widths). The stylesheet keeps the unified
|
|
329
|
+
// menu-item pill on this root and strips the card-list
|
|
330
|
+
// row's own chrome so the two specs don't double-paint.
|
|
331
|
+
data-active={isActive || undefined}
|
|
332
|
+
aria-current={isActive ? "true" : undefined}
|
|
333
|
+
actions={actions}
|
|
334
|
+
actionsLabel={t("hikari::theme.rowActionsLabel")}
|
|
335
|
+
onClick={() => onSelectTheme(th.id)}
|
|
273
336
|
>
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
{
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
) : th.isCustom ? (
|
|
298
|
-
<HkIconButton
|
|
299
|
-
class="s-theme-item-delete"
|
|
300
|
-
size={24}
|
|
301
|
-
variant="ghost"
|
|
302
|
-
aria-label={t("hikari::theme.deleteTheme")}
|
|
303
|
-
{...{ title: t("hikari::theme.deleteTheme") }}
|
|
304
|
-
onClick={() => removeCustomTheme(th.id)}
|
|
305
|
-
>
|
|
306
|
-
{{ icon: () => <Trash2 aria-hidden="true" /> }}
|
|
307
|
-
</HkIconButton>
|
|
308
|
-
) : null}
|
|
309
|
-
</div>
|
|
337
|
+
{{
|
|
338
|
+
default: () => (
|
|
339
|
+
<div class="s-theme-item-line">
|
|
340
|
+
{/* The selected-check fallback is RETIRED (2026-10-21
|
|
341
|
+
user direction): selection is conveyed by the row's
|
|
342
|
+
data-active wash alone. No leading slot = no
|
|
343
|
+
leading mark. */}
|
|
344
|
+
{leadingSlot ? (
|
|
345
|
+
<span class="hk-menu-item-icon s-theme-item-lead">
|
|
346
|
+
{leadingSlot(scope)}
|
|
347
|
+
</span>
|
|
348
|
+
) : null}
|
|
349
|
+
<span class="s-theme-item-name">{displayName}</span>
|
|
350
|
+
{nameSuffixSlot ? (
|
|
351
|
+
<span class="s-theme-item-name-suffix">{nameSuffixSlot(scope)}</span>
|
|
352
|
+
) : null}
|
|
353
|
+
</div>
|
|
354
|
+
),
|
|
355
|
+
trailing: trailingSlot
|
|
356
|
+
? () => <span class="s-theme-item-trailing">{trailingSlot(scope)}</span>
|
|
357
|
+
: undefined,
|
|
358
|
+
}}
|
|
359
|
+
</HkListRow>
|
|
310
360
|
);
|
|
311
361
|
})}
|
|
362
|
+
</div>
|
|
312
363
|
|
|
313
364
|
{/* The customize entry is the standard add tile (2026-11-11
|
|
314
365
|
family migration): the compact dashed form riding the END of
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
* (chest's DPI entry) align their labels with the theme rows' names
|
|
18
18
|
* without rescaling their icons. (The customize row left this contract
|
|
19
19
|
* 2026-11-11: the entry is the standard HkAddTile compact form now — a
|
|
20
|
-
* self-contained dashed tile, not a lead-column row.
|
|
20
|
+
* self-contained dashed tile, not a lead-column row. The lead cell rides
|
|
21
|
+
* the standard row's name line since 2026-11-13.)
|
|
21
22
|
*/
|
|
22
23
|
import { describe, expect, it } from "vitest";
|
|
23
24
|
import { readFileSync } from "node:fs";
|
|
@@ -31,52 +32,65 @@ describe("HkThemeToggle theme-row pill contract", () => {
|
|
|
31
32
|
// 2026-10-01 user report: with the item-trailing slot reserving a real
|
|
32
33
|
// column, the row button's hover wash stopped short of the row edge —
|
|
33
34
|
// theme rows and the standalone 自定义 row hovered at different widths.
|
|
34
|
-
// The pill
|
|
35
|
-
//
|
|
36
|
-
//
|
|
37
|
-
//
|
|
38
|
-
|
|
35
|
+
// The pill lives on `.s-theme-item-row` (full row width no matter how
|
|
36
|
+
// wide the trailing column is). Since 2026-11-13 the row root IS the
|
|
37
|
+
// standard list row (HkListRow), so the same element carries both
|
|
38
|
+
// families' classes and the card-list metrics must be compound-beaten.
|
|
39
|
+
// happy-dom has no layout engine, so the geometry is pinned as
|
|
40
|
+
// scss-text assertions.
|
|
41
|
+
it("puts the unified menu-item pill on the row root", () => {
|
|
39
42
|
const css = read("HkThemeToggle.scss");
|
|
40
43
|
const rowBlock = css.match(/\.s-theme-item-row\s*\{[^}]*\}/);
|
|
41
44
|
expect(rowBlock).not.toBeNull();
|
|
42
45
|
expect(rowBlock![0]).toContain("@include mi.item;");
|
|
43
|
-
// The
|
|
46
|
+
// The standard lane's overlay pins to the row (positioning context).
|
|
44
47
|
expect(rowBlock![0]).toContain("position: relative");
|
|
45
48
|
});
|
|
46
49
|
|
|
47
|
-
it("
|
|
50
|
+
it("compound-beats the card-list row metrics WITHOUT re-including the mixin", () => {
|
|
48
51
|
const css = read("HkThemeToggle.scss");
|
|
49
|
-
const block = css.match(/\.
|
|
52
|
+
const block = css.match(/\.hk-list-row\.s-theme-item-row\s*\{[^}]*\}/);
|
|
50
53
|
expect(block).not.toBeNull();
|
|
51
|
-
// The
|
|
52
|
-
// the
|
|
53
|
-
//
|
|
54
|
-
|
|
55
|
-
expect(block![0]).toContain("
|
|
56
|
-
expect(block![0]).toContain("min-height:
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
//
|
|
60
|
-
//
|
|
61
|
-
//
|
|
62
|
-
//
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
expect(block![0]).toContain("
|
|
54
|
+
// The card-list base (0,1,0 in HkCardList.scss) would tie-break
|
|
55
|
+
// against the pill chrome; the compound selector (0,2,0) pins the
|
|
56
|
+
// menu-item metrics deterministically — through var() references so
|
|
57
|
+
// the sheet-context token re-binding keeps flowing in.
|
|
58
|
+
expect(block![0]).toContain("padding: var(--hk-menu-item-pad-y) var(--hk-menu-item-pad-x)");
|
|
59
|
+
expect(block![0]).toContain("min-height: var(--hk-menu-item-min-h)");
|
|
60
|
+
expect(block![0]).toContain("gap: var(--hk-menu-item-gap)");
|
|
61
|
+
expect(block![0]).toContain("border-radius: var(--hk-menu-item-radius)");
|
|
62
|
+
// The re-include trap (see _menu-item.scss's adoption note): a nested
|
|
63
|
+
// mi.item at (0,2,0) would tie with the modal sheet-token re-binding
|
|
64
|
+
// (0,2,0) and defeat the 44px touch geometry there (HkBreadcrumb).
|
|
65
|
+
// This rule must reference the tokens, never re-declare them.
|
|
66
|
+
expect(block![0]).not.toContain("mi.item");
|
|
67
|
+
// The full state transition is restored (the clickable class's
|
|
68
|
+
// narrower transition would otherwise win at (0,2,0)).
|
|
69
|
+
expect(block![0]).toContain("border-color 0.12s ease");
|
|
67
70
|
});
|
|
68
71
|
|
|
69
|
-
it("
|
|
72
|
+
it("keeps the row focus ring deterministic against the clickable class", () => {
|
|
70
73
|
const css = read("HkThemeToggle.scss");
|
|
71
|
-
//
|
|
72
|
-
// the
|
|
73
|
-
|
|
74
|
-
expect(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
74
|
+
// mi.item's :focus-visible ties with HkListRow-clickable's at (0,2,0);
|
|
75
|
+
// the compound rule (0,3,0) makes the ring order-independent.
|
|
76
|
+
const block = css.match(/\.hk-list-row\.s-theme-item-row:focus-visible\s*\{[^}]*\}/);
|
|
77
|
+
expect(block).not.toBeNull();
|
|
78
|
+
expect(block![0]).toContain("outline: 2px solid rgb(var(--color-primary) / 70%)");
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it("keeps the item-list wrapper on the family row rhythm", () => {
|
|
82
|
+
// The rows used to be direct flex children of .s-theme-menu and
|
|
83
|
+
// lived on its 4px gap; the list wrapper (role="list" band) must
|
|
84
|
+
// carry the SAME gap or adjacent pills touch edge-to-edge (2026-11-13
|
|
85
|
+
// R2). happy-dom has no layout engine — pin the declarations.
|
|
86
|
+
const css = read("HkThemeToggle.scss");
|
|
87
|
+
const block = css.match(/\.s-theme-item-list\s*\{[^}]*\}/);
|
|
88
|
+
expect(block).not.toBeNull();
|
|
89
|
+
expect(block![0]).toContain("display: flex");
|
|
90
|
+
expect(block![0]).toContain("flex-direction: column");
|
|
91
|
+
expect(block![0]).toContain("gap: var(--space-4, 0.25rem)");
|
|
92
|
+
// Band width invariant: the wrapper pads nothing horizontally.
|
|
93
|
+
expect(block![0]).not.toMatch(/padding/);
|
|
80
94
|
});
|
|
81
95
|
|
|
82
96
|
it("registers the theme row family for the mobile sheet token swap", () => {
|
|
@@ -92,13 +106,37 @@ describe("HkThemeToggle theme-row pill contract", () => {
|
|
|
92
106
|
expect(modalList).not.toBeNull();
|
|
93
107
|
expect(modalList![0]).toContain(".s-theme-item-row");
|
|
94
108
|
});
|
|
109
|
+
|
|
110
|
+
it("sizes the sheet action trigger up to the family's touch contract", () => {
|
|
111
|
+
// The standard lane's touch trigger (⋯) is the ONLY actions tap
|
|
112
|
+
// target on touch-first clients; the generic 26px box would be the
|
|
113
|
+
// one undersized target among 44px sheet rows (the retired delete
|
|
114
|
+
// button made the same accommodation). The rule MUST sit in the
|
|
115
|
+
// component's own touch predicate block — the 2026-11-13 R2b round
|
|
116
|
+
// caught the width-based regex bridging across blocks and pinning
|
|
117
|
+
// nothing (reverting the predicate kept every test green), so the
|
|
118
|
+
// fence below pins the media block CONTAINMENT the same way the
|
|
119
|
+
// customize tile's does: no `[\s\S]*?` crossing a closing brace.
|
|
120
|
+
const css = read("HkThemeToggle.scss");
|
|
121
|
+
const block = css.match(
|
|
122
|
+
/@media \(hover: none\), \(pointer: coarse\) \{[^@]*?\.s-theme-item-row \.hk-list-row-actions__trigger\s*\{[^}]*width: 2\.25rem[^}]*\}/,
|
|
123
|
+
);
|
|
124
|
+
expect(block).not.toBeNull();
|
|
125
|
+
expect(block![0]).toContain("height: 2.25rem");
|
|
126
|
+
// And the retired width-based seat must not come back: no trigger
|
|
127
|
+
// rule under the viewport block.
|
|
128
|
+
const widthBlock = css.match(
|
|
129
|
+
/@media \(max-width: 767px\) \{[^@]*\.s-theme-item-row \.hk-list-row-actions__trigger/,
|
|
130
|
+
);
|
|
131
|
+
expect(widthBlock).toBeNull();
|
|
132
|
+
});
|
|
95
133
|
});
|
|
96
134
|
|
|
97
135
|
describe("HkThemeToggle row lead-cell contract", () => {
|
|
98
136
|
it("sizes the theme-row lead cell to fit a 28px swatch mark", () => {
|
|
99
137
|
const css = read("HkThemeToggle.scss");
|
|
100
138
|
const block = css.match(
|
|
101
|
-
/\.s-theme-item-
|
|
139
|
+
/\.s-theme-item-line \.hk-menu-item-icon\.s-theme-item-lead\s*\{[^}]*\}/,
|
|
102
140
|
);
|
|
103
141
|
expect(block).not.toBeNull();
|
|
104
142
|
expect(block![0]).toContain("width: 28px");
|
|
@@ -107,10 +145,10 @@ describe("HkThemeToggle row lead-cell contract", () => {
|
|
|
107
145
|
|
|
108
146
|
it("does not widen icon cells with a bare unscoped theme-row rule", () => {
|
|
109
147
|
const css = read("HkThemeToggle.scss");
|
|
110
|
-
// A bare `.s-theme-item-
|
|
111
|
-
//
|
|
148
|
+
// A bare `.s-theme-item-line .hk-menu-item-icon {` would normalize
|
|
149
|
+
// every cell in the line; the widened cell may only target named
|
|
112
150
|
// scopes (lead slot, mode-extra strip).
|
|
113
|
-
expect(css).not.toMatch(/^\.s-theme-item-
|
|
151
|
+
expect(css).not.toMatch(/^\.s-theme-item-line \.hk-menu-item-icon\s*\{/m);
|
|
114
152
|
});
|
|
115
153
|
|
|
116
154
|
it("renders the customize entry as the standard HkAddTile compact form", () => {
|