'use client'; import { useState, useEffect } from 'react'; import AppLayout from '../../components/layout/AppLayout'; import { useTheme } from '../../lib/theme'; import Button from '../../components/ui/Button'; type FontFamily = 'serif' | 'sans' | 'mono'; type FontSize = 'small' | 'medium' | 'large' | 'extra-large'; type ReadingWidth = 'narrow' | 'medium' | 'wide'; interface Settings { theme: 'light' | 'dark'; fontFamily: FontFamily; fontSize: FontSize; readingWidth: ReadingWidth; } const defaultSettings: Settings = { theme: 'light', fontFamily: 'serif', fontSize: 'medium', readingWidth: 'medium', }; export default function SettingsPage() { const { theme, setTheme } = useTheme(); const [settings, setSettings] = useState(defaultSettings); const [saved, setSaved] = useState(false); // Load settings from localStorage on mount useEffect(() => { const savedSettings = localStorage.getItem('storycove-settings'); if (savedSettings) { try { const parsed = JSON.parse(savedSettings); setSettings({ ...defaultSettings, ...parsed, theme }); } catch (error) { console.error('Failed to parse saved settings:', error); setSettings({ ...defaultSettings, theme }); } } else { setSettings({ ...defaultSettings, theme }); } }, [theme]); // Save settings to localStorage const saveSettings = () => { localStorage.setItem('storycove-settings', JSON.stringify(settings)); // Apply theme change setTheme(settings.theme); // Apply font settings to CSS custom properties const root = document.documentElement; const fontFamilyMap = { serif: 'Georgia, Times, serif', sans: 'Inter, system-ui, sans-serif', mono: 'Monaco, Consolas, monospace', }; const fontSizeMap = { small: '14px', medium: '16px', large: '18px', 'extra-large': '20px', }; const readingWidthMap = { narrow: '600px', medium: '800px', wide: '1000px', }; root.style.setProperty('--reading-font-family', fontFamilyMap[settings.fontFamily]); root.style.setProperty('--reading-font-size', fontSizeMap[settings.fontSize]); root.style.setProperty('--reading-max-width', readingWidthMap[settings.readingWidth]); setSaved(true); setTimeout(() => setSaved(false), 2000); }; const updateSetting = (key: K, value: Settings[K]) => { setSettings(prev => ({ ...prev, [key]: value })); }; return (

Settings

Customize your StoryCove reading experience

{/* Theme Settings */}

Appearance

{/* Reading Settings */}

Reading Experience

{/* Font Family */}
{/* Font Size */}
{(['small', 'medium', 'large', 'extra-large'] as FontSize[]).map((size) => ( ))}
{/* Reading Width */}
{(['narrow', 'medium', 'wide'] as ReadingWidth[]).map((width) => ( ))}
{/* Preview */}

Preview

Sample Story Title

by Sample Author

This is how your story text will look with the current settings. The quick brown fox jumps over the lazy dog. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

{/* Actions */}
); }