mirror of
https://github.com/dergigi/boris.git
synced 2025-12-16 22:24:25 +01:00
feat: add configurable link color setting for article links
- Add linkColor field to UserSettings interface - Add LINK_COLORS palette with 6 link-appropriate colors - Update ColorPicker to accept custom color arrays - Add Link Color setting UI after Reading Font setting - Apply link color as CSS variable in useSettings hook - Update reader CSS to use --link-color variable instead of --color-primary - Add link color preview in settings preview section - Default to indigo-400 (#818cf8) for better visibility on dimmed displays
This commit is contained in:
@@ -1,22 +1,23 @@
|
||||
import React from 'react'
|
||||
import { HIGHLIGHT_COLORS } from '../utils/colorHelpers'
|
||||
import { HIGHLIGHT_COLORS, LINK_COLORS } from '../utils/colorHelpers'
|
||||
|
||||
interface ColorPickerProps {
|
||||
selectedColor: string
|
||||
onColorChange: (color: string) => void
|
||||
colors?: typeof HIGHLIGHT_COLORS
|
||||
}
|
||||
|
||||
const ColorPicker: React.FC<ColorPickerProps> = ({ selectedColor, onColorChange }) => {
|
||||
const ColorPicker: React.FC<ColorPickerProps> = ({ selectedColor, onColorChange, colors = HIGHLIGHT_COLORS }) => {
|
||||
return (
|
||||
<div className="color-picker">
|
||||
{HIGHLIGHT_COLORS.map(color => (
|
||||
{colors.map(color => (
|
||||
<button
|
||||
key={color.value}
|
||||
onClick={() => onColorChange(color.value)}
|
||||
className={`color-swatch ${selectedColor === color.value ? 'active' : ''}`}
|
||||
style={{ backgroundColor: color.value }}
|
||||
title={color.name}
|
||||
aria-label={`${color.name} highlight color`}
|
||||
aria-label={`${color.name} color`}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@@ -51,6 +51,7 @@ const DEFAULT_SETTINGS: UserSettings = {
|
||||
ttsDetectContentLanguage: true,
|
||||
ttsLanguageMode: 'content',
|
||||
ttsDefaultSpeed: 2.1,
|
||||
linkColor: '#818cf8',
|
||||
}
|
||||
|
||||
interface SettingsProps {
|
||||
|
||||
@@ -5,7 +5,7 @@ import IconButton from '../IconButton'
|
||||
import ColorPicker from '../ColorPicker'
|
||||
import FontSelector from '../FontSelector'
|
||||
import { getFontFamily } from '../../utils/fontLoader'
|
||||
import { hexToRgb } from '../../utils/colorHelpers'
|
||||
import { hexToRgb, LINK_COLORS } from '../../utils/colorHelpers'
|
||||
|
||||
interface ReadingDisplaySettingsProps {
|
||||
settings: UserSettings
|
||||
@@ -109,6 +109,17 @@ const ReadingDisplaySettings: React.FC<ReadingDisplaySettingsProps> = ({ setting
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="setting-group setting-inline">
|
||||
<label className="setting-label">Link Color</label>
|
||||
<div className="setting-control">
|
||||
<ColorPicker
|
||||
selectedColor={settings.linkColor || '#818cf8'}
|
||||
onColorChange={(color) => onUpdate({ linkColor: color })}
|
||||
colors={LINK_COLORS}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="setting-group setting-inline">
|
||||
<label className="setting-label">Font Size</label>
|
||||
<div className="setting-control">
|
||||
@@ -179,14 +190,15 @@ const ReadingDisplaySettings: React.FC<ReadingDisplaySettingsProps> = ({ setting
|
||||
fontFamily: previewFontFamily,
|
||||
fontSize: `${settings.fontSize || 21}px`,
|
||||
'--highlight-rgb': hexToRgb(settings.highlightColor || '#ffff00'),
|
||||
'--paragraph-alignment': settings.paragraphAlignment || 'justify'
|
||||
'--paragraph-alignment': settings.paragraphAlignment || 'justify',
|
||||
'--link-color': settings.linkColor || '#818cf8'
|
||||
} as React.CSSProperties}
|
||||
>
|
||||
<h3>The Quick Brown Fox</h3>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. <span className={settings.showHighlights !== false && settings.defaultHighlightVisibilityMine !== 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 && settings.defaultHighlightVisibilityFriends !== 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 && settings.defaultHighlightVisibilityNostrverse !== 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>
|
||||
<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. <a href="#">This is a sample link</a> to demonstrate the link color.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -68,6 +68,9 @@ export function useSettings({ relayPool, eventStore, pubkey, accountManager }: U
|
||||
root.setProperty('--highlight-color-friends', settings.highlightColorFriends || '#f97316')
|
||||
root.setProperty('--highlight-color-nostrverse', settings.highlightColorNostrverse || '#9333ea')
|
||||
|
||||
// Set link color
|
||||
root.setProperty('--link-color', settings.linkColor || '#818cf8')
|
||||
|
||||
// Set paragraph alignment
|
||||
root.setProperty('--paragraph-alignment', settings.paragraphAlignment || 'justify')
|
||||
|
||||
|
||||
@@ -74,6 +74,8 @@ export interface UserSettings {
|
||||
ttsLanguageMode?: 'system' | 'content' | string // default: 'content', can also be language code like 'en', 'es', etc.
|
||||
// Text-to-Speech settings
|
||||
ttsDefaultSpeed?: number // default: 2.1
|
||||
// Link color for article content
|
||||
linkColor?: string // default: #818cf8 (indigo-400)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -55,8 +55,8 @@
|
||||
--color-text: #e4e4e7; /* zinc-200 */
|
||||
--color-text-secondary: #a1a1aa; /* zinc-400 */
|
||||
--color-text-muted: #71717a; /* zinc-500 */
|
||||
--color-primary: #818cf8; /* indigo-400 - lighter for better visibility on dimmed displays */
|
||||
--color-primary-hover: #6366f1; /* indigo-500 */
|
||||
--color-primary: #6366f1; /* indigo-500 */
|
||||
--color-primary-hover: #4f46e5; /* indigo-600 */
|
||||
}
|
||||
|
||||
/* Light theme */
|
||||
@@ -95,8 +95,8 @@
|
||||
--color-text: #e4e4e7;
|
||||
--color-text-secondary: #a1a1aa;
|
||||
--color-text-muted: #71717a;
|
||||
--color-primary: #818cf8; /* indigo-400 - lighter for better visibility on dimmed displays */
|
||||
--color-primary-hover: #6366f1; /* indigo-500 */
|
||||
--color-primary: #6366f1;
|
||||
--color-primary-hover: #4f46e5;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +43,13 @@
|
||||
word-wrap: break-word;
|
||||
text-align: var(--paragraph-alignment, justify);
|
||||
}
|
||||
.preview-content a {
|
||||
color: var(--link-color, #818cf8);
|
||||
text-decoration: none;
|
||||
}
|
||||
.preview-content a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
.setting-select { width: 100%; padding: 0.5rem 1.75rem 0.5rem 0.5rem; background: var(--color-bg-elevated); border: 1px solid var(--color-border-subtle); border-radius: 4px; color: var(--color-text); font-size: 1rem; }
|
||||
.setting-inline .setting-select { width: auto; min-width: 200px; flex: 1; }
|
||||
.setting-select:focus { outline: none; border-color: var(--color-primary); }
|
||||
|
||||
@@ -160,7 +160,7 @@
|
||||
opacity: 0.69;
|
||||
margin: 2.5rem 0;
|
||||
}
|
||||
.reader-markdown a { color: var(--color-primary); text-decoration: none; }
|
||||
.reader-markdown a { color: var(--link-color, #818cf8); text-decoration: none; }
|
||||
.reader-markdown a:hover { text-decoration: underline; }
|
||||
.reader-markdown code { background: var(--color-bg-subtle); border: 1px solid var(--color-border); border-radius: 4px; padding: 0.15rem 0.4rem; font-size: 0.9em; font-family: 'Monaco', 'Menlo', 'Consolas', 'Courier New', monospace; }
|
||||
.reader-markdown pre { background: var(--color-bg-subtle); border: 1px solid var(--color-border); border-radius: 8px; padding: 1rem; overflow-x: auto; margin: 1rem 0; line-height: 1.5; font-family: 'Monaco', 'Menlo', 'Consolas', 'Courier New', monospace; }
|
||||
|
||||
@@ -15,3 +15,13 @@ export const HIGHLIGHT_COLORS = [
|
||||
{ name: 'Blue', value: '#3b82f6' }, // blue-500
|
||||
{ name: 'Purple', value: '#9333ea' } // purple-600
|
||||
]
|
||||
|
||||
// Tailwind color palette for link colors
|
||||
export const LINK_COLORS = [
|
||||
{ name: 'Sky Blue', value: '#38bdf8' }, // sky-400
|
||||
{ name: 'Cyan', value: '#22d3ee' }, // cyan-400
|
||||
{ name: 'Blue', value: '#3b82f6' }, // blue-500
|
||||
{ name: 'Light Blue', value: '#60a5fa' }, // blue-400
|
||||
{ name: 'Indigo Light', value: '#818cf8' }, // indigo-400
|
||||
{ name: 'Purple', value: '#9333ea' } // purple-600
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user