mirror of
https://github.com/lc-soft/LCUI.git
synced 2026-11-30 16:48:21 +01:00
- 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
37 lines
963 B
JavaScript
37 lines
963 B
JavaScript
const DARK_IS = ":is(.dark *)";
|
|
const DARK_WHERE = ":where(.dark, .dark *)";
|
|
|
|
function rewriteSelector(selector) {
|
|
if (!selector.includes(DARK_IS) && !selector.includes(DARK_WHERE)) {
|
|
return selector;
|
|
}
|
|
const normalized = selector.replaceAll(DARK_WHERE, DARK_IS);
|
|
return normalized
|
|
.split(",")
|
|
.map((part) => {
|
|
const trimmed = part.trim();
|
|
if (!trimmed.includes(DARK_IS)) {
|
|
return trimmed;
|
|
}
|
|
const base = trimmed.replaceAll(DARK_IS, "").trim();
|
|
if (!base || base === ".dark" || base.startsWith(".dark ")) {
|
|
return base || ".dark";
|
|
}
|
|
return `.dark ${base}`;
|
|
})
|
|
.join(", ");
|
|
}
|
|
|
|
module.exports = () => ({
|
|
postcssPlugin: "lcui-dark-selectors",
|
|
Rule(rule) {
|
|
const selector = rewriteSelector(rule.selector);
|
|
if (selector !== rule.selector) {
|
|
rule.selector = selector;
|
|
}
|
|
},
|
|
});
|
|
|
|
module.exports.rewriteSelector = rewriteSelector;
|
|
module.exports.postcss = true;
|