refactor: extract various constants

This commit is contained in:
2025-11-25 10:10:42 +01:00
parent 4d30e47ee8
commit ccc22beda2
40 changed files with 326 additions and 216 deletions
+1 -7
View File
@@ -32,6 +32,7 @@ import { useSidebarContext } from './SidebarContext';
import { usePanelManager, usePanelResizeBindings } from '../app/PanelManagerContext';
import type { StatusMessage } from '../hooks/documents/store/useDocumentsStore';
import type { Identifier } from '../types/identifiers';
import { THEME_MODE_LABELS, THEME_MODES } from '../constants/sidebar';
interface CommunityLink {
label: string;
@@ -260,13 +261,6 @@ const FolderNode: React.FC<FolderNodeProps> = ({
);
};
const THEME_MODES = ['system', 'light', 'dark'];
const THEME_MODE_LABELS = {
system: 'System',
light: 'Light',
dark: 'Dark',
};
interface FloatingMenuControls {
isOpen: boolean;
toggle: () => void;
+11 -11
View File
@@ -6,6 +6,16 @@ import React, {
useCallback,
useEffect,
} from 'react';
import {
DARK_MODE_MEDIA_QUERY,
DEFAULT_NEUTRAL_CHROMA,
DEFAULT_NEUTRAL_CONTRAST,
DEFAULT_NEUTRAL_HUE,
DEFAULT_THEME_MODE,
SIDEBAR_COLLAPSE_STORAGE_KEY,
THEME_MODES,
THEME_STORAGE_KEY,
} from '../constants/sidebar';
interface SidebarContextValue {
collapsed: boolean;
@@ -25,20 +35,10 @@ interface SidebarContextValue {
themeModes: ThemeMode[];
}
type ThemeMode = 'system' | 'light' | 'dark';
const SIDEBAR_COLLAPSE_STORAGE_KEY = 'papercrate_sidebar_collapsed';
type ThemeMode = (typeof THEME_MODES)[number];
const SidebarContext = createContext<SidebarContextValue | null>(null);
const THEME_STORAGE_KEY = 'papercrate_theme_settings';
const DEFAULT_NEUTRAL_HUE = 29;
const DEFAULT_NEUTRAL_CHROMA = 0.44;
const DEFAULT_NEUTRAL_CONTRAST = 0.56;
const DEFAULT_THEME_MODE = 'system';
const THEME_MODES = ['system', 'light', 'dark'];
const DARK_MODE_MEDIA_QUERY = '(prefers-color-scheme: dark)';
const loadInitialThemeSettings = () => {
const defaults = {
neutralHue: DEFAULT_NEUTRAL_HUE,