From b33439e75d4b22a0c68b5cb56851b518a5ea7db7 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Sat, 17 Apr 2021 10:30:24 +0200 Subject: started moving to css files --- styles/global.css | 92 +++++++++++++++++++++++++++++++++++++++---------- styles/index.module.css | 7 ++++ styles/navbar.css | 11 ++++++ styles/ui.css | 9 +++++ styles/utility.css | 27 +++++++++++++++ 5 files changed, 128 insertions(+), 18 deletions(-) create mode 100644 styles/index.module.css create mode 100644 styles/navbar.css create mode 100644 styles/ui.css create mode 100644 styles/utility.css (limited to 'styles') diff --git a/styles/global.css b/styles/global.css index 1e87524..350a2a7 100644 --- a/styles/global.css +++ b/styles/global.css @@ -1,17 +1,73 @@ -html { - --text: #FCFFFD; - --page-background: var(--text); - - --background: #5D737E; - --text-alt: var(--background); - --background-alt: #81949E; - - --disk-a: #E16D82; - --disk-a-text: #FDC0C4; - --disk-b: #71D9CC; - --disk-b-text: #C0FDEB; +:root { + --background: #E3E6EE; + --foreground: var(--gray-100); + + --accent: #7E3AA6; + + --error: #A63A4D; + --disk-b-alt: #582D35; + + --confirm: #3AA699; + --disk-a-alt: #244743; + + /* shade */ + --gray-100: #141619; + --gray-200: #1F242D; + --gray-300: #293140; + --gray-700: #757D92; + --gray-800: #A9AFC0; + --gray-900: #CED2DC; + + /* box-shadow */ + --drop-level-2: 0px 8px 32px 0px rgba(0, 0, 0, 0.3); + --drop-level-1: 0px 8px 12px -4px rgba(0, 0, 0, 0.15); + + /* border-radius */ + --tight-corner: 6px; + --loose-corner: 8px; + + /* margin/padding */ + --spacing-small: 6px; + --spacing-medium: 12px; + --spacing-large: 24px; } +@media (prefers-color-scheme: dark) { + :root { + --background: var(--gray-900); + --foreground: #FFFFF3; + + --accent: #AD34F3; + + --error: #FF4365; + --disk-b-alt: #F49BA1; + + --confirm: #00D9C0; + --disk-a-alt: #86F3F3; + + --gray-100: #CED2DC; + --gray-200: #A9AFC0; + --gray-300: #757D92; + --gray-700: #293140; + --gray-800: #1F242D; + --gray-900: #141619; + } +} + +/* html { */ +/* --text: #FCFFFD; */ +/* --page-background: var(--text); */ + +/* --background: #5D737E; */ +/* --text-alt: var(--background); */ +/* --background-alt: #81949E; */ + +/* --disk-a: #E16D82; */ +/* --disk-a-text: #FDC0C4; */ +/* --disk-b: #71D9CC; */ +/* --disk-b-text: #C0FDEB; */ +/* } */ + /* default margin */ html, body { margin: 0; @@ -27,17 +83,17 @@ h3 { padding-bottom: 6px; } -/* global font zize */ -p, b, i, span, td, th { font-size: 15px; } - /* navbar fix */ body { padding-left: 48px; } /* font */ -html { font-family: "Inter"; } +html { font-family: "Inter", sans-serif; } -/* background color */ -html, body { background-color: var(--page-background); } +/* color */ +:root, html, body { + background-color: var(--background); + color: var(--foreground); +} /* link fix */ a { diff --git a/styles/index.module.css b/styles/index.module.css new file mode 100644 index 0000000..9b518ea --- /dev/null +++ b/styles/index.module.css @@ -0,0 +1,7 @@ +.loginOrRegisterBox { + --squareSize: 90px; + vertical-align: top; + height: calc(var(--squareSize) + 2 * var(--spacing-large)); + width: 100%; + max-width: calc(100% - var(--squareSize) - var(--spacing-medium) * 2 - var(--spacing-large) * 2); +} diff --git a/styles/navbar.css b/styles/navbar.css new file mode 100644 index 0000000..5866b8f --- /dev/null +++ b/styles/navbar.css @@ -0,0 +1,11 @@ +.navbar .item { + margin: var(--spacing-medium); + margin-bottom: calc(var(--spacing-medium) + 4px); + display: block; +} + +.navbar .bottomArea { + position: absolute; + bottom: -4px; + left: 0; +} diff --git a/styles/ui.css b/styles/ui.css new file mode 100644 index 0000000..d665044 --- /dev/null +++ b/styles/ui.css @@ -0,0 +1,9 @@ +.vierkant { + margin: var(--spacing-small); + display: inline-block; + position: relative; + box-sizing: border-box; +} + +.fullwidth { width: calc(100% - var(--spacing-medium)); } + diff --git a/styles/utility.css b/styles/utility.css new file mode 100644 index 0000000..753b88d --- /dev/null +++ b/styles/utility.css @@ -0,0 +1,27 @@ +.drop-1 { box-shadow: var(--drop-level-1); } +.drop-2 { box-shadow: var(--drop-level-2); } + +.pad-s { padding: var(--spacing-small); } +.pad-m { padding: var(--spacing-medium); } +.pad-l { padding: var(--spacing-large); } + +.round-l { border-radius: var(--loose-corner); } +.round-t { border-radius: var(--tight-corner); } + +.bg-100 { background-color: var(--gray-100); } +.bg-200 { background-color: var(--gray-200); } +.bg-300 { background-color: var(--gray-300); } +.bg-700 { background-color: var(--gray-700); } +.bg-800 { background-color: var(--gray-800); } +.bg-900 { background-color: var(--gray-900); } + +.subtile { + color: var(--gray-300); + font-style: italic; +} + +/* no-select */ +.nosel { + user-select: none; + font-weight: 600; +} -- cgit v1.2.3 From dd77d6bb276f6a70b36f69d11cde7f5c8995f5e1 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Sat, 17 Apr 2021 17:24:59 +0200 Subject: home page without inline react styles :tada: --- components/recentGames.tsx | 20 +++---- components/ui.tsx | 21 +------ pages/_app.tsx | 2 + pages/index.tsx | 144 +++++++++------------------------------------ styles/global.css | 13 ++-- styles/index.css | 72 +++++++++++++++++++++++ styles/index.module.css | 7 --- styles/ui.css | 12 ++++ styles/utility.css | 27 ++++++++- 9 files changed, 161 insertions(+), 157 deletions(-) create mode 100644 styles/index.css delete mode 100644 styles/index.module.css (limited to 'styles') diff --git a/components/recentGames.tsx b/components/recentGames.tsx index 988126f..65c819a 100644 --- a/components/recentGames.tsx +++ b/components/recentGames.tsx @@ -28,18 +28,14 @@ function GameOutcome(props: { game: gameInfo; }) { }, }[props.game.status](); })(); - var outcome = props.game.outcome; - return - {gameStatus} + return + + {gameStatus} + ; } diff --git a/components/ui.tsx b/components/ui.tsx index 99479a8..db858a4 100644 --- a/components/ui.tsx +++ b/components/ui.tsx @@ -30,6 +30,7 @@ export function Button(props: { children?: ReactNode; style?: CSSProperties; href?: string; + className?: string; onclick?: (() => void); id?: string; }) { @@ -37,26 +38,10 @@ export function Button(props: { onClick={props.onclick} href={props.href} id={props.id} - style={{ - padding: props.text ? 8 : 16, - textAlign: props.text ? 'center' : 'left', - borderRadius: 8, - backgroundColor: 'var(--disk-a)', - cursor: 'pointer', - position: 'relative', - textDecoration: 'none', - display: 'block', - userSelect: 'none', - ...props.style, - }} + className={"button pad-s round-t " + props.className} > {props.text - ? + ? {props.text} : undefined} diff --git a/pages/_app.tsx b/pages/_app.tsx index bf9a280..46aa8d0 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -11,6 +11,8 @@ import '../styles/utility.css'; import '../styles/ui.css'; import '../styles/navbar.css'; +import '../styles/index.css'; + export default function VierOpEenRijWebsite({ Component, pageProps }) { return
diff --git a/pages/index.tsx b/pages/index.tsx index c1b912d..c3fe955 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -1,5 +1,5 @@ import axios from 'axios'; -import { CSSProperties, useContext, useEffect, useState } from 'react'; +import { useContext, useEffect, useState } from 'react'; import { userGames, userGameTotals, userInfo } from '../api/api'; import { Footer } from '../components/footer'; import { SocketContext } from '../components/socketContext'; @@ -16,72 +16,14 @@ import VideogameAssetIcon from '@material-ui/icons/VideogameAsset'; import { mdiRobotExcited } from '@mdi/js'; import Icon from '@mdi/react'; -import styles from '../styles/index.module.css'; - -var GameModeIconStyle: CSSProperties = { - fontSize: 64, - width: 64, - height: 64, - display: 'inline-block', - position: 'absolute', - top: 24, - left: '50%', - transform: 'translateX(-50%)', -}; - -var GameModeTextStyle: CSSProperties = { - whiteSpace: 'nowrap', - display: 'inline-block', - position: 'absolute', - bottom: 24, - left: '50%', - transform: 'translateX(-50%)', - userSelect: 'none', - fontWeight: 500, -}; - -var SquareSize: CSSProperties = { - width: 90, - height: 90, -}; - -var InnerLoginOrRegisterBoxStyle: CSSProperties = { - position: 'relative', - width: '100%', - height: '100%', -}; - function LoginOrRegisterBox() { - return
- - Log in of maak een account aan om je scores op te slaan en toegang te krijgen tot meer functies + return
+ + Log in of maak een account aan om toegang tot meer functies te krijgen -
-
; } @@ -90,44 +32,19 @@ function AccountBox(props: { info: userInfo; sumGameInfo: userGameTotals; }) { - return
-
+ return
+
-
-

- {props.info?.username} -

-

Score: {props.info?.rating}

-

- {props.sumGameInfo?.win} W - / - {props.sumGameInfo?.lose} V - / - {props.sumGameInfo?.draw} G +

+

{props.info?.username}

+

Score: {props.info?.rating}

+

+ {props.sumGameInfo?.win} W + / + {props.sumGameInfo?.lose} V + / + {props.sumGameInfo?.draw} G

; @@ -175,25 +92,22 @@ export default function HomePage() { 4 op een rij -
- - - Nieuw spel -
+
+ + + Nieuw spel {false - && - - Puzzels -
+ && + + Puzzels } {false - && - - Tegen computer -
+ && + + Tegen computer } - + {loggedIn ? : } diff --git a/styles/global.css b/styles/global.css index 350a2a7..3c28cfc 100644 --- a/styles/global.css +++ b/styles/global.css @@ -1,5 +1,5 @@ :root { - --background: #E3E6EE; + --background: var(--gray-900); --foreground: var(--gray-100); --accent: #7E3AA6; @@ -14,9 +14,10 @@ --gray-100: #141619; --gray-200: #1F242D; --gray-300: #293140; - --gray-700: #757D92; - --gray-800: #A9AFC0; - --gray-900: #CED2DC; + --gray-600: #757D92; + --gray-700: #A9AFC0; + --gray-800: #CED2DC; + --gray-900: #E3E6EE; /* box-shadow */ --drop-level-2: 0px 8px 32px 0px rgba(0, 0, 0, 0.3); @@ -150,3 +151,7 @@ input.light::placeholder { color: var(--text-alt); } border-width: 2px; } +.outcome.win { color: var(--disk-a-alt); } +.outcome.lose { color: var(--disk-b-alt); } +.outcome.draw { color: var(--gray-600); } + diff --git a/styles/index.css b/styles/index.css new file mode 100644 index 0000000..8ba12a6 --- /dev/null +++ b/styles/index.css @@ -0,0 +1,72 @@ +.topbar * { + --squareSize: 90px; +} + +.loginOrRegisterBox { + vertical-align: top; + height: calc(var(--squareSize) + 2 * var(--spacing-large)); + width: 100%; + max-width: calc(100% - var(--squareSize) - var(--spacing-medium) * 2 - var(--spacing-large) * 2); +} + +.loginOrRegisterBox .inner { + position: relative; + width: 100%; + height: 100%; +} + +.loginOrRegisterBox .inner .registerMessage { + user-select: none; + display: inline-block; + margin: 0 auto; + min-width: 240px; + max-width: 350px; + text-align: center; +} + +.loginOrRegisterBox .inner .button.register { + background-color: var(--gray-700); + color: var(--foreground); +} + +.gamemode .icon { + font-size: 64px; + font-size: 64px; + height: 64px; + display: inline-block; + position: absolute; + top: var(--spacing-large); + left: 50%; + transform: translateX(-50%); +} + +.gamemode .text { + white-space: nowrap; + display: inline-block; + position: absolute; + bottom: var(--spacing-large); + left: 50%; + transform: translateX(-50%); + user-select: none; + font-weight: 500; +} + +.topbar .gamemode { + --size: calc(var(--squareSize) + 2 * var(--spacing-large)); + width: var(--size); + height: var(--size); +} + +.topbar .profile .info { + left: calc(90px + 12px); + width: calc(100% - 90px - 12px); + height: 100%; +} + +.topbar .profile .info .username { max-width: 178px; } +.topbar .profile .info .score { margin-top: var(--spacing-small); } + +.topbar .profile .info .games .divider { + margin: 0 3px; +} + diff --git a/styles/index.module.css b/styles/index.module.css deleted file mode 100644 index 9b518ea..0000000 --- a/styles/index.module.css +++ /dev/null @@ -1,7 +0,0 @@ -.loginOrRegisterBox { - --squareSize: 90px; - vertical-align: top; - height: calc(var(--squareSize) + 2 * var(--spacing-large)); - width: 100%; - max-width: calc(100% - var(--squareSize) - var(--spacing-medium) * 2 - var(--spacing-large) * 2); -} diff --git a/styles/ui.css b/styles/ui.css index d665044..f1d65e2 100644 --- a/styles/ui.css +++ b/styles/ui.css @@ -7,3 +7,15 @@ .fullwidth { width: calc(100% - var(--spacing-medium)); } +.button { + background-color: var(--accent); + color: var(--gray-900); + text-align: center; + cursor: pointer; + position: relative; + text-decoration: none; + display: block; + user-select: none; + font-weight: 600; +} + diff --git a/styles/utility.css b/styles/utility.css index 753b88d..4331d3a 100644 --- a/styles/utility.css +++ b/styles/utility.css @@ -15,13 +15,38 @@ .bg-800 { background-color: var(--gray-800); } .bg-900 { background-color: var(--gray-900); } +.posabs { position: absolute; } +.posrel { position: relative; } + +.t0 { top: 0; } +.b0 { bottom: 0; } +.r0 { right: 0; } +.l0 { left: 0; } + +.h0 { left: 0; right: 0; } +.v0 { top: 0; bottom: 0; } + +.a0 { top: 0; bottom: 0; left: 0; right: 0; } + .subtile { color: var(--gray-300); font-style: italic; } -/* no-select */ .nosel { user-select: none; font-weight: 600; } + +.sidebyside { + display: grid; + grid-gap: var(--spacing-medium); + grid-auto-flow: column; +} + +.truncate { + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} + -- cgit v1.2.3 From 18652c6ff5e10208298bea67ffce6b4ed327c97d Mon Sep 17 00:00:00 2001 From: lonkaars Date: Sun, 18 Apr 2021 11:30:10 +0200 Subject: search page without inline css --- components/ui.tsx | 19 +++--------------- pages/_app.tsx | 1 + pages/index.tsx | 6 +++--- pages/search.tsx | 56 +++++++++++------------------------------------------- styles/global.css | 18 ++++++++++-------- styles/search.css | 12 ++++++++++++ styles/utility.css | 11 ++++++++++- 7 files changed, 50 insertions(+), 73 deletions(-) create mode 100644 styles/search.css (limited to 'styles') diff --git a/components/ui.tsx b/components/ui.tsx index e2d19ad..60b80f4 100644 --- a/components/ui.tsx +++ b/components/ui.tsx @@ -12,14 +12,11 @@ export function Vierkant(props: { children?: ReactNode; className?: string; id?: string; - fullwidth?: boolean; onclick?: () => void; }) { return @@ -98,6 +95,7 @@ export function Input(props: { dark?: boolean; autocomplete?: string; autofocus?: boolean; + className?: string; }) { return ; } diff --git a/pages/_app.tsx b/pages/_app.tsx index 290e687..3f66711 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -12,6 +12,7 @@ import '../styles/ui.css'; import '../styles/utility.css'; import '../styles/index.css'; +import '../styles/search.css'; export default function VierOpEenRijWebsite({ Component, pageProps }) { return
diff --git a/pages/index.tsx b/pages/index.tsx index 3d9da21..b5f4b50 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -107,17 +107,17 @@ export default function HomePage() { Tegen computer } - + {loggedIn ? : }
{loggedIn - && + && } - +

Nieuws ofzo

Chess.com heeft heel veel troep waar niemand naar kijkt

diff --git a/pages/search.tsx b/pages/search.tsx index 2b8668a..90f1f67 100644 --- a/pages/search.tsx +++ b/pages/search.tsx @@ -24,32 +24,21 @@ function search(callback: (results: Array) => void) { } function SearchResults(props: { userList: Array; }) { - return
+ return
{props.userList?.map(user => )}
; } function SearchResult(props: { user: userInfo; }) { return -
+
-
- {props.user.username} -

{props.user.status}

+
+ {props.user.username} +

{props.user.status}

; @@ -58,40 +47,22 @@ function SearchResult(props: { user: userInfo; }) { function SearchBar(props: { searchFunction: (event?: FormEvent) => void; }) { - return + return
- +
; } @@ -112,12 +83,7 @@ export default function HomePage() { {searched && results.length == 0 &&

Geen zoekresultaten gevonden

} diff --git a/styles/global.css b/styles/global.css index 3c28cfc..b6ed028 100644 --- a/styles/global.css +++ b/styles/global.css @@ -116,14 +116,20 @@ h1, h2, h3, p, b, i, span, td, th { table { table-layout: fixed; } /* table styles */ -td, th { - padding: 4px; - font-size: 15px; +td, th { padding: 4px; } + +input { + color: var(--foreground); + background-color: transparent; + font-family: inherit; + border: 0; + font-size: 1rem; /* why? */ } input::placeholder { font-style: italic; - opacity: .8; + opacity: 1; + color: var(--gray-600); } /* remove chrome's ugly :focus outline */ @@ -135,10 +141,6 @@ input::placeholder { /* material-ui default state */ svg.MuiSvgIcon-root { transition: none !important; } -input::placeholder { opacity: .75; } -input.dark::placeholder { color: var(--text); } -input.light::placeholder { color: var(--text-alt); } - /* editable field status */ *[contenteditable] { border-color: var(--background-alt); } *[contenteditable="true"]:focus { border-color: var(--disk-a); } diff --git a/styles/search.css b/styles/search.css new file mode 100644 index 0000000..06a3918 --- /dev/null +++ b/styles/search.css @@ -0,0 +1,12 @@ +.searchBar input { + width: calc(100% - 2 * var(--spacing-medium) - 48px); + margin: 2px 0; +} + +.results .result .inner .userInfo { + left: calc(48px + var(--spacing-medium)); +} + +h1.noresults { + margin: 24px 32px; +} diff --git a/styles/utility.css b/styles/utility.css index 4331d3a..783b168 100644 --- a/styles/utility.css +++ b/styles/utility.css @@ -28,8 +28,17 @@ .a0 { top: 0; bottom: 0; left: 0; right: 0; } +.dispnone { display: none; } +.dispinbl { display: inline-block; } +.dispbl { display: block; } + +.valigntop { vertical-align: top; } +.valignsup { vertical-align: super; } + +.center { text-align: center; } + .subtile { - color: var(--gray-300); + color: var(--gray-600); font-style: italic; } -- cgit v1.2.3 From 2527a6a2e0a9e679cb5a19abb56ad6a363cf980d Mon Sep 17 00:00:00 2001 From: lonkaars Date: Sun, 18 Apr 2021 13:42:44 +0200 Subject: settings page / balloon+tuitje without inline css done --- components/ui.tsx | 131 ++++++++++------------------------------------------ pages/_app.tsx | 1 + pages/index.tsx | 2 +- pages/settings.tsx | 63 +++++++++---------------- styles/index.css | 1 - styles/settings.css | 8 ++++ styles/ui.css | 46 ++++++++++++++++++ styles/utility.css | 2 + 8 files changed, 105 insertions(+), 149 deletions(-) create mode 100644 styles/settings.css (limited to 'styles') diff --git a/components/ui.tsx b/components/ui.tsx index 89e8ffe..f939456 100644 --- a/components/ui.tsx +++ b/components/ui.tsx @@ -27,10 +27,9 @@ export function Vierkant(props: { export function Button(props: { text?: string; children?: ReactNode; - style?: CSSProperties; href?: string; className?: string; - onclick?: (() => void); + onclick?: () => void; id?: string; }) { return
void; - style?: CSSProperties; href?: string; + className?: string; }) { return ; @@ -186,110 +170,43 @@ export function CheckBox(props: {
; } -export class ColorPicker extends Component<{ - style?: CSSProperties; -}> { - state: { - color: string; - dark: boolean; - } = { - color: '#012345', - dark: true, - }; +export function ColorPicker() { + var [ dark, setDark ] = useState(false); + var [ color, setColor ] = useState("#012345"); - render() { - return ; - } +
+ ; } -export function Tuitje(props: { - style?: CSSProperties; - rotation?: number; -}) { +export function Tuitje() { return ; } export function Bubble(props: { children?: ReactNode; - style?: CSSProperties; - tuitjeStyle?: CSSProperties; }) { - return + return {props.children} - + ; } diff --git a/pages/_app.tsx b/pages/_app.tsx index 3f66711..bbdbae8 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -13,6 +13,7 @@ import '../styles/utility.css'; import '../styles/index.css'; import '../styles/search.css'; +import '../styles/settings.css'; export default function VierOpEenRijWebsite({ Component, pageProps }) { return
diff --git a/pages/index.tsx b/pages/index.tsx index 9f63229..31aee57 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -107,7 +107,7 @@ export default function HomePage() { Tegen computer } - + {loggedIn ? : } diff --git a/pages/settings.tsx b/pages/settings.tsx index 0f40a90..e9fc5fa 100644 --- a/pages/settings.tsx +++ b/pages/settings.tsx @@ -1,7 +1,6 @@ import axios from 'axios'; import reduce from 'image-blob-reduce'; -import { CSSProperties, useContext } from 'react'; -import * as cookies from 'react-cookies'; +import { useContext } from 'react'; import { AccountAvatar } from '../components/account'; import { Footer } from '../components/footer'; @@ -16,11 +15,6 @@ import ExitToAppOutlinedIcon from '@material-ui/icons/ExitToAppOutlined'; import PublishOutlinedIcon from '@material-ui/icons/PublishOutlined'; import VisibilityOutlinedIcon from '@material-ui/icons/VisibilityOutlined'; -var SettingsSubsectionStyle: CSSProperties = { - marginTop: 24, - minHeight: 40, -}; - async function uploadNewProfileImage() { if (!this.result) return; @@ -54,9 +48,9 @@ export default function SettingsPage() { Instellingen - +

Account

-
+
-
+
} /> -
+

Gebruikersnaam

Hier staat hij dan

-
+
} /> } /> -
+

Email

******@example.com

-
+
} /> -
+

Wachtwoord

- +

Kleuren

-
+
-
+

Schijfjes

-
+
-
+

Achtergrond

-
-
+
+
updatePreference({ 'darkMode': state })} @@ -123,31 +117,20 @@ export default function SettingsPage() {

Donkere modus

- +

Standaard spelregels

-
+
- +

Uitloggen

-
+
} text='Uitloggen' - style={{ - float: 'none', - marginLeft: 0, - }} - onclick={() => { - cookies.remove('token'); - window.location.pathname = '/'; - }} + href="/logout" />
diff --git a/styles/index.css b/styles/index.css index 8ba12a6..fcda8e0 100644 --- a/styles/index.css +++ b/styles/index.css @@ -3,7 +3,6 @@ } .loginOrRegisterBox { - vertical-align: top; height: calc(var(--squareSize) + 2 * var(--spacing-large)); width: 100%; max-width: calc(100% - var(--squareSize) - var(--spacing-medium) * 2 - var(--spacing-large) * 2); diff --git a/styles/settings.css b/styles/settings.css new file mode 100644 index 0000000..bcce5b5 --- /dev/null +++ b/styles/settings.css @@ -0,0 +1,8 @@ +.section.logout .button { + float: unset; +} + +.subsection { + margin-top: var(--spacing-large); + min-height: 40px; +} diff --git a/styles/ui.css b/styles/ui.css index f1d65e2..b8cd44c 100644 --- a/styles/ui.css +++ b/styles/ui.css @@ -19,3 +19,49 @@ font-weight: 600; } +.button.iconlabel, +.button.colorpicker { + margin-left: var(--spacing-medium); +} + +.button.colorpicker { + --color: var(--gray-100); + --background: #ff00ff; + + background-color: var(--background); + color: var(--color); + border-width: 2px; + border-style: solid; + border-color: var(--color); +} + +.button.iconlabel .label { + margin: 3px; + margin-left: 8px; +} + +.button.colorpicker .labelwrapper { + width: 150px; + height: 24px; +} + +.button.colorpicker .labelwrapper .label { + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + font-feature-settings: "tnum", "ss01"; +} + +.bubble { + margin: 0; + overflow: visible; + left: 50%; + top: -24px; + transform: translateY(-100%) translateX(-50%); +} + +.bubble .tuitje { + bottom: -12px; + transform: translate(-50%, 0%) rotate(0deg); +} diff --git a/styles/utility.css b/styles/utility.css index 783b168..f8954cd 100644 --- a/styles/utility.css +++ b/styles/utility.css @@ -37,6 +37,8 @@ .center { text-align: center; } +.floatr { float: right; } + .subtile { color: var(--gray-600); font-style: italic; -- cgit v1.2.3 From af796b465c66a61b498facff010b372a52a24508 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Sun, 18 Apr 2021 14:28:53 +0200 Subject: wip dialog box --- components/dialogBox.tsx | 16 +- components/gameSettings.tsx | 363 +++++++++++++++++++++----------------------- styles/ui.css | 5 + styles/utility.css | 7 + 4 files changed, 188 insertions(+), 203 deletions(-) (limited to 'styles') diff --git a/components/dialogBox.tsx b/components/dialogBox.tsx index 7abbded..0a61762 100644 --- a/components/dialogBox.tsx +++ b/components/dialogBox.tsx @@ -1,4 +1,4 @@ -import { CSSProperties, ReactNode } from 'react'; +import { ReactNode } from 'react'; import { Vierkant } from './ui'; @@ -7,20 +7,10 @@ import CancelIcon from '@material-ui/icons/Cancel'; export function DialogBox(props: { children: ReactNode; title: string; - style?: CSSProperties; onclick?: () => void; + hidden?: boolean; }) { - return + return

{props.title}

({ + timelimit: { + enabled: false, + shared: false, + minutes: 0, + seconds: 0, + addmove: 0, }, - }; - - constructor(props: {}) { - super(props); + ranked: false, + }); - if (typeof window === 'undefined') return; // return if run on server - - axios.request({ + useEffect(() => { + axios.request<{ preferences: userPreferences; }>({ method: 'get', url: `/api/user/preferences`, headers: { 'content-type': 'application/json' }, }) - // FIXME: this assumes the request ruleset has all properties of a ruleset - .then(request => this.setState({ ruleset: request.data.ruleset || this.state.ruleset })) + .then(request => setRuleset(request.data.preferences.ruleset)) .catch(() => {}); - } + }, []); - showEditGameRules = () => this.setState({ editGameRulesDialogVisible: true }); - hideEditGameRules = () => this.setState({ editGameRulesDialogVisible: false }); - setGameRules = (newRules: ruleset) => this.setState({ ruleset: newRules }); + /* showEditGameRules = () => this.setState({ editGameRulesDialogVisible: true }); */ + /* hideEditGameRules = () => this.setState({ editGameRulesDialogVisible: false }); */ + /* setGameRules = (newRules: ruleset) => this.setState({ ruleset: newRules }); */ - render() { - var timelimit_str = this.state.ruleset.timelimit.enabled - ? `${this.state.ruleset.timelimit.minutes}m${this.state.ruleset.timelimit.seconds}s plus ${this.state.ruleset.timelimit.addmove}` - : 'Geen tijdslimiet'; - var ranked_str = this.state.ruleset.ranked - ? 'Gerangschikt' - : 'Niet gerangschikt'; - return
+

-

- {timelimit_str} -
- {ranked_str} -

- - -
; - } + Spelregels aanpassen +
+ + setEditGameRulesDialogVisible(false)} + setGameRules={setRuleset} + ruleset={ruleset} + visible={editGameRulesDialogVisible} + /> +
; } function GameSettingsSection(props: { @@ -168,120 +155,116 @@ function GameRule(props: { } type editGameSettingsProps = { - parentState: CurrentGameSettingsStateType; + visible: boolean; + ruleset: ruleset; hideEditGameRules: () => void; setGameRules: (newRules: ruleset) => void; }; -export class EditGameSettings extends Component { - render() { - return
+ + ; } diff --git a/styles/ui.css b/styles/ui.css index b8cd44c..efc96b7 100644 --- a/styles/ui.css +++ b/styles/ui.css @@ -65,3 +65,8 @@ bottom: -12px; transform: translate(-50%, 0%) rotate(0deg); } + +.dialogbox { + width: 392px; +} + diff --git a/styles/utility.css b/styles/utility.css index f8954cd..0393d1d 100644 --- a/styles/utility.css +++ b/styles/utility.css @@ -17,6 +17,7 @@ .posabs { position: absolute; } .posrel { position: relative; } +.posfix { position: fixed; } .t0 { top: 0; } .b0 { bottom: 0; } @@ -61,3 +62,9 @@ text-overflow: ellipsis; } +.abscenter { + top: 51%; + left: 50%; + transform: translate(-50%, -50%); +} + -- cgit v1.2.3 From 763d21dc09ea1ae5bf7bda03763386039de396a9 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Sun, 18 Apr 2021 19:34:00 +0200 Subject: edit game rules working (still some inline css) --- components/dialogBox.tsx | 19 ++++------ components/gameSettings.tsx | 85 ++++++++------------------------------------- pages/_app.tsx | 1 + styles/gameSettings.css | 59 +++++++++++++++++++++++++++++++ styles/ui.css | 10 ++++++ 5 files changed, 92 insertions(+), 82 deletions(-) create mode 100644 styles/gameSettings.css (limited to 'styles') diff --git a/components/dialogBox.tsx b/components/dialogBox.tsx index 0a61762..4ead7c5 100644 --- a/components/dialogBox.tsx +++ b/components/dialogBox.tsx @@ -9,20 +9,15 @@ export function DialogBox(props: { title: string; onclick?: () => void; hidden?: boolean; + className?: string; }) { - return -

{props.title}

+ return +

{props.title}

- + {props.children}
; diff --git a/components/gameSettings.tsx b/components/gameSettings.tsx index 3c3a699..bb01284 100644 --- a/components/gameSettings.tsx +++ b/components/gameSettings.tsx @@ -30,60 +30,24 @@ export function CurrentGameSettings() { .catch(() => {}); }, []); - /* showEditGameRules = () => this.setState({ editGameRulesDialogVisible: true }); */ - /* hideEditGameRules = () => this.setState({ editGameRulesDialogVisible: false }); */ - /* setGameRules = (newRules: ruleset) => this.setState({ ruleset: newRules }); */ - var timelimit_str = ruleset.timelimit.enabled ? `${ruleset.timelimit.minutes}m${ruleset.timelimit.seconds}s plus ${ruleset.timelimit.addmove}` : 'Geen tijdslimiet'; var ranked_str = ruleset.ranked ? 'Gerangschikt' : 'Niet gerangschikt'; - return
-

+ return

+

{timelimit_str}
{ranked_str}

@@ -105,13 +69,7 @@ function GameSettingsSection(props: { }) { return