mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
62 lines
2.6 KiB
TypeScript
62 lines
2.6 KiB
TypeScript
import { Trans } from "@lingui/macro"
|
|
import { Divider, Select, SimpleGrid, Stack, Switch } from "@mantine/core"
|
|
import { Constants } from "app/constants"
|
|
import { changeLanguage, changeScrollMarks, changeScrollSpeed, changeSharingSetting, changeShowRead } from "app/slices/user"
|
|
import { useAppDispatch, useAppSelector } from "app/store"
|
|
import { SharingSettings } from "app/types"
|
|
import { locales } from "i18n"
|
|
|
|
export function DisplaySettings() {
|
|
const language = useAppSelector(state => state.user.settings?.language)
|
|
const scrollSpeed = useAppSelector(state => state.user.settings?.scrollSpeed)
|
|
const showRead = useAppSelector(state => state.user.settings?.showRead)
|
|
const scrollMarks = useAppSelector(state => state.user.settings?.scrollMarks)
|
|
const sharingSettings = useAppSelector(state => state.user.settings?.sharingSettings)
|
|
const dispatch = useAppDispatch()
|
|
|
|
return (
|
|
<Stack>
|
|
<Select
|
|
description={<Trans>Language</Trans>}
|
|
value={language}
|
|
data={locales.map(l => ({
|
|
value: l.key,
|
|
label: l.label,
|
|
}))}
|
|
onChange={s => s && dispatch(changeLanguage(s))}
|
|
/>
|
|
|
|
<Switch
|
|
label={<Trans>Scroll smoothly when navigating between entries</Trans>}
|
|
checked={scrollSpeed ? scrollSpeed > 0 : false}
|
|
onChange={e => dispatch(changeScrollSpeed(e.currentTarget.checked))}
|
|
/>
|
|
|
|
<Switch
|
|
label={<Trans>Show feeds and categories with no unread entries</Trans>}
|
|
checked={showRead}
|
|
onChange={e => dispatch(changeShowRead(e.currentTarget.checked))}
|
|
/>
|
|
|
|
<Switch
|
|
label={<Trans>In expanded view, scrolling through entries mark them as read</Trans>}
|
|
checked={scrollMarks}
|
|
onChange={e => dispatch(changeScrollMarks(e.currentTarget.checked))}
|
|
/>
|
|
|
|
<Divider label={<Trans>Sharing sites</Trans>} labelPosition="center" />
|
|
|
|
<SimpleGrid cols={2}>
|
|
{(Object.keys(Constants.sharing) as Array<keyof SharingSettings>).map(site => (
|
|
<Switch
|
|
key={site}
|
|
label={Constants.sharing[site].label}
|
|
checked={sharingSettings && sharingSettings[site]}
|
|
onChange={e => dispatch(changeSharingSetting({ site, value: e.currentTarget.checked }))}
|
|
/>
|
|
))}
|
|
</SimpleGrid>
|
|
</Stack>
|
|
)
|
|
}
|