feat(web): Dracula theme

- a livelier dark theme: violet ground, hot pink accent
- covered by the same contrast test as the others
- README lists five themes
This commit is contained in:
tgiachi 2026-11-12 12:08:54 +01:00
commit 0d5805fd37
8 changed files with 36 additions and 10 deletions

View file

@ -281,7 +281,7 @@ npm install
SONDA_URL=http://127.0.0.1:8080 npm run dev # open http://localhost:5173, /api is proxied to Sonda
```
What it does today: sign in (and create the first account of a new server), browse artists, albums and songs, search, and play with a queue, shuffle, repeat, media keys and a full-screen player. Artist pages show the Wikipedia text, similar artists and tags when those providers are on, each with its credit, and the photo credit next to the photo. It reports one listen per play. There are four themes (Sonda, Tokyo Night, Gruvbox dark and Gruvbox light) and two languages (English and Italian), both chosen in Settings.
What it does today: sign in (and create the first account of a new server), browse artists, albums and songs, search, and play with a queue, shuffle, repeat, media keys and a full-screen player. Artist pages show the Wikipedia text, similar artists and tags when those providers are on, each with its credit, and the photo credit next to the photo. It reports one listen per play. There are five themes (Sonda, Tokyo Night, Gruvbox dark, Gruvbox light and Dracula) and two languages (English and Italian), both chosen in Settings.
More commands, all run in `web/`: `npm test`, `npm run build`, and `npm run gen:api`, which rebuilds `src/api/schema.d.ts` from the OpenAPI spec (it fetches the generator with `npx`, so it needs the network once). Discover, the admin screens and serving the app from the binary come later.

View file

@ -116,7 +116,8 @@
"sonda": "Sonda",
"tokyo-night": "Tokyo Night",
"gruvbox-dark": "Gruvbox dark",
"gruvbox-light": "Gruvbox light"
"gruvbox-light": "Gruvbox light",
"dracula": "Dracula"
},
"lang": {
"en": "English",

View file

@ -116,7 +116,8 @@
"sonda": "Sonda",
"tokyo-night": "Tokyo Night",
"gruvbox-dark": "Gruvbox scuro",
"gruvbox-light": "Gruvbox chiaro"
"gruvbox-light": "Gruvbox chiaro",
"dracula": "Dracula"
},
"lang": {
"en": "English",

View file

@ -11,7 +11,7 @@
@import "./theme/themes.css";
/* The dark variant follows the theme, not the OS setting. */
@custom-variant dark (&:is([data-theme="sonda"] *, [data-theme="tokyo-night"] *, [data-theme="gruvbox-dark"] *));
@custom-variant dark (&:is([data-theme="sonda"] *, [data-theme="tokyo-night"] *, [data-theme="gruvbox-dark"] *, [data-theme="dracula"] *));
@theme inline {
--font-heading: var(--font-sans);

View file

@ -59,11 +59,11 @@ test('each group of choices has a label you can see, not only one for screen rea
expect(screen.getByRole('radiogroup', { name: 'Language' })).toBeInTheDocument()
})
test('all four themes can be chosen and the current one is selected', async () => {
test('all five themes can be chosen and the current one is selected', async () => {
renderSettings()
const group = screen.getByRole('radiogroup', { name: 'Theme' })
expect(group).toBeInTheDocument()
for (const name of ['Sonda', 'Tokyo Night', 'Gruvbox dark', 'Gruvbox light']) {
for (const name of ['Sonda', 'Tokyo Night', 'Gruvbox dark', 'Gruvbox light', 'Dracula']) {
expect(screen.getByRole('radio', { name })).toBeInTheDocument()
}
expect(screen.getByRole('radio', { name: 'Sonda' })).toBeChecked()

View file

@ -9,8 +9,8 @@ afterEach(() => {
vi.restoreAllMocks()
})
test('there are four themes and sonda comes first', () => {
expect(THEMES.map((t) => t.id)).toEqual(['sonda', 'tokyo-night', 'gruvbox-dark', 'gruvbox-light'])
test('there are five themes and sonda comes first', () => {
expect(THEMES.map((t) => t.id)).toEqual(['sonda', 'tokyo-night', 'gruvbox-dark', 'gruvbox-light', 'dracula'])
})
test('initTheme with nothing stored uses sonda', () => {

View file

@ -1,12 +1,13 @@
import { useSyncExternalStore } from 'react'
export type ThemeId = 'sonda' | 'tokyo-night' | 'gruvbox-dark' | 'gruvbox-light'
export type ThemeId = 'sonda' | 'tokyo-night' | 'gruvbox-dark' | 'gruvbox-light' | 'dracula'
export const THEMES: readonly { id: ThemeId; labelKey: string }[] = [
{ id: 'sonda', labelKey: 'theme.sonda' },
{ id: 'tokyo-night', labelKey: 'theme.tokyo-night' },
{ id: 'gruvbox-dark', labelKey: 'theme.gruvbox-dark' },
{ id: 'gruvbox-light', labelKey: 'theme.gruvbox-light' },
{ id: 'dracula', labelKey: 'theme.dracula' },
]
const KEY = 'sonda.theme'

View file

@ -1,5 +1,5 @@
/*
* The four themes. Every colour is a plain hex value so that contrast.test.ts can check it.
* The five themes. Every colour is a plain hex value so that contrast.test.ts can check it.
* Token names are the ones shadcn/ui uses.
* --border is a quiet divider; --input is the outline of a form control and has to be seen (3:1).
*/
@ -70,6 +70,29 @@
--ring: #fabd2f;
}
/* The lively one: Dracula's violet ground with a hot pink accent. */
[data-theme="dracula"] {
color-scheme: dark;
--background: #282a36;
--foreground: #f8f8f2;
--card: #343746;
--card-foreground: #f8f8f2;
--popover: #343746;
--popover-foreground: #f8f8f2;
--primary: #ff79c6;
--primary-foreground: #282a36;
--secondary: #44475a;
--secondary-foreground: #f8f8f2;
--muted: #44475a;
--muted-foreground: #b4b8d4;
--accent: #44475a;
--accent-foreground: #f8f8f2;
--destructive: #ff5555;
--border: #44475a;
--input: #7081b8;
--ring: #ff79c6;
}
[data-theme="gruvbox-light"] {
color-scheme: light;
--background: #fbf1c7;