@celestia-island/hikari 0.55.257 → 0.55.258
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
|
@@ -80,6 +80,25 @@ describe("HkDonutChart", () => {
|
|
|
80
80
|
expect(empty.querySelector(".hk-donut--empty")).toBeTruthy();
|
|
81
81
|
});
|
|
82
82
|
|
|
83
|
+
it("renders the legendIcon slot's glyph in place of the text label", () => {
|
|
84
|
+
const el = mount(
|
|
85
|
+
<HkDonutChart
|
|
86
|
+
entries={ENTRIES}
|
|
87
|
+
v-slots={{
|
|
88
|
+
legendIcon: (slice: { key: string }) => <b data-flag={slice.key}>flag</b>,
|
|
89
|
+
}}
|
|
90
|
+
/>,
|
|
91
|
+
);
|
|
92
|
+
const rows = [...el.querySelectorAll(".hk-donut__legend-row")];
|
|
93
|
+
expect(rows.map((r) => r.querySelector("[data-flag]")?.getAttribute("data-flag"))).toEqual([
|
|
94
|
+
"dd",
|
|
95
|
+
"ca",
|
|
96
|
+
"bb",
|
|
97
|
+
]);
|
|
98
|
+
// the plain-text labels are gone; the color dots stay
|
|
99
|
+
expect(rows.every((r) => r.querySelector(".hk-donut__legend-dot"))).toBe(true);
|
|
100
|
+
});
|
|
101
|
+
|
|
83
102
|
it("carries the chart-level aria label", () => {
|
|
84
103
|
const el = mount(<HkDonutChart entries={ENTRIES} ariaLabel="ship mix" />);
|
|
85
104
|
expect(el.querySelector(".hk-donut")?.getAttribute("aria-label")).toBe("ship mix");
|
|
@@ -29,7 +29,9 @@ function defaultFill(i: number): string {
|
|
|
29
29
|
* o'clock start, clockwise), legend rows that stack in fixed-height
|
|
30
30
|
* columns with percents shown inline, and paired hover focus —
|
|
31
31
|
* hovering a slice or its legend row lifts the pair and dims the
|
|
32
|
-
* block's siblings without rescaling any shape.
|
|
32
|
+
* block's siblings without rescaling any shape. A scoped `legendIcon`
|
|
33
|
+
* slot (slice => node) swaps a legend row's text label for a glyph —
|
|
34
|
+
* nation flags, tier marks — keeping the color dot and the row hint.
|
|
33
35
|
*
|
|
34
36
|
* Entries may carry an explicit `color`; absent entries ride the
|
|
35
37
|
* default primary ladder above. Hints ride the consumer's tooltip
|
|
@@ -63,7 +65,7 @@ export default defineComponent({
|
|
|
63
65
|
emits: {
|
|
64
66
|
select: (key: string) => typeof key === "string",
|
|
65
67
|
},
|
|
66
|
-
setup(props, { emit }) {
|
|
68
|
+
setup(props, { emit, slots }) {
|
|
67
69
|
const hovered = ref<string | null>(null);
|
|
68
70
|
|
|
69
71
|
const slices = computed<HkDonutSlice[]>(() =>
|
|
@@ -129,7 +131,14 @@ export default defineComponent({
|
|
|
129
131
|
onClick={() => emit("select", s.key)}
|
|
130
132
|
>
|
|
131
133
|
<span class="hk-donut__legend-dot" style={{ background: s.fill }} />
|
|
132
|
-
<span class="hk-donut__legend-label">
|
|
134
|
+
<span class="hk-donut__legend-label">
|
|
135
|
+
{/* legendIcon slot: an optional per-slice glyph
|
|
136
|
+
* (flags, tier marks) rendered IN PLACE of the
|
|
137
|
+
* text label — the color dot stays, and the row's
|
|
138
|
+
* data-hint carries the full slice hint either
|
|
139
|
+
* way (wowsp's NationFlag contract). */}
|
|
140
|
+
{slots.legendIcon?.(s) ?? s.label}
|
|
141
|
+
</span>
|
|
133
142
|
<span class="hk-donut__legend-pct">{s.percentInt}%</span>
|
|
134
143
|
</div>
|
|
135
144
|
))}
|