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(-) 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