-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconstants.ts
33 lines (30 loc) · 868 Bytes
/
constants.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const rootStyles = process.env.NODE_ENV !== "test" ? getComputedStyle(document.documentElement) : {
values: {
"--board-size": "8",
"--square-size-units": "3.5"
},
getPropertyValue(prop: keyof typeof this.values) {
if (process.env.NODE_ENV !== "test") {
throw new Error("getComputedStyle fallback only meant for testing");
}
return this.values[prop];
}
};
/**
* Width of a square in viewport height units
*/
export const squareSize = Number(rootStyles.getPropertyValue("--square-size-units"))
export const getSquareSizePixels = () => window.innerHeight * (squareSize / 100)
/**
* Board size in amount of squares
*/
export const boardSize = Number(rootStyles.getPropertyValue("--board-size"))
export const hues = [
0,
60,
120,
180,
300
]
export const highscoreLocalStorageKey = "KLODS_HIGHSCORE"
export const undos = 3