mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-04-02 08:13:37 +01:00
48 lines
1.1 KiB
TypeScript
48 lines
1.1 KiB
TypeScript
// Copyright 2020 Signal Messenger, LLC
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
import { z } from 'zod';
|
|
import { missingCaseError } from './missingCaseError.std.ts';
|
|
import { ThemeType } from '../types/Util.std.ts';
|
|
|
|
export enum Theme {
|
|
Light,
|
|
Dark,
|
|
}
|
|
|
|
export const themeSettingSchema = z.enum(['system', 'light', 'dark']);
|
|
export type ThemeSettingType = z.infer<typeof themeSettingSchema>;
|
|
|
|
export function themeClassName(theme: Theme): string {
|
|
switch (theme) {
|
|
case Theme.Light:
|
|
return 'light-theme';
|
|
case Theme.Dark:
|
|
return 'dark-theme';
|
|
default:
|
|
throw missingCaseError(theme);
|
|
}
|
|
}
|
|
|
|
export function themeClassName2(theme: ThemeType): string {
|
|
switch (theme) {
|
|
case ThemeType.light:
|
|
return 'light-theme';
|
|
case ThemeType.dark:
|
|
return 'dark-theme';
|
|
default:
|
|
throw missingCaseError(theme);
|
|
}
|
|
}
|
|
|
|
export function getThemeByThemeType(theme: ThemeType): Theme {
|
|
switch (theme) {
|
|
case ThemeType.light:
|
|
return Theme.Light;
|
|
case ThemeType.dark:
|
|
return Theme.Dark;
|
|
default:
|
|
throw missingCaseError(theme);
|
|
}
|
|
}
|