fix(docs): restore pinned color demos and color values

This commit is contained in:
maoyingjie
2026-10-27 23:24:15 +08:00
parent 748abe4dfe
commit dd0d7b22ee
10 changed files with 1228 additions and 98 deletions
+51
View File
@@ -10,6 +10,57 @@ import Theme from "../apps/docs/demos/handbook-theme.vue";
import States from "../apps/docs/demos/handbook-states.vue";
import Composition from "../apps/docs/demos/handbook-composition.vue";
import Motion from "../apps/docs/demos/handbook-animation.vue";
import DocsColorSection from "../apps/docs/.vitepress/theme/DocsColorSection.vue";
import { colorValue } from "../apps/docs/.vitepress/theme/color-value";
it("copies computed colors in the original OKLCH format without losing alpha", () => {
expect(colorValue("oklab(0.5 0.1 0.1 / 0.2)")).toBe(
"oklch(0.5 0.1414 45 / 0.2)",
);
expect(colorValue("rgba(0, 0, 0, 0.5)")).toBe("oklch(0 0 0 / 0.5)");
expect(colorValue("rgb(255, 255, 255)")).toBe("oklch(1 0 0)");
expect(colorValue("rgb(255, 0, 0)")).toBe("oklch(0.628 0.2577 29.2339)");
expect(colorValue("oklch(99.11% 0 0)")).toBe("oklch(0.9911 0 0)");
});
import {
colorSections,
type SectionId,
} from "../apps/docs/.vitepress/theme/color-sections";
it("renders each original color layout without dropping groups or adding primitive theme duplicates", () => {
const counts = [10, 6, 10, 10, 10, 10, 8, 6, 8, 6, 8, 4];
Object.keys(colorSections).forEach((id, i) => {
const wrapper = mount(DocsColorSection, {
props: { section: id as SectionId },
});
wrappers.push(wrapper);
expect(wrapper.findAll("button.docs-swatch"), id).toHaveLength(counts[i]);
if (["accent", "success", "warning", "danger"].includes(id)) {
expect(wrapper.findAll(".docs-color-soft"), id).toHaveLength(2);
expect(
wrapper
.findAll('.docs-color-soft [data-color-label="Foreground"]')
.map((w) => w.attributes("data-color-expression")),
).toEqual([`var(--${id})`, `var(--${id})`]);
}
if (id === "field")
expect(
wrapper
.findAll('[data-color-label="Hover"]')
.map((w) => w.attributes("data-color-expression")),
).toEqual(
Array(2).fill(
"color-mix(in oklab, var(--field-background) 90%, var(--field-foreground) 10%)",
),
);
if (id === "foreground")
expect(
wrapper
.findAll('[data-theme="light"] [data-color-label]')
.map((w) => w.attributes("data-color-label")),
).toEqual(["前景", "弱化", "分段", "遮罩", "链接"]);
});
});
it("ships self-contained follow-up cards with real prerequisite and test paths", () => {
const ids = [