diff --git a/src/components/features/settings/Settings.tsx b/src/components/features/settings/Settings.tsx
index 7413119..b0136c6 100644
--- a/src/components/features/settings/Settings.tsx
+++ b/src/components/features/settings/Settings.tsx
@@ -1,4 +1,6 @@
import { useState, useEffect } from 'react';
+import { useAppStore } from '../../../store/useAppStore';
+import { getTranslation } from '../../../utils/i18n';
import {
Sun,
Moon,
@@ -138,24 +140,60 @@ export function Settings() {
() => localStorage.getItem('cinder-theme') || ''
);
const [colorMode, setColorMode] = useState<'light' | 'dark' | 'system'>(
- 'dark'
+ () =>
+ (localStorage.getItem('cinder-color-mode') as
+ | 'light'
+ | 'dark'
+ | 'system') || 'dark'
);
const [showAllThemes, setShowAllThemes] = useState(false);
+ const {
+ defaultView,
+ setDefaultView,
+ sidebarPosition,
+ setSidebarPosition,
+ isAutoSave,
+ toggleAutoSave,
+ language,
+ setLanguage,
+ } = useAppStore();
- useEffect(() => {
- THEME_PRESETS.forEach((t) => {
- if (t.value) document.documentElement.classList.remove(t.value);
- });
+ const t = (key: string) => getTranslation(language, key);
- THEME_VARIABLES.forEach((v) =>
- document.documentElement.style.removeProperty(v)
- );
+ useEffect(() => {
+ const applyTheme = (theme: string) => {
+ THEME_PRESETS.forEach((t) => {
+ if (t.value) document.documentElement.classList.remove(t.value);
+ });
+ THEME_VARIABLES.forEach((v) =>
+ document.documentElement.style.removeProperty(v)
+ );
+ if (theme) {
+ document.documentElement.classList.add(theme);
+ }
+ };
- if (currentTheme) {
- document.documentElement.classList.add(currentTheme);
+ if (colorMode === 'system') {
+ const mediaQuery = window.matchMedia('(prefers-color-scheme: light)');
+ const handleChange = (e: MediaQueryListEvent | MediaQueryList) => {
+ if (e.matches) {
+ applyTheme('theme-cinder-light');
+ } else {
+ applyTheme(currentTheme || '');
+ }
+ };
+ handleChange(mediaQuery);
+ mediaQuery.addEventListener('change', handleChange);
+ return () => mediaQuery.removeEventListener('change', handleChange);
+ } else if (colorMode === 'light') {
+ applyTheme('theme-cinder-light');
+ } else {
+ applyTheme(currentTheme);
}
+
localStorage.setItem('cinder-theme', currentTheme);
- }, [currentTheme]);
+ localStorage.setItem('cinder-color-mode', colorMode);
+ }, [currentTheme, colorMode]);
return (
@@ -163,21 +201,21 @@ export function Settings() {
{/* Sidebar-style Tabs */}
- Settings
+ {t('settings')}
@@ -188,135 +226,150 @@ export function Settings() {
- General Settings
+ {t('general')}
- Customize your editor experience
+ {t('generalDesc') || 'Customize your editor experience'}
- Editor
+ {t('editor')}
-
+
-
- Auto-save
-
- Coming Soon
-
+
+ {t('autoSave')}
- Automatically save changes while typing
+ {t('autoSaveDesc')}
- {[
- {
- icon: Monitor,
- title: 'Default View',
- desc: 'Choose default view for new files',
- options: ['Split View', 'Editor Only', 'Preview Only'],
- },
- {
- icon: FolderOpen,
- title: 'Sidebar Position',
- desc: 'Change the location of the sidebar',
- options: ['Left', 'Right'],
- },
- ].map((item, idx) => (
-
+
+
+
+
+
+
+ {t('defaultView')}
+
+
+ {t('defaultViewDesc')}
+
+
+
+
- System
+ {t('system')}
- {[
- {
- icon: Globe,
- title: 'Language',
- desc: 'Change interface language',
- options: [
- 'English',
- 'Spanish',
- 'French',
- 'German',
- 'Japanese',
- ],
- },
- {
- icon: Bell,
- title: 'Notifications',
- desc: 'Configure desktop notifications',
- options: ['All', 'Important Only', 'None'],
- },
- ].map((item, idx) => (
-
+
+
+
+
+
+
+ {t('language')}
+
+
+ {t('languageDesc')}
+
+
+
+
setLanguage(e.target.value)}
+ className="px-3 py-1.5 text-xs font-medium border border-[var(--border-secondary)] rounded hover:bg-[var(--bg-hover)] bg-[var(--bg-tertiary)] text-[var(--text-primary)] outline-none transition-all cursor-pointer"
>
-
-
-
-
-
-
- {item.title}
-
-
- {item.desc}
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {t('notifications')}
+
+ Coming Soon
+
+
+
+ {t('notificationsDesc')}
+
-
- {item.options.map((opt) => (
-
- ))}
-
- ))}
+
+
+
+
@@ -324,22 +377,23 @@ export function Settings() {
- Themes
+ {t('themes')}
- Manage app appearance and customization
+ {t('themesDesc') ||
+ 'Manage app appearance and customization'}
- Color Mode
+ {t('colorMode')}
{[
- { id: 'light', label: 'Light mode', icon: Sun },
- { id: 'dark', label: 'Dark mode', icon: Moon },
- { id: 'system', label: 'System', icon: Monitor },
+ { id: 'light', label: t('lightMode'), icon: Sun },
+ { id: 'dark', label: t('darkMode'), icon: Moon },
+ { id: 'system', label: t('system'), icon: Monitor },
].map((mode) => (