Skip to content

Commit

Permalink
Add user params for colour scheme
Browse files Browse the repository at this point in the history
  • Loading branch information
bembelimen committed Dec 7, 2023
1 parent 06b78cd commit d69e66f
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 5 deletions.
12 changes: 12 additions & 0 deletions administrator/components/com_users/forms/user.xml
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,18 @@
<option value="">JOPTION_USE_DEFAULT</option>
</field>

<field
name="colorScheme"
type="list"
label="COM_USERS_USER_COLORSCHEME_LABEL"
default=""
filter="options"
>
<option value="">JOPTION_USE_DEFAULT</option>
<option value="light">COM_USERS_USER_COLORSCHEME_OPTION_LIGHT</option>
<option value="dark">COM_USERS_USER_COLORSCHEME_OPTION_DARK</option>
</field>

</fieldset>
<!-- User accessibility settings -->
<fieldset
Expand Down
4 changes: 4 additions & 0 deletions administrator/language/en-GB/com_users.ini
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,10 @@ COM_USERS_USER_BACKUPCODES_CAPTIVE_PROMPT="If you do not have access to your usu
COM_USERS_USER_BACKUPCODES_DESC="Lets you access the site if all other Multi-factor Authentication methods you have set up fail."
COM_USERS_USER_BATCH_FAILED="An error was encountered while performing the batch operation: %s."
COM_USERS_USER_BATCH_SUCCESS="Batch operation completed."
COM_USERS_USER_COLORSCHEME_LABEL="Dark Mode"
COM_USERS_USER_COLORSCHEME_OPTION_DARK="Use Dark theme"
COM_USERS_USER_COLORSCHEME_OPTION_FOLLOW_OS="Follow OS settings"
COM_USERS_USER_COLORSCHEME_OPTION_LIGHT="Use Light theme"
COM_USERS_USER_FIELD_BACKEND_LANGUAGE_LABEL="Backend Language"
COM_USERS_USER_FIELD_BACKEND_TEMPLATE_LABEL="Backend Template Style"
COM_USERS_USER_FIELD_BLOCK="Blocked"
Expand Down
2 changes: 1 addition & 1 deletion administrator/templates/atum/component.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
$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 = $this->params->get('colorScheme', 0);
$darkMode = $app->getIdentity()->getParams('colorScheme', $this->params->get('colorScheme', 0));
$lastMode = !$darkMode ? $app->getInput()->cookie->get('atumColorScheme', '') : false;
$themeModes = [0 => ' 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] ?? '') : '');
Expand Down
2 changes: 1 addition & 1 deletion administrator/templates/atum/error_full.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
$this->setMetaData('viewport', 'width=device-width, initial-scale=1');

$monochrome = (bool) $this->params->get('monochrome');
$darkMode = $this->params->get('colorScheme', 0);
$darkMode = $app->getIdentity()->getParams('colorScheme', $this->params->get('colorScheme', 0));
$lastMode = !$darkMode ? $app->getInput()->cookie->get('atumColorScheme', '') : false;
$themeModes = [0 => ' 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] ?? '') : '');
Expand Down
2 changes: 1 addition & 1 deletion administrator/templates/atum/error_login.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
$this->setMetaData('viewport', 'width=device-width, initial-scale=1');

$monochrome = (bool) $this->params->get('monochrome');
$darkMode = $this->params->get('colorScheme', 0);
$darkMode = $app->getIdentity()->getParams('colorScheme', $this->params->get('colorScheme', 0));
$lastMode = !$darkMode ? $app->getInput()->cookie->get('atumColorScheme', '') : false;
$themeModes = [0 => ' 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] ?? '') : '');
Expand Down
2 changes: 1 addition & 1 deletion administrator/templates/atum/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
$this->setMetaData('viewport', 'width=device-width, initial-scale=1');

$monochrome = (bool) $this->params->get('monochrome');
$darkMode = $this->params->get('colorScheme', 0);
$darkMode = $app->getIdentity()->getParams('colorScheme', $this->params->get('colorScheme', 0));
$lastMode = !$darkMode ? $app->getInput()->cookie->get('atumColorScheme', '') : false;
$themeModes = [0 => ' 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] ?? '') : '');
Expand Down
2 changes: 1 addition & 1 deletion administrator/templates/atum/login.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
$this->setMetaData('viewport', 'width=device-width, initial-scale=1');

$monochrome = (bool) $this->params->get('monochrome');
$darkMode = $this->params->get('colorScheme', 0);
$darkMode = $app->getIdentity()->getParams('colorScheme', $this->params->get('colorScheme', 0));
$lastMode = !$darkMode ? $app->getInput()->cookie->get('atumColorScheme', '') : false;
$themeModes = [0 => ' 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] ?? '') : '');
Expand Down
12 changes: 12 additions & 0 deletions components/com_users/forms/frontend.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@
>
<option value="">JOPTION_USE_DEFAULT</option>
</field>

<field
name="colorScheme"
type="list"
label="COM_USERS_USER_COLORSCHEME_LABEL"
default=""
filter="options"
>
<option value="">JOPTION_USE_DEFAULT</option>
<option value="light">COM_USERS_USER_COLORSCHEME_OPTION_LIGHT</option>
<option value="dark">COM_USERS_USER_COLORSCHEME_OPTION_DARK</option>
</field>
</fieldset>
</fields>
</form>
4 changes: 4 additions & 0 deletions language/en-GB/com_users.ini
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ COM_USERS_USER_BACKUPCODES="Backup Codes"
COM_USERS_USER_BACKUPCODES_CAPTIVE_PROMPT="If you do not have access to your usual Multi-factor Authentication method use any of your Backup Codes in the field below. Please remember that this emergency backup code cannot be reused."
COM_USERS_USER_BACKUPCODES_DESC="If you do not have access to your Multi-factor Authentication device you can use any of the following passwords instead of a regular security code. Each one of these emergency codes is immediately destroyed upon use. We recommend printing these codes out and keeping the printout in a safe and accessible location, eg your wallet or a safety deposit box."
COM_USERS_USER_BLOCKED="This user is blocked. If this is an error, please contact an administrator."
COM_USERS_USER_COLORSCHEME_LABEL="Dark Mode"
COM_USERS_USER_COLORSCHEME_OPTION_DARK="Use Dark theme"
COM_USERS_USER_COLORSCHEME_OPTION_FOLLOW_OS="Follow OS settings"
COM_USERS_USER_COLORSCHEME_OPTION_LIGHT="Use Light theme"
COM_USERS_USER_FIELD_BACKEND_LANGUAGE_LABEL="Backend Language"
COM_USERS_USER_FIELD_BACKEND_TEMPLATE_LABEL="Backend Template Style"
COM_USERS_USER_FIELD_EDITOR_LABEL="Editor"
Expand Down

0 comments on commit d69e66f

Please sign in to comment.