Feature Language Change NPM Resource Changed PBF PR-5.1-dev Dark Mode Pending

User tests: Successful: Unsuccessful:

avatar Fedik
Fedik
26 Oct 2023

Pull Request for Issue #42134 .

Summary of Changes

Add a Color scheme switch to Atum template.
The PR allow to choose prefered color scheme based on OS setting, or fixed.
Instead of using media query (which is not possible to override) it uses data attribute (data-bs-theme for bootstrap).
Very similar to what @dgrammatiko tried in #42209 .

New API

The following data attributes should be used within template:
data-color-scheme-os When template should follow OS setting
data-color-scheme="light" Use Light scheme
data-color-scheme="dark" Use Dark scheme

The combination data-color-scheme-os data-color-scheme="dark" means that the template will follow OS setting, but initialy will be used dark color scheme.

Addittionaly the PR introduce a new JavaScript event joomla:color-scheme-change which dispatched when color scheme changes.

All of this will allow to extensions easily follow to actual template state.
And in theory, should simplify Editor fixes for specified color scheme.

SCSS fixes needed

Following SCSS code does not work:

// Inherit parent with &
.foo{
  @if $enable-dark-mode {
    @include color-mode(dark) {
      &.bar {
        background-color: var(--template-bg-dark-90);
      }
    }
  }
}
// Child element
.foo{
  @if $enable-dark-mode {
    @include color-mode(dark) {
      .bar {
        background-color: var(--template-bg-dark-90);
      }
    }
  }
}

All such instance should use:

// For fisrt example
@if $enable-dark-mode {
  @include color-mode(dark) {
    .foo.bar {
      background-color: var(--template-bg-dark-90);
    }
  }
}
// For second example
@if $enable-dark-mode {
  @include color-mode(dark) {
    .foo .bar {
      background-color: var(--template-bg-dark-90);
    }
  }
}

(Or maybe someoen know better fixes?)

After the PR will be merged someone should look on it. Or can send PR against my PR.

Testing Instructions

Apply patch run npm install.
Check the template Atum parameters Dark mode.
When its set to Follow OS settings then template color scheme should changes when OS color scheme changes.
When its set to Use Light theme or Use Dark theme then template color scheme should stay Light or Dark, always.

Link to documentations

Please select:

  • Documentation link for docs.joomla.org:
  • No documentation changes for docs.joomla.org needed
  • Pull Request link for manual.joomla.org: joomla/Manual#238
  • No documentation changes for manual.joomla.org needed
avatar Fedik Fedik - open - 26 Oct 2023
avatar Fedik Fedik - change - 26 Oct 2023
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 26 Oct 2023
Category Administration Language & Strings Templates (admin) JavaScript Repository NPM Change
avatar Fedik Fedik - change - 26 Oct 2023
Labels Added: Feature Language Change NPM Resource Changed PR-5.0-dev Dark Mode
avatar bembelimen
bembelimen - comment - 26 Oct 2023

Hey @Fedik , looks good. Do you see also an option to add the user parameters as an extra layer, so a user can define their preferences?

avatar Fedik
Fedik - comment - 26 Oct 2023

Do you see also an option to add the user parameters as an extra layer

I thought about it, but I would make it in separated PR.
We need a feature that will allow to define "User specific" params in templateDetails.xml. This way it will be more flexible, than hardcoding something in to User profile form.
I think some years ago there already was a discussion about it.

avatar HLeithner
HLeithner - comment - 26 Oct 2023

can't we do this in a generic way? maybe with a module and joomla w-c and event trigger and not only for atum?

avatar HLeithner
HLeithner - comment - 26 Oct 2023

also you call it color scheme switcher, which leads to the expectation that you can more then on/off dark mode (which by the way would make sense, allowing more then just darkmode on/off) if this things is also useable for the frontend and by 3rd party

avatar brianteeman
brianteeman - comment - 26 Oct 2023

Why not do it the bootstrap way as this is for a bootstrap template?

Specifically I am redferring to the javascript so that this can be easily toggled. Currently if i understand this correctly then its a template style setting which will mean its about 5 clicks just to toggle.

