Closed acoreyj closed 1 year ago
Hi! π
Firstly, thanks for your work on this project! π
Today I used patch-package to patch unocss-preset-theme@0.3.0 for the project I'm working on.
unocss-preset-theme@0.3.0
If setting dark:'media' this preset spits out invalid css for the prefers-color-scheme @media queries. They need to be in a rule like :root
Here is the diff that solved my problem:
diff --git a/node_modules/unocss-preset-theme/dist/index.cjs b/node_modules/unocss-preset-theme/dist/index.cjs index e7730b2..558503b 100644 --- a/node_modules/unocss-preset-theme/dist/index.cjs +++ b/node_modules/unocss-preset-theme/dist/index.cjs @@ -96,7 +96,7 @@ const presetTheme = (options) => { return css.replace(/\/\* layer: .* \*\/\n/, "").replace(new RegExp(`(?:\\.(?:dark|light))?.*${PRESET_THEME_RULE}\\\\\\:(${keys.join("|")})\\\\\\:\\d+({(.*)})?`, "gm"), (full, kind, targetCSS, cleanCode) => { if (isMedia) { if (kind === "dark" || kind === "light") - return cleanCode; + return `:root{${cleanCode}}`; } return `${selectors[kind] || `.${kind}`}${targetCSS || ""}`; }); diff --git a/node_modules/unocss-preset-theme/dist/index.mjs b/node_modules/unocss-preset-theme/dist/index.mjs index 0ace6fb..be5e948 100644 --- a/node_modules/unocss-preset-theme/dist/index.mjs +++ b/node_modules/unocss-preset-theme/dist/index.mjs @@ -92,7 +92,7 @@ const presetTheme = (options) => { return css.replace(/\/\* layer: .* \*\/\n/, "").replace(new RegExp(`(?:\\.(?:dark|light))?.*${PRESET_THEME_RULE}\\\\\\:(${keys.join("|")})\\\\\\:\\d+({(.*)})?`, "gm"), (full, kind, targetCSS, cleanCode) => { if (isMedia) { if (kind === "dark" || kind === "light") - return cleanCode; + return `:root{${cleanCode}}`; } return `${selectors[kind] || `.${kind}`}${targetCSS || ""}`; });
This issue body was partially generated by patch-package.
Thanks for your feedback and the solution you provided, I've fixed it in 0.3.1.
0.3.1
Hi! π
Firstly, thanks for your work on this project! π
Today I used patch-package to patch
unocss-preset-theme@0.3.0
for the project I'm working on.If setting dark:'media' this preset spits out invalid css for the prefers-color-scheme @media queries. They need to be in a rule like :root
Here is the diff that solved my problem:
This issue body was partially generated by patch-package.