import { HStack, VStack, SpanBox } from '../../elements/LayoutPrimitives' import { Button } from '../../elements/Button' import { StyledText } from '../../elements/StyledText' import { styled, theme, ThemeId } from '../../tokens/stitches.config' import { ArrowsHorizontal, ArrowsInLineHorizontal, CaretLeft, CaretRight, Check, } from 'phosphor-react' import { TickedRangeSlider } from '../../elements/TickedRangeSlider' import { showSuccessToast } from '../../../lib/toastHelpers' import { ReaderSettings } from '../../../lib/hooks/useReaderSettings' import { useCallback, useState } from 'react' import { currentThemeName, updateTheme } from '../../../lib/themeUpdater' import { LineHeightIncreaseIcon } from '../../elements/images/LineHeightIncreaseIconProps' import { LineHeightDecreaseIcon } from '../../elements/images/LineHeightDecreaseIcon' import * as Switch from '@radix-ui/react-switch' type ReaderSettingsProps = { readerSettings: ReaderSettings } const HorizontalDivider = styled(SpanBox, { width: '100%', height: '1px', background: `${theme.colors.grayLine.toString()}`, }) const FONT_FAMILIES = [ 'Inter', 'System Default', 'Merriweather', 'Lora', 'Open Sans', 'Roboto', 'Newsreader', 'Montserrat', 'Crimson Text', 'OpenDyslexic', 'Source Serif Pro', 'LXGWWenKai', 'AtkinsonHyperlegible', ] type SettingsProps = { readerSettings: ReaderSettings setShowAdvanced: (show: boolean) => void } export function ReaderSettingsControl(props: ReaderSettingsProps): JSX.Element { const [showAdvanced, setShowAdvanced] = useState(false) return ( <> {showAdvanced ? ( ) : ( )} ) } function AdvancedSettings(props: SettingsProps): JSX.Element { const { readerSettings } = props return ( { readerSettings.setJustifyText(checked) }} > { readerSettings.setHighContrastText(checked) }} > ) } const SwitchRoot = styled(Switch.Root, { all: 'unset', width: 42, height: 25, backgroundColor: '$thBorderColor', borderRadius: '9999px', position: 'relative', WebkitTapHighlightColor: 'rgba(0, 0, 0, 0)', '&:focus': { boxShadow: `0 0 0 2px $thBorderColor` }, '&[data-state="checked"]': { backgroundColor: '$thBorderColor' }, }) const SwitchThumb = styled(Switch.Thumb, { display: 'block', width: 21, height: 21, backgroundColor: '$thTextContrast2', borderRadius: '9999px', transition: 'transform 100ms', transform: 'translateX(2px)', willChange: 'transform', '&[data-state="checked"]': { transform: 'translateX(19px)' }, }) const Label = styled('label', { color: 'white', fontSize: 15, lineHeight: 1, }) function BasicSettings(props: SettingsProps): JSX.Element { const { readerSettings } = props return ( ) } type FontControlsProps = { readerSettings: ReaderSettings } function FontControls(props: FontControlsProps): JSX.Element { const { readerSettings } = props const FontSelect = styled('select', { pl: '5px', height: '30px', minWidth: '100px', display: 'flex', alignItems: 'center', fontSize: '12px', background: '$thBackground', border: '1px solid $thBorderColor', fontFamily: readerSettings.fontFamily, textTransform: 'capitalize', borderRadius: '4px', }) const handleFontSizeChange = useCallback( (value) => { readerSettings.actionHandler('setFontSize', value) }, [readerSettings] ) return ( Font ) => { const font = e.currentTarget.value if (FONT_FAMILIES.indexOf(font) < 0) { return } readerSettings.setFontFamily(font) }} > {FONT_FAMILIES.map((family) => ( ))} ) } type LayoutControlsProps = { readerSettings: ReaderSettings } function LayoutControls(props: LayoutControlsProps): JSX.Element { const { readerSettings } = props const handleMarginWidthChange = useCallback( (value) => { readerSettings.setMarginWidth(value) }, [readerSettings] ) return ( <> Margin Line Height { props.readerSettings.setLineHeight(value) }} /> ) } function ThemeSelector(): JSX.Element { const [currentTheme, setCurrentTheme] = useState(currentThemeName()) return ( Themes ) }