-
-
Notifications
You must be signed in to change notification settings - Fork 424
Expand file tree
/
Copy pathapp-settings.ts
More file actions
28 lines (24 loc) · 1.04 KB
/
app-settings.ts
File metadata and controls
28 lines (24 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import * as v from 'valibot'
import { ACCENT_COLORS, BACKGROUND_THEMES } from '#shared/utils/constants'
type AccentColorKey = keyof typeof ACCENT_COLORS.light
type BackgroundThemeKey = keyof typeof BACKGROUND_THEMES
const accentColorIds = Object.keys(ACCENT_COLORS.light) as [AccentColorKey, ...AccentColorKey[]]
const backgroundThemeIds = Object.keys(BACKGROUND_THEMES) as [
BackgroundThemeKey,
...BackgroundThemeKey[],
]
export const AppSettingsSchema = v.object({
theme: v.picklist(['light', 'dark', 'system']),
relativeDates: v.boolean(),
includeTypesInInstall: v.boolean(),
accentColorId: v.nullable(v.picklist(accentColorIds)),
preferredBackgroundTheme: v.nullable(v.picklist(backgroundThemeIds)),
hidePlatformPackages: v.boolean(),
selectedLocale: v.nullable(v.string()),
sidebar: v.object({
collapsed: v.array(v.string()),
}),
})
export type AppSettings = v.InferOutput<typeof AppSettingsSchema>
export type AccentColorId = AppSettings['accentColorId']
export type BackgroundThemeId = AppSettings['preferredBackgroundTheme']