https://getbootstrap.com/docs/5.3/customize/color-modes/#javascript

avatar Fedik
Fedik - comment - 26 Oct 2023

can't we do this in a generic way? maybe with a module and joomla w-c and event trigger and not only for atum?

You mean for User specific? Yeah, that can work also, it will be "local setting" and in each browser user should do it again. Also will need to add a Swicth somewhere in to UI.

If you mean in general, it already is as generic as possible.

you call it color scheme switcher,

Because in Browser API it called (prefers-color-scheme: dark) πŸ˜‰

Currently if i understand this correctly then its a template style setting which will mean its about 5 clicks just to toggle.

Let's be honest, how often do you need it? I will set it once and will forget it exists.

avatar Fedik Fedik - change - 26 Oct 2023
Title
[5.x] Color scheme switcher
[5.x] Template color scheme configuration
avatar Fedik Fedik - edited - 26 Oct 2023
avatar brianteeman
brianteeman - comment - 26 Oct 2023

Currently if i understand this correctly then its a template style setting which will mean its about 5 clicks just to toggle.

Let's be honest, how often do you need it? I will set it once and will forget it exists.

Perhaps but perhaps not

avatar C-Lodder
C-Lodder - comment - 26 Oct 2023

Why not do it the bootstrap way as this is for a bootstrap template?

Suppose it boils down to whether Joomla wants to simply toggle between OS, light and dark, or whether they want to offer a spectrum of themes.

I'd even go as far as saying a switcher (toggle) doesn't warrant saving the preference in the database, but instead just via local storage, seeing as it's a quick and easy action.

avatar brianteeman
brianteeman - comment - 26 Oct 2023

I agree with you about using local storage. That is the most logical place to store an environmental setting as opposed to a site setting

avatar ceford
ceford - comment - 27 Oct 2023

With Firefox dark mode OFF and Dark Mode set to use Dark Theme the Toolbar button text has too little contrast. Otherwise OK.
screen shot 2023-10-27 at 08 35 01
With Firefox dark mode ON and Follow OS Settings selected the tab panels are stacked vertically and the Dark Mode list with Follow OS Settings or Use Light Theme selected has too little contrast - white on grey.
screen shot 2023-10-27 at 08 35 20
So: more work needed?


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/42221.

avatar Fedik
Fedik - comment - 27 Oct 2023

So: more work needed?

yes, this part is in the description under "SCSS fixes needed" title,
I have a hope it will be fixed in #42010, but not sure currently

avatar Septdir
Septdir - comment - 1 Nov 2023

I don't want to offend anyone, but why should the choice of color scheme be in the template settings?

This is fundamentally the wrong approach. Same as taking your browser settings to select a theme.

Does the site only have one administrator? No, there may be a lot of them. And some people use the dark theme, and some don't.
Moreover, one person may have different color schemes on different devices.

For example, when working at a computer in good lighting, I do not use dark themes. But in phone I use dark scheme, it’s very difficult for me to look at light scheme on phone.

Therefore, if you make different color schemes, then changing the scheme should be available on each page so that a person can change it at any time.

Otherwise, it is not much different from what it is now.

And once again I apologize if my words or tone offended anyone.
I just had time to look at Joomla 5 and I was simply shocked by the dark theme and the fact that I can only change it in the browser settings.

avatar progreccor
progreccor - comment - 1 Nov 2023

I totally agree with @Septdir . It is a smart approach.

avatar pavluk
pavluk - comment - 1 Nov 2023

I also want a color scheme switch on the admin toolbar

avatar fiction13
fiction13 - comment - 1 Nov 2023

@Septdir is right!

avatar korenevskiy
korenevskiy - comment - 2 Nov 2023

In the future, some day there will be settings in the browser to fast switch the site mode. But such times have not come yet and it will not be soon. Need a switch of 3 modes on the panel: Auto, Light, Dark. Or store the template settings mode. Or store it in the browser storage using JS.

