Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Improvements to the dark theme

Damian Legawiec4324a46f63a3
diff --git a/packages/dashboard-ui/src/styles.css b/packages/dashboard-ui/src/styles.css
index dded0b818b..b9bdac22e3 100644
--- a/packages/dashboard-ui/src/styles.css
+++ b/packages/dashboard-ui/src/styles.css
@@ -31,28 +31,38 @@
/* Brand palette.
*
- * Surfaces, borders and text are Tailwind's `stone` ramp — the same lightness
- * ladder as `neutral`, carrying a trace of warm chroma (0.001–0.013) rather
- * than none. Far too little to read as a colour: it stops large white and grey
- * areas looking blue-cold, and leaves the blue accent still the only thing in
- * the palette that reads as interaction.
+ * The two themes take different neutral families, for the reason each one's
+ * large areas need.
*
- * Values are stone's chroma and hue interpolated onto the lightnesses this
- * palette already chose, rather than snapped to the nearest ramp step: the
- * lightness decisions below are load-bearing for contrast, and none of them
- * move.
+ * Light mode is Tailwind's `stone` ramp — the same lightness ladder as
+ * `neutral`, carrying a trace of warm chroma (0.001–0.013) rather than none.
+ * Far too little to read as a colour: it stops large white and grey areas
+ * looking blue-cold, and leaves the blue accent still the only thing in the
+ * palette that reads as interaction.
+ *
+ * Dark mode is a true zero-chroma grey (Geist's own neutral, and shadcn's
+ * default). The warm tint that flatters a white sheet works against a
+ * near-black one: at these lightnesses the same chroma stops reading as
+ * warmth and starts reading as a brown cast over the whole screen. Keep dark
+ * neutrals at chroma 0 — the hue channel there is noise, not decoration.
+ *
+ * In both themes the lightness decisions below are load-bearing for contrast,
+ * and none of them move. Light mode's values are stone's chroma and hue
+ * interpolated onto those lightnesses rather than snapped to the nearest ramp
+ * step; dark mode's are the same lightnesses with the chroma dropped.
*
* Primary CTAs stay near-black rather than adopting the site's blue button:
* in a dense admin UI the blue has to stay meaningful as a selection and
* focus signal, which it stops being once every page renders a saturated
* blue button. */
:root {
- /* Neutrals are Tailwind's **stone** scale — a warm grey. Every neutral here
- is either an exact stone step (labelled with it) or, where a step could not
- meet a contrast requirement, a value on stone's own hue so it belongs to
- the same family. Never introduce a zero-chroma grey or another neutral
- ramp (zinc, slate, neutral): mixed families read as a colour cast on
- whichever surface is the odd one out.
+ /* Light-mode neutrals are Tailwind's **stone** scale — a warm grey. Every
+ neutral here is either an exact stone step (labelled with it) or, where a
+ step could not meet a contrast requirement, a value on stone's own hue so
+ it belongs to the same family. Never mix another warm-neutral ramp (zinc,
+ slate, neutral) into THIS block: two families read as a colour cast on
+ whichever surface is the odd one out. Dark mode deliberately uses a
+ different family — see the note on `.dark`.
Tokens that must equal another token point at it with var() rather than
repeating its value, so the two cannot drift. */
@@ -264,33 +274,52 @@
}
.dark {
- /* Vercel-style "true black" base, with surfaces stepping up in lightness. */
- --background: oklch(19.13% 0.005 56.043);
- --foreground: oklch(95% 0.002 106.424);
- --card: oklch(21.6% 0.006 56.043); /* stone-900 */
+ /* Vercel-style "true black" base, with surfaces stepping up in lightness.
+ *
+ * Every neutral below is zero-chroma — a true grey, not light mode's warm
+ * stone. See the palette note at the top of this file for why the two
+ * themes split. The lightness ladder is unchanged from the warm version;
+ * only the tint was removed.
+ *
+ * Dark surfaces step in roughly 4-5 points of OKLCH lightness, not the 1-2
+ * light mode uses. Near-black compresses perceived difference, so a step
+ * that reads clearly on white disappears down here: an earlier version of
+ * this ramp had sidebar, muted, background and card inside a 3.5-point band
+ * and the whole middle of the screen read as one flat surface, which in turn
+ * made the one boundary that was visible — the sidebar's — look like the
+ * sheet had been lit. Reference dark dashboards space adjacent surfaces
+ * 5-6 points apart for the same reason.
+ *
+ * The ladder, ground upward: sidebar 14 / muted + background 17 / card 21.6
+ * / secondary + nested-raised 25 / accent 29.5 / accent-hover 33 /
+ * accent-strong 38. --card is the anchor, since the inset sheet is the
+ * surface a merchant actually reads; keep the gaps if you move anything. */
+ --background: oklch(17% 0 0);
+ --foreground: oklch(95% 0 0);
+ --card: oklch(21.6% 0 0);
--card-foreground: var(--foreground);
--popover: var(--card);
--popover-foreground: var(--foreground);
/* Mirrors the light theme's primary: there a navy fill carries white text,
so here the two swap rather than the button taking on its own colour. */
--primary: var(--foreground);
- --primary-foreground: oklch(14.7% 0.004 49.25); /* stone-950 — light theme's primary */
+ --primary-foreground: oklch(14.7% 0 0); /* light theme's primary */
/* Above --card, but only just. These fill elements that sit *on* a card
(combobox chips, badges, secondary buttons, table header rows), so a value
at or under the card's lightness erases them — while too big a step reads
as a bright band across a full-width table header. Dark mode raises where
light mode lowers, since a surface reads as raised by getting lighter. */
- --secondary: oklch(22.5% 0.006 56.043);
+ --secondary: oklch(25% 0 0);
--secondary-foreground: var(--foreground);
- --muted: oklch(18.5% 0.005 56.043);
- /* stone-400. The old value failed 4.5:1 on --accent (4.20:1); this clears
- every dark ground, the accent included, at 5.87:1. */
- --muted-foreground: oklch(70.9% 0.01 56.259);
- --accent: oklch(26.8% 0.007 34.298); /* stone-800 */
+ --muted: oklch(17% 0 0);
+ /* At stone-400's lightness. The old value failed 4.5:1 on --accent
+ (4.20:1); this clears every dark ground, the accent included. */
+ --muted-foreground: oklch(70.9% 0 0);
+ --accent: oklch(29.5% 0 0);
--accent-foreground: var(--foreground);
- --accent-strong: oklch(37.4% 0.01 67.558); /* stone-700 */
- --accent-hover: oklch(31% 0.008 34.298);
- --accent-strong-hover: oklch(44.4% 0.011 73.639); /* stone-600 */
+ --accent-strong: oklch(38% 0 0);
+ --accent-hover: oklch(33% 0 0);
+ --accent-strong-hover: oklch(44.4% 0 0);
--destructive: oklch(0.704 0.191 22.216);
/* A white veil over whatever surface it crosses, so one value works on the
page ground and the raised sheet alike. Both shares below are half of it,
@@ -303,15 +332,15 @@
/* Light mode darkens the control edge away from the card; dark mode lightens
it. Not the light value inverted — measured on this theme's own surfaces:
3.22:1 on the card, 3.34:1 on the page ground. */
- --border-control: oklch(52% 0.01 56.259);
+ --border-control: oklch(52% 0 0);
/* Same arrangement as light — container at the page colour, records raised
- above it. 1.118:1 between them here. Records take `--nested-raised` rather
+ above it. 1.20:1 between them here. Records take `--nested-raised` rather
than `--card`: the card token is a step above the page, which is where the
container would sit if it had a fill of its own. */
--card-container: var(--background);
- --nested-raised: oklch(23.5% 0.006 56.043);
- /* Not --accent here: dark mode's accent (stone-800) is lighter than every
- raised surface, so a shared token would put the selected tab below its own
+ --nested-raised: oklch(25% 0 0);
+ /* Not --accent here: dark mode's accent is lighter than every raised
+ surface, so a shared token would put the selected tab below its own
track. --muted is the step under --nested-raised. */
--track-recessed: var(--muted);
--input: color-mix(in srgb, var(--border-base) 80%, transparent);
@@ -329,8 +358,19 @@
--chart-5: oklch(0.424 0.199 265.638);
/* One step back from the page, as in light mode — see the note there. Darker
rather than lighter: the sheet is the raised surface, so the ground behind
- it recedes. */
- --sidebar: oklch(14.7% 0.004 49.25); /* stone-950 */
+ it recedes.
+
+ Measured against --card, not --background: the shell renders the sidebar's
+ `inset` variant, so the sheet beside it is the card surface and that
+ pairing is what a merchant actually sees.
+
+ The sheet looking "too bright" was never this token being too dark — it
+ was the four surfaces above it sitting within half a point of each other,
+ so the sidebar edge was the only visible boundary on the screen and it
+ carried the whole contrast budget alone. Widening those steps (see the
+ ramp note on --background) fixes it; this stays low so the ground still
+ recedes. */
+ --sidebar: oklch(14% 0 0);
--sidebar-foreground: var(--foreground);
--sidebar-primary: var(--primary);
--sidebar-primary-foreground: var(--primary-foreground);