From 7bdbe3ce5b2e355dd9f877895d27b136020d2a8e Mon Sep 17 00:00:00 2001 From: MechaCat02 Date: Mon, 6 Jul 2026 19:44:43 +0200 Subject: [PATCH] fix: define missing --font-md and --success-soft-bg tokens Both were referenced by components (RecommendationShelf, the manga detail page) but never declared, so var() fell through to inherited/fallback values. Adds --font-md (1rem, on the xs/sm/md/lg scale) and --success-soft-bg in both the light and dark theme blocks. Co-Authored-By: Claude Opus 4.8 (1M context) --- backend/Cargo.lock | 2 +- backend/Cargo.toml | 2 +- frontend/package.json | 2 +- frontend/src/lib/styles/tokens.css | 5 ++++ frontend/src/lib/styles/tokens.test.ts | 32 ++++++++++++++++++++++++++ 5 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 frontend/src/lib/styles/tokens.test.ts diff --git a/backend/Cargo.lock b/backend/Cargo.lock index 0161963..6415588 100644 --- a/backend/Cargo.lock +++ b/backend/Cargo.lock @@ -1558,7 +1558,7 @@ checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4" [[package]] name = "mangalord" -version = "0.114.0" +version = "0.114.1" dependencies = [ "anyhow", "argon2", diff --git a/backend/Cargo.toml b/backend/Cargo.toml index b2a1697..3e7d006 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mangalord" -version = "0.114.0" +version = "0.114.1" edition = "2021" default-run = "mangalord" diff --git a/frontend/package.json b/frontend/package.json index accd90d..1ed8283 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,6 @@ { "name": "mangalord-frontend", - "version": "0.114.0", + "version": "0.114.1", "private": true, "type": "module", "scripts": { diff --git a/frontend/src/lib/styles/tokens.css b/frontend/src/lib/styles/tokens.css index 5e4e468..2455ae1 100644 --- a/frontend/src/lib/styles/tokens.css +++ b/frontend/src/lib/styles/tokens.css @@ -16,6 +16,7 @@ --danger: #b00020; --danger-soft-bg: #fff5f5; --success: #0a7d2c; + --success-soft-bg: #eaf7ee; --warning-soft-bg: #fff5d6; --warning-border: #d6a800; --focus-ring: #2563eb; @@ -28,6 +29,9 @@ --font-xs: 0.75rem; --font-sm: 0.875rem; + /* Alias of --font-base at the body size; named on the xs/sm/md/lg/xl + scale that some components reach for. */ + --font-md: 1rem; --font-base: 1rem; --font-lg: 1.125rem; --font-xl: 1.5rem; @@ -117,6 +121,7 @@ --danger: #f87171; --danger-soft-bg: #3a1620; --success: #4ade80; + --success-soft-bg: #12301c; --warning-soft-bg: #3a2e10; --warning-border: #a37800; --focus-ring: #60a5fa; diff --git a/frontend/src/lib/styles/tokens.test.ts b/frontend/src/lib/styles/tokens.test.ts new file mode 100644 index 0000000..57fed90 --- /dev/null +++ b/frontend/src/lib/styles/tokens.test.ts @@ -0,0 +1,32 @@ +import { describe, it, expect } from 'vitest'; +import { readFileSync } from 'node:fs'; +import { resolve } from 'node:path'; + +// Guards against components referencing design tokens that were never +// declared. `var(--x)` with no declaration silently falls through to the +// inherited/initial value, so a typo'd or missing token degrades quietly +// rather than failing loudly. These two were referenced by components +// (RecommendationShelf, the manga detail page) but absent from tokens.css. + +const TOKENS = readFileSync(resolve(process.cwd(), 'src/lib/styles/tokens.css'), 'utf8'); + +// Every design token must be declared at least once (in :root and/or a theme +// override). We only assert declaration, not value. +function declares(name: string): boolean { + return new RegExp(`${name}\\s*:`).test(TOKENS); +} + +describe('design tokens', () => { + it('declares --font-md (referenced by RecommendationShelf)', () => { + expect(declares('--font-md')).toBe(true); + }); + + it('declares --success-soft-bg (referenced by the manga detail page)', () => { + expect(declares('--success-soft-bg')).toBe(true); + }); + + it('declares --success-soft-bg in the dark theme override too', () => { + const darkBlock = TOKENS.slice(TOKENS.indexOf("[data-theme='dark']")); + expect(/--success-soft-bg\s*:/.test(darkBlock)).toBe(true); + }); +});