Dark mode switcher
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Halfdan Mouritzen 2024-02-27 23:15:24 +01:00
parent fa6fdb6ff2
commit 817ea2a702
6 changed files with 111 additions and 18 deletions

View file

@ -0,0 +1,52 @@
html.dark body {
--splash: #5b47e0;
background: var(--dark-dark);
color: var(--medium-dust)
}
html.dark h1,
html.dark h2,
html.dark h3,
html.dark h4,
html.dark h5,
html.dark h6,
html.dark footer,
html.dark nav ol li a {
color: var(--medium-dust);
}
html.dark nav ol li a:not(.current):hover {
border-color: var(--medium-dust);
}
html.dark header,
html.dark main aside,
html.dark nav {
background: #1d1d1d;
}
html.dark nav {
border: none;
}
html.dark hr {
border-color: var(--twilight);
}
html.dark main aside div,
html.dark article div.content-view {
background: var(--dark-twilight);
}
html.dark article table tbody {
background: var(--dark-twilight);
}
html.dark article table tbody tr:nth-child(2n+1) {
background: var(--dark);
}
html.dark article table tbody tr:nth-child(2n+1) td {
border-top: 1px solid var(--dark-dark);
border-bottom: 1px solid var(--dark-dark);
}

View file

@ -46,6 +46,7 @@ h6 {
/* Variables */ /* Variables */
:root { :root {
color-scheme: light dark;
/* Colors */ /* Colors */
--light: #ffffff; --light: #ffffff;
--light-dust: #fefef9; --light-dust: #fefef9;
@ -129,7 +130,21 @@ header>h1 {
font-size: 1.44em; font-size: 1.44em;
} }
header>a.logout { #switch-icon {
width: 30px;
height: 30px;
display: inline-block;
vertical-align: middle;
margin: 0 var(--space);
top: -2px;
position: relative;
}
#switch-icon #layer1 path {
fill: var(--twilight);
}
header>div>a#logout {
padding: 6px 12px; padding: 6px 12px;
border-radius: 6px; border-radius: 6px;
background: var(--twilight); background: var(--twilight);
@ -138,7 +153,7 @@ header>a.logout {
transition: background 0.2s; transition: background 0.2s;
} }
header>a.logout:hover { header>div>a#logout:hover {
background: var(--splash); background: var(--splash);
color: var(--light); color: var(--light);
} }
@ -519,6 +534,7 @@ span.time_remaining {
cursor: default; cursor: default;
} }
/*
@media (prefers-color-scheme: dark) { @media (prefers-color-scheme: dark) {
body { body {
background: var(--dark-dark); background: var(--dark-dark);
@ -536,8 +552,6 @@ span.time_remaining {
color: var(--medium-dust); color: var(--medium-dust);
} }
nav ol li a.current {}
nav ol li a:not(.current):hover { nav ol li a:not(.current):hover {
border-color: var(--medium-dust); border-color: var(--medium-dust);
} }
@ -573,6 +587,5 @@ span.time_remaining {
border-top: 1px solid var(--dark-dark); border-top: 1px solid var(--dark-dark);
border-bottom: 1px solid var(--dark-dark); border-bottom: 1px solid var(--dark-dark);
} }
}
*/
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -7,7 +7,6 @@
{% block content %} {% block content %}
<div class="content-view"> <div class="content-view">
<h2>{% trans "Email Addresses" %}</h2> <h2>{% trans "Email Addresses" %}</h2>
<p>Her kan du tilføje og ændre emailadresser tilknyttet din konto.</p>
<p>{% trans 'The following email addresses are associated with your account:' %}</p> <p>{% trans 'The following email addresses are associated with your account:' %}</p>
<hr /> <hr />
@ -17,7 +16,7 @@
{% csrf_token %} {% csrf_token %}
<fieldset class="blockLabels"> <fieldset class="blockLabels">
<div class="buttonHolder"> <div class="buttonHolder">
<button class="small" type="submit" name="action_primary" style="float:right">+ Add Email</button> <button class="small" name="action_add" style="float:right">Add Email</button>
<button class="small" disabled type="submit" id="action_primary" name="action_primary">Make Primary</button> <button class="small" disabled type="submit" id="action_primary" name="action_primary">Make Primary</button>
<button class="small" type="submit" name="action_send">Re-send Verification</button> <button class="small" type="submit" name="action_send">Re-send Verification</button>
<button class="small" type="submit" name="action_remove">Remove</button> <button class="small" type="submit" name="action_remove">Remove</button>

View file

@ -10,11 +10,39 @@
<title>{% block head_title %}{% endblock %} {{ site.name }}</title> <title>{% block head_title %}{% endblock %} {{ site.name }}</title>
<link rel="stylesheet" href="{% static "fonts/inter.css" %}"> <link rel="stylesheet" href="{% static "fonts/inter.css" %}">
<link rel="stylesheet" href="{% static "css/style.css" %}"> <link rel="stylesheet" href="{% static "css/style.css" %}">
<link rel="stylesheet" href="{% static "css/dark-style.css" %}">
<script>
const savedTheme = localStorage.getItem('theme');
if (savedTheme === "dark" || (savedTheme == null && window.matchMedia("(prefers-color-scheme: dark)").matches)) {
document.querySelector('html').classList.add('dark');
}
</script>
</head> </head>
<body> <body>
<header> <header>
<h1> data.coop membersystem </h1> <h1> data.coop membersystem </h1>
<a class="logout" href="{% url "account_logout" %}">Log out</a> <div>
<a id="theme-switcher" title="Switch theme">
<svg id="switch-icon"
width="20.00033mm"
height="20.000334mm"
viewBox="0 0 20.00033 20.000334"
version="1.1"
id="svg1"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<defs
id="defs1" />
<g id="layer1">
<path id="path1"
style="fill-opacity:1;stroke:none;stroke-width:0.697782;stroke-linecap:round"
d="M 9.999906,20.000334 A 10,10 0 0 0 20.000329,9.999911 10,10 0 0 0 9.999906,0 10,10 0 0 0 0,9.999911 10,10 0 0 0 9.999906,20.000334 Z m 0,-2.00039 V 1.99988 a 8,8 0 0 1 8.000023,8.000031 8,8 0 0 1 -8.000023,8.000033 z" />
</g>
</svg>
</a>
<a id="logout" href="{% url "account_logout" %}">Log out</a>
</div>
</header> </header>
<main> <main>
<aside> <aside>
@ -80,5 +108,14 @@
<footer> <footer>
data.coop membersystem version 0.0.1 data.coop membersystem version 0.0.1
</footer> </footer>
<script>
const themeSwitcher = document.getElementById('theme-switcher');
themeSwitcher.addEventListener('click', function() {
themeSwitcher.classList.toggle('active')
let isDark = document.querySelector('html').classList.toggle('dark');
localStorage.setItem('theme', isDark ? 'dark' : 'light');
});
</script>
</body> </body>
</html> </html>