WIP
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import { Coords } from "../../types";
|
import { Coords } from "../../types";
|
||||||
|
|
||||||
const BASE_FONT_SIZE = 24;
|
const BASE_FONT_SIZE = 22;
|
||||||
const FONT_FAMILY = "Fira Mono";
|
const FONT_FAMILY = "Fira Mono";
|
||||||
|
|
||||||
const drawCoords = (
|
const drawCoords = (
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ const style: Style = {
|
|||||||
type: "gradient",
|
type: "gradient",
|
||||||
data: {
|
data: {
|
||||||
dir: "diagonal-top",
|
dir: "diagonal-top",
|
||||||
colors: ["#3df5a7", "#096fe0"],
|
colors: ["#00c4a0", "#096fe0"],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
dark: {
|
dark: {
|
||||||
@@ -19,7 +19,7 @@ const style: Style = {
|
|||||||
light: {
|
light: {
|
||||||
type: "solid",
|
type: "solid",
|
||||||
data: {
|
data: {
|
||||||
color: "#ffffff55",
|
color: "#ffffff77",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
moveIndicator: {
|
moveIndicator: {
|
||||||
@@ -30,7 +30,7 @@ const style: Style = {
|
|||||||
type: "gradient",
|
type: "gradient",
|
||||||
data: {
|
data: {
|
||||||
dir: "diagonal-top",
|
dir: "diagonal-top",
|
||||||
colors: ["#00b568", "#0052ad"],
|
colors: ["#009c7f", "#0052ad"],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
coords: {
|
coords: {
|
||||||
|
|||||||
@@ -1,50 +0,0 @@
|
|||||||
import { Style } from "../../../types";
|
|
||||||
|
|
||||||
const style: Style = {
|
|
||||||
name: "Rainbow Light",
|
|
||||||
category: "gradient",
|
|
||||||
background: {
|
|
||||||
type: "gradient",
|
|
||||||
data: {
|
|
||||||
dir: "vertical",
|
|
||||||
colors: [
|
|
||||||
"hsl(350, 100%, 60%)",
|
|
||||||
"hsl(35, 100%, 60%)",
|
|
||||||
"hsl(80, 100%, 60%)",
|
|
||||||
"hsl(125, 100%, 60%)",
|
|
||||||
"hsl(215, 100%, 60%)",
|
|
||||||
"hsl(260, 100%, 60%)",
|
|
||||||
"hsl(305, 100%, 60%)",
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
dark: {
|
|
||||||
type: "solid",
|
|
||||||
data: {
|
|
||||||
color: "#ffffff22",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
light: {
|
|
||||||
type: "solid",
|
|
||||||
data: {
|
|
||||||
color: "#ffffff88",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
moveIndicator: {
|
|
||||||
type: "color",
|
|
||||||
data: "#00ffff66",
|
|
||||||
},
|
|
||||||
border: {
|
|
||||||
type: "solid",
|
|
||||||
data: {
|
|
||||||
color: "#bd2f47",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
coords: {
|
|
||||||
onLight: "#bd2f47",
|
|
||||||
onDark: "#000000bb",
|
|
||||||
onBorder: "#ffffffcc",
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
export default style;
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
import { Style } from "../../../types";
|
|
||||||
|
|
||||||
const style: Style = {
|
|
||||||
name: "Rainbow",
|
|
||||||
category: "gradient",
|
|
||||||
background: {
|
|
||||||
type: "gradient",
|
|
||||||
data: {
|
|
||||||
dir: "vertical",
|
|
||||||
colors: [
|
|
||||||
"hsl(350, 70%, 50%)",
|
|
||||||
"hsl(35, 70%, 50%)",
|
|
||||||
"hsl(80, 70%, 50%)",
|
|
||||||
"hsl(125, 70%, 50%)",
|
|
||||||
"hsl(215, 70%, 50%)",
|
|
||||||
"hsl(260, 70%, 50%)",
|
|
||||||
"hsl(305, 70%, 50%)",
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
dark: {
|
|
||||||
type: "solid",
|
|
||||||
data: {
|
|
||||||
color: "#ffffff22",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
light: {
|
|
||||||
type: "solid",
|
|
||||||
data: {
|
|
||||||
color: "#ffffff99",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
moveIndicator: {
|
|
||||||
type: "color",
|
|
||||||
data: "#00ffff66",
|
|
||||||
},
|
|
||||||
border: {
|
|
||||||
type: "solid",
|
|
||||||
data: {
|
|
||||||
color: "#271936",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
coords: {
|
|
||||||
onLight: "#271936",
|
|
||||||
onDark: "#271936",
|
|
||||||
onBorder: "#ffffffbb",
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
export default style;
|
|
||||||
@@ -12,25 +12,23 @@ import avocado from "./colorful/avocado";
|
|||||||
import calm from "./gradient/calm";
|
import calm from "./gradient/calm";
|
||||||
import laguna from "./gradient/laguna";
|
import laguna from "./gradient/laguna";
|
||||||
import sunset from "./gradient/sunset";
|
import sunset from "./gradient/sunset";
|
||||||
import rainbow from "./gradient/rainbow";
|
|
||||||
import rainbowLight from "./gradient/rainbow-light";
|
|
||||||
|
|
||||||
// import kittens from "./pic/kittens";
|
// import kittens from "./pic/kittens";
|
||||||
|
|
||||||
export default {
|
const styles = {
|
||||||
standard,
|
standard,
|
||||||
chesscom,
|
|
||||||
lichess,
|
|
||||||
lila,
|
lila,
|
||||||
peach,
|
peach,
|
||||||
violet,
|
violet,
|
||||||
|
chesscom,
|
||||||
|
lichess,
|
||||||
danya,
|
danya,
|
||||||
botez,
|
botez,
|
||||||
avocado,
|
avocado,
|
||||||
calm,
|
calm,
|
||||||
laguna,
|
laguna,
|
||||||
sunset,
|
sunset,
|
||||||
rainbow,
|
|
||||||
rainbowLight,
|
|
||||||
// kittens,
|
// kittens,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default styles;
|
||||||
|
|||||||
@@ -28,13 +28,13 @@ const style: Style = {
|
|||||||
border: {
|
border: {
|
||||||
type: "solid",
|
type: "solid",
|
||||||
data: {
|
data: {
|
||||||
color: "#271936",
|
color: "#50346e",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
coords: {
|
coords: {
|
||||||
onLight: "#271936",
|
onLight: "#50346e",
|
||||||
onDark: "#271936",
|
onDark: "#eedeff",
|
||||||
onBorder: "#cea9f5",
|
onBorder: "#e2c7ff",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
10
src/main.tsx
10
src/main.tsx
@@ -10,6 +10,7 @@ import Player from "./player/Player";
|
|||||||
import App from "./ui/App";
|
import App from "./ui/App";
|
||||||
|
|
||||||
import { state, setState } from "./state";
|
import { state, setState } from "./state";
|
||||||
|
import saveConfig from "./persistance/saveConfig";
|
||||||
|
|
||||||
import createImage from "./encoders/createImage";
|
import createImage from "./encoders/createImage";
|
||||||
import createAnimation from "./encoders/createAnimation";
|
import createAnimation from "./encoders/createAnimation";
|
||||||
@@ -45,15 +46,18 @@ const main = async () => {
|
|||||||
toggleBorder() {
|
toggleBorder() {
|
||||||
board.toggleBorder();
|
board.toggleBorder();
|
||||||
setState("boardConfig", "showBorder", !state.boardConfig.showBorder);
|
setState("boardConfig", "showBorder", !state.boardConfig.showBorder);
|
||||||
|
saveConfig("board");
|
||||||
},
|
},
|
||||||
|
|
||||||
showBorder() {
|
showBorder() {
|
||||||
board.showBorder();
|
board.showBorder();
|
||||||
setState("boardConfig", "showBorder", true);
|
setState("boardConfig", "showBorder", true);
|
||||||
|
saveConfig("board");
|
||||||
},
|
},
|
||||||
hideBorder() {
|
hideBorder() {
|
||||||
board.hideBorder();
|
board.hideBorder();
|
||||||
setState("boardConfig", "showBorder", false);
|
setState("boardConfig", "showBorder", false);
|
||||||
|
saveConfig("board");
|
||||||
},
|
},
|
||||||
toggleExtraInfo() {
|
toggleExtraInfo() {
|
||||||
board.toggleExtraInfo();
|
board.toggleExtraInfo();
|
||||||
@@ -62,6 +66,7 @@ const main = async () => {
|
|||||||
"showExtraInfo",
|
"showExtraInfo",
|
||||||
!state.boardConfig.showExtraInfo
|
!state.boardConfig.showExtraInfo
|
||||||
);
|
);
|
||||||
|
saveConfig("board");
|
||||||
},
|
},
|
||||||
toggleAnonymous() {
|
toggleAnonymous() {
|
||||||
setState("boardConfig", "anonymous", !state.boardConfig.anonymous);
|
setState("boardConfig", "anonymous", !state.boardConfig.anonymous);
|
||||||
@@ -69,6 +74,7 @@ const main = async () => {
|
|||||||
},
|
},
|
||||||
toggleTitleScreen() {
|
toggleTitleScreen() {
|
||||||
setState("gameConfig", "titleScreen", !state.gameConfig.titleScreen);
|
setState("gameConfig", "titleScreen", !state.gameConfig.titleScreen);
|
||||||
|
saveConfig("game");
|
||||||
},
|
},
|
||||||
flip() {
|
flip() {
|
||||||
console.log("FLIP");
|
console.log("FLIP");
|
||||||
@@ -85,10 +91,12 @@ const main = async () => {
|
|||||||
changeBoardStyle(style: BoardStyle) {
|
changeBoardStyle(style: BoardStyle) {
|
||||||
board.setStyle(style);
|
board.setStyle(style);
|
||||||
setState("boardConfig", "boardStyle", style);
|
setState("boardConfig", "boardStyle", style);
|
||||||
|
saveConfig("board");
|
||||||
},
|
},
|
||||||
changePiecesStyle(style: PiecesStyle) {
|
changePiecesStyle(style: PiecesStyle) {
|
||||||
board.setPiecesStyle(style);
|
board.setPiecesStyle(style);
|
||||||
setState("boardConfig", "piecesStyle", style);
|
setState("boardConfig", "piecesStyle", style);
|
||||||
|
saveConfig("board");
|
||||||
},
|
},
|
||||||
async loadPGN(pgn: string) {
|
async loadPGN(pgn: string) {
|
||||||
const game = new Game().loadPGN(pgn);
|
const game = new Game().loadPGN(pgn);
|
||||||
@@ -240,7 +248,7 @@ const main = async () => {
|
|||||||
|
|
||||||
WebFont.load({
|
WebFont.load({
|
||||||
google: {
|
google: {
|
||||||
families: ["Ubuntu:500,700", "Fira Mono"],
|
families: ["Ubuntu:500,700", "Fira Mono:500"],
|
||||||
},
|
},
|
||||||
custom: {
|
custom: {
|
||||||
families: ["Chess"],
|
families: ["Chess"],
|
||||||
|
|||||||
11
src/persistance/loadConfig.ts
Normal file
11
src/persistance/loadConfig.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
const loadConfig = () => {
|
||||||
|
const boardConfig = localStorage.getItem("boardConfig");
|
||||||
|
const gameConfig = localStorage.getItem("gameConfig");
|
||||||
|
|
||||||
|
return {
|
||||||
|
boardConfig: boardConfig === null ? {} : JSON.parse(boardConfig),
|
||||||
|
gameConfig: gameConfig === null ? {} : JSON.parse(gameConfig),
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export default loadConfig;
|
||||||
8
src/persistance/saveConfig.ts
Normal file
8
src/persistance/saveConfig.ts
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
import { state } from "../state";
|
||||||
|
|
||||||
|
const saveConfig = (type: "board" | "game") =>
|
||||||
|
type === "board"
|
||||||
|
? localStorage.setItem("boardConfig", JSON.stringify(state.boardConfig))
|
||||||
|
: localStorage.setItem("gameConfig", JSON.stringify(state.gameConfig));
|
||||||
|
|
||||||
|
export default saveConfig;
|
||||||
14
src/state.ts
14
src/state.ts
@@ -1,11 +1,14 @@
|
|||||||
import isMobile from "is-mobile";
|
import isMobile from "is-mobile";
|
||||||
import { createStore } from "solid-js/store";
|
import { createStore } from "solid-js/store";
|
||||||
import Game from "./game/Game";
|
import Game from "./game/Game";
|
||||||
|
import loadConfig from "./persistance/loadConfig";
|
||||||
import { BoardConfig, GameConfig } from "./types";
|
import { BoardConfig, GameConfig } from "./types";
|
||||||
|
|
||||||
const mobile = isMobile();
|
const mobile = isMobile();
|
||||||
|
|
||||||
const boardConfig: BoardConfig = {
|
const saved = loadConfig();
|
||||||
|
|
||||||
|
const initialBoardConfig: BoardConfig = {
|
||||||
size: 1024,
|
size: 1024,
|
||||||
tiles: 8,
|
tiles: 8,
|
||||||
boardStyle: "standard",
|
boardStyle: "standard",
|
||||||
@@ -20,11 +23,8 @@ const boardConfig: BoardConfig = {
|
|||||||
anonymous: false,
|
anonymous: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
const gameConfig: GameConfig = {
|
const initialGameConfig: GameConfig = {
|
||||||
titleScreen: true,
|
titleScreen: true,
|
||||||
fromPly: null,
|
|
||||||
toPly: null,
|
|
||||||
loop: true,
|
|
||||||
format: "GIF",
|
format: "GIF",
|
||||||
picSize: "M",
|
picSize: "M",
|
||||||
animationSize: "M",
|
animationSize: "M",
|
||||||
@@ -43,8 +43,8 @@ export type State = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const initialState: State = {
|
const initialState: State = {
|
||||||
boardConfig,
|
boardConfig: { ...initialBoardConfig, ...saved.boardConfig },
|
||||||
gameConfig,
|
gameConfig: { ...initialGameConfig, ...saved.gameConfig },
|
||||||
game: new Game(),
|
game: new Game(),
|
||||||
pgn: "",
|
pgn: "",
|
||||||
fen: "",
|
fen: "",
|
||||||
|
|||||||
35
src/types.ts
35
src/types.ts
@@ -1,4 +1,6 @@
|
|||||||
import { Move } from "chess.js";
|
import { Move } from "chess.js";
|
||||||
|
import stylesBoard from "./board/styles-board";
|
||||||
|
import stylesPieces from "./board/styles-pieces";
|
||||||
|
|
||||||
export type GradientDir =
|
export type GradientDir =
|
||||||
| "horizontal"
|
| "horizontal"
|
||||||
@@ -92,35 +94,9 @@ export type Piece =
|
|||||||
| "nb"
|
| "nb"
|
||||||
| "pb";
|
| "pb";
|
||||||
|
|
||||||
export type BoardStyle =
|
export type BoardStyle = keyof typeof stylesBoard;
|
||||||
| "standard"
|
|
||||||
| "chesscom"
|
|
||||||
| "lichess"
|
|
||||||
| "lila"
|
|
||||||
| "peach"
|
|
||||||
| "violet"
|
|
||||||
| "danya"
|
|
||||||
| "botez"
|
|
||||||
| "avocado"
|
|
||||||
| "calm"
|
|
||||||
| "laguna"
|
|
||||||
| "sunset"
|
|
||||||
| "rainbow"
|
|
||||||
| "rainbowLight";
|
|
||||||
|
|
||||||
export type PiecesStyle =
|
export type PiecesStyle = keyof typeof stylesPieces;
|
||||||
| "alpha"
|
|
||||||
| "cardinal"
|
|
||||||
| "cburnett"
|
|
||||||
| "companion"
|
|
||||||
| "fantasy"
|
|
||||||
| "gioco"
|
|
||||||
| "governor"
|
|
||||||
| "horsey"
|
|
||||||
| "maestro"
|
|
||||||
| "merida"
|
|
||||||
| "staunty"
|
|
||||||
| "tatiana";
|
|
||||||
|
|
||||||
export type BoardConfig = {
|
export type BoardConfig = {
|
||||||
size: number;
|
size: number;
|
||||||
@@ -141,9 +117,6 @@ export type Size = "XS" | "S" | "M" | "L" | "XL";
|
|||||||
|
|
||||||
export type GameConfig = {
|
export type GameConfig = {
|
||||||
titleScreen: boolean;
|
titleScreen: boolean;
|
||||||
fromPly: number | null;
|
|
||||||
toPly: number | null;
|
|
||||||
loop: boolean;
|
|
||||||
format: "GIF" | "MP4" | "WebM";
|
format: "GIF" | "MP4" | "WebM";
|
||||||
picSize: Size;
|
picSize: Size;
|
||||||
animationSize: Size;
|
animationSize: Size;
|
||||||
|
|||||||
Reference in New Issue
Block a user