Add more elements to the dark mode
This commit is contained in:
parent
366d135285
commit
2a46a70620
13 changed files with 105 additions and 13 deletions
|
@ -37,7 +37,7 @@ openpyxl==3.0.10 # via tablib
|
||||||
packaging==21.3 # via redis
|
packaging==21.3 # via redis
|
||||||
pillow==9.2.0 # via wagtail
|
pillow==9.2.0 # via wagtail
|
||||||
psycopg2==2.9.3 # via -r requirements/base.in
|
psycopg2==2.9.3 # via -r requirements/base.in
|
||||||
pygments==2.12.0 # via -r requirements/base.in
|
pygments==2.13.0 # via -r requirements/base.in
|
||||||
pyparsing==3.0.9 # via packaging
|
pyparsing==3.0.9 # via packaging
|
||||||
pytz==2022.1 # via django-modelcluster, djangorestframework, l18n
|
pytz==2022.1 # via django-modelcluster, djangorestframework, l18n
|
||||||
redis==4.3.4 # via django-redis, django-rq, rq
|
redis==4.3.4 # via django-redis, django-rq, rq
|
||||||
|
|
|
@ -60,7 +60,7 @@ platformdirs==2.5.2 # via black
|
||||||
psycopg2==2.9.3 # via -r requirements/base.txt
|
psycopg2==2.9.3 # via -r requirements/base.txt
|
||||||
pycodestyle==2.8.0 # via flake8
|
pycodestyle==2.8.0 # via flake8
|
||||||
pyflakes==2.4.0 # via flake8
|
pyflakes==2.4.0 # via flake8
|
||||||
pygments==2.12.0 # via -r requirements/base.txt
|
pygments==2.13.0 # via -r requirements/base.txt
|
||||||
pyparsing==3.0.9 # via -r requirements/base.txt, packaging
|
pyparsing==3.0.9 # via -r requirements/base.txt, packaging
|
||||||
python-dateutil==2.8.2 # via faker
|
python-dateutil==2.8.2 # via faker
|
||||||
pytz==2022.1 # via -r requirements/base.txt, django-modelcluster, djangorestframework, l18n
|
pytz==2022.1 # via -r requirements/base.txt, django-modelcluster, djangorestframework, l18n
|
||||||
|
|
|
@ -1,17 +1,26 @@
|
||||||
const DARK_MODE_CLASS = "dark-mode";
|
const DARK_MODE_CLASS = "dark-mode";
|
||||||
const STORAGE_KEY = "dark-mode";
|
const STORAGE_KEY = "dark-mode";
|
||||||
|
|
||||||
const body = document.getElementsByTagName("body")[0];
|
const htmlTag = document.getElementsByTagName("html")[0];
|
||||||
const darkModeToggle = document.getElementById("dark-mode-toggle");
|
const darkModeToggle = document.getElementById("dark-mode-toggle");
|
||||||
|
|
||||||
const matchesDarkMode = window.matchMedia("(prefers-color-scheme: dark)");
|
const matchesDarkMode = window.matchMedia("(prefers-color-scheme: dark)");
|
||||||
|
|
||||||
|
const darkModeCodeStyles = document.getElementById("pygments-dark");
|
||||||
|
const lightModeCodeStyles = document.getElementById("pygments-light");
|
||||||
|
|
||||||
function handleDarkMode(darkMode) {
|
function handleDarkMode(darkMode) {
|
||||||
window.localStorage.setItem(STORAGE_KEY, darkMode.toString());
|
window.localStorage.setItem(STORAGE_KEY, darkMode.toString());
|
||||||
|
|
||||||
if (darkMode) {
|
if (darkMode) {
|
||||||
body.classList.add(DARK_MODE_CLASS);
|
htmlTag.classList.add(DARK_MODE_CLASS);
|
||||||
} else {
|
} else {
|
||||||
body.classList.remove(DARK_MODE_CLASS);
|
htmlTag.classList.remove(DARK_MODE_CLASS);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (darkModeCodeStyles) {
|
||||||
|
darkModeCodeStyles.sheet.disabled = !darkMode;
|
||||||
|
lightModeCodeStyles.sheet.disabled = darkMode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,6 +41,6 @@ window.addEventListener("load", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
window.setTimeout(() => {
|
window.setTimeout(() => {
|
||||||
body.classList.add("dark-mode-animate");
|
htmlTag.classList.add("dark-mode-animate");
|
||||||
}, 1000);
|
}, 1000);
|
||||||
});
|
});
|
||||||
|
|
|
@ -46,5 +46,17 @@ div.block-mermaid {
|
||||||
|
|
||||||
img {
|
img {
|
||||||
width: unset;
|
width: unset;
|
||||||
|
|
||||||
|
@include dark-mode {
|
||||||
|
filter: invert(100%);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
div.block-code .highlight {
|
||||||
|
pre,
|
||||||
|
span,
|
||||||
|
& {
|
||||||
|
@include dark-mode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,3 +41,9 @@ section.content {
|
||||||
max-width: calc(99% - ($column-gap * 2));
|
max-width: calc(99% - ($column-gap * 2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.tags.has-addons {
|
||||||
|
@include dark-mode {
|
||||||
|
filter: invert(100%);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -3,8 +3,8 @@ footer.footer {
|
||||||
padding: 1rem;
|
padding: 1rem;
|
||||||
|
|
||||||
@include dark-mode {
|
@include dark-mode {
|
||||||
background-color: $dark;
|
background-color: $black;
|
||||||
color: $grey-light;
|
color: $dark-mode-text;
|
||||||
|
|
||||||
a:hover {
|
a:hover {
|
||||||
color: $grey-lighter;
|
color: $grey-lighter;
|
||||||
|
|
|
@ -14,6 +14,10 @@ section.hero {
|
||||||
background-color: $white;
|
background-color: $white;
|
||||||
display: block;
|
display: block;
|
||||||
|
|
||||||
|
@include dark-mode {
|
||||||
|
background-color: $dark-mode-background;
|
||||||
|
}
|
||||||
|
|
||||||
&.stuck {
|
&.stuck {
|
||||||
box-shadow: $shadow;
|
box-shadow: $shadow;
|
||||||
}
|
}
|
||||||
|
@ -36,6 +40,18 @@ section.hero {
|
||||||
.dropdown-content {
|
.dropdown-content {
|
||||||
overflow-y: scroll;
|
overflow-y: scroll;
|
||||||
max-height: 50vh;
|
max-height: 50vh;
|
||||||
|
|
||||||
|
@include dark-mode {
|
||||||
|
background-color: $grey-dark;
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: $dark-mode-text;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background-color: $grey-darker;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ul {
|
ul {
|
||||||
|
@ -47,6 +63,18 @@ section.hero {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.button {
|
||||||
|
@include dark-mode {
|
||||||
|
background-color: $grey-darker;
|
||||||
|
border-color: $black;
|
||||||
|
color: $dark-mode-text;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
border-color: $grey-dark;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.subtitle {
|
.subtitle {
|
||||||
margin-bottom: 0.5rem;
|
margin-bottom: 0.5rem;
|
||||||
}
|
}
|
||||||
|
@ -55,6 +83,10 @@ section.hero {
|
||||||
margin-bottom: 1.25rem;
|
margin-bottom: 1.25rem;
|
||||||
font-weight: 300;
|
font-weight: 300;
|
||||||
font-size: 3.5rem;
|
font-size: 3.5rem;
|
||||||
|
|
||||||
|
@include dark-mode {
|
||||||
|
color: $dark-mode-text;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.column {
|
.column {
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
body.page-homepage {
|
body.page-homepage {
|
||||||
|
height: 100vh;
|
||||||
|
|
||||||
main {
|
main {
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
background-size: cover;
|
background-size: cover;
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
@mixin dark-mode {
|
@mixin dark-mode {
|
||||||
// Ensure animations aren't for the initial transition
|
// Ensure animations aren't for the initial transition
|
||||||
body.dark-mode-animate & {
|
html.dark-mode-animate & {
|
||||||
transition-duration: 0.5s;
|
transition-duration: 0.5s;
|
||||||
transition-property: color, background-color;
|
transition-property: color, background-color, border-color, filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
body.dark-mode & {
|
html.dark-mode & {
|
||||||
@content;
|
@content;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,10 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.navbar-item:hover {
|
||||||
|
background-color: transparent !important;
|
||||||
|
}
|
||||||
|
|
||||||
#dark-mode-toggle i {
|
#dark-mode-toggle i {
|
||||||
transition: transform 0.5s !important;
|
transition: transform 0.5s !important;
|
||||||
|
|
||||||
|
@ -14,3 +18,9 @@
|
||||||
transform: rotate(180deg);
|
transform: rotate(180deg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nav.navbar {
|
||||||
|
@include dark-mode {
|
||||||
|
background-color: $black;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
2
static/src/scss/_variables.scss
Normal file
2
static/src/scss/_variables.scss
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
$dark-mode-background: $dark;
|
||||||
|
$dark-mode-text: $grey-lighter;
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
@import "bulma/bulma";
|
@import "bulma/bulma";
|
||||||
|
|
||||||
|
@import "variables";
|
||||||
@import "navbar";
|
@import "navbar";
|
||||||
@import "homepage";
|
@import "homepage";
|
||||||
@import "footer";
|
@import "footer";
|
||||||
|
@ -20,10 +21,15 @@
|
||||||
|
|
||||||
html,
|
html,
|
||||||
body {
|
body {
|
||||||
height: 100%;
|
min-height: 100vh;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
font-variant-ligatures: none;
|
font-variant-ligatures: none;
|
||||||
|
|
||||||
|
@include dark-mode {
|
||||||
|
background-color: $dark-mode-background;
|
||||||
|
color: $dark-mode-text;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
main {
|
main {
|
||||||
|
@ -32,4 +38,16 @@ main {
|
||||||
|
|
||||||
a {
|
a {
|
||||||
transition: color 0.25s, background-color 0.25s;
|
transition: color 0.25s, background-color 0.25s;
|
||||||
|
|
||||||
|
@include dark-mode {
|
||||||
|
&:hover {
|
||||||
|
color: $grey-lighter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.wagtail-userbar {
|
||||||
|
@include dark-mode {
|
||||||
|
filter: invert(100%);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,8 @@
|
||||||
{% block extra_css %}
|
{% block extra_css %}
|
||||||
<link rel="stylesheet" type="text/css" href="{% static 'css/lite-youtube-embed.css' %}">
|
<link rel="stylesheet" type="text/css" href="{% static 'css/lite-youtube-embed.css' %}">
|
||||||
<link rel="stylesheet" type="text/css" href="{% static 'contrib/shareon/shareon.min.css' %}">
|
<link rel="stylesheet" type="text/css" href="{% static 'contrib/shareon/shareon.min.css' %}">
|
||||||
<link rel="stylesheet" type="text/css" href="{% url 'code-block:styles' 'default' %}">
|
<link rel="stylesheet" type="text/css" href="{% url 'code-block:styles' 'default' %}" id="pygments-light">
|
||||||
|
<link rel="stylesheet" type="text/css" href="{% url 'code-block:styles' 'github-dark' %}" id="pygments-dark">
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block extra_js %}
|
{% block extra_js %}
|
||||||
|
|
Loading…
Reference in a new issue