diff --git a/index.html b/index.html index a564e18..c36bdd7 100644 --- a/index.html +++ b/index.html @@ -5,7 +5,7 @@ { ); const $board = document.querySelector("#board"); - $board?.appendChild(board.canvas); + $board?.prepend(board.canvas); /* Restore game from the url */ @@ -219,6 +219,9 @@ const main = async () => { )); /* Register events */ + document.addEventListener("dblclick", function (el) { + el.preventDefault(); + }); if (!state.mobile) { const keyMapping: { [key: string]: () => void } = { diff --git a/src/state.ts b/src/state.ts index 9002681..3c25768 100644 --- a/src/state.ts +++ b/src/state.ts @@ -30,6 +30,8 @@ const initialGameConfig: GameConfig = { animationSize: "M", }; +export type TabName = "game" | "load" | "share" | "boards" | "pieces"; + export type State = { boardConfig: BoardConfig; gameConfig: GameConfig; @@ -39,7 +41,8 @@ export type State = { moves: string[]; ply: number; mobile: boolean; - activeTab: "game" | "load"; + layout: "single" | "double" | "triple"; + activeTab: TabName; playing: boolean; }; @@ -56,6 +59,7 @@ const initialState: State = { moves: [], ply: 0, mobile, + layout: mobile ? "single" : "triple", activeTab: "load", playing: false, }; diff --git a/src/ui/App.css b/src/ui/App.css index 925fdb8..ab05138 100644 --- a/src/ui/App.css +++ b/src/ui/App.css @@ -188,6 +188,12 @@ a:hover { .board-box { height: auto; + padding: var(--header-height) 0 1rem 0; + font-size: 0; + } + + .board { + border-radius: 0; } .setup-box { diff --git a/src/ui/App.tsx b/src/ui/App.tsx index 81920fe..2d1607a 100644 --- a/src/ui/App.tsx +++ b/src/ui/App.tsx @@ -1,12 +1,13 @@ -import type { Component } from "solid-js"; +import { Component, Show } from "solid-js"; import type { DeepReadonly } from "solid-js/store"; import { Handlers } from "../types"; -import { State } from "../state"; +import { State, state } from "../state"; import Header from "./components/Header"; import GameTabs from "./components/GameTabs"; import SetupTabs from "./components/SetupTabs"; +import Controls from "./components/Controls"; import "./App.css"; @@ -17,10 +18,16 @@ const App: Component<{ handlers: Handlers; state: DeepReadonly }> = ( <>
-
- + +
+ +
+
+
+ + +
-
{ return boards; }; -const Boards: Component<{ handlers: Handlers }> = (props) => { +const Boards: Component<{ handlers: Handlers; class?: string }> = (props) => { const [boards, setBoards] = createSignal([]); prepareBoards().then((data) => setBoards(data)); return ( - + {(board) => { return ( diff --git a/src/ui/components/GameTabs.css b/src/ui/components/GameTabs.css index da829b7..17ff9b4 100644 --- a/src/ui/components/GameTabs.css +++ b/src/ui/components/GameTabs.css @@ -8,39 +8,24 @@ @media screen and (max-width: 1024px) { .game-box { - height: auto; + padding: 0; + height: 800px; } } -.game-tabs { +.game { height: 100%; display: grid; grid-template-rows: 38px 195px 1fr 84px; } -.game-tabs__btn { - width: 48%; - border-bottom-left-radius: 0; - border-bottom-right-radius: 0; - height: 38px; - background: var(--color-tab); +.game-tabs { + display: grid; + grid-auto-flow: column; + grid-template-columns: 1fr 1fr; + column-gap: 0.5rem; } -.game-tabs__btn:hover { - background: var(--color-tab-light); -} - -.game-tabs__btn--active { - width: 50%; - background: var(--color-bg-block); - color: var(--color-text); - cursor: default; -} - -.game-tabs__btn--active:hover { - background: var(--color-bg-block); -} - -.game-tabs__btn:nth-child(1) { - margin-right: 2%; +.span3 { + grid-row-end: span 3; } diff --git a/src/ui/components/GameTabs.tsx b/src/ui/components/GameTabs.tsx index 2e8089a..022714a 100644 --- a/src/ui/components/GameTabs.tsx +++ b/src/ui/components/GameTabs.tsx @@ -1,36 +1,55 @@ -import { Component, Switch, Match } from "solid-js"; +import { Component, Switch, Match, Show } from "solid-js"; import Moves from "./Moves"; import Controls from "./Controls"; import Info from "./Info"; import Load from "./Load"; +import Share from "./Share"; +import Boards from "./Boards"; +import Pieces from "./Pieces"; +import Tab from "./reusable/Tab"; import { Handlers } from "../../types"; +import { setState, state, TabName } from "../../state"; import "./GameTabs.css"; -import { setState, state } from "../../state"; + +const setTab = (tab: TabName) => { + setState("activeTab", tab); +}; const GameTabs: Component<{ moves: readonly string[]; handlers: Handlers }> = ( props ) => { return ( -
-
- - + + + + + + + + + + + +
@@ -39,8 +58,19 @@ const GameTabs: Component<{ moves: readonly string[]; handlers: Handlers }> = ( - + + + + + + + + + + + +
); diff --git a/src/ui/components/Load.css b/src/ui/components/Load.css index 16318c3..82f20cf 100644 --- a/src/ui/components/Load.css +++ b/src/ui/components/Load.css @@ -3,7 +3,6 @@ padding: 20px; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; - grid-row-end: span 3; } .load__pgn-input { diff --git a/src/ui/components/Load.tsx b/src/ui/components/Load.tsx index 18972f8..2671bc0 100644 --- a/src/ui/components/Load.tsx +++ b/src/ui/components/Load.tsx @@ -4,7 +4,7 @@ import readFile from "../../utils/readFile"; import { state } from "../../state"; import "./Load.css"; -const Load: Component<{ handlers: Handlers }> = (props) => { +const Load: Component<{ handlers: Handlers; class?: string }> = (props) => { const [fen, setFEN] = createSignal(""); const [pgn, setPGN] = createSignal(""); const [link, setLink] = createSignal(""); @@ -12,7 +12,7 @@ const Load: Component<{ handlers: Handlers }> = (props) => { let filePicker: HTMLInputElement | undefined = undefined; return ( -
+
({ img: data.nw, })) as { key: PiecesStyle; img: string }[]; -const Pieces: Component<{ handlers: Handlers }> = (props) => { +const Pieces: Component<{ handlers: Handlers; class?: string }> = (props) => { return ( - + { {(item) => ( diff --git a/src/ui/components/SetupTabs.css b/src/ui/components/SetupTabs.css index 81e7282..dff6adc 100644 --- a/src/ui/components/SetupTabs.css +++ b/src/ui/components/SetupTabs.css @@ -6,12 +6,6 @@ min-width: 375px; } -@media screen and (max-width: 1024px) { - .setup-box { - height: auto; - } -} - .setup { font-size: 1.6rem; height: 100%; @@ -19,29 +13,9 @@ grid-template-rows: 38px 1fr; } -.setup-tabs__btn { - width: 32%; - border-bottom-left-radius: 0; - border-bottom-right-radius: 0; - height: 38px; - background: var(--color-tab); -} - -.setup-tabs__btn:hover { - background: var(--color-tab-light); -} - -.setup-tabs__btn--active { - background: var(--color-bg-block); - color: var(--color-text); - cursor: default; -} - -.setup-tabs__btn--active:hover { - background: var(--color-bg-block); -} - -.setup-tabs__btn:nth-child(1), -.setup-tabs__btn:nth-child(2) { - margin-right: 2%; +.setup-tabs { + display: grid; + grid-auto-flow: column; + grid-template-columns: 1fr 1fr 1fr; + column-gap: 0.5rem; } diff --git a/src/ui/components/SetupTabs.tsx b/src/ui/components/SetupTabs.tsx index 4481bf4..e5ea09d 100644 --- a/src/ui/components/SetupTabs.tsx +++ b/src/ui/components/SetupTabs.tsx @@ -4,6 +4,7 @@ import "./SetupTabs.css"; import Share from "./Share"; import Boards from "./Boards"; import Pieces from "./Pieces"; +import Tab from "./reusable/Tab"; const SetupTabs: Component<{ handlers: Handlers; @@ -12,34 +13,16 @@ const SetupTabs: Component<{ return (
-
- - - +
diff --git a/src/ui/components/Share.tsx b/src/ui/components/Share.tsx index c2a6f01..4a30a06 100644 --- a/src/ui/components/Share.tsx +++ b/src/ui/components/Share.tsx @@ -5,7 +5,7 @@ import { state, setState } from "../../state"; import "./Share.css"; import download from "../../utils/download"; -const Share: Component<{ handlers: Handlers }> = (props) => { +const Share: Component<{ handlers: Handlers; class?: string }> = (props) => { const [copyId, setCopyId] = createSignal(""); const [imageRendering, setImageRendering] = createSignal(false); const [animationRendering, setAnimationRendering] = createSignal(false); @@ -16,7 +16,7 @@ const Share: Component<{ handlers: Handlers }> = (props) => { }; return ( -