This commit is contained in:
Maciej Caderek
2022-03-02 23:50:34 +01:00
parent 05a6234389
commit 24358c1fdd
7 changed files with 210 additions and 10 deletions

View File

@@ -0,0 +1,43 @@
import { Style } from "../../../types";
const style: Style = {
name: "Contrast A",
category: "gradient",
background: {
type: "gradient",
data: {
dir: "vertical",
colors: ["#ff9b38", "#389bff"],
},
},
dark: {
type: "solid",
data: {
color: "transparent",
},
},
light: {
type: "solid",
data: {
color: "#ffffff66",
},
},
moveIndicator: {
type: "color",
data: "#3cff0055",
},
border: {
type: "gradient",
data: {
dir: "vertical",
colors: ["#f27f0d", "#0d7ff2"],
},
},
coords: {
onLight: "#00000077",
onDark: "#fff",
onBorder: "#fff",
},
};
export default style;

View File

@@ -0,0 +1,43 @@
import { Style } from "../../../types";
const style: Style = {
name: "Contrast B",
category: "gradient",
background: {
type: "gradient",
data: {
dir: "vertical",
colors: ["#FF4DA6", "#4D74FF"],
},
},
dark: {
type: "solid",
data: {
color: "transparent",
},
},
light: {
type: "solid",
data: {
color: "#ffffff66",
},
},
moveIndicator: {
type: "color",
data: "#3cff0055",
},
border: {
type: "gradient",
data: {
dir: "vertical",
colors: ["#BB3D7C", "#3653BB"],
},
},
coords: {
onLight: "#00000077",
onDark: "#fff",
onBorder: "#fff",
},
};
export default style;

View File

@@ -0,0 +1,43 @@
import { Style } from "../../../types";
const style: Style = {
name: "Contrast C",
category: "gradient",
background: {
type: "gradient",
data: {
dir: "vertical",
colors: ["#FF8D4D", "#914DFF"],
},
},
dark: {
type: "solid",
data: {
color: "transparent",
},
},
light: {
type: "solid",
data: {
color: "#ffffff66",
},
},
moveIndicator: {
type: "color",
data: "#3cff0055",
},
border: {
type: "gradient",
data: {
dir: "vertical",
colors: ["#E8702C", "#6334B0"],
},
},
coords: {
onLight: "#00000077",
onDark: "#fff",
onBorder: "#fff",
},
};
export default style;

View File

@@ -0,0 +1,43 @@
import { Style } from "../../../types";
const style: Style = {
name: "Contrast D",
category: "gradient",
background: {
type: "gradient",
data: {
dir: "vertical",
colors: ["#61c43f", "#864DFF"],
},
},
dark: {
type: "solid",
data: {
color: "transparent",
},
},
light: {
type: "solid",
data: {
color: "#ffffff66",
},
},
moveIndicator: {
type: "color",
data: "#3cff0055",
},
border: {
type: "gradient",
data: {
dir: "vertical",
colors: ["#559a3c", "#6333cc"],
},
},
coords: {
onLight: "#00000077",
onDark: "#fff",
onBorder: "#fff",
},
};
export default style;

View File

@@ -29,6 +29,10 @@ import smoothLaguna from "./gradient/smooth-laguna";
import smoothSea from "./gradient/smooth-sea"; import smoothSea from "./gradient/smooth-sea";
import smoothViolet from "./gradient/smooth-violet"; import smoothViolet from "./gradient/smooth-violet";
import smoothMono from "./gradient/smooth-mono"; import smoothMono from "./gradient/smooth-mono";
import contrastA from "./gradient/contrast-a";
import contrastB from "./gradient/contrast-b";
import contrastC from "./gradient/contrast-c";
import contrastD from "./gradient/contrast-d";
import wood1 from "./pic/wood1"; import wood1 from "./pic/wood1";
import wood2 from "./pic/wood2"; import wood2 from "./pic/wood2";
@@ -71,6 +75,10 @@ const styles = {
smoothSea, smoothSea,
smoothViolet, smoothViolet,
smoothMono, smoothMono,
contrastA,
contrastB,
contrastC,
contrastD,
wood1, wood1,
wood2, wood2,
wood3, wood3,

View File

@@ -83,6 +83,7 @@ const main = async () => {
if (state.pgn !== "") { if (state.pgn !== "") {
const pgn = state.anonymous ? state.game.anonymousPGN : state.game.pgn; const pgn = state.anonymous ? state.game.anonymousPGN : state.game.pgn;
window.location.hash = `pgn/${compressPGN(pgn)}`; window.location.hash = `pgn/${compressPGN(pgn)}`;
setState("refreshHash", false);
} }
}, },
toggleTitleScreen() { toggleTitleScreen() {
@@ -114,6 +115,7 @@ const main = async () => {
game, game,
}); });
window.location.hash = `pgn/${compressPGN(game.pgn)}`; window.location.hash = `pgn/${compressPGN(game.pgn)}`;
setState("refreshHash", false);
await player.load(game); await player.load(game);
setState("activeTab", "game"); setState("activeTab", "game");
@@ -142,6 +144,7 @@ const main = async () => {
if (hash) { if (hash) {
window.location.hash = `fen/${state.fen}`; window.location.hash = `fen/${state.fen}`;
setState("refreshHash", false);
setState("activeTab", "game"); setState("activeTab", "game");
} }
@@ -203,18 +206,22 @@ const main = async () => {
const $board = document.querySelector<HTMLImageElement>("#board"); const $board = document.querySelector<HTMLImageElement>("#board");
$board?.prepend(board.canvas); $board?.prepend(board.canvas);
/* Restore game from the url */ /* Load game from the url */
const { pgn, fen } = extractUrlData(); const loadFromUrl = async () => {
const { pgn, fen } = extractUrlData();
await (pgn await (pgn
? handlers.loadPGN(pgn) ? handlers.loadPGN(pgn)
: fen : fen
? handlers.loadFEN(fen) ? handlers.loadFEN(fen)
: handlers.loadFEN( : handlers.loadFEN(
"rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1", "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
false false
)); ));
};
await loadFromUrl();
/* Register events */ /* Register events */
document.addEventListener("dblclick", function (el) { document.addEventListener("dblclick", function (el) {
@@ -232,6 +239,17 @@ const main = async () => {
); );
}); });
window.addEventListener("hashchange", () => {
if (!state.refreshHash) {
setState("refreshHash", true);
console.log("No refresh");
return;
}
console.log("Refresh!");
loadFromUrl();
});
if (!state.mobile) { if (!state.mobile) {
const keyMapping: { [key: string]: () => void } = { const keyMapping: { [key: string]: () => void } = {
ArrowLeft: handlers.prev, ArrowLeft: handlers.prev,

View File

@@ -44,6 +44,7 @@ export type State = {
activeTab: TabName; activeTab: TabName;
playing: boolean; playing: boolean;
anonymous: boolean; anonymous: boolean;
refreshHash: boolean;
}; };
const initialState: State = { const initialState: State = {
@@ -67,6 +68,7 @@ const initialState: State = {
activeTab: "load", activeTab: "load",
playing: false, playing: false,
anonymous: false, anonymous: false,
refreshHash: true,
}; };
console.log(initialState); console.log(initialState);