summaryrefslogtreecommitdiffstats
path: root/dist/js/lib/themes.js
blob: bc5d485da014713b34726eb930cb80fa6d605d68 (plain) (blame)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152

        "background-color": "rgba(255, 255, 255, 1)",
        "background-accent": "rgba(0, 156, 101, 0.2)",
        "background-accent-1": "rgb(192, 219, 207, 1)",

        "color-header-bold": "rgba(255, 255, 255, 1)",
        "color-header-span": "rgba(255, 255, 255, 1)",

        "color-text": "rgba(0, 0, 0, 1)",
        "color-text-light": "rgba(97, 97, 97, 1)",
        "color-label-text": "rgba(158, 158, 158, 1)",
        "color-table-hover": "rgba(242, 242, 242, 0.5)",

        "color-sidenav-background": "rgba(255, 255, 255, 1)",
        "color-sidenav-text": "rgba(0, 0, 0, 0.87)",
        "color-sidenav-header": "rgba(0, 0, 0, 0.54)",
        "color-divider": "rgba(224, 224, 224, 1)",

        "color-btn-flat": "rgba(52, 52, 52, 1)",
        "color-btn-flat-disabled": "rgba(178, 178, 178, 1)"

    },
    dark: {
        "color-primary": "rgba(0, 128, 83, 1)",
        "color-secondary": "rgba(0, 94, 61, 1)",
        "color-accent": "rgba(20, 117, 83, 1)",
        "color-primary-light": "rgba(6, 137, 9, 1)", // it's not really light anymore, is it?
        "color-invalid": "rgba(192, 0, 0, 1)",
        "color-primary-transparent": "rgba(0, 128, 83, 0.3)",

        "background-color": "rgba(31, 31, 31, 1)",
        "background-accent": "rgba(0, 92, 44, 0.2)",
        "background-accent-1": "rgb(26, 43, 32, 1)",

        "color-header-bold": "rgba(255, 255, 255, 1)",
        "color-header-span": "rgba(255, 255, 255, 1)",

        "color-text": "rgba(189, 189, 189, 1)",
        "color-text-light": "rgba(160, 160, 160, 1)",
        "color-label-text": "rgba(158, 158, 158, 1)",
        "color-table-hover": "rgba(70, 70, 70, 0.5)",

        "color-sidenav-background": "rgba(31, 31, 31, 1)",
        "color-sidenav-text": "rgba(189, 189, 189, 1)",
        "color-sidenav-header": "rgba(189, 189, 189, 0.54)",
        "color-divider": "rgba(80, 80, 80, 1)",

        "color-btn-flat": "rgba(178, 178, 178, 1)",
        "color-btn-flat-disabled": "rgba(52, 52, 52, 1)"
    },
    night: {
        "color-primary": "rgba(0, 79, 51, 1)",
        "color-secondary": "rgba(0, 94, 61, 1)",
        "color-accent": "rgba(28, 107, 79, 1)",
        "color-primary-light": "rgba(0, 77, 2, 1)", // it's not really light anymore, is it?
        "color-invalid": "rgba(138, 0, 0, 1)",
        "color-primary-transparent": "rgba(0, 79, 51, 0.3)",

        "background-color": "rgba(0, 0, 0, 1)",
        "background-accent": "rgba(0, 38, 18, 0.2)",
        "background-accent-1": "rgb(20, 33, 25, 1)",

        "color-header-bold": "rgba(255, 255, 255, 1)",
        "color-header-span": "rgba(255, 255, 255, 1)",

        "color-text": "rgba(255, 255, 255, 1)",
        "color-text-light": "rgba(200, 200, 200, 1)",
        "color-label-text": "rgba(158, 158, 158, 1)",
        "color-table-hover": "rgba(43, 43, 43, 0.5)",

        "color-sidenav-background": "rgba(0, 0, 0, 1)",
        "color-sidenav-text": "rgba(255, 255, 255, 1)",
        "color-sidenav-header": "rgba(255, 255, 255, 0.54)",
        "color-divider": "rgba(50, 50, 50, 1)",

        "color-btn-flat": "rgba(178, 178, 178, 1)",
        "color-btn-flat-disabled": "rgba(52, 52, 52, 1)"
    },
    left: {
        "color-primary": "rgba(173, 0, 0, 1)",
        "color-secondary": "rgba(148, 15, 15, 1)",
        "color-accent": "rgba(181, 42, 42, 1)",
        "color-primary-light": "rgba(250, 230, 230, 1)",
        "color-invalid": "rgba(120, 0, 108, 1)",
        "color-primary-transparent": "rgba(173, 0, 0, 0.3)",

        "background-color": "rgba(255, 255, 255, 1)",
        "background-accent": "rgba(199, 38, 38, 0.2)",
        "background-accent-1": "rgb(219, 192, 192, 1)",

        "color-header-bold": "rgba(255, 255, 255, 1)",
        "color-header-span": "rgba(255, 255, 255, 1)",

        "color-text": "rgba(0, 0, 0, 1)",
        "color-text-light": "rgba(97, 97, 97, 1)",
        "color-label-text": "rgba(158, 158, 158, 1)",
        "color-table-hover": "rgba(242, 242, 242, 0.5)",

        "color-sidenav-background": "rgba(255, 255, 255, 1)",
        "color-sidenav-text": "rgba(0, 0, 0, 0.87)",
        "color-sidenav-header": "rgba(0, 0, 0, 0.54)",
        "color-divider": "rgba(224, 224, 224, 1)",

        "color-btn-flat": "rgba(52, 52, 52, 1)",
        "color-btn-flat-disabled": "rgba(178, 178, 178, 1)"
    },
    right: {
        "color-primary": "rgba(7, 0, 105, 1)",
        "color-secondary": "rgba(0, 94, 156, 1)",
        "color-accent": "rgba(217, 214, 80, 1)",
        "color-primary-light": "rgba(195, 191, 255, 1)",
        "color-invalid": "rgba(192, 0, 0, 1)",
        "color-primary-transparent": "rgba(7, 0, 105, 0.3)",

        "background-color": "rgba(255, 255, 255, 1)",
        "background-accent": "rgba(0, 60, 156, 0.2)",
        "background-accent-1": "rgb(215, 219, 192, 1)",

        "color-header-bold": "rgba(255, 255, 255, 1)",
        "color-header-span": "rgba(255, 255, 255, 1)",

        "color-text": "rgba(0, 0, 0, 1)",
        "color-text-light": "rgba(97, 97, 97, 1)",
        "color-label-text": "rgba(158, 158, 158, 1)",
        "color-table-hover": "rgba(242, 242, 242, 0.5)",

        "color-sidenav-background": "rgba(255, 255, 255, 1)",
        "color-sidenav-text": "rgba(0, 0, 0, 0.87)",
        "color-sidenav-header": "rgba(0, 0, 0, 0.54)",
        "color-divider": "rgba(224, 224, 224, 1)",

        "color-btn-flat": "rgba(52, 52, 52, 1)",
        "color-btn-flat-disabled": "rgba(178, 178, 178, 1)"
    }
}

function applyTheme(themeName) {
    for (const [property, value] of Object.entries(THEME_COLOR_SCHEMES[themeName])) {
        document.documentElement.style.setProperty(`--${property}`, value);
    }
}

document.addEventListener("DOMContentLoaded", () => {
    localforage.getItem("theme").then((selectedTheme) => {
        if (selectedTheme == null) {
            let isOsDarkTheme = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
            applyTheme(isOsDarkTheme ? "dark" : "light");
        } else {
            applyTheme(selectedTheme);
        }
    });
});