Skip to content

Implement Dark Mode (CFM-239) #94

Merged
merged 5 commits into from
Jun 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions app/resources/locales/en_US/menu.po
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,27 @@ msgstr "Switch CO"
msgid "menu.advanced"
msgstr "Advanced Menu"

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.introduction"
msgstr "Please select an action from the menu."

msgid "menu.main"
msgstr "Main Menu"

msgid "menu.settings"
msgstr "Settings"

msgid "menu.user"
msgstr "User Menu"

Expand Down
4 changes: 3 additions & 1 deletion app/templates/Dashboards/dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,6 @@
// XXX This is a placeholder
?>

Please select an action from the menu.
<div id="introduction">
<p><?= __d('menu','menu.introduction') ?></p>
</div>
27 changes: 21 additions & 6 deletions app/templates/element/javascript.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,14 @@
$("select").addClass("form-select");

// Use select2 library everywhere except
// XXX TODO: Find a replacement for Select2 - it is not accessible.
// - duet-date
$("select").not("#limit").not(".duet-date__select--month").not(".duet-date__select--year").select2({
width: '100%',
tags: true,
placeholder: "-- Select --",
allowClear: true
});
// $("select").not("#limit").not(".duet-date__select--month").not(".duet-date__select--year").select2({
// width: '100%',
// tags: true,
// placeholder: "-- Select --",
// allowClear: true
// });

// Generic row click handling
// First capture mouse location to test if we're clicking or drag-selecting (for copy)
Expand Down Expand Up @@ -252,6 +253,20 @@

});

// 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.
// XXX TODO: Replace this with setting an application variable (when available) so we do not flash the light color briefly on each page load
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