refactor: replace .dark CSS selectors with @variant dark for strategy-agnostic dark mode

Replace all hardcoded .dark class selectors with Tailwind v4's @variant dark
directive, which compiles to whatever strategy is configured in
@custom-variant dark. This means changing the dark mode strategy
(class, prefers-color-scheme, data-attribute, or combined) only requires
updating one line in globals.css — all dark mode variable overrides
and token styles follow automatically.

Changes:
- globals.css: update @custom-variant to (&:where(.dark, .dark *)) to
  include the .dark element itself with zero specificity, replace
  .dark {} block with @variant dark {}
- liveline.css: replace .dark .liveline-page {} with
  @variant dark { .liveline-page {} }
- liveline-prism.css: replace 20+ .dark .token.* rules with a single
  @variant dark {} block
This commit is contained in:
Tommy D. Rossi
2026-02-20 11:05:09 +01:00
parent d562047618
commit a71cc88336
3 changed files with 119 additions and 112 deletions
+2 -2
View File
@@ -1,5 +1,5 @@
@import "tailwindcss";
@custom-variant dark (&:is(.dark *));
@custom-variant dark (&:where(.dark, .dark *));
@plugin "@tailwindcss/typography";
@@ -38,7 +38,7 @@
--sidebar-border: oklch(0.92 0.004 286.32);
--sidebar-ring: oklch(0.871 0.006 286.286);
}
.dark {
@variant dark {
--background: oklch(0.21 0.006 285.885);
--foreground: oklch(0.985 0 0);
--card: oklch(0.21 0.006 285.885);
+37 -33
View File
@@ -135,92 +135,96 @@ pre[class*="language-"] {
}
/* ======================================================================
Dark mode - GitHub Dark inspired palette
Dark mode - GitHub Dark inspired palette.
Uses @variant dark so it follows whatever strategy is configured
in @custom-variant dark (globals.css).
====================================================================== */
.dark code[class*="language-"],
.dark pre[class*="language-"] {
@variant dark {
code[class*="language-"],
pre[class*="language-"] {
color: #e6edf3;
}
.dark .token.keyword,
.dark .token.module,
.dark .token.imports,
.dark .token.control-flow {
.token.keyword,
.token.module,
.token.imports,
.token.control-flow {
color: #ff7b72;
}
.dark .token.string,
.dark .token.template-string,
.dark .token.attr-value {
.token.string,
.token.template-string,
.token.attr-value {
color: #a5d6ff;
}
.dark .token.function,
.dark .token.class-name {
.token.function,
.token.class-name {
color: #d2a8ff;
}
.dark .token.property,
.dark .token.parameter {
.token.property,
.token.parameter {
color: #ffa657;
}
.dark .token.tag .token.tag {
.token.tag .token.tag {
color: #7ee787;
}
.dark .token.tag .token.class-name {
.token.tag .token.class-name {
color: #7ee787;
}
.dark .token.tag .token.attr-name,
.dark .token.attr-name {
.token.tag .token.attr-name,
.token.attr-name {
color: #79c0ff;
}
.dark .token.number {
.token.number {
color: #79c0ff;
}
.dark .token.operator {
.token.operator {
color: #ff7b72;
}
.dark .token.punctuation {
.token.punctuation {
color: #e6edf3;
}
.dark .token.boolean,
.dark .token.constant,
.dark .token.builtin {
.token.boolean,
.token.constant,
.token.builtin {
color: #79c0ff;
}
.dark .token.comment,
.dark .token.prolog,
.dark .token.doctype,
.dark .token.cdata {
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
color: #8b949e;
font-style: italic;
}
.dark .token.tag .token.punctuation {
.token.tag .token.punctuation {
color: #e6edf3;
}
.dark .token.spread {
.token.spread {
color: #ff7b72;
}
.dark .token.plain-text {
.token.plain-text {
color: #e6edf3;
}
.dark .token.regex {
.token.regex {
color: #a5d6ff;
}
.dark .language-bash .token.function {
.language-bash .token.function {
color: #79c0ff;
}
}
+5 -2
View File
@@ -96,8 +96,10 @@
--ll-fade-12: rgba(255, 255, 255, 0);
}
/* Dark mode overrides */
.dark .liveline-page {
/* Dark mode overrides — uses @variant dark so it follows whatever
strategy is configured in @custom-variant dark (globals.css) */
@variant dark {
.liveline-page {
--ll-text-primary: rgba(255, 255, 255, 0.9);
--ll-text-secondary: rgba(255, 255, 255, 0.45);
--ll-text-tertiary: rgba(255, 255, 255, 0.25);
@@ -142,6 +144,7 @@
--ll-fade-11: rgba(17, 17, 17, 0.002);
--ll-fade-12: rgba(17, 17, 17, 0);
}
}
@supports (color: color(display-p3 1 1 1)) {
.liveline-page {