Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion extension.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "themes",
"private": true,
"version": "1.0.0",
"version": "1.0.1",
"type": "module",
"scripts": {
"build": "vite build",
Expand Down
13 changes: 10 additions & 3 deletions src/client/account/PresetPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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: (
<span className='flex items-center gap-2'>
Expand All @@ -50,7 +51,13 @@ export default function PresetPicker() {
<label htmlFor='ts-own-preset' className='sr-only'>
Theme preset
</label>
<Select id='ts-own-preset' value={data.choice ?? 0} disabled={choose.isPending} options={options} onChange={(value) => choose.mutate(Number(value) || null)} />
<Select
id='ts-own-preset'
value={toSelectValue(data.choice)}
disabled={choose.isPending}
options={options}
onChange={(value) => choose.mutate(fromSelectValue(value))}
/>
</div>
</section>
);
Expand Down
17 changes: 17 additions & 0 deletions src/client/account/choice.spec.ts
Original file line number Diff line number Diff line change
@@ -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();
});
});
12 changes: 12 additions & 0 deletions src/client/account/choice.ts
Original file line number Diff line number Diff line change
@@ -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);
}
19 changes: 19 additions & 0 deletions src/client/lib/palette.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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\)\);/);
});
});
11 changes: 11 additions & 0 deletions src/client/theme.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Loading