fix(css): leave tailwind theme vars on :root so obsidian's accent wins inside the view
This commit is contained in:
1 parent
8c971e431a
commit
4f485b0bc4
2 files changed
+6
-7
No files matched your search
@@ -12,8 +12,9 @@ import { transform } from "lightningcss";
|
|||||||
* order, while still reaching the view root itself and the portal layer,
|
* order, while still reaching the view root itself and the portal layer,
|
||||||
* both of which carry `.bcal-root`.
|
* both of which carry `.bcal-root`.
|
||||||
*
|
*
|
||||||
* Theme variables move from `:root, :host` onto `.bcal-root` for the same
|
* Tailwind's own theme variables stay on `:root, :host`: moved onto the view
|
||||||
* reason: a later `:root{--spacing:…}` from someone else must not resize us.
|
* root they would sit above Obsidian's `body` values, and `--color-accent`
|
||||||
|
* is a name both sides use — the accent would turn into the hover grey.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const ROOT = "bcal-root";
|
const ROOT = "bcal-root";
|
||||||
@@ -48,9 +49,7 @@ function mentions(selector, name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function scopeSelector(selector) {
|
function scopeSelector(selector) {
|
||||||
if (isPseudo(selector, "root")) return [{ type: "class", name: ROOT }];
|
if (isPseudo(selector, "root") || isPseudo(selector, "host")) return selector;
|
||||||
// `:root, :host` is one rule; the root alone carries it, so :host goes.
|
|
||||||
if (isPseudo(selector, "host")) return [];
|
|
||||||
if (mentions(selector, ROOT)) return selector;
|
if (mentions(selector, ROOT)) return selector;
|
||||||
// `*` has to open a compound, and :is() takes that place now.
|
// `*` has to open a compound, and :is() takes that place now.
|
||||||
const rest = selector[0]?.type === "universal" ? selector.slice(1) : selector;
|
const rest = selector[0]?.type === "universal" ? selector.slice(1) : selector;
|
||||||
|
|||||||
@@ -40,9 +40,9 @@ describe("scoping the built stylesheet", () => {
|
|||||||
expect(out).not.toContain("*)*");
|
expect(out).not.toContain("*)*");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("moves theme variables from :root onto the view root", () => {
|
it("leaves tailwind's theme variables on :root, under obsidian's body values", () => {
|
||||||
expect(one(":root,:host{--spacing:.25rem}")).toBe(
|
expect(one(":root,:host{--spacing:.25rem}")).toBe(
|
||||||
".bcal-root { --spacing: .25rem; }",
|
":root, :host { --spacing: .25rem; }",
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user