Skip to content

Commit ca007a8

Browse files
authored
Merge pull request #939 from erwindon/darkmode2
implement dark mode
2 parents b6c09a8 + 40f1770 commit ca007a8

15 files changed

Lines changed: 225 additions & 83 deletions

File tree

docs/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ But note that browsers that are older than that are not detected and failures ma
5757
- Choose between live info and cached info for grains/pillar
5858
- View details of orchestrations and allow to start them
5959
- Act on multiple minions/keys/nodegroups by first selecting them
60+
- Follows dark-mode selection from the browser
6061

6162

6263
## Quick start using PAM as authentication method

saltgui/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
<head>
55
<title>SaltGUI</title>
6+
<link rel='stylesheet' type='text/css' href='static/stylesheets/variables.css'/>
67
<link rel='stylesheet' type='text/css' href='static/stylesheets/controls.css'/>
78
<link rel='stylesheet' type='text/css' href='static/stylesheets/main.css'/>
89
<link rel='stylesheet' type='text/css' href='static/stylesheets/login.css'/>

saltgui/static/scripts/Character.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,6 @@ export class Character {
6161
}
6262

6363
static buttonInText (txt) {
64-
return "<span style=\"background-color:#eee\">&nbsp;" + txt + "&nbsp;</span>";
64+
return "<span style=\"background-color:#eee; color:black\">&nbsp;" + txt + "&nbsp;</span>";
6565
}
6666
}

saltgui/static/scripts/Router.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,11 @@ export class Router {
277277
// perform the hiding/showing
278278
for (let nr = 1; nr <= 2; nr++) {
279279
const item = document.getElementById("button-" + pPage.path + nr);
280-
item.style.color = !visible && hasVisibleChild ? "lightgray" : "black";
280+
if (!visible && hasVisibleChild) {
281+
item.classList.add("menu-item-dimmed");
282+
} else {
283+
item.classList.remove("menu-item-dimmed");
284+
}
281285
if (visible && item.dataset.hasShortcut === "true") {
282286
// show the shortcut indicator only when item is enabled
283287
item.classList.add("menu-item-first-letter");

saltgui/static/scripts/panels/Login.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,12 @@ export class LoginPanel extends Panel {
6868
aa.rel = "noopener";
6969

7070
const img = Utils.createElem("img");
71-
img.src = "static/images/GitHub_Invertocat_Black.png";
71+
const darkModeQuery = window.matchMedia("(prefers-color-scheme: dark)");
72+
const updateGithubLogo = () => {
73+
img.src = darkModeQuery.matches ? "static/images/GitHub_Invertocat_White.png" : "static/images/GitHub_Invertocat_Black.png";
74+
};
75+
updateGithubLogo();
76+
darkModeQuery.addEventListener("change", updateGithubLogo);
7277
img.style = "width: 1em; margin-right: 5px";
7378
aa.append(img);
7479

saltgui/static/stylesheets/beacons.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@
1616

1717
.beacon-disabled,
1818
.beacon-waiting {
19-
color: gray;
19+
color: var(--text-light);
2020
}

saltgui/static/stylesheets/controls.css

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
input,
44
select {
5-
color: #272727;
5+
color: var(--text-primary);
6+
background-color: var(--bg-panel);
67
padding: 7px 10px;
78
display: inline-block;
89
margin-bottom: 15px;
@@ -14,24 +15,24 @@ select {
1415
input[type="text"],
1516
input[type="password"],
1617
select {
17-
border: 2px solid #e2e2e2;
18+
border: 2px solid var(--border-color-input);
1819
border-radius: 2px;
1920
}
2021

2122
input[type="text"]:focus,
2223
input[type="password"]:focus,
2324
select:focus {
24-
border: 2px solid #4caf50;
25+
border: 2px solid var(--border-color-focus);
2526
}
2627

2728
input[type="submit"] {
28-
background-color: #4caf50;
29+
background-color: var(--color-primary);
2930
color: white;
3031
border: 0;
3132
margin-top: 5px;
3233
margin-bottom: 0;
3334
cursor: pointer;
34-
box-shadow: 0 0 5px rgba(33, 33, 33, 50%);
35+
box-shadow: 0 0 5px var(--shadow-color);
3536
width: 20%;
3637
min-width: 200px;
3738
}

saltgui/static/stylesheets/dropdown.css

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@ div.search-box .menu-dropdown {
1313
position: absolute;
1414
max-height: 300px;
1515
overflow-y: auto;
16-
background: #fff;
17-
box-shadow: 0 3px 10px -2px rgba(0, 0, 0, 30%);
16+
background: var(--bg-dropdown);
17+
box-shadow: 0 3px 10px -2px var(--shadow-dropdown-dark);
1818
border: 1px solid rgba(0, 0, 0, 10%);
1919
z-index: 5;
2020
cursor: pointer;
2121
text-align: left;
22+
color: var(--text-primary);
2223
}
2324

2425
/* Links inside the menu-dropdown */
@@ -60,8 +61,8 @@ pre.output .run-command-button {
6061
}
6162

6263
pre.output .run-command-button:hover .menu-dropdown {
63-
background-color: #f9f9f9;
64-
color: black;
64+
background-color: var(--bg-dropdown);
65+
color: var(--text-primary);
6566
}
6667

6768
.dropdown {
@@ -72,9 +73,10 @@ pre.output .run-command-button:hover .menu-dropdown {
7273
.dropdown-content {
7374
display: none;
7475
position: absolute;
75-
background-color: #f9f9f9;
76-
box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 20%);
76+
background-color: var(--bg-dropdown);
77+
box-shadow: 0 8px 16px 0 var(--shadow-dropdown);
7778
z-index: 3;
79+
color: var(--text-primary);
7880
}
7981

8082
.dropdown:hover .dropdown-content {

saltgui/static/stylesheets/job.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
}
1818

1919
.highlight-task {
20-
background-color: gray;
20+
background-color: var(--bg-panel-hover);
2121
}
2222

2323
#summary-list-job {

saltgui/static/stylesheets/login.css

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,16 @@
99

1010
@media not print {
1111
#page-login {
12-
background-color: #263238;
12+
background-color: var(--bg-body);
1313
}
1414
}
1515

1616
#login-panel {
1717
align-self: center;
18-
background-color: white;
19-
box-shadow: 0 0 24px rgba(0, 0, 0, 70%);
18+
background-color: var(--bg-login-panel);
19+
box-shadow: 0 0 24px var(--shadow-login);
2020
border-radius: 2px;
21+
color: var(--text-primary);
2122

2223
/* 1px needed to prevent bottom margin to disappear when using small screens */
2324
padding: 0 50px 1px;
@@ -30,7 +31,7 @@
3031
font-weight: lighter;
3132
font-size: 60px;
3233
width: 100%;
33-
color: #505050;
34+
color: var(--text-login);
3435
}
3536

3637
#login-panel input {
@@ -45,12 +46,12 @@
4546
}
4647

4748
#login-panel select option#eauth-default {
48-
color: gray;
49+
color: var(--text-light);
4950
}
5051

5152
.attribution {
5253
display: block;
53-
opacity: 0.4;
54+
color: var(--text-secondary);
5455
font-size: 15px;
5556
margin-top: 40px;
5657
margin-bottom: 20px;

0 commit comments

Comments
 (0)