import { updatePrimaryPalette } from '@primevue/themes'; import { Feature, Game, Package } from './types'; export const changePrimaryColor = (game: Game | null) => { const color = game === 'ongeki' ? 'pink' : game === 'chunithm' ? 'yellow' : 'purple'; updatePrimaryPalette({ 50: `{${color}.50}`, 100: `{${color}.100}`, 200: `{${color}.200}`, 300: `{${color}.300}`, 400: `{${color}.400}`, 500: `{${color}.500}`, 600: `{${color}.600}`, 700: `{${color}.700}`, 800: `{${color}.800}`, 900: `{${color}.900}`, 950: `{${color}.950}`, }); }; export const pkgKey = (pkg: Package) => `${pkg.namespace}-${pkg.name}`; export const needsUpdate = (pkg: Package | undefined) => { const loc = pkg?.loc?.version; const rmt = pkg?.rmt?.version; if (loc === undefined || rmt === undefined) { return false; } const [l1, l2, l3] = loc.split('.'); const [r1, r2, r3] = rmt.split('.'); if (l1 === r1) { if (l2 === r2) { return l3 < r3; } return l2 < r2; } return l1 < r1; }; export const hasFeature = (pkg: Package | undefined, feature: Feature) => { return ( pkg !== undefined && pkg.loc !== null && pkg.loc !== undefined && typeof pkg.loc?.status !== 'string' && pkg.loc.status.OK[0] & feature ); }; export const messageSplit = (message: any) => { return message.message?.split('\n'); }; export const shouldPreferDark = () => { return window.matchMedia('(prefers-color-scheme: dark)').matches; }; export const prettyPrint = (game: Game) => { switch (game) { case 'ongeki': return 'O.N.G.E.K.I.'; case 'chunithm': return 'CHUNITHM'; } };