Merge branch 'main' of ssh://git.hofer.link:2222/philipp/website-risg
All checks were successful
CI/CD Pipeline / deploy-main (push) Successful in 9m39s
All checks were successful
CI/CD Pipeline / deploy-main (push) Successful in 9m39s
This commit is contained in:
commit
bed8fb7ba2
@ -119,6 +119,12 @@ button {
|
||||
|
||||
body > footer {
|
||||
padding-block: calc(var(--pico-block-spacing-vertical) * 2);
|
||||
background: linear-gradient(180deg, black, transparent);
|
||||
}
|
||||
|
||||
:root:not([data-theme=dark]) body > footer,
|
||||
[data-theme=light] body > footer {
|
||||
background: linear-gradient(180deg, rgba(0,0,0,.1), transparent);
|
||||
}
|
||||
|
||||
/* approx 800px */
|
||||
@ -177,3 +183,59 @@ body > footer {
|
||||
font-style: italic;
|
||||
padding: calc(var(--pico-spacing) / 3) 0;
|
||||
}
|
||||
|
||||
/* List index.html */
|
||||
ol {
|
||||
counter-reset: index;
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* List element index.html */
|
||||
ol li {
|
||||
counter-increment: index;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 12px 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
|
||||
/* Element counter */
|
||||
ol li::before {
|
||||
content: "§";
|
||||
font-size: 1.5rem;
|
||||
text-align: right;
|
||||
font-weight: bold;
|
||||
padding-right: 12px;
|
||||
align-self: flex-start;
|
||||
background-image: linear-gradient(to bottom, #08AEEA, #2AF598);
|
||||
background-attachment: fixed;
|
||||
-webkit-background-clip: text;
|
||||
background-clip: text;
|
||||
-webkit-text-fill-color: transparent;
|
||||
}
|
||||
|
||||
|
||||
/* Element separation */
|
||||
ol li + li {
|
||||
border-top: var(--pico-contrast-focus) solid 1px;
|
||||
}
|
||||
|
||||
.hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.inline {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
:root:not([data-theme=dark]) .dark-inline,
|
||||
[data-theme=light] .dark-inline{
|
||||
display: inline;
|
||||
}
|
||||
|
||||
:root:not([data-theme=dark]) .dark-hidden,
|
||||
[data-theme=light] .dark-hidden {
|
||||
display: none;
|
||||
}
|
@ -111,7 +111,7 @@ fn main() {
|
||||
.replace("{{title}}", &lawname);
|
||||
|
||||
li_of_files.push_str(&format!(
|
||||
"<li><a href='./{law_name}'>{lawname}</a></li><br />\n"
|
||||
"<li><a href='./{law_name}' title='{law_name}' class='contrast'>{lawname}</a></li>"
|
||||
));
|
||||
fs::write(&format!("output/{law_name}.html"), &site).expect("Unable to write file");
|
||||
}
|
||||
@ -124,6 +124,9 @@ fn main() {
|
||||
let js = fs::read_to_string("templates/app.js").unwrap();
|
||||
fs::write(&format!("output/app.js"), &js).expect("Unable to write file");
|
||||
|
||||
let js = fs::read_to_string("templates/toggle.js").unwrap();
|
||||
fs::write(&format!("output/toggle.js"), &js).expect("Unable to write file");
|
||||
|
||||
let mut index = fs::read_to_string("templates/index.html").unwrap();
|
||||
index = index.replace("{{content}}", &li_of_files);
|
||||
fs::write(&format!("output/index.html"), &index).expect("Unable to write file");
|
||||
|
@ -1,21 +1,71 @@
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
toggleSummary();
|
||||
changeTheme();
|
||||
initcolorTheme();
|
||||
});
|
||||
|
||||
function toggleSummary() {
|
||||
const openBtns = document.querySelectorAll('.open-js');
|
||||
const closeBtns = document.querySelectorAll('.close-js');
|
||||
const detailElements = document.querySelectorAll('details');
|
||||
function changeTheme() {
|
||||
let toggleBtn = document.querySelector('#theme-toggle-js');
|
||||
|
||||
openBtns.forEach(function(openBtn) {
|
||||
openBtn.addEventListener('click', function(){
|
||||
detailElements.forEach((detail) => detail.setAttribute("open", ""));
|
||||
});
|
||||
});
|
||||
|
||||
closeBtns.forEach(function(closeBtn) {
|
||||
closeBtn.addEventListener('click', function(){
|
||||
detailElements.forEach((detail) => detail.removeAttribute("open", ""));
|
||||
});
|
||||
if(toggleBtn) {
|
||||
toggleBtn.addEventListener('click', function() {
|
||||
if(toggleBtn.dataset.theme === 'light') {
|
||||
setTheme('dark', true);
|
||||
} else {
|
||||
setTheme('light', true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/***
|
||||
* init javascript
|
||||
* 1) detect native color scheme or use set theme in local storage
|
||||
* 2) detect view (desktop or responsive) if on mobile device with touch screen
|
||||
* 3) set base font size to 112.5% -> 18px
|
||||
*/
|
||||
function initcolorTheme() {
|
||||
colorThemeWatcher();
|
||||
let theme = localStorage.getItem('theme');
|
||||
if (theme == null || theme === 'auto') {
|
||||
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
||||
setTheme('dark', false);
|
||||
} else {
|
||||
setTheme('light', false);
|
||||
}
|
||||
} else {
|
||||
setTheme(theme)
|
||||
}
|
||||
}
|
||||
|
||||
/***
|
||||
* Listener operating system native color configuration
|
||||
*/
|
||||
function colorThemeWatcher() {
|
||||
try {
|
||||
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', e => {
|
||||
setTheme(e.matches ? 'dark' : 'light');
|
||||
});
|
||||
} catch {
|
||||
console.warn('color theme watcher not supported');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Define color scheme, colors without losing the base font size configuration
|
||||
* and add data-theme to html tag
|
||||
* @param theme
|
||||
*/
|
||||
function setTheme(theme, setLocalStorage = true) {
|
||||
let toggleBtn = document.querySelector('#theme-toggle-js');
|
||||
|
||||
if (setLocalStorage) {
|
||||
localStorage.setItem('theme', theme);
|
||||
}
|
||||
if (toggleBtn) toggleBtn.setAttribute('data-theme', theme);
|
||||
|
||||
if (document.documentElement.dataset.theme === 'dark' && theme === 'light') {
|
||||
document.documentElement.dataset.theme = 'light';
|
||||
} else if(document.documentElement.dataset.theme === 'light' && theme === 'dark'){
|
||||
document.documentElement.dataset.theme = 'dark';
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
<html lang="de">
|
||||
<html lang="de" data-theme="dark">
|
||||
<head>
|
||||
<link rel="stylesheet" href="pico.min.css" />
|
||||
<link rel="stylesheet" href="style.css" />
|
||||
@ -19,7 +19,8 @@
|
||||
{{content}}
|
||||
</ol>
|
||||
</main>
|
||||
<footer class="container">
|
||||
<footer>
|
||||
<div class="container">
|
||||
<nav>
|
||||
<ul>
|
||||
<li>
|
||||
@ -31,6 +32,20 @@
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<button id="theme-toggle-js" type="button" data-theme="light" class="btn btn-primary">
|
||||
<span class="inline dark-hidden">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16">
|
||||
<path d="M8 11a3 3 0 1 1 0-6 3 3 0 0 1 0 6zm0 1a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM8 0a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-1 0v-2A.5.5 0 0 1 8 0zm0 13a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-1 0v-2A.5.5 0 0 1 8 13zm8-5a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1 0-1h2a.5.5 0 0 1 .5.5zM3 8a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1 0-1h2A.5.5 0 0 1 3 8zm10.657-5.657a.5.5 0 0 1 0 .707l-1.414 1.415a.5.5 0 1 1-.707-.708l1.414-1.414a.5.5 0 0 1 .707 0zm-9.193 9.193a.5.5 0 0 1 0 .707L3.05 13.657a.5.5 0 0 1-.707-.707l1.414-1.414a.5.5 0 0 1 .707 0zm9.193 2.121a.5.5 0 0 1-.707 0l-1.414-1.414a.5.5 0 0 1 .707-.707l1.414 1.414a.5.5 0 0 1 0 .707zM4.464 4.465a.5.5 0 0 1-.707 0L2.343 3.05a.5.5 0 1 1 .707-.707l1.414 1.414a.5.5 0 0 1 0 .708z"/>
|
||||
</svg>
|
||||
</span>
|
||||
<span class="hidden dark-inline">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16">
|
||||
<path d="M6 .278a.768.768 0 0 1 .08.858 7.208 7.208 0 0 0-.878 3.46c0 4.021 3.278 7.277 7.318 7.277.527 0 1.04-.055 1.533-.16a.787.787 0 0 1 .81.316.733.733 0 0 1-.031.893A8.349 8.349 0 0 1 8.344 16C3.734 16 0 12.286 0 7.71 0 4.266 2.114 1.312 5.124.06A.752.752 0 0 1 6 .278zM4.858 1.311A7.269 7.269 0 0 0 1.025 7.71c0 4.02 3.279 7.276 7.319 7.276a7.316 7.316 0 0 0 5.205-2.162c-.337.042-.68.063-1.029.063-4.61 0-8.343-3.714-8.343-8.29 0-1.167.242-2.278.681-3.286z"/>
|
||||
</svg>
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
</footer>
|
||||
<script src="app.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<html lang="de">
|
||||
<html lang="de" data-theme="dark">
|
||||
<head>
|
||||
<link rel="stylesheet" href="pico.min.css" />
|
||||
<link rel="stylesheet" href="style.css" />
|
||||
@ -22,7 +22,8 @@
|
||||
<h1><mark>{{title}}</mark></h1>
|
||||
{{content}}
|
||||
</main>
|
||||
<footer class="container">
|
||||
<footer>
|
||||
<div class="container">
|
||||
<nav>
|
||||
<ul>
|
||||
<li>
|
||||
@ -34,7 +35,21 @@
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<button id="theme-toggle-js" type="button" data-theme="light" class="btn btn-primary">
|
||||
<span class="inline dark-hidden">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16">
|
||||
<path d="M8 11a3 3 0 1 1 0-6 3 3 0 0 1 0 6zm0 1a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM8 0a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-1 0v-2A.5.5 0 0 1 8 0zm0 13a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-1 0v-2A.5.5 0 0 1 8 13zm8-5a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1 0-1h2a.5.5 0 0 1 .5.5zM3 8a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1 0-1h2A.5.5 0 0 1 3 8zm10.657-5.657a.5.5 0 0 1 0 .707l-1.414 1.415a.5.5 0 1 1-.707-.708l1.414-1.414a.5.5 0 0 1 .707 0zm-9.193 9.193a.5.5 0 0 1 0 .707L3.05 13.657a.5.5 0 0 1-.707-.707l1.414-1.414a.5.5 0 0 1 .707 0zm9.193 2.121a.5.5 0 0 1-.707 0l-1.414-1.414a.5.5 0 0 1 .707-.707l1.414 1.414a.5.5 0 0 1 0 .707zM4.464 4.465a.5.5 0 0 1-.707 0L2.343 3.05a.5.5 0 1 1 .707-.707l1.414 1.414a.5.5 0 0 1 0 .708z"/>
|
||||
</svg>
|
||||
</span>
|
||||
<span class="hidden dark-inline">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16">
|
||||
<path d="M6 .278a.768.768 0 0 1 .08.858 7.208 7.208 0 0 0-.878 3.46c0 4.021 3.278 7.277 7.318 7.277.527 0 1.04-.055 1.533-.16a.787.787 0 0 1 .81.316.733.733 0 0 1-.031.893A8.349 8.349 0 0 1 8.344 16C3.734 16 0 12.286 0 7.71 0 4.266 2.114 1.312 5.124.06A.752.752 0 0 1 6 .278zM4.858 1.311A7.269 7.269 0 0 0 1.025 7.71c0 4.02 3.279 7.276 7.319 7.276a7.316 7.316 0 0 0 5.205-2.162c-.337.042-.68.063-1.029.063-4.61 0-8.343-3.714-8.343-8.29 0-1.167.242-2.278.681-3.286z"/>
|
||||
</svg>
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
</footer>
|
||||
<script src="app.js"></script>
|
||||
<script src="toggle.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -119,6 +119,12 @@ button {
|
||||
|
||||
body > footer {
|
||||
padding-block: calc(var(--pico-block-spacing-vertical) * 2);
|
||||
background: linear-gradient(180deg, black, transparent);
|
||||
}
|
||||
|
||||
:root:not([data-theme=dark]) body > footer,
|
||||
[data-theme=light] body > footer {
|
||||
background: linear-gradient(180deg, rgba(0,0,0,.1), transparent);
|
||||
}
|
||||
|
||||
/* approx 800px */
|
||||
@ -177,3 +183,59 @@ body > footer {
|
||||
font-style: italic;
|
||||
padding: calc(var(--pico-spacing) / 3) 0;
|
||||
}
|
||||
|
||||
/* List index.html */
|
||||
ol {
|
||||
counter-reset: index;
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* List element index.html */
|
||||
ol li {
|
||||
counter-increment: index;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 12px 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
|
||||
/* Element counter */
|
||||
ol li::before {
|
||||
content: "§";
|
||||
font-size: 1.5rem;
|
||||
text-align: right;
|
||||
font-weight: bold;
|
||||
padding-right: 12px;
|
||||
align-self: flex-start;
|
||||
background-image: linear-gradient(to bottom, #08AEEA, #2AF598);
|
||||
background-attachment: fixed;
|
||||
-webkit-background-clip: text;
|
||||
background-clip: text;
|
||||
-webkit-text-fill-color: transparent;
|
||||
}
|
||||
|
||||
|
||||
/* Element separation */
|
||||
ol li + li {
|
||||
border-top: var(--pico-contrast-focus) solid 1px;
|
||||
}
|
||||
|
||||
.hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.inline {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
:root:not([data-theme=dark]) .dark-inline,
|
||||
[data-theme=light] .dark-inline{
|
||||
display: inline;
|
||||
}
|
||||
|
||||
:root:not([data-theme=dark]) .dark-hidden,
|
||||
[data-theme=light] .dark-hidden {
|
||||
display: none;
|
||||
}
|
21
templates/toggle.js
Normal file
21
templates/toggle.js
Normal file
@ -0,0 +1,21 @@
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
toggleSummary();
|
||||
});
|
||||
|
||||
function toggleSummary() {
|
||||
const openBtns = document.querySelectorAll('.open-js');
|
||||
const closeBtns = document.querySelectorAll('.close-js');
|
||||
const detailElements = document.querySelectorAll('details');
|
||||
|
||||
openBtns.forEach(function(openBtn) {
|
||||
openBtn.addEventListener('click', function(){
|
||||
detailElements.forEach((detail) => detail.setAttribute("open", ""));
|
||||
});
|
||||
});
|
||||
|
||||
closeBtns.forEach(function(closeBtn) {
|
||||
closeBtn.addEventListener('click', function(){
|
||||
detailElements.forEach((detail) => detail.removeAttribute("open", ""));
|
||||
});
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue
Block a user