From 3fbbe86c5007ac82069feb342a462202d6a1a2b5 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Thu, 11 Feb 2021 11:25:06 +0100 Subject: semi-working dark mode toggle + color pickers --- components/ui.tsx | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++- pages/_app.tsx | 1 + pages/settings.tsx | 17 +++++++++++++---- public/index.html | 1 - styles/dark.css | 2 +- styles/global.css | 2 +- 6 files changed, 68 insertions(+), 8 deletions(-) diff --git a/components/ui.tsx b/components/ui.tsx index bb2a2ff..e6fdceb 100644 --- a/components/ui.tsx +++ b/components/ui.tsx @@ -3,6 +3,7 @@ import { Component, CSSProperties, ReactNode } from "react"; import SearchIcon from '@material-ui/icons/Search'; import CheckBoxOutlineBlankIcon from '@material-ui/icons/CheckBoxOutlineBlank'; import CheckBoxIcon from '@material-ui/icons/CheckBox'; +import EditOutlinedIcon from '@material-ui/icons/EditOutlined'; export function Vierkant(props: { href?: string; @@ -154,9 +155,13 @@ export class CheckBox extends Component<{ state?: boolean; style?: CSSProperties; id?: string; + onclick?: (state: boolean) => void; }> { state = { on: this.props.state || false } - public toggle = () => this.setState({ on: !this.state.on }) + public toggle = () => { + this.setState({ on: !this.state.on }); + this.props.onclick && this.props.onclick(!this.state.on); + } render() { return
{ + state: { + color: string; + dark: boolean; + } = { + color: "#012345", + dark: true + } + render() { + return + } +} diff --git a/pages/_app.tsx b/pages/_app.tsx index 7be2763..23f9f79 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -1,4 +1,5 @@ import '../styles/global.css'; +import '../styles/dark.css'; export default function VierOpEenRijWebsite({ Component, pageProps }) { return diff --git a/pages/settings.tsx b/pages/settings.tsx index 96c6a2f..5034bd7 100644 --- a/pages/settings.tsx +++ b/pages/settings.tsx @@ -3,7 +3,7 @@ import * as cookies from 'react-cookies'; import { NavBar } from '../components/navbar'; import { CenteredPage, PageTitle } from '../components/page'; -import { Vierkant, IconLabelButton, CheckBox } from '../components/ui'; +import { Vierkant, IconLabelButton, CheckBox, ColorPicker } from '../components/ui'; import { AccountAvatar } from '../components/account'; import { CurrentGameSettings } from '../components/gameSettings'; @@ -53,14 +53,23 @@ export default function SettingsPage() {

Kleuren

-

Schijfjes

+ + +
+

Schijfjes

+
-

Achtergrond

+ +
+

Achtergrond

+
- + document.getElementsByTagName("html")[0].classList[state ? "add" : "remove"]("dark") + }/>

Donkere modus

diff --git a/public/index.html b/public/index.html index d9fdb5d..05b60c9 100644 --- a/public/index.html +++ b/public/index.html @@ -8,7 +8,6 @@ - 4 op een rij diff --git a/styles/dark.css b/styles/dark.css index a0f652e..681116f 100644 --- a/styles/dark.css +++ b/styles/dark.css @@ -1,4 +1,4 @@ -:root { +html.dark { --text: #FCFFFD; --text-alt: var(--text); diff --git a/styles/global.css b/styles/global.css index 2a82fa2..03f329e 100644 --- a/styles/global.css +++ b/styles/global.css @@ -1,4 +1,4 @@ -:root { +html { --text: #FCFFFD; --page-background: var(--text); -- cgit v1.2.3