@celestia-island/hikari 0.55.99 → 0.55.100
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
CHANGED
|
@@ -25,6 +25,73 @@ import { fileURLToPath } from "node:url";
|
|
|
25
25
|
const here = dirname(fileURLToPath(import.meta.url));
|
|
26
26
|
const read = (f: string): string => readFileSync(join(here, f), "utf-8");
|
|
27
27
|
|
|
28
|
+
describe("HkThemeToggle theme-row pill contract", () => {
|
|
29
|
+
// 2026-10-01 user report: with the item-trailing slot reserving a real
|
|
30
|
+
// column, the row button's hover wash stopped short of the row edge —
|
|
31
|
+
// theme rows and the standalone 自定义 row hovered at different widths.
|
|
32
|
+
// The pill therefore lives on `.s-theme-item-row` (full row width no
|
|
33
|
+
// matter how wide the trailing column is) and the row's button is
|
|
34
|
+
// chromeless. happy-dom has no layout engine, so the geometry is pinned
|
|
35
|
+
// as scss-text assertions.
|
|
36
|
+
it("puts the unified menu-item pill on the row, not the row button", () => {
|
|
37
|
+
const css = read("HkThemeToggle.scss");
|
|
38
|
+
const rowBlock = css.match(/\.s-theme-item-row\s*\{[^}]*\}/);
|
|
39
|
+
expect(rowBlock).not.toBeNull();
|
|
40
|
+
expect(rowBlock![0]).toContain("@include mi.item;");
|
|
41
|
+
// The overlaid delete affordance pins to the row (positioning context).
|
|
42
|
+
expect(rowBlock![0]).toContain("position: relative");
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it("strips the row button's own chrome so the wash is not doubled", () => {
|
|
46
|
+
const css = read("HkThemeToggle.scss");
|
|
47
|
+
const block = css.match(/\.s-theme-item-row \.s-theme-item-btn\s*\{[^}]*\}/);
|
|
48
|
+
expect(block).not.toBeNull();
|
|
49
|
+
// The ROW owns the frame: its border 1 + padding 12 put the content at
|
|
50
|
+
// the same 13px the standalone pills measure (border 1 + padding 12), so
|
|
51
|
+
// the button drops its own border entirely.
|
|
52
|
+
expect(block![0]).toContain("border: none;");
|
|
53
|
+
expect(block![0]).toContain("background: transparent");
|
|
54
|
+
expect(block![0]).toContain("min-height: 0");
|
|
55
|
+
// The button stretches over the row's frame (negative block margins
|
|
56
|
+
// mirrored by re-applied padding) so the WHOLE pill is the click/focus
|
|
57
|
+
// target — master's pill WAS the button — while the name's content box
|
|
58
|
+
// keeps the standalone offsets. Losing the stretch drops the button
|
|
59
|
+
// back to a centered auto-height box inside the row (misaligned and
|
|
60
|
+
// undersized); losing the bleed pair desyncs the content offset by the
|
|
61
|
+
// frame width.
|
|
62
|
+
expect(block![0]).toContain("align-self: stretch");
|
|
63
|
+
expect(block![0]).toContain("margin-block: calc(");
|
|
64
|
+
expect(block![0]).toContain("padding-block: calc(");
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it("suppresses the row button's own hover and active state chrome", () => {
|
|
68
|
+
const css = read("HkThemeToggle.scss");
|
|
69
|
+
// The hover override must repeat mi.item's guard chain to out-specify
|
|
70
|
+
// the mixin's hover rule; the active/checked suppression targets the
|
|
71
|
+
// state attributes directly.
|
|
72
|
+
expect(css).toContain(
|
|
73
|
+
".s-theme-item-row .s-theme-item-btn:hover:not(:disabled):not([data-disabled]):not([data-active]):not([data-checked])",
|
|
74
|
+
);
|
|
75
|
+
expect(css).toMatch(
|
|
76
|
+
/\.s-theme-item-row \.s-theme-item-btn\[data-active\][^{]*\{[^}]*background: transparent/,
|
|
77
|
+
);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it("registers the theme row family for the mobile sheet token swap", () => {
|
|
81
|
+
const mi = read("_menu-item.scss");
|
|
82
|
+
// The row carries the pill, so the sheet-context token binding must
|
|
83
|
+
// target it too — otherwise sheets keep the desktop 34px metrics.
|
|
84
|
+
const sheetList = mi.match(
|
|
85
|
+
/\.hk-popover-panel\.hk-is-sheet[^{]*\{[^{]*\{[^}]*\}/,
|
|
86
|
+
);
|
|
87
|
+
expect(sheetList).not.toBeNull();
|
|
88
|
+
expect(sheetList![0]).toContain(".s-theme-item-row");
|
|
89
|
+
const modalList = mi.match(/\.hk-modal-content\s*\{[^{]*\{[^}]*\}/);
|
|
90
|
+
expect(modalList).not.toBeNull();
|
|
91
|
+
expect(modalList![0]).toContain(".s-theme-item-row");
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
|
|
28
95
|
describe("HkThemeToggle row lead-cell contract", () => {
|
|
29
96
|
it("sizes the theme-row lead cell to fit a 28px swatch mark", () => {
|
|
30
97
|
const css = read("HkThemeToggle.scss");
|
|
@@ -136,32 +136,84 @@
|
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
/* ── Theme list rows ────────────────────────────────────────────────────
|
|
139
|
-
* Every row is ONE full-width pill
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
*
|
|
139
|
+
* Every row is ONE full-width pill, and the pill is THE ROW (2026-10-01
|
|
140
|
+
* user report: with the trailing slot reserving a real column, the row
|
|
141
|
+
* button's wash stopped short of the row edge — theme rows and the
|
|
142
|
+
* standalone 自定义 row hovered at different widths). The unified
|
|
143
|
+
* menu-item chrome therefore lives on `.s-theme-item-row` (which also
|
|
144
|
+
* carries `data-active` from the TSX), and the row's button surrenders
|
|
145
|
+
* its own chrome below, so the hover/active wash, border and radius
|
|
146
|
+
* span the full row no matter how wide the trailing column is. The
|
|
147
|
+
* standalone pills (自定义 row, host mode-extra rows) keep the chrome on
|
|
148
|
+
* the button itself — same spec, same width as a row.
|
|
145
149
|
*
|
|
146
150
|
* Metrics/states come from the unified menu-item spec (./_menu-item.scss)
|
|
147
151
|
* — the same grammar as menu rows and select options; inside the mobile
|
|
148
152
|
* sheet the shared `.hk-popover-panel.hk-is-sheet` token context applies
|
|
149
|
-
* the 44px touch geometry
|
|
150
|
-
*
|
|
153
|
+
* the 44px touch geometry (the row family is registered there), so the
|
|
154
|
+
* old component-local media bump is gone (only the overlaid delete
|
|
155
|
+
* button keeps its own touch sizing below).
|
|
151
156
|
*/
|
|
152
157
|
|
|
153
158
|
.s-theme-item-row {
|
|
159
|
+
@include mi.item;
|
|
160
|
+
|
|
154
161
|
position: relative;
|
|
155
|
-
display: flex;
|
|
156
|
-
align-items: center;
|
|
157
162
|
}
|
|
158
163
|
|
|
159
|
-
/*
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
164
|
+
/* The row's button keeps the CLICK and FOCUS semantics (keyboard parity,
|
|
165
|
+
* screen-reader role) but no visual chrome of its own: background goes
|
|
166
|
+
* transparent and the border is dropped entirely — the ROW now owns the
|
|
167
|
+
* frame, and the content x lands on the same offset as the standalone
|
|
168
|
+
* pills anyway (row border 1 + row padding 12 = the standalone border 1 +
|
|
169
|
+
* padding 12 = 13px from the pill edge). Vertically the button bleeds
|
|
170
|
+
* over the row's frame (negative margins) and re-applies the padding
|
|
171
|
+
* inside, so the WHOLE pill is the click/focus target — master's pill
|
|
172
|
+
* WAS the button — while the name's content box keeps the standalone
|
|
173
|
+
* offsets (border 1 + pad-y). Row heights are unchanged: the button's
|
|
174
|
+
* net layout contribution is its content, so the row's own min-height
|
|
175
|
+
* rules exactly as the button's did before. */
|
|
176
|
+
.s-theme-item-row .s-theme-item-btn {
|
|
177
|
+
min-width: 0;
|
|
178
|
+
min-height: 0;
|
|
179
|
+
flex: 1;
|
|
180
|
+
width: auto;
|
|
181
|
+
/* Fill the row's full cross size (overriding the row's align-items:
|
|
182
|
+
* center FOR THIS ITEM only) so the click/focus target is the whole
|
|
183
|
+
* pill, not just the name's line box. */
|
|
184
|
+
align-self: stretch;
|
|
185
|
+
/* Bleed over the row's frame — its vertical padding plus the 1px
|
|
186
|
+
* mi.item border — then re-apply that padding inside: the name's
|
|
187
|
+
* content box keeps the standalone pills' offsets (border 1 + pad)
|
|
188
|
+
* while the hit area covers the pill edge to edge. The 1px constant
|
|
189
|
+
* mirrors mi.item's border width; if the mixin's border ever changes,
|
|
190
|
+
* this pair moves with it. */
|
|
191
|
+
margin-block: calc(-1 * var(--hk-menu-item-pad-y, 6px) - 1px);
|
|
192
|
+
padding-block: calc(var(--hk-menu-item-pad-y, 6px) + 1px);
|
|
193
|
+
padding-inline: 0;
|
|
194
|
+
border: none;
|
|
195
|
+
/* Follow the row's pill radius: the button keeps mi.item's :focus-visible
|
|
196
|
+
* inset outline (keyboard parity), and outlines follow border-radius —
|
|
197
|
+
* a zero radius here would render the ring as a sharp rectangle poking
|
|
198
|
+
* past the row's rounded corners. */
|
|
199
|
+
border-radius: inherit;
|
|
200
|
+
background: transparent;
|
|
201
|
+
font: inherit;
|
|
202
|
+
color: inherit;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/* Suppress the button's own state chrome — the row above owns the wash.
|
|
206
|
+
* The hover guard repeats mi.item's guard chain so this override
|
|
207
|
+
* out-specifies the mixin's (0,6,0) hover rule. */
|
|
208
|
+
.s-theme-item-row .s-theme-item-btn:hover:not(:disabled):not([data-disabled]):not([data-active]):not([data-checked]),
|
|
209
|
+
.s-theme-item-row .s-theme-item-btn[data-active],
|
|
210
|
+
.s-theme-item-row .s-theme-item-btn[data-checked] {
|
|
211
|
+
background: transparent;
|
|
212
|
+
border-color: transparent;
|
|
213
|
+
color: inherit;
|
|
214
|
+
font-weight: inherit;
|
|
215
|
+
}
|
|
216
|
+
|
|
165
217
|
.s-theme-item-btn {
|
|
166
218
|
@include mi.item;
|
|
167
219
|
|
|
@@ -283,6 +283,13 @@ describe("HkThemeToggle color-mode group", () => {
|
|
|
283
283
|
// Active check glyph sits inside the pill, leading the name.
|
|
284
284
|
const activeBtn = document.body.querySelector<HTMLButtonElement>(".s-theme-item-btn[data-active]");
|
|
285
285
|
expect(activeBtn?.querySelector(".s-theme-item-check")).toBeTruthy();
|
|
286
|
+
|
|
287
|
+
// The ROW is the pill (2026-10-01): the active state surfaces on the
|
|
288
|
+
// row element too, so the highlight spans the full row width instead
|
|
289
|
+
// of stopping short at a trailing column.
|
|
290
|
+
const activeRows = rows.filter((r) => r.hasAttribute("data-active"));
|
|
291
|
+
expect(activeRows).toHaveLength(1);
|
|
292
|
+
expect(activeRows[0].querySelector(".s-theme-item-btn[data-active]")).toBeTruthy();
|
|
286
293
|
});
|
|
287
294
|
it("renders the mode-extra strip under the mode group when provided", async () => {
|
|
288
295
|
const container = document.createElement("div");
|
|
@@ -181,16 +181,18 @@ export const HkThemeToggle = defineComponent({
|
|
|
181
181
|
* cache icon vnodes across renders, or closing/reopening the popover
|
|
182
182
|
* would re-mount the same vnode instances. In AUTO mode the Light/
|
|
183
183
|
* Dark options collapse into the group's merged cell (the altitude
|
|
184
|
-
* strip) via `mergeKeys
|
|
185
|
-
*
|
|
186
|
-
*
|
|
184
|
+
* strip) via `mergeKeys`. They stay ENABLED (2026-10-01 user report:
|
|
185
|
+
* disabled Light/Dark read as the mode being locked to the sun): in
|
|
186
|
+
* the merged rendering they are not rendered at all, and on the
|
|
187
|
+
* degradation path (merge requested without the #merged slot) a
|
|
188
|
+
* click must drop OUT of auto onto the pressed side instead of
|
|
189
|
+
* doing nothing.
|
|
187
190
|
*/
|
|
188
191
|
function modeOptions(): TabItem[] {
|
|
189
|
-
const auto = isAutoMode.value;
|
|
190
192
|
return [
|
|
191
193
|
{ key: "system", label: t("hikari::theme.modeAuto"), icon: <Monitor size={16} /> },
|
|
192
|
-
{ key: "light", label: t("hikari::theme.modeLight"), icon: <Sun size={16}
|
|
193
|
-
{ key: "dark", label: t("hikari::theme.modeDark"), icon: <MoonStar size={16}
|
|
194
|
+
{ key: "light", label: t("hikari::theme.modeLight"), icon: <Sun size={16} /> },
|
|
195
|
+
{ key: "dark", label: t("hikari::theme.modeDark"), icon: <MoonStar size={16} /> },
|
|
194
196
|
];
|
|
195
197
|
}
|
|
196
198
|
|
|
@@ -336,6 +338,13 @@ export const HkThemeToggle = defineComponent({
|
|
|
336
338
|
data-custom={th.isCustom || undefined}
|
|
337
339
|
data-trailing={trailingSlot ? "slot" : undefined}
|
|
338
340
|
data-name-suffix={nameSuffixSlot ? "slot" : undefined}
|
|
341
|
+
// The ROW is the pill: the highlight state lives here so
|
|
342
|
+
// the hover/active wash spans the full row width — a
|
|
343
|
+
// trailing slot column must not shrink it (2026-10-01
|
|
344
|
+
// user report: theme rows and the 自定义 row hovered at
|
|
345
|
+
// different widths). The button keeps the click/focus
|
|
346
|
+
// semantics; the stylesheet strips its own chrome.
|
|
347
|
+
data-active={currentTheme.value === th.id || undefined}
|
|
339
348
|
>
|
|
340
349
|
<button
|
|
341
350
|
type="button"
|
|
@@ -79,6 +79,7 @@
|
|
|
79
79
|
.hk-menu-action-item,
|
|
80
80
|
.hk-select-option,
|
|
81
81
|
.hk-popup-select-item,
|
|
82
|
+
.s-theme-item-row,
|
|
82
83
|
.s-theme-item-btn,
|
|
83
84
|
.s-popup-menu-item,
|
|
84
85
|
.hk-popup-menu-item,
|
|
@@ -98,6 +99,7 @@
|
|
|
98
99
|
.hk-menu-row,
|
|
99
100
|
.hk-menu-action-item,
|
|
100
101
|
.hk-select-option,
|
|
102
|
+
.s-theme-item-row,
|
|
101
103
|
.s-theme-item-btn,
|
|
102
104
|
.s-popup-menu-item,
|
|
103
105
|
.hk-popup-menu-item,
|