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 {
|
||||
--background-color-light: #f4e8e9;
|
||||
--background-color-light-2: #f5e6f3;
|
||||
--text-color-light: #333;
|
||||
--confirm-color-light: #91d9bb;
|
||||
--link-color-light: #d291bc;
|
||||
--container-bg-light: #fff7f87a;
|
||||
--border-color-light: #692fcc;
|
||||
--error-color-light: #a83254;
|
||||
/* Light mode colors */
|
||||
--background-color-light: #f6f2ee; /* base00 */
|
||||
--background-color-light-2: #dbd1dd; /* base01 */
|
||||
--text-color-light: #3d2b5a; /* base05 */
|
||||
--confirm-color-light: #396847; /* base0B */
|
||||
--link-color-light: #6e33ce; /* base0E */
|
||||
--container-bg-light: #f4ece6; /* base07 */
|
||||
--border-color-light: #2848a9; /* base0D */
|
||||
--error-color-light: #a5222f; /* base08 */
|
||||
|
||||
--background-color-dark: #333;
|
||||
--background-color-dark-2: #2c2c2c;
|
||||
--text-color-dark: #f4e8e9;
|
||||
--confirm-color-dark: #4d8f73;
|
||||
--link-color-dark: #b86b77;
|
||||
--container-bg-dark: #424242ea;
|
||||
--border-color-dark: #956ade;
|
||||
--error-color-dark: #851736;
|
||||
/* Dark mode colors */
|
||||
--background-color-dark: #192330; /* base00 */
|
||||
--background-color-dark-2: #212e3f; /* base01 */
|
||||
--text-color-dark: #cdcecf; /* base05 */
|
||||
--confirm-color-dark: #81b29a; /* base0B */
|
||||
--link-color-dark: #9d79d6; /* base0E */
|
||||
--container-bg-dark: #29394f; /* base02 */
|
||||
--border-color-dark: #719cd6; /* base0D */
|
||||
--error-color-dark: #c94f6d; /* base08 */
|
||||
}
|
||||
|
||||
|
||||
[data-theme="DARK"] {
|
||||
--background-color: var(--background-color-dark);
|
||||
--background-color-2: var(--background-color-dark-2);
|
||||
|
@ -2,12 +2,17 @@
|
||||
@import "/static/css/form.css";
|
||||
@import "/static/css/table.css";
|
||||
|
||||
@font-face {
|
||||
font-family: 'GeistMono';
|
||||
src: url('/static/fonts/GeistMono-Medium.ttf') format('truetype');
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
color: var(--text-color);
|
||||
font-family: GeistMono;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: "Roboto", sans-serif;
|
||||
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">
|
||||
{{ template "content" . }}
|
||||
</div>
|
||||
<script data-main="/static/js/script.js" src="/static/js/require.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
{{ end }}
|
||||
|
Loading…
x
Reference in New Issue
Block a user