Skip to content

Commit

Permalink
Dark mode support.
Browse files Browse the repository at this point in the history
Uses the system them preference
  • Loading branch information
mcgrew committed Feb 10, 2022
1 parent b9a723f commit f4ecd89
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 4 deletions.
2 changes: 1 addition & 1 deletion common/build.h
@@ -1,2 +1,2 @@
/* This file is generated by git */
#define BUILD "652"
#define BUILD "653"
3 changes: 3 additions & 0 deletions electron/preload.js
Expand Up @@ -12,6 +12,9 @@ window.addEventListener('DOMContentLoaded', () => {
}

document.body.style.backgroundColor = '#fff';
if (window.matchMedia("(prefers-color-scheme: dark)").matches) {
document.body.style.backgroundColor = '#333';
}
})

function createElement(element, text, style) {
Expand Down
57 changes: 57 additions & 0 deletions webui/index.css
Expand Up @@ -16,6 +16,10 @@ body {
user-select: none;
}

#application > img {
filter: drop-shadow(2px 2px 1px #aaa);
}

h1, h3 {
text-align: center;
}
Expand Down Expand Up @@ -54,6 +58,59 @@ tabcontent {
padding: 3em;
}

/* Hide the "spinner" in number fields */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}

/* Firefox */
input[type=number] {
-moz-appearance: textfield;
}

.invalid {
border-color: red;
}

div.description {
color: #666;
}

@media (prefers-color-scheme: dark) {
body {
background-color: #111;
color: #ccc;
}

#application {
background-color: #333;
}

tab {
background-color: #222;
}

tab:hover, tab.active {
background-color: #333;
}

button, select {
background-color: #333;
color: #ccc;
border-color: #3a3a3a;
}
input {
background-color: #111;
color: #ccc;
border-color: #333;
}
#application > img {
filter: drop-shadow(2px 2px 1px #000);
}
div.description {
color: #888;
}

}
2 changes: 1 addition & 1 deletion webui/index.html
Expand Up @@ -9,7 +9,7 @@
<datalist id='sprites' type='text'>
</datalist>
</head>
<body>
<body class="dark">
<div id='application'>
<noscript>
Hey there!
Expand Down
3 changes: 1 addition & 2 deletions webui/interface.js
Expand Up @@ -188,7 +188,6 @@ class Interface {
this.title = this.create('img', null, {
'display': 'block',
'margin': 'auto',
'filter': 'drop-shadow(2px 2px 1px #aaa)',
});
this.title.src = 'logo.png';
this.title.alt = 'Dragon Warrior Randomizer';
Expand Down Expand Up @@ -714,9 +713,9 @@ class Interface {
if (description) {
let descriptionEl = this.create('div', description, {
'font-size': '0.7em',
'color': '#666',
'margin-left': '2em',
});
descriptionEl.classList.add('description');
container.append(descriptionEl);
}
if (retain)
Expand Down

0 comments on commit f4ecd89

Please sign in to comment.