@celestia-island/hikari 0.55.403 → 0.55.406
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/HkAlert.role.test.tsx +103 -0
- package/src/components/HkAlert.tsx +23 -1
- package/src/components/HkNotificationBell.scss +10 -1
- package/src/components/HkNotificationBell.styles.test.ts +17 -0
- package/src/components/HkVirtualCursor.ink.test.ts +41 -0
- package/src/components/HkVirtualCursor.scss +18 -7
package/package.json
CHANGED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { afterEach, describe, expect, it } from "vitest";
|
|
2
|
+
import { createApp, defineComponent, h, nextTick, reactive } from "vue";
|
|
3
|
+
|
|
4
|
+
import HkAlert from "./HkAlert";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A11y guard for HkAlert's root live-region semantics: error/warning
|
|
8
|
+
* announce assertively (`role="alert"` + aria-live="assertive"), info/
|
|
9
|
+
* success politely (`role="status"` + aria-live="polite") — the same
|
|
10
|
+
* split and explicit pairing as the HkToast family. The role rides the
|
|
11
|
+
* ROOT element so the whole alert body is one announced region, and
|
|
12
|
+
* the pairing must survive a runtime variant change (both real
|
|
13
|
+
* consumers mount the alert conditionally; HkSectionCard swaps the
|
|
14
|
+
* variant as state changes).
|
|
15
|
+
*
|
|
16
|
+
* (Repo test convention: raw createApp + document queries, no
|
|
17
|
+
* @vue/test-utils dependency.)
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
const mounts: Array<{ app: ReturnType<typeof createApp>; container: HTMLElement }> = [];
|
|
21
|
+
|
|
22
|
+
function mountAlert(props: Record<string, unknown> = {}): HTMLElement {
|
|
23
|
+
const container = document.createElement("div");
|
|
24
|
+
document.body.appendChild(container);
|
|
25
|
+
const Wrapper = defineComponent({
|
|
26
|
+
setup() {
|
|
27
|
+
return () => h(HkAlert, { message: "mind the gap", ...props });
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
const app = createApp(Wrapper);
|
|
31
|
+
app.mount(container);
|
|
32
|
+
mounts.push({ app, container });
|
|
33
|
+
const el = container.querySelector<HTMLElement>(".hk-alert");
|
|
34
|
+
expect(el, ".hk-alert renders").toBeTruthy();
|
|
35
|
+
return el!;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
afterEach(() => {
|
|
39
|
+
for (const { app, container } of mounts) {
|
|
40
|
+
app.unmount();
|
|
41
|
+
container.remove();
|
|
42
|
+
}
|
|
43
|
+
mounts.length = 0;
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
describe("HkAlert live-region role", () => {
|
|
47
|
+
it.each([
|
|
48
|
+
["error", "alert", "assertive"],
|
|
49
|
+
["warning", "alert", "assertive"],
|
|
50
|
+
["info", "status", "polite"],
|
|
51
|
+
["success", "status", "polite"],
|
|
52
|
+
] as const)(
|
|
53
|
+
"the %s variant renders role=%s + aria-live=%s on the root",
|
|
54
|
+
(variant, role, live) => {
|
|
55
|
+
const el = mountAlert({ variant });
|
|
56
|
+
expect(el.getAttribute("role")).toBe(role);
|
|
57
|
+
expect(el.getAttribute("aria-live")).toBe(live);
|
|
58
|
+
},
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
it("the default variant (error) announces assertively", () => {
|
|
62
|
+
const el = mountAlert();
|
|
63
|
+
expect(el.getAttribute("role")).toBe("alert");
|
|
64
|
+
expect(el.getAttribute("aria-live")).toBe("assertive");
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it("the pairing survives a runtime variant change", async () => {
|
|
68
|
+
// The computed role must react to the prop: HkSectionCard swaps the
|
|
69
|
+
// variant while mounted (idle → error), so a stale role would
|
|
70
|
+
// mis-announce the whole class of state-driven alerts.
|
|
71
|
+
const state = reactive<{ variant: "info" | "error" }>({ variant: "info" });
|
|
72
|
+
const container = document.createElement("div");
|
|
73
|
+
document.body.appendChild(container);
|
|
74
|
+
const Wrapper = defineComponent({
|
|
75
|
+
setup() {
|
|
76
|
+
return () => h(HkAlert, { message: "mind the gap", ...state });
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
const app = createApp(Wrapper);
|
|
80
|
+
app.mount(container);
|
|
81
|
+
mounts.push({ app, container });
|
|
82
|
+
|
|
83
|
+
const el = container.querySelector<HTMLElement>(".hk-alert")!;
|
|
84
|
+
expect(el.getAttribute("role")).toBe("status");
|
|
85
|
+
expect(el.getAttribute("aria-live")).toBe("polite");
|
|
86
|
+
|
|
87
|
+
state.variant = "error";
|
|
88
|
+
await nextTick();
|
|
89
|
+
expect(el.getAttribute("role")).toBe("alert");
|
|
90
|
+
expect(el.getAttribute("aria-live")).toBe("assertive");
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it("the root is the only role carrier — even with title + close button", () => {
|
|
94
|
+
// The closable configuration adds the most plausible nested
|
|
95
|
+
// candidate (a <button>); it must stay role-less so the root
|
|
96
|
+
// remains the ONE announced region (no double announcement).
|
|
97
|
+
const el = mountAlert({ variant: "info", closable: true, title: "Heads up" });
|
|
98
|
+
expect(el.classList.contains("hk-alert")).toBe(true);
|
|
99
|
+
expect(el.getAttribute("role")).toBe("status");
|
|
100
|
+
expect(el.querySelector("button.hk-alert-close")).toBeTruthy();
|
|
101
|
+
expect(el.querySelectorAll("[role]").length).toBe(0);
|
|
102
|
+
});
|
|
103
|
+
});
|
|
@@ -45,6 +45,23 @@ export default defineComponent({
|
|
|
45
45
|
!props.title ? "hk-alert-no-title" : "",
|
|
46
46
|
]);
|
|
47
47
|
|
|
48
|
+
// Live-region semantics by variant — the HkToast family split
|
|
49
|
+
// (HkToast.tsx): errors/warnings interrupt (`role="alert"` +
|
|
50
|
+
// assertive), everything else announces politely (`role="status"` +
|
|
51
|
+
// polite). The aria-live attribute rides along explicitly, same as
|
|
52
|
+
// HkToast / HkLoadingVeil / HkPersistentToast, though ARIA already
|
|
53
|
+
// implies it from the role. A live region only announces content
|
|
54
|
+
// inserted or changed AFTER it registers — an alert present at
|
|
55
|
+
// mount is read in document order like static content; both real
|
|
56
|
+
// in-repo consumers mount the alert conditionally (HkSectionCard
|
|
57
|
+
// error state, HkMfaVerifyCard retry hint). The role rides the
|
|
58
|
+
// ROOT so the whole alert body is one announced region.
|
|
59
|
+
const a11y = computed(() =>
|
|
60
|
+
props.variant === "error" || props.variant === "warning"
|
|
61
|
+
? ({ role: "alert", "aria-live": "assertive" } as const)
|
|
62
|
+
: ({ role: "status", "aria-live": "polite" } as const),
|
|
63
|
+
);
|
|
64
|
+
|
|
48
65
|
function onClose() {
|
|
49
66
|
isDismissed.value = true;
|
|
50
67
|
emit("close");
|
|
@@ -56,7 +73,12 @@ export default defineComponent({
|
|
|
56
73
|
const IconComp = VARIANT_ICONS[props.variant];
|
|
57
74
|
|
|
58
75
|
return (
|
|
59
|
-
<div
|
|
76
|
+
<div
|
|
77
|
+
class={rootCls.value}
|
|
78
|
+
style={hkPadStyle(props.padding)}
|
|
79
|
+
role={a11y.value.role}
|
|
80
|
+
aria-live={a11y.value["aria-live"]}
|
|
81
|
+
>
|
|
60
82
|
<span class="hk-alert-icon">
|
|
61
83
|
{slots.icon ? (
|
|
62
84
|
slots.icon()
|
|
@@ -82,6 +82,16 @@
|
|
|
82
82
|
|
|
83
83
|
.hk-notification-row {
|
|
84
84
|
display: flex;
|
|
85
|
+
/* All three columns (glyph / body / actions) center against the ROW
|
|
86
|
+
height, never against their own content. The default stretch
|
|
87
|
+
stretched a ONE-LINE body to the 24px dismiss button's height while
|
|
88
|
+
the block body hugged the top — the title floated ~4px above the
|
|
89
|
+
shared center line, clearly visible exactly when the row has a
|
|
90
|
+
single line (user report 2026-11-17; both the desktop flyout and
|
|
91
|
+
the mobile sheet share this renderer). Whole-row centering is the
|
|
92
|
+
same grammar the actions column already speaks (2026-11-15 ruling
|
|
93
|
+
below). */
|
|
94
|
+
align-items: center;
|
|
85
95
|
gap: var(--space-12, 0.75rem);
|
|
86
96
|
padding: var(--space-8, 0.5rem) var(--space-8, 0.5rem);
|
|
87
97
|
border-bottom: 1px solid rgb(var(--color-border) / 6%);
|
|
@@ -95,7 +105,6 @@
|
|
|
95
105
|
flex: none;
|
|
96
106
|
display: inline-flex;
|
|
97
107
|
align-items: center;
|
|
98
|
-
padding-top: 2px;
|
|
99
108
|
/* Tone ink follows the row's tone class (rules below). */
|
|
100
109
|
color: rgb(var(--color-text) / 65%);
|
|
101
110
|
}
|
|
@@ -25,6 +25,23 @@ describe("HkNotificationBell scss contract", () => {
|
|
|
25
25
|
);
|
|
26
26
|
});
|
|
27
27
|
|
|
28
|
+
it("the row centers its columns against the ROW height (one-line rows included)", () => {
|
|
29
|
+
// Default stretch stretched a one-line body to the 24px dismiss
|
|
30
|
+
// button and hugged the title to the body's top — visibly off the
|
|
31
|
+
// shared center line exactly when the row has a single line
|
|
32
|
+
// (user report 2026-11-17).
|
|
33
|
+
expect(scss).toMatch(/^\.hk-notification-row \{[^}]*align-items:\s*center;/m);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("the tone glyph carries no stretch-era first-line padding hack", () => {
|
|
37
|
+
// `padding-top: 2px` was an optical nudge for the first line under
|
|
38
|
+
// stretch; under row centering it parks the glyph below the shared
|
|
39
|
+
// center line, so the icon rule must not carry any padding-top.
|
|
40
|
+
const iconBlock = scss.match(/^\.hk-notification-row__icon \{([^}]*)\}/m);
|
|
41
|
+
expect(iconBlock).toBeTruthy();
|
|
42
|
+
expect(iconBlock![1]).not.toContain("padding-top");
|
|
43
|
+
});
|
|
44
|
+
|
|
28
45
|
it("the dismiss glyph ink rides --hi-icon-button-icon-color (ancestor color is inert)", () => {
|
|
29
46
|
// Rest ink on the button, plus the row-hover/focus-within brighten —
|
|
30
47
|
// both through the var channel the ghost button itself consumes.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
|
|
4
|
+
import { describe, expect, it } from "vitest";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The cursor's ink is THEME-INDEPENDENT (2026-11-16 field finding).
|
|
8
|
+
*
|
|
9
|
+
* The glyph rides the remote screen, which is dark in every app theme —
|
|
10
|
+
* the HkTerminal doctrine. The first cut used the page's text token, so
|
|
11
|
+
* in a light theme (--color-text near-black) the pointer rendered
|
|
12
|
+
* near-invisible against the black remote canvas: measured computed
|
|
13
|
+
* fill `rgb(30 30 30)` over `#0b0d12`. Both the arrow and the lobes now
|
|
14
|
+
* speak fixed light ink / dark glass, and this pin keeps a future edit
|
|
15
|
+
* from quietly restoring the theme tokens.
|
|
16
|
+
*/
|
|
17
|
+
const scss = readFileSync(join(__dirname, "HkVirtualCursor.scss"), "utf8");
|
|
18
|
+
|
|
19
|
+
describe("HkVirtualCursor ink", () => {
|
|
20
|
+
it("the arrow is fixed light ink with a dark outline", () => {
|
|
21
|
+
// The sheet nests `path { … }` inside the arrow block; take the
|
|
22
|
+
// arrow block and check the nested rule inside it.
|
|
23
|
+
const arrow = /\.hk-virtual-cursor__arrow \{[\s\S]*?\n\}/.exec(scss)?.[0] ?? "";
|
|
24
|
+
expect(arrow, "the arrow block is present").not.toBe("");
|
|
25
|
+
const path = /path \{[\s\S]*?\n \}/.exec(arrow)?.[0] ?? "";
|
|
26
|
+
expect(path, "the nested path rule is present").not.toBe("");
|
|
27
|
+
expect(path).toMatch(/fill:\s*rgb\(255 255 255/);
|
|
28
|
+
expect(path).toMatch(/stroke:\s*rgb\(0 0 0/);
|
|
29
|
+
// The theme ink must not come back: it is near-black in light themes.
|
|
30
|
+
expect(path).not.toContain("--color-text");
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("the lobes speak a fixed dark-glass face, not the theme surface", () => {
|
|
34
|
+
const lobe = /\.hk-virtual-cursor__lobe \{[\s\S]*?\n\}/.exec(scss)?.[0] ?? "";
|
|
35
|
+
expect(lobe, "the lobe rule is present").not.toBe("");
|
|
36
|
+
expect(lobe).toMatch(/background:\s*rgb\(0 0 0 \//);
|
|
37
|
+
expect(lobe).toMatch(/color:\s*rgb\(255 255 255/);
|
|
38
|
+
expect(lobe, "no theme surface on the remote face").not.toContain("--color-background");
|
|
39
|
+
expect(lobe, "no theme ink on the remote face").not.toContain("--color-text");
|
|
40
|
+
});
|
|
41
|
+
});
|
|
@@ -28,9 +28,16 @@
|
|
|
28
28
|
filter: drop-shadow(0 1px 2px rgb(0 0 0 / 55%));
|
|
29
29
|
pointer-events: none;
|
|
30
30
|
|
|
31
|
+
/* The glyph rides a REMOTE-SCREEN surface, which is dark in every
|
|
32
|
+
* app theme (the HkTerminal doctrine: a remote canvas does not follow
|
|
33
|
+
* the page palette). Theme ink is therefore wrong here: in a light
|
|
34
|
+
* theme --color-text is near-black, and the pointer vanished against
|
|
35
|
+
* the black screen (measured: computed fill rgb(30 30 30) over
|
|
36
|
+
* #0b0d12 → effectively invisible). Fixed light ink + dark outline
|
|
37
|
+
* keeps the pointer legible on both dark and light remote content. */
|
|
31
38
|
path {
|
|
32
|
-
fill: rgb(
|
|
33
|
-
stroke: rgb(0 0 0 /
|
|
39
|
+
fill: rgb(255 255 255 / 96%);
|
|
40
|
+
stroke: rgb(0 0 0 / 70%);
|
|
34
41
|
stroke-width: 1;
|
|
35
42
|
}
|
|
36
43
|
}
|
|
@@ -45,9 +52,13 @@
|
|
|
45
52
|
place-items: center;
|
|
46
53
|
width: 30px;
|
|
47
54
|
height: 24px;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
55
|
+
/* Same doctrine as the arrow: the lobes ride the remote screen, not
|
|
56
|
+
* the page, so they speak a fixed dark-glass face (a theme-tinted
|
|
57
|
+
* pill vanishes on the remote black in dark themes and glares in
|
|
58
|
+
* light ones). Held state keeps the brand accent. */
|
|
59
|
+
border: 1px solid rgb(255 255 255 / 28%);
|
|
60
|
+
background: rgb(0 0 0 / 55%);
|
|
61
|
+
color: rgb(255 255 255 / 92%);
|
|
51
62
|
border-radius: 8px;
|
|
52
63
|
vertical-align: top;
|
|
53
64
|
cursor: pointer;
|
|
@@ -72,9 +83,9 @@
|
|
|
72
83
|
}
|
|
73
84
|
|
|
74
85
|
&[data-held] {
|
|
75
|
-
background: rgb(var(--color-primary) /
|
|
86
|
+
background: rgb(var(--color-primary) / 85%);
|
|
76
87
|
border-color: rgb(var(--color-primary));
|
|
77
|
-
color: rgb(
|
|
88
|
+
color: rgb(255 255 255);
|
|
78
89
|
|
|
79
90
|
&::after {
|
|
80
91
|
opacity: 1;
|