Skip to content

Commit

Permalink
First commit for Dark Mode: enable dark mode toggle and OS system che…
Browse files Browse the repository at this point in the history
…cking; rename all color variables; add color-scheme meta tag to all layouts. (CFM-239)
  • Loading branch information
arlen committed Jun 12, 2023
1 parent b195b17 commit b4d5fdf
Show file tree
Hide file tree
Showing 9 changed files with 295 additions and 252 deletions.
15 changes: 15 additions & 0 deletions app/resources/locales/en_US/menu.po
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,21 @@ msgstr "All Groups"
msgid "co.switch"
msgstr "Switch CO"

msgid "menu.darkmode"
msgstr "Dark mode"

msgid "menu.density.small"
msgstr "Density small"

msgid "menu.density.medium"
msgstr "Density medium"

msgid "menu.density.large"
msgstr "Density large"

msgid "menu.settings"
msgstr "Settings"

msgid "menu.user"
msgstr "User Menu"

Expand Down
13 changes: 13 additions & 0 deletions app/templates/element/javascript.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,19 @@

});

// SETTINGS (from User Menu)
// Dark Mode toggle
$("#dark-mode-toggle").click(function(e) {
e.preventDefault();
$('html').toggleClass('dark-mode');
});

// Test for dark mode OS preference, and add the 'dark-mode' body class by default if it is present.
const darkModeOsEnabled = window.matchMedia("(prefers-color-scheme: dark)");
if(darkModeOsEnabled.matches) {
$('html').addClass('dark-mode');
}

});

// Define default text for confirm dialog
Expand Down
8 changes: 4 additions & 4 deletions app/templates/element/menuTop.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ class="dropdown-toggle top-menu-button"
Settings
</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#"><span class="material-icons" aria-hidden="true">dark_mode</span> Dark mode</a></li>
<li><a class="dropdown-item nospin" href="#" id="dark-mode-toggle"><span class="material-icons" aria-hidden="true">dark_mode</span><?= __d('menu','menu.darkmode'); ?></a></li>
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item" href="#"><span class="material-icons" aria-hidden="true">density_small</span>Density small</a></li>
<li><a class="dropdown-item" href="#"><span class="material-icons" aria-hidden="true">density_medium</span>Density medium</a></li>
<li><a class="dropdown-item" href="#"><span class="material-icons" aria-hidden="true">density_large</span>Density large</a></li>
<li><a class="dropdown-item nospin" href="#"><span class="material-icons" aria-hidden="true">density_small</span><?= __d('menu','menu.density.small'); ?></a></li>
<li><a class="dropdown-item nospin" href="#"><span class="material-icons" aria-hidden="true">density_medium</span><?= __d('menu','menu.density.medium'); ?></a></li>
<li><a class="dropdown-item nospin" href="#"><span class="material-icons" aria-hidden="true">density_large</span><?= __d('menu','menu.density.large'); ?></a></li>
</ul>
</div>
<?php if(count($vv_available_cos) > 1): // More than one CO is available, so present the switch button ?>
Expand Down
1 change: 1 addition & 0 deletions app/templates/layout/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<html lang="<?= __('registry.meta.lang'); ?>">
<head>
<?= $this->Html->meta('viewport', 'width=device-width, initial-scale=1.0') . PHP_EOL ?>
<?= $this->Html->meta('color-scheme', 'light dark') . PHP_EOL ?>
<?= $this->Html->charset(); ?>

<title><?= (!empty($vv_title) ? $vv_title : __('registry.meta.registry')); ?></title>
Expand Down
1 change: 1 addition & 0 deletions app/templates/layout/error.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<html lang="<?= __('registry.meta.lang'); ?>">
<head>
<?= $this->Html->meta('viewport', 'width=device-width, initial-scale=1.0') . PHP_EOL ?>
<?= $this->Html->meta('color-scheme', 'light dark') . PHP_EOL ?>
<?= $this->Html->charset() ?>

<title><?= $this->fetch('title') ?></title>
Expand Down
1 change: 1 addition & 0 deletions app/templates/layout/iframe.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<html lang="<?= __('registry.meta.lang'); ?>">
<head>
<?= $this->Html->meta('viewport', 'width=device-width, initial-scale=1.0') . PHP_EOL ?>
<?= $this->Html->meta('color-scheme', 'light dark') . PHP_EOL ?>
<?= $this->Html->charset(); ?>

<title><?= (!empty($vv_title) ? $vv_title : __('registry.meta.registry')); ?></title>
Expand Down
Loading

0 comments on commit b4d5fdf

Please sign in to comment.