update accessibility panel
This commit is contained in:
1 parent
85c0d8c4ab
commit
e0a6ddcafc
12 files changed
+174
-493
No files matched your search
@@ -1,4 +1,5 @@
|
||||
import { decreaseFontSize, hideImages, increaseFontSize, reset, setBlackOnWhite, setBlueOnBlue, setBrownOnYellow, setDefaultTheme, setGreenOnBrown, setLetterSpacingOne, setLetterSpacingTwo, setLetterSpacingFour, setLineHeightOneAndHalf, setLineHeightTwo, setLineHeightTwoAndHalf, setSansFont, setSerifFont, setWhiteOnBlack, showImages } from "@/store/theme"
|
||||
import { decreaseFontSize, hideImages, increaseFontSize, reset, setBlackOnWhite, setBlueOnBlue, setBrownOnYellow, setDefaultTheme, setGreenOnBrown, setLetterSpacingOne, setLetterSpacingTwo, setLetterSpacingFour, setLineHeightOneAndHalf, setLineHeightTwo, setLineHeightTwoAndHalf, setSerifFont, setSansSerifFont, setWhiteOnBlack, showImages } from "@/store/theme"
|
||||
import { HiCog, HiOutlineEyeOff } from "react-icons/hi"
|
||||
import s from "./panel.module.css"
|
||||
|
||||
function AccessibilityPanel() {
|
||||
@@ -27,8 +28,8 @@ function AccessibilityPanel() {
|
||||
|
||||
<div className={s.block}>
|
||||
<p>Шрифт:</p>
|
||||
<a onClick={setSansFont}>С засечками</a>
|
||||
<a onClick={setSerifFont}>Без засечек</a>
|
||||
<a onClick={setSerifFont}>С засечками</a>
|
||||
<a onClick={setSansSerifFont}>Без засечек</a>
|
||||
{/*<a id="btn-on-braille" href="javascript:void(0)" onClick="smSetting('fontBraille', 'brailleOn')" title="только для печати">Брайля</a>*/}
|
||||
{/*<a id="btn-off-braille" href="javascript:void(0)" onClick="smSetting('fontBraille', 'brailleOff')">Обычный</a>*/}
|
||||
</div>
|
||||
@@ -49,9 +50,14 @@ function AccessibilityPanel() {
|
||||
</div>
|
||||
|
||||
<div className={s.row}>
|
||||
<a onClick={reset}><i className="fa fa-cog fa-fw"></i>Сброс настроек</a>
|
||||
{/*<a id="mobile-version" href="?mobile=1"><i className="fa fa-mobile fa-fw"></i> Мобильная версия</a>*/}
|
||||
<a onClick={setDefaultTheme}><i className="fa fa-eye-slash fa-fw"></i>Обычная версия</a>
|
||||
<button onClick={reset}>
|
||||
<HiCog />
|
||||
Сброс настроек
|
||||
</button>
|
||||
<button onClick={setDefaultTheme}>
|
||||
<HiOutlineEyeOff />
|
||||
Обычная версия
|
||||
</button>
|
||||
{/*<a id="_playlist" href="javascript:void(0)" onClick="playSound('all', this);"><i className="fa fa-play fa-fw"></i>Прослушать всё</a>*/}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -6,25 +6,25 @@
|
||||
}*/
|
||||
|
||||
.viewsettings {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
|
||||
color: black;
|
||||
background: white;
|
||||
z-index: 10;
|
||||
display: block;
|
||||
/*width: 96%;*/
|
||||
font-size: 20px !important;
|
||||
line-height: 30px;
|
||||
font-family: sans-serif, arial;
|
||||
font-family: sans-serif;
|
||||
letter-spacing: normal !important;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
|
||||
/*position: fixed;
|
||||
top: 0;*/
|
||||
margin: 10px;
|
||||
padding: 10px;
|
||||
|
||||
text-align: center;
|
||||
border: 2px solid;
|
||||
/*border-right: 2px solid;
|
||||
border-bottom: 2px solid;
|
||||
border-bottom-right-radius: 25px;
|
||||
border-bottom-left-radius: 25px;*/
|
||||
}
|
||||
|
||||
.viewsettings .row {
|
||||
@@ -32,12 +32,12 @@
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
justify-content: center;
|
||||
|
||||
margin: 8px 0;
|
||||
}
|
||||
|
||||
.viewsettings p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.viewsettings a {
|
||||
border: 1px solid;
|
||||
text-decoration: none;
|
||||
@@ -67,367 +67,25 @@
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
#mainContent {
|
||||
padding-top: 60px;
|
||||
}
|
||||
.viewsettings button {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
|
||||
.feedback label {
|
||||
display: block;
|
||||
margin: 16px 0 0 0;
|
||||
}
|
||||
.feedback input {
|
||||
width: 50%;
|
||||
}
|
||||
.feedback textarea {
|
||||
width: 50%;
|
||||
height: 100px;
|
||||
}
|
||||
.feedback input[name="agree"] {
|
||||
display: block;
|
||||
width: 100px;
|
||||
}
|
||||
#captcha {
|
||||
display: none;
|
||||
}
|
||||
|
||||
body.line_1_5 {
|
||||
line-height: 1.5;
|
||||
}
|
||||
body.line_2_0 {
|
||||
line-height: 2;
|
||||
}
|
||||
body.line_2_5 {
|
||||
line-height: 2.5;
|
||||
}
|
||||
|
||||
.letter_spacing1 {
|
||||
letter-spacing: normal;
|
||||
}
|
||||
.letter_spacing2 {
|
||||
letter-spacing: 2px;
|
||||
}
|
||||
.letter_spacing4 {
|
||||
letter-spacing: 4px;
|
||||
}
|
||||
|
||||
#btn-black-text {
|
||||
background-color: white;
|
||||
color: black;
|
||||
}
|
||||
#btn-white-text {
|
||||
background-color: black;
|
||||
color: white;
|
||||
}
|
||||
#btn-blue-text {
|
||||
background-color: #9dd1ff;
|
||||
color: #063462;
|
||||
}
|
||||
#btn-sand-text {
|
||||
background-color: #f7f3d6;
|
||||
color: #4d4b43;
|
||||
}
|
||||
#btn-brown-text {
|
||||
background-color: #3b2716;
|
||||
color: #a9e44d;
|
||||
}
|
||||
|
||||
body.imageOff #btn-hide-images,
|
||||
body.imageOff img {
|
||||
display: none;
|
||||
}
|
||||
body.imageOn #btn-show-images {
|
||||
display: none;
|
||||
}
|
||||
|
||||
body.brailleOff #btn-off-braille {
|
||||
display: none;
|
||||
}
|
||||
body.brailleOn #btn-on-braille {
|
||||
display: none;
|
||||
}
|
||||
body.brailleOn {
|
||||
font-family: "Kanischev_Braille" !important;
|
||||
}
|
||||
|
||||
body.noSerif #btn-font-sans {
|
||||
display: none;
|
||||
}
|
||||
body.noSerif {
|
||||
font-family: sans-serif, Arial;
|
||||
}
|
||||
|
||||
body.sans #btn-font-serif {
|
||||
display: none;
|
||||
}
|
||||
body.sans {
|
||||
font-family: serif, "Times New Roman";
|
||||
}
|
||||
|
||||
body.BlackOnWhite {
|
||||
background-color: white;
|
||||
color: black;
|
||||
}
|
||||
body.BlackOnWhite a:link,
|
||||
body.BlackOnWhite a:visited,
|
||||
body.BlackOnWhite .viewsettings .block,
|
||||
body.BlackOnWhite .viewsettings,
|
||||
body.BlackOnWhite .additional_text,
|
||||
body.BlackOnWhite .img-wrp::after,
|
||||
body.BlackOnWhite .date {
|
||||
color: black;
|
||||
}
|
||||
body.BlackOnWhite a#active {
|
||||
color: white;
|
||||
background-color: black;
|
||||
}
|
||||
body.BlackOnWhite .image_placeholder {
|
||||
border: 1px solid black;
|
||||
}
|
||||
body.BlackOnWhite a:focus,
|
||||
body.BlackOnWhite input:focus,
|
||||
body.BlackOnWhite textarea:focus,
|
||||
body.BlackOnWhite #attach_cont:focus,
|
||||
body.BlackOnWhite button:focus {
|
||||
outline: #000 solid 5px;
|
||||
}
|
||||
body.BlackOnWhite button,
|
||||
body.BlackOnWhite input,
|
||||
body.BlackOnWhite textarea {
|
||||
background-color: #fff;
|
||||
color: #000;
|
||||
border: 1px solid #000;
|
||||
}
|
||||
|
||||
body.WhiteOnBlack {
|
||||
background-color: black;
|
||||
color: white;
|
||||
}
|
||||
body.WhiteOnBlack a:link,
|
||||
body.WhiteOnBlack a:visited,
|
||||
body.WhiteOnBlack .viewsettings .block,
|
||||
body.WhiteOnBlack .viewsettings,
|
||||
body.WhiteOnBlack .additional_text,
|
||||
body.WhiteOnBlack .img-wrp::after,
|
||||
body.WhiteOnBlack .date {
|
||||
color: white;
|
||||
}
|
||||
body.WhiteOnBlack a#active {
|
||||
color: black;
|
||||
background-color: white;
|
||||
}
|
||||
body.WhiteOnBlack .image_placeholder {
|
||||
border: 1px solid white;
|
||||
}
|
||||
body.WhiteOnBlack a:focus,
|
||||
body.WhiteOnBlack input:focus,
|
||||
body.WhiteOnBlack textarea:focus,
|
||||
body.WhiteOnBlack #attach_cont:focus,
|
||||
body.WhiteOnBlack button:focus {
|
||||
outline: #fff solid 5px;
|
||||
}
|
||||
body.WhiteOnBlack button,
|
||||
body.BlackOnWhite input,
|
||||
body.BlackOnWhite textarea {
|
||||
background-color: #000;
|
||||
color: #fff;
|
||||
border: 1px solid #fff;
|
||||
}
|
||||
|
||||
body.BlueOnBlue {
|
||||
background-color: #9dd1ff;
|
||||
color: #063462;
|
||||
}
|
||||
body.BlueOnBlue a:link,
|
||||
body.BlueOnBlue a:visited,
|
||||
body.BlueOnBlue .viewsettings .block,
|
||||
body.BlueOnBlue .viewsettings,
|
||||
body.BlueOnBlue .additional_text,
|
||||
body.BlueOnBlue .img-wrp::after,
|
||||
body.BlueOnBlue .date {
|
||||
color: #063462;
|
||||
}
|
||||
body.BlueOnBlue a#active {
|
||||
color: #9dd1ff;
|
||||
background-color: #063462;
|
||||
}
|
||||
body.BlueOnBlue .image_placeholder {
|
||||
border: 1px solid #063462;
|
||||
}
|
||||
body.BlueOnBlue a:focus,
|
||||
body.BlueOnBlue input:focus,
|
||||
body.BlueOnBlue textarea:focus,
|
||||
body.BlueOnBlue #attach_cont:focus,
|
||||
body.BlueOnBlue button:focus {
|
||||
outline: #063462 solid 5px;
|
||||
}
|
||||
body.BlueOnBlue button,
|
||||
body.BlueOnBlue input,
|
||||
body.BlueOnBlue textarea {
|
||||
background-color: #9dd1ff;
|
||||
color: #063462;
|
||||
border: 1px solid #063462;
|
||||
}
|
||||
|
||||
body.SandTheme {
|
||||
background-color: #f7f3d6;
|
||||
color: #4d4b43;
|
||||
}
|
||||
body.SandTheme a:link,
|
||||
body.SandTheme a:visited,
|
||||
body.SandTheme .viewsettings .block,
|
||||
body.SandTheme .viewsettings,
|
||||
body.SandTheme .additional_text,
|
||||
body.SandTheme .img-wrp::after,
|
||||
body.SandTheme .date {
|
||||
color: #4d4b43;
|
||||
}
|
||||
body.SandTheme a#active {
|
||||
color: #f7f3d6;
|
||||
background-color: #4d4b43;
|
||||
}
|
||||
body.SandTheme .image_placeholder {
|
||||
border: 1px solid #4d4b43;
|
||||
}
|
||||
body.SandTheme a:focus,
|
||||
body.SandTheme input:focus,
|
||||
body.SandTheme textarea:focus,
|
||||
body.SandTheme #attach_cont:focus,
|
||||
body.SandTheme button:focus {
|
||||
outline: #4d4b43 solid 5px;
|
||||
}
|
||||
body.SandTheme button,
|
||||
body.SandTheme input,
|
||||
body.SandTheme textarea {
|
||||
background-color: #f7f3d6;
|
||||
color: #4d4b43;
|
||||
border: 1px solid #4d4b43;
|
||||
}
|
||||
|
||||
body.BrownTheme {
|
||||
background-color: #3b2716;
|
||||
color: #a9e44d;
|
||||
}
|
||||
body.BrownTheme a:link,
|
||||
body.BrownTheme a:visited,
|
||||
body.BrownTheme .viewsettings .block,
|
||||
body.BrownTheme .viewsettings,
|
||||
body.BrownTheme .additional_text,
|
||||
body.BrownTheme .img-wrp::after,
|
||||
body.BrownTheme .date {
|
||||
color: #a9e44d;
|
||||
}
|
||||
body.BrownTheme a#active {
|
||||
color: #3b2716;
|
||||
background-color: #a9e44d;
|
||||
}
|
||||
body.BrownTheme .image_placeholder {
|
||||
border: 1px solid #a9e44d;
|
||||
}
|
||||
body.BrownTheme a:focus,
|
||||
body.BrownTheme input:focus,
|
||||
body.BrownTheme textarea:focus,
|
||||
body.BrownTheme #attach_cont:focus,
|
||||
body.BrownTheme button:focus {
|
||||
outline: #a9e44d solid 5px;
|
||||
}
|
||||
body.BrownTheme button,
|
||||
body.BrownTheme input,
|
||||
body.BrownTheme textarea {
|
||||
background-color: #3b2716;
|
||||
color: #a9e44d;
|
||||
border: 1px solid #a9e44d;
|
||||
}
|
||||
|
||||
ul#navmenu-h li a {
|
||||
padding: 0 6px 0 6px;
|
||||
}
|
||||
|
||||
.news_list_item strong {
|
||||
padding-bottom: 4px;
|
||||
padding-right: 8px;
|
||||
}
|
||||
|
||||
.date {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.s-on {
|
||||
background-position: 0 0;
|
||||
}
|
||||
.s-of {
|
||||
background-position: 0 30px;
|
||||
}
|
||||
.image_alt {
|
||||
width: 144px;
|
||||
height: 144px;
|
||||
border: 1px solid black;
|
||||
font-size: 18px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.gallery_album_thumbail {
|
||||
display: block;
|
||||
max-width: 150px;
|
||||
max-height: 150px;
|
||||
overflow: hidden;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
ul#navmenu-h li a {
|
||||
text-decoration: none;
|
||||
}
|
||||
ul#navmenu-h li a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.additional_text {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-size: 70%;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.image_placeholder {
|
||||
font-size: 70%;
|
||||
font-weight: normal;
|
||||
margin: 5px;
|
||||
text-align: center;
|
||||
word-wrap: break-word;
|
||||
overflow: hidden;
|
||||
min-width: 100px;
|
||||
min-height: 100px;
|
||||
}
|
||||
|
||||
.play-button {
|
||||
display: block;
|
||||
min-width: 30px;
|
||||
min-height: 30px;
|
||||
border: 1px solid;
|
||||
font-size: 20px !important;
|
||||
padding: 4px 10px;
|
||||
cursor: pointer;
|
||||
text-align: right;
|
||||
|
||||
color: black;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
#playlist {
|
||||
float: right;
|
||||
display: block;
|
||||
font-size: inherit;
|
||||
.viewsettings button:hover {
|
||||
background-color: #cfcfcf !important;
|
||||
color: #000 !important;
|
||||
}
|
||||
|
||||
._afisha_table_content {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.img-wrp {
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.img-wrp::after {
|
||||
content: attr(data-alt);
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
z-index: 2;
|
||||
font-size: 70%;
|
||||
font-style: italic;
|
||||
text-align: center;
|
||||
.viewsettings button:focus {
|
||||
outline: 1px solid !important;
|
||||
}
|
||||
@@ -22,6 +22,7 @@ import qr0 from "src/assets/qr00.png"
|
||||
import qr1 from "src/assets/qr01.png"
|
||||
import Image from "next/image"
|
||||
import AccessibilityPanel from "../AccessibilityPanel"
|
||||
import useAccessibility from "@/hooks/useAccessibility"
|
||||
|
||||
const Gosuslugi = dynamic(import("../Gosuslugi").then(module => module.Gosuslugi), {
|
||||
ssr: false,
|
||||
@@ -37,6 +38,7 @@ export type AppProps = {
|
||||
|
||||
export const App: React.FC<AppProps> = ({ showAuthor = false, menu, ...props }) => {
|
||||
const hideBreadcrumbs = useMobile()
|
||||
const accessibility = useAccessibility()
|
||||
const router = useRouter()
|
||||
const blockStyle = {
|
||||
justifyContent: "center",
|
||||
@@ -50,6 +52,10 @@ export const App: React.FC<AppProps> = ({ showAuthor = false, menu, ...props })
|
||||
<Wrapper
|
||||
header={(
|
||||
<header>
|
||||
{!accessibility ? null : (
|
||||
<AccessibilityPanel/>
|
||||
)}
|
||||
|
||||
<Navigation style={{
|
||||
padding: "var(--size-s)",
|
||||
}} />
|
||||
@@ -145,8 +151,6 @@ export const App: React.FC<AppProps> = ({ showAuthor = false, menu, ...props })
|
||||
</Footer>
|
||||
)}
|
||||
>
|
||||
<AccessibilityPanel/>
|
||||
|
||||
<Box style={blockStyle}>
|
||||
<Content style={props.contentStyle}>
|
||||
{props.children}
|
||||
|
||||
@@ -16,7 +16,7 @@ export const Wrapper: React.FC<WrapperProps> = props => {
|
||||
const t = useSnapshot(theme)
|
||||
|
||||
return (
|
||||
<div className={cx(s.container, `theme-${t.theme}`, !t.showImages ? "no-images" : null)} style={props.style}>
|
||||
<div className={cx(s.container, `theme-${t.theme}`, `font-${t.fontType}`, t.colorScheme ?? "black-on-white", !t.showImages ? "no-images" : null)} style={props.style}>
|
||||
{props.header}
|
||||
|
||||
<main className={s.main} style={props.mainStyle}>
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
.container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background-color: var(--color-back-main);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
font-family: var(--text-font);
|
||||
font-size: var(--font-size-default);
|
||||
color: var(--color-text);
|
||||
background-color: var(--color-back-main);
|
||||
|
||||
font-family: var(--text-font);
|
||||
font-size: var(--font-size-default);
|
||||
}
|
||||
|
||||
.main {
|
||||
min-height: 100vh;
|
||||
flex: 1;
|
||||
min-height: 100vh;
|
||||
flex: 1;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import { theme } from "@/store/theme"
|
||||
import { useSnapshot } from "valtio"
|
||||
|
||||
function useAccessibility(): boolean {
|
||||
const t = useSnapshot(theme)
|
||||
|
||||
return t.theme === "contrast"
|
||||
}
|
||||
|
||||
export default useAccessibility
|
||||
+19
-35
@@ -1,11 +1,12 @@
|
||||
import { proxy, subscribe, useSnapshot } from "valtio"
|
||||
import { proxy, subscribe } from "valtio"
|
||||
|
||||
export type ThemeName = "default" | "contrast"
|
||||
export type ColorSchemeVariant = "black-on-white" | "white-on-black" | "blue-on-blue" | "brown-on-yellow" | "green-on-brown"
|
||||
export type FontTypeVariant = "serif" | "sans-serif"
|
||||
|
||||
const MIN_FONT_SIZE = 8
|
||||
const MAX_FONT_SIZE = 48
|
||||
const CHANGE_FONT_SIZE_DELTA = 0.2
|
||||
const CHANGE_FONT_SIZE_DELTA = 1
|
||||
|
||||
function clamp(val: number, min: number, max: number): number {
|
||||
if (val < min) {
|
||||
@@ -19,7 +20,7 @@ function clamp(val: number, min: number, max: number): number {
|
||||
|
||||
export type ThemeOptions = {
|
||||
theme: ThemeName
|
||||
fontType: string
|
||||
fontType: FontTypeVariant
|
||||
fontSize: number
|
||||
lineHeight: number
|
||||
letterSpacing: number
|
||||
@@ -32,7 +33,7 @@ export const theme = proxy<ThemeOptions>({
|
||||
fontSize: 14,
|
||||
lineHeight: 1.5,
|
||||
letterSpacing: 1,
|
||||
fontType: "Times New Roman",
|
||||
fontType: "sans-serif",
|
||||
showImages: true,
|
||||
colorScheme: "black-on-white",
|
||||
})
|
||||
@@ -41,7 +42,7 @@ export function reset() {
|
||||
theme.fontSize = 14
|
||||
theme.lineHeight = 1.5
|
||||
theme.letterSpacing = 1
|
||||
theme.fontType = "Times New Roman"
|
||||
theme.fontType = "sans-serif"
|
||||
theme.showImages = true
|
||||
theme.colorScheme = "black-on-white"
|
||||
}
|
||||
@@ -63,12 +64,12 @@ export function decreaseFontSize() {
|
||||
theme.fontSize = clamp(theme.fontSize - CHANGE_FONT_SIZE_DELTA, MIN_FONT_SIZE, MAX_FONT_SIZE)
|
||||
}
|
||||
|
||||
export function setSerifFont() {
|
||||
export function setSansSerifFont() {
|
||||
theme.fontType = "sans-serif"
|
||||
}
|
||||
|
||||
export function setSansFont() {
|
||||
theme.fontType = "Times New Roman"
|
||||
export function setSerifFont() {
|
||||
theme.fontType = "serif"
|
||||
}
|
||||
|
||||
export function showImages() {
|
||||
@@ -123,29 +124,10 @@ export function setLetterSpacingFour() {
|
||||
theme.letterSpacing = 4
|
||||
}
|
||||
|
||||
function getColor(scheme: ColorSchemeVariant): [string, string] {
|
||||
switch (theme.colorScheme) {
|
||||
case "black-on-white":
|
||||
return ["black", "white"]
|
||||
case "white-on-black":
|
||||
return ["white", "black"]
|
||||
case "blue-on-blue":
|
||||
return ["oklch(32% 24% 253deg)", "oklch(84% 21% 245deg)"]
|
||||
case "brown-on-yellow":
|
||||
return ["oklch(41% 3% 92deg)", "oklch(96% 9% 101deg)"]
|
||||
case "green-on-brown":
|
||||
return ["oklch(85% 47% 128deg)", "oklch(29% 10% 61deg)"]
|
||||
default:
|
||||
return ["black", "white"]
|
||||
}
|
||||
}
|
||||
|
||||
const unsubscribe = subscribe(theme, () => {
|
||||
document.documentElement.style.setProperty("--font-size-default", `${theme.fontSize}pt`)
|
||||
|
||||
document.documentElement.style.setProperty("--title-font", theme.fontType)
|
||||
document.documentElement.style.setProperty("--text-font", theme.fontType)
|
||||
|
||||
document.documentElement.style.setProperty("--font-size-second", `${theme.fontSize}pt`)
|
||||
document.documentElement.style.setProperty("--font-size-accent", `${theme.fontSize}pt`)
|
||||
document.documentElement.style.setProperty("--article-line-height", `${theme.lineHeight}em`)
|
||||
if (theme.letterSpacing === 1) {
|
||||
document.documentElement.style.setProperty("--letter-spacing", "normal")
|
||||
@@ -153,10 +135,12 @@ const unsubscribe = subscribe(theme, () => {
|
||||
document.documentElement.style.setProperty("--letter-spacing", `${theme.letterSpacing}px`)
|
||||
}
|
||||
|
||||
const [t, b] = getColor(theme.colorScheme)
|
||||
document.documentElement.style.setProperty("--color-text", t)
|
||||
document.documentElement.style.setProperty("--color-text-second", t)
|
||||
document.documentElement.style.setProperty("--color-text-opposite", b)
|
||||
document.documentElement.style.setProperty("--color-back-main", b)
|
||||
document.documentElement.style.setProperty("--color-back", b)
|
||||
// TODO remove this from here and move this logic directly to body tag after moving from pages to app
|
||||
document.body.classList.forEach(name => {
|
||||
document.body.classList.remove(name)
|
||||
})
|
||||
if (theme.theme === "contrast") {
|
||||
document.body.classList.add("theme-contrast")
|
||||
document.body.classList.add(theme.colorScheme);
|
||||
}
|
||||
})
|
||||
+91
-41
@@ -170,26 +170,9 @@ h3 {
|
||||
|
||||
/* CONTRAST THEME */
|
||||
.theme-contrast {
|
||||
/* FONTS */
|
||||
/*--title-font: "Roboto", Helvetica, sans-serif;*/
|
||||
/*--text-font: "Roboto", Helvetica, sans-serif;*/
|
||||
|
||||
/* TEXT COLOR */
|
||||
/*--color-text: black;
|
||||
--color-text-second: black;
|
||||
--color-text-opposite: white;
|
||||
--color-back-main: white;
|
||||
--color-back: white;
|
||||
--color-back-active: hsl(240, 10%, 20%);
|
||||
--color-back-opposite: black;
|
||||
--color-link: hsl(240, 10%, 40%);
|
||||
--color-link-opposite: hsl(240, 10%, 60%);*/
|
||||
|
||||
--color-hover: white;
|
||||
--color-hover-back: black;
|
||||
/*margin-top: 235px;*/
|
||||
|
||||
/* EFFECTS */
|
||||
/* --radius: 0px; */
|
||||
--shadow: none;
|
||||
--shadow-active: none;
|
||||
|
||||
@@ -208,10 +191,98 @@ h3 {
|
||||
--border: 5px solid var(--color-back-opposite);
|
||||
}
|
||||
|
||||
.theme-contrast.font-sans-serif {
|
||||
--title-font: "Roboto", Helvetica, sans-serif;
|
||||
--text-font: "Roboto", Helvetica, sans-serif;
|
||||
}
|
||||
|
||||
.theme-contrast.font-serif {
|
||||
--title-font: "Times New Roman", serif;
|
||||
--text-font: "Times New Roman", serif;
|
||||
}
|
||||
|
||||
.theme-contrast.black-on-white {
|
||||
--color-text: black;
|
||||
--color-text-second: black;
|
||||
--color-text-opposite: white;
|
||||
--color-back-main: white;
|
||||
--color-back: white;
|
||||
--color-back-opposite: black;
|
||||
|
||||
--color-hover: white;
|
||||
--color-hover-back: black;
|
||||
|
||||
--color-back-active: black;
|
||||
--color-link: black;
|
||||
--color-link-opposite: white;
|
||||
}
|
||||
|
||||
.theme-contrast.white-on-black {
|
||||
--color-text: white;
|
||||
--color-text-second: white;
|
||||
--color-text-opposite: black;
|
||||
--color-back-main: black;
|
||||
--color-back: black;
|
||||
--color-back-opposite: white;
|
||||
|
||||
--color-hover: black;
|
||||
--color-hover-back: white;
|
||||
|
||||
/*--color-back-active: hsl(240, 10%, 20%);*/
|
||||
/*--color-link: hsl(240, 10%, 40%);*/
|
||||
/*--color-link-opposite: hsl(240, 10%, 60%);*/
|
||||
}
|
||||
|
||||
.theme-contrast.blue-on-blue {
|
||||
--color-text: oklch(32% 24% 253deg);
|
||||
--color-text-second: oklch(32% 24% 253deg);
|
||||
--color-text-opposite: oklch(84% 21% 245deg);
|
||||
--color-back-main: oklch(84% 21% 245deg);
|
||||
--color-back: oklch(84% 21% 245deg);
|
||||
--color-back-opposite: oklch(32% 24% 253deg);
|
||||
|
||||
--color-hover: oklch(84% 21% 245deg);
|
||||
--color-hover-back: oklch(32% 24% 253deg);
|
||||
|
||||
/*--color-back-active: hsl(240, 10%, 20%);*/
|
||||
/*--color-link: hsl(240, 10%, 40%);*/
|
||||
/*--color-link-opposite: hsl(240, 10%, 60%);*/
|
||||
}
|
||||
|
||||
.theme-contrast.brown-on-yellow {
|
||||
--color-text: oklch(41% 3% 92deg);
|
||||
--color-text-second: oklch(41% 3% 92deg);
|
||||
--color-text-opposite: oklch(96% 9% 101deg);
|
||||
--color-back-main: oklch(96% 9% 101deg);
|
||||
--color-back: oklch(96% 9% 101deg);
|
||||
--color-back-opposite: oklch(41% 3% 92deg);
|
||||
|
||||
--color-hover: oklch(96% 9% 101deg);
|
||||
--color-hover-back: oklch(41% 3% 92deg);
|
||||
|
||||
/*--color-back-active: hsl(240, 10%, 20%);*/
|
||||
/*--color-link: hsl(240, 10%, 40%);*/
|
||||
/*--color-link-opposite: hsl(240, 10%, 60%);*/
|
||||
}
|
||||
|
||||
.theme-contrast.green-on-brown {
|
||||
--color-text: oklch(85% 47% 128deg);
|
||||
--color-text-second: oklch(85% 47% 128deg);
|
||||
--color-text-opposite: oklch(29% 10% 61deg);
|
||||
--color-back-main: oklch(29% 10% 61deg);
|
||||
--color-back: oklch(29% 10% 61deg);
|
||||
--color-back-opposite: oklch(85% 47% 128deg);
|
||||
|
||||
--color-hover: oklch(29% 10% 61deg);
|
||||
--color-hover-back: oklch(85% 47% 128deg);
|
||||
|
||||
/*--color-back-active: hsl(240, 10%, 20%);*/
|
||||
/*--color-link: hsl(240, 10%, 40%);*/
|
||||
/*--color-link-opposite: hsl(240, 10%, 60%);*/
|
||||
}
|
||||
|
||||
.theme-contrast.no-images img {
|
||||
display: none;
|
||||
/*opacity: 0.5;*/
|
||||
/*position: relative;*/
|
||||
}
|
||||
|
||||
/*.theme-contrast.no-images img:after {
|
||||
@@ -220,24 +291,3 @@ h3 {
|
||||
height: 100%;
|
||||
border: 1px solid black;
|
||||
}*/
|
||||
|
||||
/* CONTRAST + DARK THEME */
|
||||
@media (prefers-color-scheme: dark) {
|
||||
.theme-contrast {
|
||||
/* TEXT COLOR */
|
||||
--color-text: white;
|
||||
--color-text-second: white;
|
||||
--color-text-opposite: black;
|
||||
|
||||
--color-back-main: black;
|
||||
--color-back: black;
|
||||
--color-back-opposite: white;
|
||||
|
||||
/* --color-back-active: hsl(240, 10%, 20%); */
|
||||
/* --color-link: hsl(240, 10%, 40%); */
|
||||
/* --color-link-opposite: hsl(240, 10%, 60%); */
|
||||
|
||||
--color-hover: white;
|
||||
--color-hover-back: white;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
import { createContext } from "react"
|
||||
import { DEFAULT } from "./const"
|
||||
import { SetTheme, ThemeOptions } from "./types"
|
||||
|
||||
export const ThemeContext = createContext<[ThemeOptions, SetTheme]>([DEFAULT, () => {}])
|
||||
@@ -1,5 +0,0 @@
|
||||
import { ThemeOptions } from "./types"
|
||||
|
||||
export const DEFAULT: ThemeOptions = {
|
||||
theme: "default",
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
export type ThemeOptions = {
|
||||
theme: "default" | "contrast"
|
||||
fontSize?: number
|
||||
}
|
||||
export type SetTheme = (theme: ThemeOptions["theme"]) => void
|
||||
@@ -1,18 +0,0 @@
|
||||
import { useContext } from "react"
|
||||
import { ThemeContext } from "./ThemeContext"
|
||||
import { SetTheme, ThemeOptions } from "./types"
|
||||
|
||||
export type UseThemeResult = {
|
||||
theme: ThemeOptions["theme"]
|
||||
setTheme: SetTheme
|
||||
// toggleTheme:
|
||||
}
|
||||
|
||||
export function useTheme(): UseThemeResult {
|
||||
const [theme, setTheme] = useContext(ThemeContext)
|
||||
|
||||
return {
|
||||
setTheme,
|
||||
theme: theme.theme ?? "default",
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user