init (move to laptop from pc)

This commit is contained in:
2023-08-03 21:18:50 +03:00
commit 5420715adc
29 changed files with 6094 additions and 0 deletions

1
app/assets/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
bootstrap*.min.*

38
app/assets/css/styles.css Normal file
View File

@@ -0,0 +1,38 @@
@import url('bootstrap-v5.3.1.min.css');
.nav-masthead .nav-link {
color: rgba(255, 255, 255, 0.5);
border-bottom: 0.25rem solid transparent;
}
.nav-masthead .nav-link:hover,
.nav-masthead .nav-link:focus {
border-bottom-color: rgba(255, 255, 255, 0.25);
}
.nav-masthead .nav-link + .nav-link {
margin-left: 1rem;
}
.nav-masthead .active {
color: #fff;
border-bottom-color: #fff;
}
.text-shadow {
text-shadow: 0 0.05rem 0.1rem rgba(0, 0, 0, 0.5);
}
svg.svg-icon {
flex-shrink: 0;
width: 1em;
height: 1em;
transition: transform 0.2s ease-in-out;
}
.btn-icon {
display: inline-flex;
gap: 0.375rem;
align-items: center;
justify-content: center;
}

79
app/assets/js/app.js Normal file
View File

@@ -0,0 +1,79 @@
/* main */
window.onload = function () {
let app = document.documentElement;
if (
window.matchMedia &&
window.matchMedia('(prefers-color-scheme: dark)').matches
) {
switch_theme('dark');
} else {
switch_theme('light');
}
// theme switcher
document
.getElementById('app_theme_switcher')
.addEventListener('click', switch_theme, false);
// routes handler
window.addEventListener('hashchange', location_handler);
location_handler();
};
/* Изменяет тему приложения */
function switch_theme() {
let app = document.documentElement;
let theme = app.getAttribute('data-bs-theme');
let theme_switcher = document.getElementById('app_theme_switcher');
let theme_icon = {
dark: '☀️',
light: '🌙',
};
if (theme == 'auto' || theme == 'light') {
theme_switcher.innerText = theme_icon['dark'];
app.setAttribute('data-bs-theme', 'dark');
} else {
theme_switcher.innerText = theme_icon['light'];
app.setAttribute('data-bs-theme', 'light');
}
}
const location_handler = async () => {
let location = window.location.hash.replace('#', '');
if (location.length == 0) {
location = '/';
}
const route = routes[location] || routes['404'];
const html = await fetch(route.template).then((response) => response.text());
document.getElementById('content').innerHTML = html;
document.title = route.title;
document
.querySelector('meta[name="description"]')
.setAttribute('content', route.description);
};
const routes = {
404: {
template: '/pages/404.html',
title: '404',
description: 'Page not found',
},
'/': {
template: '/pages/home.html',
title: 'Home',
description: '...',
},
about: {
template: '/pages/about.html',
title: 'About Us',
description: '...',
},
games: {
template: '/pages/games.html',
title: 'Games',
description: '...',
},
};