Files
LCUI/scripts/postcss-lcui-dark.test.js
Liu 9217b1ca3a feat(styles): add light and dark theme support
- share shadcn neutral color tokens between both Tailwind configs
- rewrite Tailwind dark selectors into LCUI-compatible descendant selectors
- theme style-nova components and doc-viewer surfaces for dark mode
- generate GitHub Light and GitHub Dark syntax line pairs for code blocks
- support alpha channels in text style tag colors
- keep focus rings and scrollbars visible on dark surfaces
- use a neutral code surface instead of GitHub's blue-tinted background
2026-11-15 23:40:42 +08:00

38 lines
1.0 KiB
JavaScript

const assert = require("node:assert/strict");
const test = require("node:test");
const postcss = require("postcss");
const plugin = require("./postcss-lcui-dark");
async function transform(css) {
const result = await postcss([plugin()]).process(css, { from: undefined });
return result.css;
}
test("rewrites :is dark selectors to a descendant selector", async () => {
assert.equal(
await transform(".foo:is(.dark *) { color: red }"),
".dark .foo { color: red }",
);
});
test("rewrites comma-separated selectors independently", async () => {
assert.equal(
await transform(".a, .b:where(.dark, .dark *) { color: red }"),
".a, .dark .b { color: red }",
);
});
test("preserves escaped tailwind class names", async () => {
assert.equal(
await transform(".dark\\:bg-card:is(.dark *) { color: red }"),
".dark .dark\\:bg-card { color: red }",
);
});
test("rewrites pseudo-class variants", async () => {
assert.equal(
await transform(".button:hover:is(.dark *) { color: red }"),
".dark .button:hover { color: red }",
);
});