feat(webui): refine appearance and add custom reading sizes
This commit is contained in:
1 parent
b048cf44f7
commit
ef8271b2c0
38 files changed
+1148
-213
No files matched your search
@@ -1,10 +1,13 @@
|
||||
export type LocalActivityMode = "auto" | "expanded";
|
||||
export type ReadingTextSize = "small" | "standard" | "large";
|
||||
export type ReadingTextSize = "small" | "standard" | "large" | "custom";
|
||||
export const MIN_READING_SIZE = 14;
|
||||
export const MAX_READING_SIZE = 28;
|
||||
export type FileEditDisplayMode = "summary" | "diff" | "collapsed_diff";
|
||||
|
||||
export interface LocalPreferences {
|
||||
activityMode: LocalActivityMode;
|
||||
readingTextSize: ReadingTextSize;
|
||||
customReadingTextSize: number;
|
||||
codeWrap: boolean;
|
||||
brandLogos: boolean;
|
||||
browserNotifications: boolean;
|
||||
@@ -23,6 +26,7 @@ type PersistedLocalPreferences = Partial<LocalPreferences> & {
|
||||
export const DEFAULT_LOCAL_PREFS: LocalPreferences = {
|
||||
activityMode: "auto",
|
||||
readingTextSize: "standard",
|
||||
customReadingTextSize: 18,
|
||||
codeWrap: true,
|
||||
brandLogos: true,
|
||||
browserNotifications: false,
|
||||
@@ -41,8 +45,11 @@ export function readLocalPreferences(): LocalPreferences {
|
||||
const parsed = JSON.parse(raw) as PersistedLocalPreferences;
|
||||
return {
|
||||
activityMode: parsed.activityMode === "expanded" ? "expanded" : "auto",
|
||||
readingTextSize: parsed.readingTextSize === "small" || parsed.readingTextSize === "large"
|
||||
readingTextSize: parsed.readingTextSize === "small" || parsed.readingTextSize === "large" || parsed.readingTextSize === "custom"
|
||||
? parsed.readingTextSize : "standard",
|
||||
customReadingTextSize: typeof parsed.customReadingTextSize === "number" && Number.isFinite(parsed.customReadingTextSize)
|
||||
? Math.min(MAX_READING_SIZE, Math.max(MIN_READING_SIZE, Math.round(parsed.customReadingTextSize)))
|
||||
: DEFAULT_LOCAL_PREFS.customReadingTextSize,
|
||||
codeWrap: parsed.codeWrap !== false,
|
||||
brandLogos: parsed.schemaVersion === LOCAL_PREFS_SCHEMA_VERSION
|
||||
? parsed.brandLogos !== false
|
||||
|
||||
Reference in new issue
Block a user