-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from readium/theming
Theming
- Loading branch information
Showing
30 changed files
with
2,217 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import React, { CSSProperties, useRef } from "react"; | ||
|
||
import { RSPrefs, Themes } from "@/preferences"; | ||
import Locale from "../resources/locales/en.json"; | ||
import settingsStyles from "./assets/styles/readerSettings.module.css"; | ||
|
||
import CheckIcon from "./assets/icons/check.svg"; | ||
|
||
import { Label, Radio, RadioGroup } from "react-aria-components"; | ||
|
||
import { useAppDispatch, useAppSelector } from "@/lib/hooks"; | ||
import { setTheme } from "@/lib/themeReducer"; | ||
|
||
import classNames from "classnames"; | ||
|
||
export const ReadingDisplayTheme = () => { | ||
const theme = useAppSelector(state => state.theming.theme); | ||
const isFXL = useAppSelector(state => state.publication.isFXL); | ||
|
||
const themeItems = useRef(isFXL ? RSPrefs.theming.themes.fxlOrder : RSPrefs.theming.themes.reflowOrder); | ||
|
||
const dispatch = useAppDispatch(); | ||
|
||
const handleTheme = (value: string) => { | ||
dispatch(setTheme(value)); | ||
}; | ||
|
||
// Yeah so it’s easier to inline styles from preferences for these | ||
// than spamming the entire app with all custom properties right now | ||
const doStyles = (t: Themes) => { | ||
let cssProps: CSSProperties = { | ||
boxSizing: "border-box", | ||
color: "#999999" | ||
}; | ||
|
||
if (t === Themes.auto) { | ||
cssProps.background = `linear-gradient(148deg, ${ RSPrefs.theming.themes[Themes.light].background } 0%, ${ RSPrefs.theming.themes[Themes.dark].background } 48%)`; | ||
cssProps.color = "#ffffff"; | ||
cssProps.border = `1px solid ${ RSPrefs.theming.themes[Themes.light].subdue }`; | ||
} else { | ||
cssProps.background = RSPrefs.theming.themes[t].background; | ||
cssProps.color = RSPrefs.theming.themes[t].text; | ||
cssProps.border = `1px solid ${ RSPrefs.theming.themes[t].subdue }`; | ||
}; | ||
|
||
return cssProps; | ||
}; | ||
|
||
return ( | ||
<> | ||
<div> | ||
<RadioGroup | ||
orientation="horizontal" | ||
value={ theme } | ||
onChange={ handleTheme } | ||
> | ||
<Label className={ settingsStyles.readerSettingsLabel }>{ Locale.reader.settings.themes.title }</Label> | ||
<div className={ classNames(settingsStyles.readerSettingsRadioWrapper, settingsStyles.readerSettingsThemesWrapper) }> | ||
{ themeItems.current.map(( t ) => | ||
<Radio | ||
className={ classNames( | ||
settingsStyles.readerSettingsRadio, | ||
settingsStyles.readerSettingsThemeRadio | ||
) } | ||
value={ t } | ||
id={ t } | ||
key={ t } | ||
style={ doStyles(t) } | ||
> | ||
<span>{ Locale.reader.settings.themes[t as keyof typeof Themes] } { t === theme ? <CheckIcon aria-hidden="true" focusable="false" /> : <></>}</span> | ||
</Radio> | ||
) } | ||
</div> | ||
</RadioGroup> | ||
</div> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#current { | ||
color: var(--color-primary); | ||
color: var(--theme-text); | ||
font-variant-numeric: lining-nums tabular-nums; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.