add static js
This commit is contained in:
parent
20d5255ff7
commit
8e33d86d27
BIN
template/.DS_Store
vendored
Normal file
BIN
template/.DS_Store
vendored
Normal file
Binary file not shown.
BIN
template/static/.DS_Store
vendored
Normal file
BIN
template/static/.DS_Store
vendored
Normal file
Binary file not shown.
@ -1,23 +1,27 @@
|
|||||||
|
/* Colors inspired by "day/night-fox" schemes */
|
||||||
:root {
|
:root {
|
||||||
--background-color-light: #f4e8e9;
|
/* Light mode colors */
|
||||||
--background-color-light-2: #f5e6f3;
|
--background-color-light: #f6f2ee; /* base00 */
|
||||||
--text-color-light: #333;
|
--background-color-light-2: #dbd1dd; /* base01 */
|
||||||
--confirm-color-light: #91d9bb;
|
--text-color-light: #3d2b5a; /* base05 */
|
||||||
--link-color-light: #d291bc;
|
--confirm-color-light: #396847; /* base0B */
|
||||||
--container-bg-light: #fff7f87a;
|
--link-color-light: #6e33ce; /* base0E */
|
||||||
--border-color-light: #692fcc;
|
--container-bg-light: #f4ece6; /* base07 */
|
||||||
--error-color-light: #a83254;
|
--border-color-light: #2848a9; /* base0D */
|
||||||
|
--error-color-light: #a5222f; /* base08 */
|
||||||
|
|
||||||
--background-color-dark: #333;
|
/* Dark mode colors */
|
||||||
--background-color-dark-2: #2c2c2c;
|
--background-color-dark: #192330; /* base00 */
|
||||||
--text-color-dark: #f4e8e9;
|
--background-color-dark-2: #212e3f; /* base01 */
|
||||||
--confirm-color-dark: #4d8f73;
|
--text-color-dark: #cdcecf; /* base05 */
|
||||||
--link-color-dark: #b86b77;
|
--confirm-color-dark: #81b29a; /* base0B */
|
||||||
--container-bg-dark: #424242ea;
|
--link-color-dark: #9d79d6; /* base0E */
|
||||||
--border-color-dark: #956ade;
|
--container-bg-dark: #29394f; /* base02 */
|
||||||
--error-color-dark: #851736;
|
--border-color-dark: #719cd6; /* base0D */
|
||||||
|
--error-color-dark: #c94f6d; /* base08 */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[data-theme="DARK"] {
|
[data-theme="DARK"] {
|
||||||
--background-color: var(--background-color-dark);
|
--background-color: var(--background-color-dark);
|
||||||
--background-color-2: var(--background-color-dark-2);
|
--background-color-2: var(--background-color-dark-2);
|
||||||
|
@ -2,12 +2,17 @@
|
|||||||
@import "/static/css/form.css";
|
@import "/static/css/form.css";
|
||||||
@import "/static/css/table.css";
|
@import "/static/css/table.css";
|
||||||
|
|
||||||
|
@font-face {
|
||||||
|
font-family: 'GeistMono';
|
||||||
|
src: url('/static/fonts/GeistMono-Medium.ttf') format('truetype');
|
||||||
|
}
|
||||||
|
|
||||||
* {
|
* {
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
color: var(--text-color);
|
color: var(--text-color);
|
||||||
|
font-family: GeistMono;
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
font-family: "Roboto", sans-serif;
|
|
||||||
background-color: var(--background-color);
|
background-color: var(--background-color);
|
||||||
}
|
}
|
||||||
|
BIN
template/static/fonts/.DS_Store
vendored
Normal file
BIN
template/static/fonts/.DS_Store
vendored
Normal file
Binary file not shown.
BIN
template/static/fonts/GeistMono-Medium.ttf
Normal file
BIN
template/static/fonts/GeistMono-Medium.ttf
Normal file
Binary file not shown.
7
template/static/js/components/formatDate.js
Normal file
7
template/static/js/components/formatDate.js
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
const timeElements = document.querySelectorAll(".time");
|
||||||
|
timeElements.forEach((timeElement) => {
|
||||||
|
const dateStr = timeElement.textContent.split(" ").slice(0, 3).join(" ");
|
||||||
|
const date = new Date(dateStr);
|
||||||
|
|
||||||
|
timeElement.textContent = date.toLocaleString();
|
||||||
|
});
|
6
template/static/js/components/infoBanners.js
Normal file
6
template/static/js/components/infoBanners.js
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
const infoBanners = document.querySelectorAll(".info");
|
||||||
|
Array.from(infoBanners).forEach((infoBanner) => {
|
||||||
|
infoBanner.addEventListener("click", () => {
|
||||||
|
infoBanner.remove();
|
||||||
|
});
|
||||||
|
});
|
27
template/static/js/components/themeSwitcher.js
Normal file
27
template/static/js/components/themeSwitcher.js
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
const THEMES = {
|
||||||
|
DARK: "DARK",
|
||||||
|
LIGHT: "LIGHT",
|
||||||
|
};
|
||||||
|
|
||||||
|
const flipFlopTheme = (theme) =>
|
||||||
|
THEMES[theme] === THEMES.DARK ? THEMES.LIGHT : THEMES.DARK;
|
||||||
|
|
||||||
|
const themePickerText = {
|
||||||
|
DARK: "light mode.",
|
||||||
|
LIGHT: "dark mode.",
|
||||||
|
};
|
||||||
|
|
||||||
|
const themeSwitcher = document.getElementById("theme-switcher");
|
||||||
|
|
||||||
|
const setTheme = (theme) => {
|
||||||
|
themeSwitcher.textContent = `${themePickerText[theme]}`;
|
||||||
|
|
||||||
|
document.documentElement.setAttribute("data-theme", theme);
|
||||||
|
localStorage.setItem("theme", theme);
|
||||||
|
};
|
||||||
|
|
||||||
|
themeSwitcher.addEventListener("click", () =>
|
||||||
|
setTheme(flipFlopTheme(document.documentElement.getAttribute("data-theme"))),
|
||||||
|
);
|
||||||
|
|
||||||
|
setTheme(localStorage.getItem("theme") || THEMES.LIGHT);
|
5
template/static/js/require.js
Normal file
5
template/static/js/require.js
Normal file
File diff suppressed because one or more lines are too long
6
template/static/js/script.js
Normal file
6
template/static/js/script.js
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
const scripts = [
|
||||||
|
"/static/js/components/themeSwitcher.js",
|
||||||
|
"/static/js/components/formatDate.js",
|
||||||
|
"/static/js/components/infoBanners.js",
|
||||||
|
];
|
||||||
|
requirejs(scripts);
|
11
template/static/js/util/setThemeBeforeRender.js
Normal file
11
template/static/js/util/setThemeBeforeRender.js
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
const preferredMode = window.matchMedia("(prefers-color-scheme: dark)").matches
|
||||||
|
? "DARK"
|
||||||
|
: "LIGHT";
|
||||||
|
|
||||||
|
// sets theme before rendering & jquery loaded to prevent flashing of uninitialized theme
|
||||||
|
// (ugly white background)
|
||||||
|
localStorage.setItem("theme", localStorage.getItem("theme") || preferredMode);
|
||||||
|
document.documentElement.setAttribute(
|
||||||
|
"data-theme",
|
||||||
|
localStorage.getItem("theme"),
|
||||||
|
);
|
@ -11,6 +11,7 @@
|
|||||||
<div id="content" class="container">
|
<div id="content" class="container">
|
||||||
{{ template "content" . }}
|
{{ template "content" . }}
|
||||||
</div>
|
</div>
|
||||||
|
<script data-main="/static/js/script.js" src="/static/js/require.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user