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"; @import "tailwindcss";
@custom-variant dark (&:is(.dark *)); @custom-variant dark (&:where(.dark, .dark *));
@plugin "@tailwindcss/typography"; @plugin "@tailwindcss/typography";
@@ -38,7 +38,7 @@
--sidebar-border: oklch(0.92 0.004 286.32); --sidebar-border: oklch(0.92 0.004 286.32);
--sidebar-ring: oklch(0.871 0.006 286.286); --sidebar-ring: oklch(0.871 0.006 286.286);
} }
.dark { @variant dark {
--background: oklch(0.21 0.006 285.885); --background: oklch(0.21 0.006 285.885);
--foreground: oklch(0.985 0 0); --foreground: oklch(0.985 0 0);
--card: oklch(0.21 0.006 285.885); --card: oklch(0.21 0.006 285.885);
+73 -69
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-"], @variant dark {
.dark pre[class*="language-"] { code[class*="language-"],
color: #e6edf3; pre[class*="language-"] {
} color: #e6edf3;
}
.dark .token.keyword, .token.keyword,
.dark .token.module, .token.module,
.dark .token.imports, .token.imports,
.dark .token.control-flow { .token.control-flow {
color: #ff7b72; color: #ff7b72;
} }
.dark .token.string, .token.string,
.dark .token.template-string, .token.template-string,
.dark .token.attr-value { .token.attr-value {
color: #a5d6ff; color: #a5d6ff;
} }
.dark .token.function, .token.function,
.dark .token.class-name { .token.class-name {
color: #d2a8ff; color: #d2a8ff;
} }
.dark .token.property, .token.property,
.dark .token.parameter { .token.parameter {
color: #ffa657; color: #ffa657;
} }
.dark .token.tag .token.tag { .token.tag .token.tag {
color: #7ee787; color: #7ee787;
} }
.dark .token.tag .token.class-name { .token.tag .token.class-name {
color: #7ee787; color: #7ee787;
} }
.dark .token.tag .token.attr-name, .token.tag .token.attr-name,
.dark .token.attr-name { .token.attr-name {
color: #79c0ff; color: #79c0ff;
} }
.dark .token.number { .token.number {
color: #79c0ff; color: #79c0ff;
} }
.dark .token.operator { .token.operator {
color: #ff7b72; color: #ff7b72;
} }
.dark .token.punctuation { .token.punctuation {
color: #e6edf3; color: #e6edf3;
} }
.dark .token.boolean, .token.boolean,
.dark .token.constant, .token.constant,
.dark .token.builtin { .token.builtin {
color: #79c0ff; color: #79c0ff;
} }
.dark .token.comment, .token.comment,
.dark .token.prolog, .token.prolog,
.dark .token.doctype, .token.doctype,
.dark .token.cdata { .token.cdata {
color: #8b949e; color: #8b949e;
font-style: italic; font-style: italic;
} }
.dark .token.tag .token.punctuation { .token.tag .token.punctuation {
color: #e6edf3; color: #e6edf3;
} }
.dark .token.spread { .token.spread {
color: #ff7b72; color: #ff7b72;
} }
.dark .token.plain-text { .token.plain-text {
color: #e6edf3; color: #e6edf3;
} }
.dark .token.regex { .token.regex {
color: #a5d6ff; color: #a5d6ff;
} }
.dark .language-bash .token.function { .language-bash .token.function {
color: #79c0ff; color: #79c0ff;
}
} }
+44 -41
View File
@@ -96,51 +96,54 @@
--ll-fade-12: rgba(255, 255, 255, 0); --ll-fade-12: rgba(255, 255, 255, 0);
} }
/* Dark mode overrides */ /* Dark mode overrides — uses @variant dark so it follows whatever
.dark .liveline-page { strategy is configured in @custom-variant dark (globals.css) */
--ll-text-primary: rgba(255, 255, 255, 0.9); @variant dark {
--ll-text-secondary: rgba(255, 255, 255, 0.45); .liveline-page {
--ll-text-tertiary: rgba(255, 255, 255, 0.25); --ll-text-primary: rgba(255, 255, 255, 0.9);
--ll-text-muted: rgba(255, 255, 255, 0.35); --ll-text-secondary: rgba(255, 255, 255, 0.45);
--ll-text-hover: rgba(255, 255, 255, 0.7); --ll-text-tertiary: rgba(255, 255, 255, 0.25);
--ll-bg: rgb(17, 17, 17); --ll-text-muted: rgba(255, 255, 255, 0.35);
--ll-border: rgba(255, 255, 255, 0.1); --ll-text-hover: rgba(255, 255, 255, 0.7);
--ll-divider: rgba(255, 255, 255, 0.06); --ll-bg: rgb(17, 17, 17);
--ll-code-bg: rgba(255, 255, 255, 0.05); --ll-border: rgba(255, 255, 255, 0.1);
--ll-code-line-nr: rgba(255, 255, 255, 0.15); --ll-divider: rgba(255, 255, 255, 0.06);
--ll-selection-bg: rgba(255, 255, 255, 0.1); --ll-code-bg: rgba(255, 255, 255, 0.05);
--ll-code-line-nr: rgba(255, 255, 255, 0.15);
--ll-selection-bg: rgba(255, 255, 255, 0.1);
--ll-btn-bg: rgb(30, 30, 30); --ll-btn-bg: rgb(30, 30, 30);
--ll-btn-shadow: rgba(255, 255, 255, 0.05) 0px 2px 8px, --ll-btn-shadow: rgba(255, 255, 255, 0.05) 0px 2px 8px,
rgba(255, 255, 255, 0.02) 0px 4px 16px, rgba(255, 255, 255, 0.02) 0px 4px 16px,
rgba(255, 255, 255, 0.06) 0px 0px 0px 1px inset; rgba(255, 255, 255, 0.06) 0px 0px 0px 1px inset;
--ll-primary: #60a5fa; --ll-primary: #60a5fa;
--ll-secondary: #f5a623; --ll-secondary: #f5a623;
--ll-overlay-bg: hsla(0, 0%, 7%, 0.8); --ll-overlay-bg: hsla(0, 0%, 7%, 0.8);
--ll-overlay-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06), --ll-overlay-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06),
0 1.625rem 3.375rem rgba(0, 0, 0, 0.3), 0 1.625rem 3.375rem rgba(0, 0, 0, 0.3),
0 1rem 2rem rgba(0, 0, 0, 0.2), 0 1rem 2rem rgba(0, 0, 0, 0.2),
0 0.625rem 1rem rgba(0, 0, 0, 0.15), 0 0.625rem 1rem rgba(0, 0, 0, 0.15),
0 0.3125rem 0.5rem rgba(0, 0, 0, 0.1), 0 0.3125rem 0.5rem rgba(0, 0, 0, 0.1),
0 0.125rem 0.25rem rgba(0, 0, 0, 0.08), 0 0.125rem 0.25rem rgba(0, 0, 0, 0.08),
0 0 0.125rem rgba(0, 0, 0, 0.05); 0 0 0.125rem rgba(0, 0, 0, 0.05);
/* Header fade gradient stops (dark) */ /* Header fade gradient stops (dark) */
--ll-fade-0: rgb(17, 17, 17); --ll-fade-0: rgb(17, 17, 17);
--ll-fade-1: rgba(17, 17, 17, 0.737); --ll-fade-1: rgba(17, 17, 17, 0.737);
--ll-fade-2: rgba(17, 17, 17, 0.541); --ll-fade-2: rgba(17, 17, 17, 0.541);
--ll-fade-3: rgba(17, 17, 17, 0.382); --ll-fade-3: rgba(17, 17, 17, 0.382);
--ll-fade-4: rgba(17, 17, 17, 0.278); --ll-fade-4: rgba(17, 17, 17, 0.278);
--ll-fade-5: rgba(17, 17, 17, 0.194); --ll-fade-5: rgba(17, 17, 17, 0.194);
--ll-fade-6: rgba(17, 17, 17, 0.126); --ll-fade-6: rgba(17, 17, 17, 0.126);
--ll-fade-7: rgba(17, 17, 17, 0.075); --ll-fade-7: rgba(17, 17, 17, 0.075);
--ll-fade-8: rgba(17, 17, 17, 0.042); --ll-fade-8: rgba(17, 17, 17, 0.042);
--ll-fade-9: rgba(17, 17, 17, 0.021); --ll-fade-9: rgba(17, 17, 17, 0.021);
--ll-fade-10: rgba(17, 17, 17, 0.008); --ll-fade-10: rgba(17, 17, 17, 0.008);
--ll-fade-11: rgba(17, 17, 17, 0.002); --ll-fade-11: rgba(17, 17, 17, 0.002);
--ll-fade-12: rgba(17, 17, 17, 0); --ll-fade-12: rgba(17, 17, 17, 0);
}
} }
@supports (color: color(display-p3 1 1 1)) { @supports (color: color(display-p3 1 1 1)) {