Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Fedik committed Jan 28, 2024
1 parent 3194b00 commit f6d1ec8
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 30 deletions.
13 changes: 9 additions & 4 deletions administrator/templates/atum/component.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,15 @@
$this->addHeadLink(HTMLHelper::_('image', 'favicon.ico', '', [], true, 1), 'alternate icon', 'rel', ['type' => 'image/vnd.microsoft.icon']);
$this->addHeadLink(HTMLHelper::_('image', 'joomla-favicon-pinned.svg', '', [], true, 1), 'mask-icon', 'rel', ['color' => '#000']);

$darkMode = $app->getIdentity()->getParam('colorScheme', $this->params->get('colorScheme', 'os'));
$lastMode = $app->getInput()->cookie->get('colorScheme', $darkMode);
$themeModes = ['os' => ' data-color-scheme-os', 'light' => ' data-bs-theme="light" data-color-scheme="light"', 'dark' => ' data-bs-theme="dark" data-color-scheme="dark"'];
$themeModeAttr = $themeModes[$lastMode] ?? '';
$colorScheme = $this->params->get('colorScheme', 'os');
$themeModeAttr = '';

if ($colorScheme) {
$colorScheme = $app->getIdentity()->getParam('colorScheme', $colorScheme);
$lastMode = $app->getInput()->cookie->get('colorScheme', $colorScheme);
$themeModes = ['os' => ' data-color-scheme-os', 'light' => ' data-bs-theme="light" data-color-scheme="light"', 'dark' => ' data-bs-theme="dark" data-color-scheme="dark"'];
$themeModeAttr = $themeModes[$lastMode] ?? '';
}
?>

<!DOCTYPE html>
Expand Down
14 changes: 10 additions & 4 deletions administrator/templates/atum/error_full.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,21 @@
$this->setMetaData('viewport', 'width=device-width, initial-scale=1');

$monochrome = (bool) $this->params->get('monochrome');
$darkMode = $app->getIdentity()->getParam('colorScheme', $this->params->get('colorScheme', 'os'));
$lastMode = $app->getInput()->cookie->get('colorScheme', $darkMode);
$themeModes = ['os' => ' data-color-scheme-os', 'light' => ' data-bs-theme="light" data-color-scheme="light"', 'dark' => ' data-bs-theme="dark" data-color-scheme="dark"'];
$colorScheme = $this->params->get('colorScheme', 'os');
$themeModeAttr = '';

if ($colorScheme) {
$colorScheme = $app->getIdentity()->getParam('colorScheme', $colorScheme);
$lastMode = $app->getInput()->cookie->get('colorScheme', $colorScheme);
$themeModes = ['os' => ' data-color-scheme-os', 'light' => ' data-bs-theme="light" data-color-scheme="light"', 'dark' => ' data-bs-theme="dark" data-color-scheme="dark"'];
$themeModeAttr = $themeModes[$lastMode] ?? '';
}

// @see administrator/templates/atum/html/layouts/status.php
$statusModules = LayoutHelper::render('status', ['modules' => 'status']);
?>
<!DOCTYPE html>
<html lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>">
<html lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>"<?php echo $themeModeAttr; ?>>
<head>
<jdoc:include type="metas" />
<jdoc:include type="styles" />
Expand Down
15 changes: 10 additions & 5 deletions administrator/templates/atum/error_login.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,21 @@
$this->setMetaData('viewport', 'width=device-width, initial-scale=1');

$monochrome = (bool) $this->params->get('monochrome');
$darkMode = $app->getIdentity()->getParam('colorScheme', $this->params->get('colorScheme', 'os'));
$lastMode = $app->getInput()->cookie->get('colorScheme', $darkMode);
$themeModes = ['os' => ' data-color-scheme-os', 'light' => ' data-bs-theme="light" data-color-scheme="light"', 'dark' => ' data-bs-theme="dark" data-color-scheme="dark"'];
$themeModeAttr = $themeModes[$lastMode] ?? '';
$colorScheme = $this->params->get('colorScheme', 'os');
$themeModeAttr = '';