I use the dark mode in the OS. But MS Word is difficult to use in dark mode, the colored text is not visible or almost invisible. How often do you switch MS Word to white mode to work with a document? It's the same here. It should be understood that the dark mode for viewing the site and the dark mode for editing the site are not the same thing at all. Often you need to switch just on the go. Moreover, we have to test the text in both modes so that the text is not intentionally colored by accident. A hot switch is NECESSARY.

I suggest making 2 settings, one in the template settings, the second on the panel in the profile drop-down menu or just on the panel near the Joomla verstion. The first setting sets the default mode. The button on the panel will override the default mode and store the status in the browser storage.

ISPmanager has a light mode change button on the status bar. ISPmanager stores this setting in the browser storage via JS.
image

avatar joomla-cms-bot joomla-cms-bot - change - 12 Dec 2023
Category Administration Language & Strings Templates (admin) JavaScript Repository NPM Change Administration com_users Language & Strings Modules Templates (admin) JavaScript Repository NPM Change Front End
avatar joomla-cms-bot joomla-cms-bot - change - 12 Dec 2023
Category Administration Language & Strings Templates (admin) JavaScript Repository NPM Change com_users Modules Front End Administration Language & Strings Templates (admin) JavaScript Repository NPM Change
avatar Fedik Fedik - change - 28 Jan 2024
Labels Added: PR-5.1-dev
Removed: PR-5.0-dev
avatar joomla-cms-bot joomla-cms-bot - change - 28 Jan 2024
Category Administration Language & Strings Templates (admin) JavaScript Repository NPM Change Administration com_users Language & Strings Modules Templates (admin) Repository NPM Change JavaScript Front End SQL Installation Postgresql
avatar fgsw fgsw - test_item - 6 Feb 2024 - Tested successfully
avatar fgsw
fgsw - comment - 6 Feb 2024

I have tested this item βœ… successfully on 9209543


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/42221.

avatar Razzo1987 Razzo1987 - change - 24 Feb 2024
Labels Added: PBF
avatar adj9
adj9 - comment - 24 Feb 2024

By installing the PR from scratch the administrative homa does not have the cottect style, the titles of all boxes are to be reduced.
While the other pages , such as articles and system, work
JD

avatar walturbo
walturbo - comment - 24 Feb 2024

@adj9 idem

home
avatar Fedik
Fedik - comment - 24 Feb 2024

The style fix will be there:

Current PR povides only the switch feature.

avatar LadySolveig LadySolveig - change - 11 Mar 2024
Status Pending Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2024-03-11 09:05:08
Closed_By LadySolveig
avatar LadySolveig LadySolveig - close - 11 Mar 2024
avatar LadySolveig LadySolveig - merge - 11 Mar 2024
avatar LadySolveig
LadySolveig - comment - 11 Mar 2024

What a very nice improvement for the dark mode - thanks @fedir for your work πŸš€ πŸ€– and also for the support, collaboration and for testing to @bembelimen @fgsw @brianteeman

avatar Quy
Quy - comment - 12 Mar 2024

@Fedik I don't remember it being this way with PR #42986. It is probably because of this PR?

42221-dark-mode

avatar Fedik
Fedik - comment - 12 Mar 2024

Yes, it probably because of an issue in scss, I wrote in the fitrst comment.
Need to check that for fancy-select style.

avatar LadySolveig
LadySolveig - comment - 12 Mar 2024

@Fedik Created a PR, sorry that we missed your comment and messed up the Fancy-Select.
Would be happy if you could give me a test @Fedik @Quy #43008

avatar Quy
Quy - comment - 12 Mar 2024

When installing, it is in light mode. After installing and redirecting to login page, then it is in dark mode. Expected behavior?

avatar Fedik
Fedik - comment - 12 Mar 2024

After installing and redirecting to login page, then it is in dark mode.

Does your OS use Dark Mode? if yes, then it is expected I guess.

avatar Quy
Quy - comment - 12 Mar 2024

Yes.

avatar Fedik Fedik - change - 17 Apr 2024
The description was changed
avatar Fedik Fedik - edited - 17 Apr 2024

Add a Comment

Login with GitHub to post a comment