Files
LCUI/scripts/tailwind-shadow-plugin.js
T
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

35 lines
1.3 KiB
JavaScript

const plugin = require("tailwindcss/plugin");
/**
* Box-shadow utilities that inline the configured shadow value.
*
* Tailwind's built-in `box-shadow` plugin emits `--tw-shadow` /
* `--tw-shadow-colored` custom properties and a `var(...)` chain. LCUI's CSS
* parser has no custom-property support, so those declarations are ignored and
* the utilities would silently do nothing. This plugin keeps the familiar
* `shadow-<name>` class names while writing the literal value instead.
*
* Pass the shadow map explicitly so only the values this project defines are
* emitted; otherwise Tailwind's default theme would also expose `shadow`,
* `shadow-xl`, `shadow-inner` and friends.
*
* Only utilities that actually appear in the scanned content are emitted,
* because Tailwind still applies its candidate-based tree shaking.
*/
module.exports = plugin.withOptions((options = {}) => {
return ({ addUtilities, theme }) => {
const shadows = options.shadows || theme("boxShadow") || {};
const utilities = {};
for (const [name, value] of Object.entries(shadows)) {
if (typeof value !== "string" || value.length === 0) {
continue;
}
utilities[name === "DEFAULT" ? ".shadow" : `.shadow-${name}`] = {
boxShadow: value,
};
}
addUtilities(utilities);
};
});