if ($colorScheme) {
$colorScheme = $app->getIdentity()->getParam('colorScheme', $colorScheme);
$lastMode = $app->getInput()->cookie->get('colorScheme', $colorScheme);
$themeModes = ['os' => ' data-color-scheme-os', 'light' => ' data-bs-theme="light" data-color-scheme="light"', 'dark' => ' data-bs-theme="dark" data-color-scheme="dark"'];
$themeModeAttr = $themeModes[$lastMode] ?? '';
}

// @see administrator/templates/atum/html/layouts/status.php
$statusModules = LayoutHelper::render('status', ['modules' => 'status']);
?>
<!DOCTYPE html>
<html lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>">
<html lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>"<?php echo $themeModeAttr; ?>>
<head>
<jdoc:include type="metas" />
<jdoc:include type="styles" />
Expand Down
13 changes: 9 additions & 4 deletions administrator/templates/atum/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,15 @@
$this->setMetaData('viewport', 'width=device-width, initial-scale=1');

$monochrome = (bool) $this->params->get('monochrome');
$darkMode = $app->getIdentity()->getParam('colorScheme', $this->params->get('colorScheme'));
$lastMode = $app->getInput()->cookie->get('colorScheme', $darkMode);
$themeModes = ['os' => ' data-color-scheme-os', 'light' => ' data-bs-theme="light" data-color-scheme="light"', 'dark' => ' data-bs-theme="dark" data-color-scheme="dark"'];
$themeModeAttr = $themeModes[$lastMode] ?? '';
$colorScheme = $this->params->get('colorScheme', 'os');
$themeModeAttr = '';

if ($colorScheme) {
$colorScheme = $app->getIdentity()->getParam('colorScheme', $colorScheme);
$lastMode = $app->getInput()->cookie->get('colorScheme', $colorScheme);
$themeModes = ['os' => ' data-color-scheme-os', 'light' => ' data-bs-theme="light" data-color-scheme="light"', 'dark' => ' data-bs-theme="dark" data-color-scheme="dark"'];
$themeModeAttr = $themeModes[$lastMode] ?? '';
}

Text::script('TPL_ATUM_MORE_ELEMENTS');

Expand Down
13 changes: 9 additions & 4 deletions administrator/templates/atum/login.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,15 @@
$this->setMetaData('viewport', 'width=device-width, initial-scale=1');

$monochrome = (bool) $this->params->get('monochrome');
$darkMode = $app->getIdentity()->getParam('colorScheme', $this->params->get('colorScheme', 'os'));
$lastMode = $app->getInput()->cookie->get('colorScheme', $darkMode);
$themeModes = ['os' => ' data-color-scheme-os', 'light' => ' data-bs-theme="light" data-color-scheme="light"', 'dark' => ' data-bs-theme="dark" data-color-scheme="dark"'];
$themeModeAttr = $themeModes[$lastMode] ?? '';
$colorScheme = $this->params->get('colorScheme', 'os');
$themeModeAttr = '';

if ($colorScheme) {
$colorScheme = $app->getIdentity()->getParam('colorScheme', $colorScheme);
$lastMode = $app->getInput()->cookie->get('colorScheme', $colorScheme);
$themeModes = ['os' => ' data-color-scheme-os', 'light' => ' data-bs-theme="light" data-color-scheme="light"', 'dark' => ' data-bs-theme="dark" data-color-scheme="dark"'];
$themeModeAttr = $themeModes[$lastMode] ?? '';
}

// Add cookie alert message
Text::script('JGLOBAL_WARNCOOKIES');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,21 +234,14 @@ function darkModeWatch() {
const newScheme = mql.matches ? 'dark' : 'light';
// Check if theme already was set
if (docEl.dataset.colorScheme === newScheme) return;
const expires = new Date();
docEl.dataset.bsTheme = newScheme;
docEl.dataset.colorScheme = newScheme;
expires.setTime(expires.getTime() + 31536000000);
// Store theme in cookies, so php will know the last choice
document.cookie = `colorScheme=${newScheme}; expires=${expires.toUTCString()};`;
document.cookie = `colorScheme=${newScheme};`;
document.dispatchEvent(new CustomEvent('joomla:color-scheme-change', { bubbles: true }));
};
mql.addEventListener('change', check);

if (!document.cookie
.split("; ")
.find((row) => row.startsWith("colorScheme"))) {
check();
}
check();
}

// Initialize
Expand Down

0 comments on commit f6d1ec8

Please sign in to comment.