diff --git a/public/img/pattern-light (1).png b/public/img/pattern-light (1).png new file mode 100644 index 0000000..212b2da Binary files /dev/null and b/public/img/pattern-light (1).png differ diff --git a/public/img/pattern-light.png b/public/img/pattern-light.png index 96ce5fe..212b2da 100644 Binary files a/public/img/pattern-light.png and b/public/img/pattern-light.png differ diff --git a/src/board/Board.ts b/src/board/Board.ts index 0cc9861..82f43eb 100644 --- a/src/board/Board.ts +++ b/src/board/Board.ts @@ -21,7 +21,6 @@ const defaultConfig: BoardConfig = { showChecks: true, showCoords: true, flipped: false, - anonymous: false, }; const defaultHeader: Header = { @@ -41,6 +40,7 @@ const defaultHeader: Header = { class Board { private cfg: BoardConfig = defaultConfig; + private _anonymous: boolean = false; private scale: number = 1; @@ -90,6 +90,11 @@ class Board { } } + set anonymous(value: boolean) { + this._anonymous = value; + this.refresh(); + } + async refresh() { await this.renderBackground(); @@ -197,7 +202,7 @@ class Board { } private getFinalHeader() { - return this.cfg.anonymous + return this._anonymous ? { ...this.header, White: "Anonymous", diff --git a/src/main.tsx b/src/main.tsx index fefc614..15b80c0 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -1,5 +1,5 @@ import WebFont from "webfontloader"; -import * as Hammer from "hammerjs"; +// import * as Hammer from "hammerjs"; import { render } from "solid-js/web"; import { BoardStyle, PiecesStyle } from "./types"; @@ -77,13 +77,11 @@ const main = async () => { saveConfig("board"); }, toggleAnonymous() { - setState("boardConfig", "anonymous", !state.boardConfig.anonymous); - board.updateConfig({ anonymous: state.boardConfig.anonymous }); + setState("anonymous", !state.anonymous); + board.anonymous = state.anonymous; if (state.pgn !== "") { - const pgn = state.boardConfig.anonymous - ? state.game.anonymousPGN - : state.game.pgn; + const pgn = state.anonymous ? state.game.anonymousPGN : state.game.pgn; window.location.hash = `pgn/${compressPGN(pgn)}`; } }, @@ -189,7 +187,7 @@ const main = async () => { state.gameConfig.titleScreen ); - const name = state.game.getFileName(state.boardConfig.anonymous); + const name = state.game.getFileName(state.anonymous); download(data, name, state.gameConfig.format.toLowerCase()); }, diff --git a/src/state.ts b/src/state.ts index 3c25768..400a113 100644 --- a/src/state.ts +++ b/src/state.ts @@ -20,7 +20,6 @@ const initialBoardConfig: BoardConfig = { showChecks: true, showCoords: true, flipped: false, - anonymous: false, }; const initialGameConfig: GameConfig = { @@ -44,13 +43,13 @@ export type State = { layout: "single" | "double" | "triple"; activeTab: TabName; playing: boolean; + anonymous: boolean; }; const initialState: State = { boardConfig: { ...initialBoardConfig, ...saved.boardConfig, - anonymous: false, }, gameConfig: { ...initialGameConfig, ...saved.gameConfig }, game: new Game(), @@ -62,6 +61,7 @@ const initialState: State = { layout: mobile ? "single" : "triple", activeTab: "load", playing: false, + anonymous: false, }; const [state, setState] = createStore(initialState); diff --git a/src/types.ts b/src/types.ts index 0c4ba63..5fde8f1 100644 --- a/src/types.ts +++ b/src/types.ts @@ -111,7 +111,6 @@ export type BoardConfig = { showChecks: boolean; showCoords: boolean; flipped: boolean; - anonymous: boolean; }; export type Size = "XS" | "S" | "M" | "L" | "XL"; diff --git a/src/ui/components/Info.tsx b/src/ui/components/Info.tsx index 4c305ee..426bdb4 100644 --- a/src/ui/components/Info.tsx +++ b/src/ui/components/Info.tsx @@ -11,14 +11,14 @@ const Info: Component<{ handlers: Handlers }> = () => {

- + {state.game.header.WhitePretty}{" "} {state.game.header.WhiteElo}

- + {state.game.header.BlackPretty}{" "} {state.game.header.BlackElo} @@ -35,11 +35,7 @@ const Info: Component<{ handlers: Handlers }> = () => {

- + = (props) => { classList={{ options__button: true, "options__button--last": true, - "options__button--active": state.boardConfig.anonymous, + "options__button--active": state.anonymous, }} onClick={props.handlers.toggleAnonymous} title="TOGGLE ANONYMOUS" @@ -191,9 +191,7 @@ const Share: Component<{ handlers: Handlers; class?: string }> = (props) => { class="share__btn" onClick={() => { navigator.clipboard.writeText( - state.boardConfig.anonymous - ? state.game.anonymousPGN - : state.pgn + state.anonymous ? state.game.anonymousPGN : state.pgn ); blinkCopy("pgn"); }} @@ -217,9 +215,7 @@ const Share: Component<{ handlers: Handlers; class?: string }> = (props) => { const data = new Blob([state.pgn], { type: "application/vnd.chess-pgn;charset=utf-8", }); - const name = state.game.getFileName( - state.boardConfig.anonymous - ); + const name = state.game.getFileName(state.anonymous); download(data, name, "pgn"); }} > @@ -229,7 +225,7 @@ const Share: Component<{ handlers: Handlers; class?: string }> = (props) => { class="share__btn" onClick={() => { const title = state.game.getTitle({ - anonymous: state.boardConfig.anonymous, + anonymous: state.anonymous, }); const md = `[${title}](${window.location.href})`;