From 7e575ea617c160242a39ee62a390cddde83e714a Mon Sep 17 00:00:00 2001 From: Gigi Date: Sun, 5 Oct 2025 23:27:43 +0100 Subject: [PATCH] feat: add reset to defaults button in settings --- src/components/Settings.tsx | 46 ++++++++++++++++++++++++++++++------- src/index.css | 6 +++++ 2 files changed, 44 insertions(+), 8 deletions(-) diff --git a/src/components/Settings.tsx b/src/components/Settings.tsx index f78696dd..4e2975f8 100644 --- a/src/components/Settings.tsx +++ b/src/components/Settings.tsx @@ -1,5 +1,5 @@ import React, { useState, useEffect, useRef } from 'react' -import { faTimes, faList, faThLarge, faImage, faUnderline, faHighlighter } from '@fortawesome/free-solid-svg-icons' +import { faTimes, faList, faThLarge, faImage, faUnderline, faHighlighter, faRotateLeft } from '@fortawesome/free-solid-svg-icons' import { UserSettings } from '../services/settingsService' import IconButton from './IconButton' import ColorPicker from './ColorPicker' @@ -7,6 +7,21 @@ import FontSelector from './FontSelector' import { loadFont, getFontFamily } from '../utils/fontLoader' import { hexToRgb } from '../utils/colorHelpers' +const DEFAULT_SETTINGS: UserSettings = { + collapseOnArticleOpen: true, + defaultViewMode: 'compact', + showHighlights: true, + sidebarCollapsed: true, + highlightsCollapsed: true, + readingFont: 'source-serif-4', + fontSize: 18, + highlightStyle: 'marker', + highlightColor: '#ffff00', + highlightColorNostrverse: '#9333ea', + highlightColorFriends: '#f97316', + highlightColorMine: '#ffff00', +} + interface SettingsProps { settings: UserSettings onSave: (settings: UserSettings) => Promise @@ -45,17 +60,32 @@ const Settings: React.FC = ({ settings, onSave, onClose }) => { const previewFontFamily = getFontFamily(localSettings.readingFont || 'source-serif-4') + const handleResetToDefaults = () => { + if (confirm('Reset all settings to defaults?')) { + setLocalSettings(DEFAULT_SETTINGS) + } + } + return (

Settings

- +
+ + +
diff --git a/src/index.css b/src/index.css index 391c6af3..c6203b14 100644 --- a/src/index.css +++ b/src/index.css @@ -1846,6 +1846,12 @@ body { text-align: left; } +.settings-header-actions { + display: flex; + gap: 0.5rem; + align-items: center; +} + .settings-content { overflow-y: auto; flex: 1;