|
| 1 | +import React from 'react'; |
| 2 | +import { motion } from 'framer-motion'; |
| 3 | +import { useSnfV3 } from '../../context/SnfV3Context'; |
| 4 | + |
| 5 | +const THEMES = [ |
| 6 | + { value: 'day', swatch: '#f4ecd8', label: 'Day' }, |
| 7 | + { value: 'sepia', swatch: '#e8d7b4', label: 'Sepia' }, |
| 8 | + { value: 'night', swatch: '#16130e', label: 'Night' }, |
| 9 | +]; |
| 10 | + |
| 11 | +const Seg = ({ on, onClick, children }) => ( |
| 12 | + <button type="button" className="snf3-seg" data-on={on ? '1' : '0'} onClick={onClick}> |
| 13 | + {children} |
| 14 | + </button> |
| 15 | +); |
| 16 | + |
| 17 | +/** Reading preferences sheet (theme · size · typeface). */ |
| 18 | +const SnfV3Prefs = ({ onClose }) => { |
| 19 | + const { settings, setPref, language } = useSnfV3(); |
| 20 | + const tr = language === 'tr'; |
| 21 | + return ( |
| 22 | + <> |
| 23 | + <div className="fixed inset-0 z-40" onClick={onClose} aria-hidden /> |
| 24 | + <motion.div |
| 25 | + initial={{ opacity: 0, y: -10, scale: 0.98 }} |
| 26 | + animate={{ opacity: 1, y: 0, scale: 1 }} |
| 27 | + exit={{ opacity: 0, y: -10, scale: 0.98 }} |
| 28 | + transition={{ type: 'spring', stiffness: 380, damping: 26 }} |
| 29 | + className="snf3-sheet absolute right-3 md:right-5 top-full mt-2 z-50 w-72 p-4" |
| 30 | + role="dialog" |
| 31 | + aria-label="Reading preferences" |
| 32 | + > |
| 33 | + <div |
| 34 | + className="text-[0.7rem] tracking-[0.18em] uppercase mb-3" |
| 35 | + style={{ color: 'var(--snf3-sheet-muted)' }} |
| 36 | + > |
| 37 | + {tr ? 'Görünüm' : 'Appearance'} |
| 38 | + </div> |
| 39 | + <div className="flex items-center justify-between gap-3 mb-4"> |
| 40 | + {THEMES.map((th) => ( |
| 41 | + <button |
| 42 | + key={th.value} |
| 43 | + type="button" |
| 44 | + className="snf3-swatch" |
| 45 | + data-on={settings.theme === th.value ? '1' : '0'} |
| 46 | + style={{ background: th.swatch }} |
| 47 | + onClick={() => setPref('theme', th.value)} |
| 48 | + aria-label={th.label} |
| 49 | + title={th.label} |
| 50 | + /> |
| 51 | + ))} |
| 52 | + </div> |
| 53 | + |
| 54 | + <div className="flex items-center justify-between gap-2 mb-3"> |
| 55 | + <span className="text-[0.72rem]" style={{ color: 'var(--snf3-sheet-muted)' }}> |
| 56 | + {tr ? 'Boyut' : 'Size'} |
| 57 | + </span> |
| 58 | + <div className="flex"> |
| 59 | + {[['sm', 'A'], ['md', 'A'], ['lg', 'A']].map(([v, l], i) => ( |
| 60 | + <Seg key={v} on={settings.size === v} onClick={() => setPref('size', v)}> |
| 61 | + <span style={{ fontSize: `${0.7 + i * 0.18}rem` }}>{l}</span> |
| 62 | + </Seg> |
| 63 | + ))} |
| 64 | + </div> |
| 65 | + </div> |
| 66 | + |
| 67 | + <div className="flex items-center justify-between gap-2"> |
| 68 | + <span className="text-[0.72rem]" style={{ color: 'var(--snf3-sheet-muted)' }}> |
| 69 | + {tr ? 'Yazı tipi' : 'Typeface'} |
| 70 | + </span> |
| 71 | + <div className="flex"> |
| 72 | + <Seg on={settings.typeface === 'serif'} onClick={() => setPref('typeface', 'serif')}> |
| 73 | + <span style={{ fontFamily: 'var(--snf3-serif)' }}>Serif</span> |
| 74 | + </Seg> |
| 75 | + <Seg on={settings.typeface === 'sans'} onClick={() => setPref('typeface', 'sans')}> |
| 76 | + <span style={{ fontFamily: 'var(--snf3-ui)' }}>Sans</span> |
| 77 | + </Seg> |
| 78 | + </div> |
| 79 | + </div> |
| 80 | + </motion.div> |
| 81 | + </> |
| 82 | + ); |
| 83 | +}; |
| 84 | + |
| 85 | +export default SnfV3Prefs; |
0 commit comments