mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-09-13 14:22:25 +03:00
Add toggle to use browser's preferred theme (#224)
* Add Auto theme that uses browser's preferred color scheme This will use dark mode automatically if the browser requests it. * fixup! Add Auto theme that uses browser's preferred color scheme * Use a toggle to use system theme
This commit is contained in:
parent
63a0adaa6e
commit
11f395f65f
5 changed files with 74 additions and 14 deletions
|
@ -5,7 +5,7 @@ import './Settings.scss';
|
|||
import initMatrix from '../../../client/initMatrix';
|
||||
import cons from '../../../client/state/cons';
|
||||
import settings from '../../../client/state/settings';
|
||||
import { toggleMarkdown, toggleMembershipEvents, toggleNickAvatarEvents } from '../../../client/action/settings';
|
||||
import { toggleSystemTheme, toggleMarkdown, toggleMembershipEvents, toggleNickAvatarEvents } from '../../../client/action/settings';
|
||||
import logout from '../../../client/action/logout';
|
||||
|
||||
import Text from '../../atoms/text/Text';
|
||||
|
@ -49,20 +49,34 @@ function AppearanceSection() {
|
|||
return (
|
||||
<div className="settings-content">
|
||||
<SettingTile
|
||||
title="Theme"
|
||||
content={(
|
||||
<SegmentedControls
|
||||
selected={settings.getThemeIndex()}
|
||||
segments={[
|
||||
{ text: 'Light' },
|
||||
{ text: 'Silver' },
|
||||
{ text: 'Dark' },
|
||||
{ text: 'Butter' },
|
||||
]}
|
||||
onSelect={(index) => settings.setTheme(index)}
|
||||
title="Follow system theme"
|
||||
options={(
|
||||
<Toggle
|
||||
isActive={settings.useSystemTheme}
|
||||
onToggle={() => { toggleSystemTheme(); updateState({}); }}
|
||||
/>
|
||||
)}
|
||||
content={<Text variant="b3">Use light or dark mode based on the system's settings.</Text>}
|
||||
/>
|
||||
{(() => {
|
||||
if (!settings.useSystemTheme) {
|
||||
return <SettingTile
|
||||
title="Theme"
|
||||
content={(
|
||||
<SegmentedControls
|
||||
selected={settings.getThemeIndex()}
|
||||
segments={[
|
||||
{ text: 'Light' },
|
||||
{ text: 'Silver' },
|
||||
{ text: 'Dark' },
|
||||
{ text: 'Butter' },
|
||||
]}
|
||||
onSelect={(index) => settings.setTheme(index)}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
}
|
||||
})()}
|
||||
<SettingTile
|
||||
title="Markdown formatting"
|
||||
options={(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue