Skip to content

Commit

Permalink
Implement dark-mode (#803)
Browse files Browse the repository at this point in the history
  • Loading branch information
zoglo authored Jun 12, 2024
1 parent e77ce2b commit e1e137e
Show file tree
Hide file tree
Showing 54 changed files with 743 additions and 478 deletions.
4 changes: 4 additions & 0 deletions src/assets/images/color_scheme--dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/images/color_scheme.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/images/downloads--dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/images/downloads.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/images/favers--dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/images/favers.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/images/language--dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 3 additions & 4 deletions src/assets/images/language.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/images/link-blank--dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 3 additions & 4 deletions src/assets/images/link-blank.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/assets/images/private--dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/assets/images/private.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions src/assets/images/symfony-logo--dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 8 additions & 1 deletion src/assets/images/symfony-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/assets/images/updated--dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/assets/images/updated.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions src/assets/styles/_defaults.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Custom properties
:root {
--header-main-bg: #FFF;
--footer-fragment-bdr: #eee;
--table-odd-bg: #f5f9fa;
--border-radius: 6px;
--log-header-bg: var(--shadow);
}

// Dark-mode
html[data-color-scheme=dark] {
--header-main-bg: #292c32;
--footer-fragment-bdr: var(--footer-bdr);
--table-odd-bg: var(--tiles-bg);
--link-footer: #fff;
--hint-bg: #151619;
--hint-rgb: 21, 22, 25;
--log-header-bg: var(--btn);

.vjs-tree-node:hover {
background-color: #2b3439;
}
}

// Dark/Light images

.color-scheme--light,
html[data-color-scheme=dark] .color-scheme--dark {
display: initial;
}

.color-scheme--dark,
html[data-color-scheme=dark] .color-scheme--light {
display: none;
}
18 changes: 16 additions & 2 deletions src/components/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,18 @@
currentView: vm => vm.views[vm.view] || null,
},
methods: {
initColorMode() {
let prefersDark = localStorage.getItem('contao--prefers-dark');
if (null === prefersDark) {
prefersDark = String(window.matchMedia('(prefers-color-scheme: dark)').matches);
}
document.documentElement.dataset.colorScheme = prefersDark === 'true' ? 'dark' : 'light';
},
},
watch: {
async isReady(ready) {
if (ready) {
Expand All @@ -106,6 +118,8 @@
},
async mounted() {
this.initColorMode();
if (this.$route.query.token) {
try {
await Vue.http.post('api/session', { token: this.$route.query.token });
Expand Down Expand Up @@ -198,7 +212,7 @@
right: 0;
height: 27px;
padding: 4px 8px;
background: $orange-button;
background: var(--btn-warning);
color: #fff;
text-align: center;
z-index: 100;
Expand Down Expand Up @@ -228,7 +242,7 @@
right: 0;
height: 27px;
padding: 4px 8px;
background: $red-button;
background: var(--btn-alert);
color: #fff;
text-align: center;
z-index: 100;
Expand Down
14 changes: 2 additions & 12 deletions src/components/boot/BootConfig.vue
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export default {
}
&__icon {
background: $contao-color;
background: var(--contao);
border-radius: 10px;
padding:10px;
}
Expand Down Expand Up @@ -191,7 +191,7 @@ export default {
&__issues {
margin-bottom: 1em;
color: $red-button;
color: var(--btn-alert);
p {
font-weight: $font-weight-bold;
Expand Down Expand Up @@ -238,16 +238,6 @@ export default {
padding-top: 10px;
font-weight: $font-weight-medium;
}
select,
input[type=text] {
width: 250px;
}
}
.widget-button {
width: 250px;
margin-left: 120px;
}
}
}
Expand Down
Loading

0 comments on commit e1e137e

Please sign in to comment.