Skip to content

Commit b6f56e5

Browse files
committed
feat(reader): pure black dark theme, 3 fonts, wider size range
1 parent 1fcce99 commit b6f56e5

1 file changed

Lines changed: 25 additions & 15 deletions

File tree

front/src/pages/BlogPostPage.jsx

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -349,10 +349,18 @@ const ScrollProgress = () => {
349349
const RM_THEMES = {
350350
light: { bg: '#ffffff', text: '#111827', subtleBg: '#f9fafb', border: '#e5e7eb', dark: false },
351351
sepia: { bg: '#f4ecd8', text: '#3b2c1a', subtleBg: '#ede3c8', border: '#d4b896', dark: false },
352-
dark: { bg: '#111827', text: '#f3f4f6', subtleBg: '#1f2937', border: '#374151', dark: true },
352+
dark: { bg: '#000000', text: '#f5f5f0', subtleBg: '#0c0c0c', border: '#222222', dark: true },
353353
};
354354
const RM_WIDTHS = { narrow: '58ch', normal: '70ch', wide: '90ch' };
355355

356+
// Reading mode font families. Cycles via toggle button.
357+
const RM_FONTS = {
358+
sans: { label: 'Sans', stack: 'Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif', sample: 'Aa' },
359+
serif: { label: 'Serif', stack: 'Newsreader, Georgia, "Palatino Linotype", Palatino, serif', sample: 'Aa' },
360+
mono: { label: 'Mono', stack: '"JetBrains Mono", "Source Code Pro", ui-monospace, SFMono-Regular, Menlo, monospace', sample: 'Aa' },
361+
};
362+
const RM_FONT_KEYS = Object.keys(RM_FONTS);
363+
356364
// Reading mode overlay component
357365
const ReadingMode = ({ post, onClose, baseImagePath }) => {
358366
const [fontSize, setFontSize] = useState(
@@ -448,8 +456,8 @@ const ReadingMode = ({ post, onClose, baseImagePath }) => {
448456
}
449457
};
450458

451-
const fontSizeMin = 14, fontSizeMax = 26;
452-
const lineHeightMin = 1.4, lineHeightMax = 2.4;
459+
const fontSizeMin = 13, fontSizeMax = 32;
460+
const lineHeightMin = 1.3, lineHeightMax = 2.6;
453461
const tc = RM_THEMES[theme] || RM_THEMES.light;
454462

455463
const sep = (
@@ -533,17 +541,21 @@ const ReadingMode = ({ post, onClose, baseImagePath }) => {
533541

534542
{sep}
535543

536-
{/* Font family */}
544+
{/* Font family — cycles through Sans / Serif / Mono */}
537545
<button
538-
onClick={() => setFontFamily(f => f === 'sans' ? 'serif' : 'sans')}
539-
title="Toggle font family"
546+
onClick={() => {
547+
const idx = RM_FONT_KEYS.indexOf(fontFamily);
548+
setFontFamily(RM_FONT_KEYS[(idx + 1) % RM_FONT_KEYS.length]);
549+
}}
550+
title={`Font: ${RM_FONTS[fontFamily]?.label || 'Sans'} (click to cycle)`}
551+
aria-label={`Current font ${RM_FONTS[fontFamily]?.label}, click to cycle`}
540552
style={{ color: tc.text }}
541-
className="px-2 h-8 rounded-lg hover:bg-black/[0.06] text-xs transition-colors flex-shrink-0 select-none"
553+
className="px-2.5 h-8 rounded-lg hover:bg-black/[0.06] text-xs transition-colors flex-shrink-0 select-none flex items-center gap-1.5"
542554
>
543-
{fontFamily === 'sans'
544-
? <span style={{ fontFamily: 'Georgia, serif' }}>Serif</span>
545-
: <span>Sans</span>
546-
}
555+
<span style={{ fontFamily: RM_FONTS[fontFamily]?.stack || 'inherit' }}>
556+
{RM_FONTS[fontFamily]?.sample || 'Aa'}
557+
</span>
558+
<span className="hidden sm:inline opacity-70">{RM_FONTS[fontFamily]?.label || 'Sans'}</span>
547559
</button>
548560

549561
{sep}
@@ -572,7 +584,7 @@ const ReadingMode = ({ post, onClose, baseImagePath }) => {
572584
{[
573585
{ key: 'light', bg: '#ffffff', border: '#d1d5db', label: 'Light' },
574586
{ key: 'sepia', bg: '#f4ecd8', border: '#c4a87a', label: 'Sepia' },
575-
{ key: 'dark', bg: '#111827', border: '#6b7280', label: 'Dark' },
587+
{ key: 'dark', bg: '#000000', border: '#444444', label: 'Dark' },
576588
].map(t => (
577589
<button
578590
key={t.key}
@@ -609,9 +621,7 @@ const ReadingMode = ({ post, onClose, baseImagePath }) => {
609621
maxWidth: RM_WIDTHS[width] || RM_WIDTHS.normal,
610622
fontSize: `${fontSize}px`,
611623
lineHeight: lineHeight,
612-
fontFamily: fontFamily === 'serif'
613-
? '"Georgia", "Palatino Linotype", Palatino, serif'
614-
: 'inherit',
624+
fontFamily: RM_FONTS[fontFamily]?.stack || 'inherit',
615625
}}
616626
>
617627
<h1

0 commit comments

Comments
 (0)