mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Backport pull request #5589 from jellyfin-web/release-10.9.z
Add support for user themes for mui components
Original-merge: 61976b8101
Merged-by: thornbill <thornbill@users.noreply.github.com>
Backported-by: Joshua M. Boniface <joshua@boniface.me>
This commit is contained in:
parent
669784bde5
commit
1929ba8eb2
16 changed files with 298 additions and 62 deletions
48
src/themes/themes.ts
Normal file
48
src/themes/themes.ts
Normal file
|
@ -0,0 +1,48 @@
|
|||
import { type Theme } from '@mui/material/styles';
|
||||
|
||||
import appletv from './appletv';
|
||||
import blueradiance from './blueradiance';
|
||||
import dark from './dark';
|
||||
import light from './light';
|
||||
import purplehaze from './purplehaze';
|
||||
import wmc from './wmc';
|
||||
|
||||
declare module '@mui/material/styles' {
|
||||
interface Palette {
|
||||
starIcon: Palette['primary'];
|
||||
}
|
||||
|
||||
interface PaletteOptions {
|
||||
starIcon?: PaletteOptions['primary'];
|
||||
}
|
||||
}
|
||||
|
||||
const ALL_THEMES = {
|
||||
appletv,
|
||||
blueradiance,
|
||||
dark,
|
||||
light,
|
||||
purplehaze,
|
||||
wmc
|
||||
};
|
||||
|
||||
/** The default theme if a user has not selected a preferred theme. */
|
||||
export const DEFAULT_THEME = dark;
|
||||
|
||||
/**
|
||||
* Gets a MUI Theme by its string id. Returns the default theme if no matching theme is found.
|
||||
*/
|
||||
export function getTheme(id?: string): Theme {
|
||||
if (!id) {
|
||||
console.info('[getTheme] no theme id; returning default theme');
|
||||
return DEFAULT_THEME;
|
||||
}
|
||||
|
||||
console.info('[getTheme] getting theme "%s"', id);
|
||||
if (Object.keys(ALL_THEMES).includes(id)) {
|
||||
return ALL_THEMES[id as keyof typeof ALL_THEMES];
|
||||
}
|
||||
|
||||
console.warn('[getTheme] theme "%s" not found; returning default theme', id);
|
||||
return DEFAULT_THEME;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue