Skip to content

Commit ffe32f1

Browse files
committed
wip
1 parent 8e33960 commit ffe32f1

File tree

19 files changed

+220
-213
lines changed

19 files changed

+220
-213
lines changed

frontend/src/html/head.html

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,7 @@
2727
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
2828
<title>Monkeytype | A minimalistic, customizable typing test</title>
2929
<!-- default colors in case theme file fails to load -->
30-
<style>
31-
:root {
32-
--bg-color: #323437;
33-
--main-color: #e2b714;
34-
--caret-color: #e2b714;
35-
--sub-color: #646669;
36-
--sub-alt-color: #2c2e31;
37-
--text-color: #d1d0c5;
38-
--error-color: #ca4754;
39-
--error-extra-color: #7e2a33;
40-
--colorful-error-color: #ca4754;
41-
--colorful-error-extra-color: #7e2a33;
42-
}
43-
</style>
30+
<ThemeColors />
4431
<link
4532
rel="icon"
4633
type="image/x-icon"

frontend/src/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
async
7272
defer
7373
></script>
74-
<link rel="stylesheet" href="/themes/serika_dark.css" id="currentTheme" />
74+
<link rel="stylesheet" id="currentTheme" />
7575
<link rel="stylesheet" href="" id="globalFunBoxTheme" type="text/css" />
7676
<script type="module" src="ts/index.ts"></script>
7777
</body>

frontend/src/ts/components/common/ChartJs.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export function ChartJs<T extends ChartType, TData = DefaultDataPoint<T>>(
5454
createEffect(() => {
5555
//react on theme changes
5656
const colors = getThemeColors();
57+
console.log("#####", { colors });
5758
if (!chart) return;
5859

5960
void chart.updateColors(colors);
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { createEffect, JSXElement } from "solid-js";
2+
import { getThemeColors } from "../../signals/theme";
3+
import { useRefWithUtils } from "../../hooks/useRefWithUtils";
4+
5+
export function ThemeColors(): JSXElement {
6+
// Refs are assigned by SolidJS via the ref attribute
7+
const [styleRef, styleEl] = useRefWithUtils<HTMLStyleElement>();
8+
9+
createEffect(() => {
10+
styleEl()?.setHtml(`
11+
:root {
12+
13+
--bg-color: ${getThemeColors().bg};
14+
--main-color: ${getThemeColors().main};
15+
--caret-color: ${getThemeColors().caret};
16+
--sub-color: ${getThemeColors().sub};
17+
--sub-alt-color: ${getThemeColors().subAlt};
18+
--text-color: ${getThemeColors().text};
19+
--error-color: ${getThemeColors().error};
20+
--error-extra-color:${getThemeColors().errorExtra};
21+
--colorful-error-color: ${getThemeColors().colorfulError};
22+
--colorful-error-extra-color: ${getThemeColors().colorfulErrorExtra};
23+
}
24+
`);
25+
});
26+
27+
return <style ref={styleRef} />;
28+
}

frontend/src/ts/components/mount.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ import { JSXElement } from "solid-js";
55
import { Footer } from "./layout/footer/Footer";
66
import { Modals } from "./modals/Modals";
77
import { AboutPage } from "./pages/AboutPage";
8+
import { ThemeColors } from "./layout/ThemeColors";
89

910
const components: Record<string, () => JSXElement> = {
1011
Footer: () => <Footer />,
1112
Modals: () => <Modals />,
1213
AboutPage: () => <AboutPage />,
14+
ThemeColors: () => <ThemeColors />,
1315
};
1416

1517
function mountToMountpoint(name: string, component: () => JSXElement): void {

frontend/src/ts/constants/themes.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { ThemeColors } from "../signals/theme";
44

55
export type Theme = {
66
name: ThemeName;
7+
hasCss?: boolean;
78
} & Pick<ThemeColors, "bg" | "main" | "sub" | "text"> &
89
Partial<Omit<ThemeColors, "bg" | "main" | "sub" | "text">>;
910

@@ -85,6 +86,7 @@ export const themes: Record<ThemeName, Omit<Theme, "name">> = {
8586
errorExtra: " #791717",
8687
colorfulError: " #da3333",
8788
colorfulErrorExtra: " #791717",
89+
hasCss: true,
8890
},
8991
nautilus: {
9092
bg: "#132237",
@@ -101,8 +103,14 @@ export const themes: Record<ThemeName, Omit<Theme, "name">> = {
101103
serika_dark: {
102104
bg: "#323437",
103105
main: "#e2b714",
106+
caret: "#e2b714",
104107
sub: "#646669",
108+
subAlt: "#2c2e31",
105109
text: "#d1d0c5",
110+
error: "#ca4754",
111+
errorExtra: "#7e2a33",
112+
colorfulError: "#ca4754",
113+
colorfulErrorExtra: "#7e2a33",
106114
},
107115
bushido: {
108116
bg: "#242933",
@@ -605,8 +613,14 @@ export const themes: Record<ThemeName, Omit<Theme, "name">> = {
605613
darling: {
606614
bg: "#fec8cd",
607615
main: "#ffffff",
616+
caret: "#ffffff",
608617
sub: "#a30000",
618+
subAlt: "#f2babd",
609619
text: "#ffffff",
620+
error: "#2e7dde",
621+
errorExtra: "#2e7dde",
622+
colorfulError: "#2e7dde",
623+
colorfulErrorExtra: "#2e7dde",
610624
},
611625
repose_dark: {
612626
bg: "#2f3338",

0 commit comments

Comments
 (0)