diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 7e9031b..f5ed748 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -6,7 +6,7 @@ body: id: version attributes: label: Theme Studio version - placeholder: 1.0.0 + placeholder: 1.0.1 validations: required: true - type: input diff --git a/CHANGELOG.md b/CHANGELOG.md index ba9d92f..2e101b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 1.0.1 + +- The account preset picker shows "The panel's choice" again instead of an empty box. +- The console's command line is readable in the light scheme: it now uses the terminal's own text colour. + ## 1.0.0 - First release: a dark mode and a light mode for the whole panel, built on the panel's own theme system, with a switch for each person in their account menu. diff --git a/extension.json b/extension.json index 6edbc55..b90a47a 100644 --- a/extension.json +++ b/extension.json @@ -3,7 +3,7 @@ "id": "themes", "type": "theme", "name": "Theme Studio", - "version": "1.0.0", + "version": "1.0.1", "description": "A free theme for the whole panel: dark and light, ten built-in presets, presets of your own, and scheduled seasonal themes like Halloween and Christmas with their effects.", "author": "RustixDev", "icon": "palette", diff --git a/package-lock.json b/package-lock.json index ee08e4d..e5808f2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "themes", - "version": "1.0.0", + "version": "1.0.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "themes", - "version": "1.0.0", + "version": "1.0.1", "devDependencies": { "@base-ui/react": "^1.6.0", "@pterodactyl/sdk": "file:./sdk/pterodactyl-sdk-2.0.0-beta.6.tgz", diff --git a/package.json b/package.json index 67a7ac0..d476a3d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "themes", "private": true, - "version": "1.0.0", + "version": "1.0.1", "type": "module", "scripts": { "build": "vite build", diff --git a/src/client/account/PresetPicker.tsx b/src/client/account/PresetPicker.tsx index 7630286..b7563ee 100644 --- a/src/client/account/PresetPicker.tsx +++ b/src/client/account/PresetPicker.tsx @@ -3,6 +3,7 @@ import { httpErrorToHuman, Select, toast } from '@pterodactyl/sdk'; import { useTheme } from '@pterodactyl/sdk/theme'; import { choicesQuery, userApi } from '../api.ts'; import { refreshPreset } from '../lib/live.ts'; +import { fromSelectValue, PANEL_CHOICE, toSelectValue } from './choice.ts'; /** * A card on the account page for picking your own preset, when an admin allows it. "The panel's @@ -26,9 +27,9 @@ export default function PresetPicker() { const swatchScheme = scheme === 'light' ? 'light' : 'dark'; const options = [ - { value: 0, label: 'The panel’s choice', textLabel: 'The panel’s choice' }, + { value: PANEL_CHOICE, label: 'The panel’s choice', textLabel: 'The panel’s choice' }, ...data.presets.map((preset) => ({ - value: preset.id, + value: String(preset.id), textLabel: preset.name, label: ( @@ -50,7 +51,13 @@ export default function PresetPicker() { - choose.mutate(fromSelectValue(value))} + /> ); diff --git a/src/client/account/choice.spec.ts b/src/client/account/choice.spec.ts new file mode 100644 index 0000000..2ac730d --- /dev/null +++ b/src/client/account/choice.spec.ts @@ -0,0 +1,17 @@ +// @vitest-environment node +import { describe, expect, test } from 'vitest'; +import { fromSelectValue, PANEL_CHOICE, toSelectValue } from './choice.ts'; + +describe('preset picker values', () => { + test("the panel's choice has a value the select shows", () => { + expect(toSelectValue(null)).toBe(PANEL_CHOICE); + expect(toSelectValue(undefined)).toBe(PANEL_CHOICE); + expect(PANEL_CHOICE).not.toBe(''); + }); + + test('a preset round-trips', () => { + expect(toSelectValue(7)).toBe('7'); + expect(fromSelectValue('7')).toBe(7); + expect(fromSelectValue(PANEL_CHOICE)).toBeNull(); + }); +}); diff --git a/src/client/account/choice.ts b/src/client/account/choice.ts new file mode 100644 index 0000000..d83c67f --- /dev/null +++ b/src/client/account/choice.ts @@ -0,0 +1,12 @@ +/** The select treats 0 as empty, so "the panel's choice" gets a string value of its own. */ +export const PANEL_CHOICE = 'panel'; + +/** The select's value for a user's saved pick: a preset id, or none for the panel's choice. */ +export function toSelectValue(choice: number | null | undefined): string { + return choice == null ? PANEL_CHOICE : String(choice); +} + +/** The pick to save for a select value. */ +export function fromSelectValue(value: string | number): number | null { + return value === PANEL_CHOICE ? null : Number(value); +} diff --git a/src/client/lib/palette.spec.ts b/src/client/lib/palette.spec.ts index d69ed5d..35615de 100644 --- a/src/client/lib/palette.spec.ts +++ b/src/client/lib/palette.spec.ts @@ -124,3 +124,22 @@ describe('stylesheet', () => { expect(css).toMatch(/prefers-reduced-motion: reduce\) \{\s*\.ts-effects \{\s*display: none/); }); }); + +describe('console command line', () => { + // Mirrors palettes.css: the terminal and the command line's text and placeholder. + const terminal = (c: { background: string; text: string }, scheme: 'dark' | 'light') => + scheme === 'dark' ? mix(c.background, '#000000', 0.7) : mix(c.text, c.background, 0.94); + const ids = Object.keys(BUILTINS); + + test.each(ids.flatMap((id) => SCHEMES.map((scheme) => [id, scheme] as const)))('%s %s reads on the terminal', (id, scheme) => { + const bg = terminal(BUILTINS[id][scheme], scheme); + expect(contrast('#d4d4d4', bg)).toBeGreaterThanOrEqual(4.5); + expect(contrast(mix('#d4d4d4', bg, 0.7), bg)).toBeGreaterThanOrEqual(3); + }); + + test('the stylesheet gives the command line the terminal colours', () => { + const css = readFileSync(new URL('../theme.css', import.meta.url), 'utf8'); + expect(css).toContain("input[aria-label='Console command input.'] + div"); + expect(css).toMatch(/::placeholder \{\s*color: color-mix\(in oklab, var\(--terminal-foreground\) 70%, var\(--terminal-background\)\);/); + }); +}); diff --git a/src/client/theme.css b/src/client/theme.css index 0813f25..b72d35d 100644 --- a/src/client/theme.css +++ b/src/client/theme.css @@ -152,3 +152,14 @@ [data-sonner-toaster][data-sonner-theme] [data-sonner-toast] [data-description] { color: var(--muted-foreground); } + +/* The console's command line sits on the dark terminal in both schemes, so it takes the terminal's text colour. */ +input[aria-label='Console command input.'], +input[aria-label='Console command input.'] + div { + color: var(--terminal-foreground); +} + +input[aria-label='Console command input.']::placeholder { + color: color-mix(in oklab, var(--terminal-foreground) 70%, var(--terminal-background)); + opacity: 1; +}