mirror of
https://github.com/dergigi/boris.git
synced 2025-12-19 07:34:28 +01:00
refactor(settings): split Settings into section components
- Extract ReadingDisplaySettings component - Extract LayoutNavigationSettings component - Extract StartupPreferencesSettings component - Reduce Settings.tsx from 295 lines to 104 lines
This commit is contained in:
@@ -1,11 +1,11 @@
|
|||||||
import React, { useState, useEffect, useRef } from 'react'
|
import React, { useState, useEffect, useRef } from 'react'
|
||||||
import { faTimes, faList, faThLarge, faImage, faUnderline, faHighlighter, faUndo, faNetworkWired, faUserGroup, faUser } from '@fortawesome/free-solid-svg-icons'
|
import { faTimes, faUndo } from '@fortawesome/free-solid-svg-icons'
|
||||||
import { UserSettings } from '../services/settingsService'
|
import { UserSettings } from '../services/settingsService'
|
||||||
import IconButton from './IconButton'
|
import IconButton from './IconButton'
|
||||||
import ColorPicker from './ColorPicker'
|
import { loadFont } from '../utils/fontLoader'
|
||||||
import FontSelector from './FontSelector'
|
import ReadingDisplaySettings from './Settings/ReadingDisplaySettings'
|
||||||
import { loadFont, getFontFamily } from '../utils/fontLoader'
|
import LayoutNavigationSettings from './Settings/LayoutNavigationSettings'
|
||||||
import { hexToRgb } from '../utils/colorHelpers'
|
import StartupPreferencesSettings from './Settings/StartupPreferencesSettings'
|
||||||
|
|
||||||
const DEFAULT_SETTINGS: UserSettings = {
|
const DEFAULT_SETTINGS: UserSettings = {
|
||||||
collapseOnArticleOpen: true,
|
collapseOnArticleOpen: true,
|
||||||
@@ -48,29 +48,28 @@ const Settings: React.FC<SettingsProps> = ({ settings, onSave, onClose }) => {
|
|||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Load font for preview when it changes
|
|
||||||
const fontToLoad = localSettings.readingFont || 'source-serif-4'
|
const fontToLoad = localSettings.readingFont || 'source-serif-4'
|
||||||
loadFont(fontToLoad).catch(err => console.warn('Failed to load preview font:', fontToLoad, err))
|
loadFont(fontToLoad).catch(err => console.warn('Failed to load preview font:', fontToLoad, err))
|
||||||
}, [localSettings.readingFont])
|
}, [localSettings.readingFont])
|
||||||
|
|
||||||
// Auto-save settings whenever they change (except on initial mount)
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isInitialMount.current) {
|
if (isInitialMount.current) {
|
||||||
isInitialMount.current = false
|
isInitialMount.current = false
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
onSave(localSettings)
|
onSave(localSettings)
|
||||||
}, [localSettings, onSave])
|
}, [localSettings, onSave])
|
||||||
|
|
||||||
const previewFontFamily = getFontFamily(localSettings.readingFont || 'source-serif-4')
|
|
||||||
|
|
||||||
const handleResetToDefaults = () => {
|
const handleResetToDefaults = () => {
|
||||||
if (confirm('Reset all settings to defaults?')) {
|
if (confirm('Reset all settings to defaults?')) {
|
||||||
setLocalSettings(DEFAULT_SETTINGS)
|
setLocalSettings(DEFAULT_SETTINGS)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleUpdate = (updates: Partial<UserSettings>) => {
|
||||||
|
setLocalSettings({ ...localSettings, ...updates })
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="settings-view">
|
<div className="settings-view">
|
||||||
<div className="settings-header">
|
<div className="settings-header">
|
||||||
@@ -94,199 +93,9 @@ const Settings: React.FC<SettingsProps> = ({ settings, onSave, onClose }) => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="settings-content">
|
<div className="settings-content">
|
||||||
<div className="settings-section">
|
<ReadingDisplaySettings settings={localSettings} onUpdate={handleUpdate} />
|
||||||
<h3 className="section-title">Reading & Display</h3>
|
<LayoutNavigationSettings settings={localSettings} onUpdate={handleUpdate} />
|
||||||
|
<StartupPreferencesSettings settings={localSettings} onUpdate={handleUpdate} />
|
||||||
<div className="setting-group setting-inline">
|
|
||||||
<label htmlFor="readingFont">Reading Font</label>
|
|
||||||
<FontSelector
|
|
||||||
value={localSettings.readingFont || 'source-serif-4'}
|
|
||||||
onChange={(font) => setLocalSettings({ ...localSettings, readingFont: font })}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="setting-group setting-inline">
|
|
||||||
<label>Font Size</label>
|
|
||||||
<div className="setting-buttons">
|
|
||||||
{[14, 16, 18, 20, 22].map(size => (
|
|
||||||
<button
|
|
||||||
key={size}
|
|
||||||
onClick={() => setLocalSettings({ ...localSettings, fontSize: size })}
|
|
||||||
className={`font-size-btn ${(localSettings.fontSize || 18) === size ? 'active' : ''}`}
|
|
||||||
title={`${size}px`}
|
|
||||||
style={{ fontSize: `${size - 2}px` }}
|
|
||||||
>
|
|
||||||
A
|
|
||||||
</button>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="setting-group">
|
|
||||||
<label htmlFor="showHighlights" className="checkbox-label">
|
|
||||||
<input
|
|
||||||
id="showHighlights"
|
|
||||||
type="checkbox"
|
|
||||||
checked={localSettings.showHighlights !== false}
|
|
||||||
onChange={(e) => setLocalSettings({ ...localSettings, showHighlights: e.target.checked })}
|
|
||||||
className="setting-checkbox"
|
|
||||||
/>
|
|
||||||
<span>Show highlights</span>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="setting-group setting-inline">
|
|
||||||
<label>Highlight Style</label>
|
|
||||||
<div className="setting-buttons">
|
|
||||||
<IconButton
|
|
||||||
icon={faHighlighter}
|
|
||||||
onClick={() => setLocalSettings({ ...localSettings, highlightStyle: 'marker' })}
|
|
||||||
title="Text marker style"
|
|
||||||
ariaLabel="Text marker style"
|
|
||||||
variant={(localSettings.highlightStyle || 'marker') === 'marker' ? 'primary' : 'ghost'}
|
|
||||||
/>
|
|
||||||
<IconButton
|
|
||||||
icon={faUnderline}
|
|
||||||
onClick={() => setLocalSettings({ ...localSettings, highlightStyle: 'underline' })}
|
|
||||||
title="Underline style"
|
|
||||||
ariaLabel="Underline style"
|
|
||||||
variant={localSettings.highlightStyle === 'underline' ? 'primary' : 'ghost'}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div className="setting-group setting-inline">
|
|
||||||
<label className="setting-label">My Highlights</label>
|
|
||||||
<div className="setting-control">
|
|
||||||
<ColorPicker
|
|
||||||
selectedColor={localSettings.highlightColorMine || '#ffff00'}
|
|
||||||
onColorChange={(color) => setLocalSettings({ ...localSettings, highlightColorMine: color })}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="setting-group setting-inline">
|
|
||||||
<label className="setting-label">Friends Highlights</label>
|
|
||||||
<div className="setting-control">
|
|
||||||
<ColorPicker
|
|
||||||
selectedColor={localSettings.highlightColorFriends || '#f97316'}
|
|
||||||
onColorChange={(color) => setLocalSettings({ ...localSettings, highlightColorFriends: color })}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="setting-group setting-inline">
|
|
||||||
<label className="setting-label">Nostrverse Highlights</label>
|
|
||||||
<div className="setting-control">
|
|
||||||
<ColorPicker
|
|
||||||
selectedColor={localSettings.highlightColorNostrverse || '#9333ea'}
|
|
||||||
onColorChange={(color) => setLocalSettings({ ...localSettings, highlightColorNostrverse: color })}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="setting-preview">
|
|
||||||
<div className="preview-label">Preview</div>
|
|
||||||
<div
|
|
||||||
className="preview-content"
|
|
||||||
style={{
|
|
||||||
fontFamily: previewFontFamily,
|
|
||||||
fontSize: `${localSettings.fontSize || 18}px`,
|
|
||||||
'--highlight-rgb': hexToRgb(localSettings.highlightColor || '#ffff00')
|
|
||||||
} as React.CSSProperties}
|
|
||||||
>
|
|
||||||
<h3>The Quick Brown Fox</h3>
|
|
||||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. <span className={localSettings.showHighlights !== false ? `content-highlight-${localSettings.highlightStyle || 'marker'} level-mine` : ""}>Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</span> Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
|
|
||||||
<p>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. <span className={localSettings.showHighlights !== false ? `content-highlight-${localSettings.highlightStyle || 'marker'} level-friends` : ""}>Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</span> Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium.</p>
|
|
||||||
<p>Totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. <span className={localSettings.showHighlights !== false ? `content-highlight-${localSettings.highlightStyle || 'marker'} level-nostrverse` : ""}>Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt.</span> Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit.</p>
|
|
||||||
<p>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt.</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="settings-section">
|
|
||||||
<h3 className="section-title">Layout & Navigation</h3>
|
|
||||||
|
|
||||||
<div className="setting-group setting-inline">
|
|
||||||
<label>Default View Mode</label>
|
|
||||||
<div className="setting-buttons">
|
|
||||||
<IconButton icon={faList} onClick={() => setLocalSettings({ ...localSettings, defaultViewMode: 'compact' })} title="Compact list view" ariaLabel="Compact list view" variant={(localSettings.defaultViewMode || 'compact') === 'compact' ? 'primary' : 'ghost'} />
|
|
||||||
<IconButton icon={faThLarge} onClick={() => setLocalSettings({ ...localSettings, defaultViewMode: 'cards' })} title="Cards view" ariaLabel="Cards view" variant={localSettings.defaultViewMode === 'cards' ? 'primary' : 'ghost'} />
|
|
||||||
<IconButton icon={faImage} onClick={() => setLocalSettings({ ...localSettings, defaultViewMode: 'large' })} title="Large preview view" ariaLabel="Large preview view" variant={localSettings.defaultViewMode === 'large' ? 'primary' : 'ghost'} />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="setting-group">
|
|
||||||
<label htmlFor="collapseOnArticleOpen" className="checkbox-label">
|
|
||||||
<input
|
|
||||||
id="collapseOnArticleOpen"
|
|
||||||
type="checkbox"
|
|
||||||
checked={localSettings.collapseOnArticleOpen !== false}
|
|
||||||
onChange={(e) => setLocalSettings({ ...localSettings, collapseOnArticleOpen: e.target.checked })}
|
|
||||||
className="setting-checkbox"
|
|
||||||
/>
|
|
||||||
<span>Collapse bookmark bar when opening an article</span>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="settings-section">
|
|
||||||
<h3 className="section-title">Startup Preferences</h3>
|
|
||||||
|
|
||||||
<div className="setting-group">
|
|
||||||
<label htmlFor="sidebarCollapsed" className="checkbox-label">
|
|
||||||
<input
|
|
||||||
id="sidebarCollapsed"
|
|
||||||
type="checkbox"
|
|
||||||
checked={localSettings.sidebarCollapsed !== false}
|
|
||||||
onChange={(e) => setLocalSettings({ ...localSettings, sidebarCollapsed: e.target.checked })}
|
|
||||||
className="setting-checkbox"
|
|
||||||
/>
|
|
||||||
<span>Start with bookmarks sidebar collapsed</span>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="setting-group">
|
|
||||||
<label htmlFor="highlightsCollapsed" className="checkbox-label">
|
|
||||||
<input
|
|
||||||
id="highlightsCollapsed"
|
|
||||||
type="checkbox"
|
|
||||||
checked={localSettings.highlightsCollapsed !== false}
|
|
||||||
onChange={(e) => setLocalSettings({ ...localSettings, highlightsCollapsed: e.target.checked })}
|
|
||||||
className="setting-checkbox"
|
|
||||||
/>
|
|
||||||
<span>Start with highlights panel collapsed</span>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="setting-group setting-inline">
|
|
||||||
<label>Default Highlight Visibility</label>
|
|
||||||
<div className="setting-buttons">
|
|
||||||
<IconButton
|
|
||||||
icon={faNetworkWired}
|
|
||||||
onClick={() => setLocalSettings({ ...localSettings, defaultHighlightVisibilityNostrverse: !(localSettings.defaultHighlightVisibilityNostrverse !== false) })}
|
|
||||||
title="Nostrverse highlights"
|
|
||||||
ariaLabel="Toggle nostrverse highlights by default"
|
|
||||||
variant={(localSettings.defaultHighlightVisibilityNostrverse !== false) ? 'primary' : 'ghost'}
|
|
||||||
/>
|
|
||||||
<IconButton
|
|
||||||
icon={faUserGroup}
|
|
||||||
onClick={() => setLocalSettings({ ...localSettings, defaultHighlightVisibilityFriends: !(localSettings.defaultHighlightVisibilityFriends !== false) })}
|
|
||||||
title="Friends highlights"
|
|
||||||
ariaLabel="Toggle friends highlights by default"
|
|
||||||
variant={(localSettings.defaultHighlightVisibilityFriends !== false) ? 'primary' : 'ghost'}
|
|
||||||
/>
|
|
||||||
<IconButton
|
|
||||||
icon={faUser}
|
|
||||||
onClick={() => setLocalSettings({ ...localSettings, defaultHighlightVisibilityMine: !(localSettings.defaultHighlightVisibilityMine !== false) })}
|
|
||||||
title="My highlights"
|
|
||||||
ariaLabel="Toggle my highlights by default"
|
|
||||||
variant={(localSettings.defaultHighlightVisibilityMine !== false) ? 'primary' : 'ghost'}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
60
src/components/Settings/LayoutNavigationSettings.tsx
Normal file
60
src/components/Settings/LayoutNavigationSettings.tsx
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import { faList, faThLarge, faImage } from '@fortawesome/free-solid-svg-icons'
|
||||||
|
import { UserSettings } from '../../services/settingsService'
|
||||||
|
import IconButton from '../IconButton'
|
||||||
|
|
||||||
|
interface LayoutNavigationSettingsProps {
|
||||||
|
settings: UserSettings
|
||||||
|
onUpdate: (updates: Partial<UserSettings>) => void
|
||||||
|
}
|
||||||
|
|
||||||
|
const LayoutNavigationSettings: React.FC<LayoutNavigationSettingsProps> = ({ settings, onUpdate }) => {
|
||||||
|
return (
|
||||||
|
<div className="settings-section">
|
||||||
|
<h3 className="section-title">Layout & Navigation</h3>
|
||||||
|
|
||||||
|
<div className="setting-group setting-inline">
|
||||||
|
<label>Default View Mode</label>
|
||||||
|
<div className="setting-buttons">
|
||||||
|
<IconButton
|
||||||
|
icon={faList}
|
||||||
|
onClick={() => onUpdate({ defaultViewMode: 'compact' })}
|
||||||
|
title="Compact list view"
|
||||||
|
ariaLabel="Compact list view"
|
||||||
|
variant={(settings.defaultViewMode || 'compact') === 'compact' ? 'primary' : 'ghost'}
|
||||||
|
/>
|
||||||
|
<IconButton
|
||||||
|
icon={faThLarge}
|
||||||
|
onClick={() => onUpdate({ defaultViewMode: 'cards' })}
|
||||||
|
title="Cards view"
|
||||||
|
ariaLabel="Cards view"
|
||||||
|
variant={settings.defaultViewMode === 'cards' ? 'primary' : 'ghost'}
|
||||||
|
/>
|
||||||
|
<IconButton
|
||||||
|
icon={faImage}
|
||||||
|
onClick={() => onUpdate({ defaultViewMode: 'large' })}
|
||||||
|
title="Large preview view"
|
||||||
|
ariaLabel="Large preview view"
|
||||||
|
variant={settings.defaultViewMode === 'large' ? 'primary' : 'ghost'}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="setting-group">
|
||||||
|
<label htmlFor="collapseOnArticleOpen" className="checkbox-label">
|
||||||
|
<input
|
||||||
|
id="collapseOnArticleOpen"
|
||||||
|
type="checkbox"
|
||||||
|
checked={settings.collapseOnArticleOpen !== false}
|
||||||
|
onChange={(e) => onUpdate({ collapseOnArticleOpen: e.target.checked })}
|
||||||
|
className="setting-checkbox"
|
||||||
|
/>
|
||||||
|
<span>Collapse bookmark bar when opening an article</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default LayoutNavigationSettings
|
||||||
|
|
||||||
132
src/components/Settings/ReadingDisplaySettings.tsx
Normal file
132
src/components/Settings/ReadingDisplaySettings.tsx
Normal file
@@ -0,0 +1,132 @@
|
|||||||
|
import React, { useMemo } from 'react'
|
||||||
|
import { faHighlighter, faUnderline } from '@fortawesome/free-solid-svg-icons'
|
||||||
|
import { UserSettings } from '../../services/settingsService'
|
||||||
|
import IconButton from '../IconButton'
|
||||||
|
import ColorPicker from '../ColorPicker'
|
||||||
|
import FontSelector from '../FontSelector'
|
||||||
|
import { getFontFamily } from '../../utils/fontLoader'
|
||||||
|
import { hexToRgb } from '../../utils/colorHelpers'
|
||||||
|
|
||||||
|
interface ReadingDisplaySettingsProps {
|
||||||
|
settings: UserSettings
|
||||||
|
onUpdate: (updates: Partial<UserSettings>) => void
|
||||||
|
}
|
||||||
|
|
||||||
|
const ReadingDisplaySettings: React.FC<ReadingDisplaySettingsProps> = ({ settings, onUpdate }) => {
|
||||||
|
const previewFontFamily = getFontFamily(settings.readingFont || 'source-serif-4')
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="settings-section">
|
||||||
|
<h3 className="section-title">Reading & Display</h3>
|
||||||
|
|
||||||
|
<div className="setting-group setting-inline">
|
||||||
|
<label htmlFor="readingFont">Reading Font</label>
|
||||||
|
<FontSelector
|
||||||
|
value={settings.readingFont || 'source-serif-4'}
|
||||||
|
onChange={(font) => onUpdate({ readingFont: font })}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="setting-group setting-inline">
|
||||||
|
<label>Font Size</label>
|
||||||
|
<div className="setting-buttons">
|
||||||
|
{[14, 16, 18, 20, 22].map(size => (
|
||||||
|
<button
|
||||||
|
key={size}
|
||||||
|
onClick={() => onUpdate({ fontSize: size })}
|
||||||
|
className={`font-size-btn ${(settings.fontSize || 18) === size ? 'active' : ''}`}
|
||||||
|
title={`${size}px`}
|
||||||
|
style={{ fontSize: `${size - 2}px` }}
|
||||||
|
>
|
||||||
|
A
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="setting-group">
|
||||||
|
<label htmlFor="showHighlights" className="checkbox-label">
|
||||||
|
<input
|
||||||
|
id="showHighlights"
|
||||||
|
type="checkbox"
|
||||||
|
checked={settings.showHighlights !== false}
|
||||||
|
onChange={(e) => onUpdate({ showHighlights: e.target.checked })}
|
||||||
|
className="setting-checkbox"
|
||||||
|
/>
|
||||||
|
<span>Show highlights</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="setting-group setting-inline">
|
||||||
|
<label>Highlight Style</label>
|
||||||
|
<div className="setting-buttons">
|
||||||
|
<IconButton
|
||||||
|
icon={faHighlighter}
|
||||||
|
onClick={() => onUpdate({ highlightStyle: 'marker' })}
|
||||||
|
title="Text marker style"
|
||||||
|
ariaLabel="Text marker style"
|
||||||
|
variant={(settings.highlightStyle || 'marker') === 'marker' ? 'primary' : 'ghost'}
|
||||||
|
/>
|
||||||
|
<IconButton
|
||||||
|
icon={faUnderline}
|
||||||
|
onClick={() => onUpdate({ highlightStyle: 'underline' })}
|
||||||
|
title="Underline style"
|
||||||
|
ariaLabel="Underline style"
|
||||||
|
variant={settings.highlightStyle === 'underline' ? 'primary' : 'ghost'}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="setting-group setting-inline">
|
||||||
|
<label className="setting-label">My Highlights</label>
|
||||||
|
<div className="setting-control">
|
||||||
|
<ColorPicker
|
||||||
|
selectedColor={settings.highlightColorMine || '#ffff00'}
|
||||||
|
onColorChange={(color) => onUpdate({ highlightColorMine: color })}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="setting-group setting-inline">
|
||||||
|
<label className="setting-label">Friends Highlights</label>
|
||||||
|
<div className="setting-control">
|
||||||
|
<ColorPicker
|
||||||
|
selectedColor={settings.highlightColorFriends || '#f97316'}
|
||||||
|
onColorChange={(color) => onUpdate({ highlightColorFriends: color })}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="setting-group setting-inline">
|
||||||
|
<label className="setting-label">Nostrverse Highlights</label>
|
||||||
|
<div className="setting-control">
|
||||||
|
<ColorPicker
|
||||||
|
selectedColor={settings.highlightColorNostrverse || '#9333ea'}
|
||||||
|
onColorChange={(color) => onUpdate({ highlightColorNostrverse: color })}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="setting-preview">
|
||||||
|
<div className="preview-label">Preview</div>
|
||||||
|
<div
|
||||||
|
className="preview-content"
|
||||||
|
style={{
|
||||||
|
fontFamily: previewFontFamily,
|
||||||
|
fontSize: `${settings.fontSize || 18}px`,
|
||||||
|
'--highlight-rgb': hexToRgb(settings.highlightColor || '#ffff00')
|
||||||
|
} as React.CSSProperties}
|
||||||
|
>
|
||||||
|
<h3>The Quick Brown Fox</h3>
|
||||||
|
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. <span className={settings.showHighlights !== false ? `content-highlight-${settings.highlightStyle || 'marker'} level-mine` : ""}>Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</span> Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
|
||||||
|
<p>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. <span className={settings.showHighlights !== false ? `content-highlight-${settings.highlightStyle || 'marker'} level-friends` : ""}>Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</span> Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium.</p>
|
||||||
|
<p>Totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. <span className={settings.showHighlights !== false ? `content-highlight-${settings.highlightStyle || 'marker'} level-nostrverse` : ""}>Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt.</span> Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit.</p>
|
||||||
|
<p>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ReadingDisplaySettings
|
||||||
|
|
||||||
73
src/components/Settings/StartupPreferencesSettings.tsx
Normal file
73
src/components/Settings/StartupPreferencesSettings.tsx
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import { faNetworkWired, faUserGroup, faUser } from '@fortawesome/free-solid-svg-icons'
|
||||||
|
import { UserSettings } from '../../services/settingsService'
|
||||||
|
import IconButton from '../IconButton'
|
||||||
|
|
||||||
|
interface StartupPreferencesSettingsProps {
|
||||||
|
settings: UserSettings
|
||||||
|
onUpdate: (updates: Partial<UserSettings>) => void
|
||||||
|
}
|
||||||
|
|
||||||
|
const StartupPreferencesSettings: React.FC<StartupPreferencesSettingsProps> = ({ settings, onUpdate }) => {
|
||||||
|
return (
|
||||||
|
<div className="settings-section">
|
||||||
|
<h3 className="section-title">Startup Preferences</h3>
|
||||||
|
|
||||||
|
<div className="setting-group">
|
||||||
|
<label htmlFor="sidebarCollapsed" className="checkbox-label">
|
||||||
|
<input
|
||||||
|
id="sidebarCollapsed"
|
||||||
|
type="checkbox"
|
||||||
|
checked={settings.sidebarCollapsed !== false}
|
||||||
|
onChange={(e) => onUpdate({ sidebarCollapsed: e.target.checked })}
|
||||||
|
className="setting-checkbox"
|
||||||
|
/>
|
||||||
|
<span>Start with bookmarks sidebar collapsed</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="setting-group">
|
||||||
|
<label htmlFor="highlightsCollapsed" className="checkbox-label">
|
||||||
|
<input
|
||||||
|
id="highlightsCollapsed"
|
||||||
|
type="checkbox"
|
||||||
|
checked={settings.highlightsCollapsed !== false}
|
||||||
|
onChange={(e) => onUpdate({ highlightsCollapsed: e.target.checked })}
|
||||||
|
className="setting-checkbox"
|
||||||
|
/>
|
||||||
|
<span>Start with highlights panel collapsed</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="setting-group setting-inline">
|
||||||
|
<label>Default Highlight Visibility</label>
|
||||||
|
<div className="setting-buttons">
|
||||||
|
<IconButton
|
||||||
|
icon={faNetworkWired}
|
||||||
|
onClick={() => onUpdate({ defaultHighlightVisibilityNostrverse: !(settings.defaultHighlightVisibilityNostrverse !== false) })}
|
||||||
|
title="Nostrverse highlights"
|
||||||
|
ariaLabel="Toggle nostrverse highlights by default"
|
||||||
|
variant={(settings.defaultHighlightVisibilityNostrverse !== false) ? 'primary' : 'ghost'}
|
||||||
|
/>
|
||||||
|
<IconButton
|
||||||
|
icon={faUserGroup}
|
||||||
|
onClick={() => onUpdate({ defaultHighlightVisibilityFriends: !(settings.defaultHighlightVisibilityFriends !== false) })}
|
||||||
|
title="Friends highlights"
|
||||||
|
ariaLabel="Toggle friends highlights by default"
|
||||||
|
variant={(settings.defaultHighlightVisibilityFriends !== false) ? 'primary' : 'ghost'}
|
||||||
|
/>
|
||||||
|
<IconButton
|
||||||
|
icon={faUser}
|
||||||
|
onClick={() => onUpdate({ defaultHighlightVisibilityMine: !(settings.defaultHighlightVisibilityMine !== false) })}
|
||||||
|
title="My highlights"
|
||||||
|
ariaLabel="Toggle my highlights by default"
|
||||||
|
variant={(settings.defaultHighlightVisibilityMine !== false) ? 'primary' : 'ghost'}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default StartupPreferencesSettings
|
||||||
|
|
||||||
Reference in New Issue
Block a user