Files
STARTLINER/src/util.ts
2025-03-17 01:58:09 +00:00

56 lines
1.4 KiB
TypeScript

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'
: 'bluegray';
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, feature: Feature) => {
return (
pkg.loc !== null &&
typeof pkg.loc?.status !== 'string' &&
pkg.loc.status.OK & feature
);
};