Skip to content

Commit

Permalink
Improve parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
bembelimen committed Dec 12, 2023
1 parent 8c8f2ef commit b5ea23c
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 16 deletions.
30 changes: 25 additions & 5 deletions administrator/modules/mod_user/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@
return;
}

$app = Factory::getApplication();

$tParams = $app->getTemplate(true)->params;

$darkMode = $app->getIdentity()->getParam('colorScheme', $tParams->get('colorScheme', 'os'));
$lastMode = $app->getInput()->cookie->get('atumColorScheme', $darkMode);

// Load the Bootstrap Dropdown
HTMLHelper::_('bootstrap.dropdown', '.dropdown-toggle');
?>
Expand Down Expand Up @@ -54,15 +61,28 @@
<?php echo Text::_('MOD_USER_ACCESSIBILITY_SETTINGS'); ?>
</a>
<?php // Not all templates support a colorScheme ?>
<?php if (Factory::getApplication()->getTemplate(true)->params->get('colorScheme')) : ?>
<?php if ($tParams->get('colorScheme')) : ?>
<div class="dropdown dropstart">
<button type="button" class="dropdown-item" data-bs-toggle="dropdown">
<span class="fa fa-moon icon-fw" aria-hidden="true"></span> Color mode
<?php
switch ($lastMode) :
case 'light':
?>
<span class="fa fa-sun icon-fw" aria-hidden="true"></span>
<?php break; ?>
<?php case 'dark': ?>
<span class="fa fa-moon icon-fw" aria-hidden="true"></span>
<?php break; ?>
<?php default: ?>
<span class="fa fa-circle-half-stroke icon-fw" aria-hidden="true"></span>
<?php break; ?>
<?php endswitch; ?>
Color mode
</button>
<div class="dropdown-menu dropdown-menu-end">
<a class="dropdown-item" href="#"><span class="fa fa-sun icon-fw" aria-hidden="true"></span> Light</a>
<a class="dropdown-item" href="#"><span class="fa fa-moon icon-fw" aria-hidden="true"></span> Dark</a>
<a class="dropdown-item" href="#"><span class="fa fa-circle-half-stroke icon-fw" aria-hidden="true"></span> Auto</a>
<button class="dropdown-item" data-mode="light" type="button"><span class="fa fa-sun icon-fw" aria-hidden="true"></span> Light</button>
<button class="dropdown-item" data-mode="dark" type="button"><span class="fa fa-moon icon-fw" aria-hidden="true"></span> Dark</button>
<button class="dropdown-item" data-mode="os" type="button"><span class="fa fa-circle-half-stroke icon-fw" aria-hidden="true"></span> Auto</button>
</div>
</div>
<?php endif; ?>
Expand Down
4 changes: 2 additions & 2 deletions administrator/templates/atum/component.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@
$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 = !$darkMode ? $app->getInput()->cookie->get('atumColorScheme', '') : false;
$lastMode = $app->getInput()->cookie->get('atumColorScheme', $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[$darkMode] ?? '') . ($lastMode ? ($themeModes[$lastMode] ?? '') : '');
$themeModeAttr = $themeModes[$lastMode] ?? '';
?>

<!DOCTYPE html>
Expand Down
4 changes: 2 additions & 2 deletions administrator/templates/atum/error_full.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@

$monochrome = (bool) $this->params->get('monochrome');
$darkMode = $app->getIdentity()->getParam('colorScheme', $this->params->get('colorScheme', 'os'));
$lastMode = !$darkMode ? $app->getInput()->cookie->get('atumColorScheme', '') : false;
$lastMode = $app->getInput()->cookie->get('atumColorScheme', $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[$darkMode] ?? '') . ($lastMode ? ($themeModes[$lastMode] ?? '') : '');
$themeModeAttr = $themeModes[$lastMode] ?? '';

// @see administrator/templates/atum/html/layouts/status.php
$statusModules = LayoutHelper::render('status', ['modules' => 'status']);
Expand Down
4 changes: 2 additions & 2 deletions administrator/templates/atum/error_login.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@

$monochrome = (bool) $this->params->get('monochrome');
$darkMode = $app->getIdentity()->getParam('colorScheme', $this->params->get('colorScheme', 'os'));
$lastMode = !$darkMode ? $app->getInput()->cookie->get('atumColorScheme', '') : false;
$lastMode = $app->getInput()->cookie->get('atumColorScheme', $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[$darkMode] ?? '') . ($lastMode ? ($themeModes[$lastMode] ?? '') : '');
$themeModeAttr = $themeModes[$lastMode] ?? '';

// @see administrator/templates/atum/html/layouts/status.php
$statusModules = LayoutHelper::render('status', ['modules' => 'status']);
Expand Down
6 changes: 3 additions & 3 deletions administrator/templates/atum/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@
$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 = !$darkMode ? $app->getInput()->cookie->get('atumColorScheme', '') : false;
$darkMode = $app->getIdentity()->getParam('colorScheme', $this->params->get('colorScheme'));
$lastMode = $app->getInput()->cookie->get('atumColorScheme', $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[$darkMode] ?? '') . ($lastMode ? ($themeModes[$lastMode] ?? '') : '');
$themeModeAttr = $themeModes[$lastMode] ?? '';

Text::script('TPL_ATUM_MORE_ELEMENTS');

Expand Down
4 changes: 2 additions & 2 deletions administrator/templates/atum/login.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@

$monochrome = (bool) $this->params->get('monochrome');
$darkMode = $app->getIdentity()->getParam('colorScheme', $this->params->get('colorScheme', 'os'));
$lastMode = !$darkMode ? $app->getInput()->cookie->get('atumColorScheme', '') : false;
$lastMode = $app->getInput()->cookie->get('atumColorScheme', $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[$darkMode] ?? '') . ($lastMode ? ($themeModes[$lastMode] ?? '') : '');
$themeModeAttr = $themeModes[$lastMode] ?? '';

// Add cookie alert message
Text::script('JGLOBAL_WARNCOOKIES');
Expand Down

0 comments on commit b5ea23c

Please sign in to comment.