- Learnset 'By TM / HM' rows show the machine number for the selected game (TM25 / HM05 / TR10), resolved from /machine when the group is expanded - Move detail page gains a 'TM / HM' fact (marked '(latest)' when the move isn't a machine in the currently-selected game) - machineNumber() exported from MovesList and reused by MoveDetail - Fresh installs now open on the National Dex (versionGroup 'all') instead of Scarlet/Violet Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
49 lines
1.6 KiB
JavaScript
49 lines
1.6 KiB
JavaScript
import { createStore } from './createStore.js';
|
|
|
|
/**
|
|
* User preferences. Small, synchronous, read on boot.
|
|
*
|
|
* - versionGroup: the selected "game" (PokéAPI version-group key)
|
|
* - pokedex: the active regional dex within that game (null = first one)
|
|
* - theme: 'system' | 'light' | 'dark'
|
|
* - spriteStyle: 'default' (pixel) | 'official' | 'home'
|
|
* - showShiny: default the detail view to shiny sprites
|
|
* - locale: reserved for localized names (PokéAPI supports many)
|
|
*/
|
|
export const settings = createStore('pdx.settings', {
|
|
versionGroup: 'all', // 'all' = National Dex, newest data, no generation limits
|
|
pokedex: null,
|
|
theme: 'system', // system | light | dark | black | sepia
|
|
accent: 'red', // red | blue | green | amber | violet | rose
|
|
spriteStyle: 'official',
|
|
showShiny: false,
|
|
locale: 'en',
|
|
});
|
|
|
|
const DARKISH = new Set(['dark', 'black']);
|
|
|
|
export function applyTheme(state = settings.get()) {
|
|
const root = document.documentElement;
|
|
const { theme, accent } = state;
|
|
|
|
if (!theme || theme === 'system') root.removeAttribute('data-theme');
|
|
else root.setAttribute('data-theme', theme);
|
|
|
|
if (!accent || accent === 'red') root.removeAttribute('data-accent');
|
|
else root.setAttribute('data-accent', accent);
|
|
|
|
const meta = document.querySelector('meta[name="theme-color"]');
|
|
if (meta) {
|
|
const dark =
|
|
DARKISH.has(theme) ||
|
|
((!theme || theme === 'system') &&
|
|
window.matchMedia('(prefers-color-scheme: dark)').matches);
|
|
meta.setAttribute(
|
|
'content',
|
|
dark
|
|
? '#0b0b0c'
|
|
: getComputedStyle(root).getPropertyValue('--accent').trim() || '#b3161a',
|
|
);
|
|
}
|
|
}
|