Dark/Light theme in the backend - configurable?

How to configure and adapt Aimeos based shops as developer
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
rowild

Dark/Light theme in the backend - configurable?

Post by rowild » 05 Mar 2023, 10:16

How does the dark/light theme in the Aimeos BE work? I always get the dark theme, even at noon. Is there a way to configure, which theme I'd prefer to have (which would be "light")? Or is there some kind of automatic dependency (browser, OS) working its magic?

rowild

Re: Dark/Light theme in the backend - configurable?

Post by rowild » 07 Mar 2023, 08:05

in JqadmController.php there is a line that checks the dark/line setting against a set cookie:

Code: Select all

$view->assign('theme', ($_COOKIE['aimeos_backend_theme'] ?? null) == 'dark' ? 'dark' : 'light');
That cookie "gets lost" as soon as the browser gets closed. It is only created again, when the toggle is clicked. (TYPO3 11, php8.1, aimeos 22.10). But – strangely enough! – phpbb cookies get set. Why is that? (I assume phpbb is the forum software you use for your help section. But why does the aimeos be in a TYPO3 installation set cookies that are irrelevant? Isn't that a GSPR problem?)

It would be great to have an option in the "settings" area that allows the admin to set a default ("light", "dark", and maybe even "auto").

User avatar
aimeos
Administrator
Posts: 7866
Joined: 01 Jan 1970, 00:00

Re: Dark/Light theme in the backend - configurable?

Post by aimeos » 08 Mar 2023, 07:44

If you have configured your browser to prefer dark mode, then the dark mode is used by default:
https://github.com/aimeos/ai-admin-jqad ... js#L10-L11

There's no "admin profile" where you can change settings for your account globally and therefore, the cookie solution was chosen. It would be also possible to use the storage of the browser which can be also session based or permanent.

The set cookie seems to be a session cookie that is removed if you close the browser because no expiry is set. If you can create a PR which adds an expiry time in the future, we are happy to merge it:
https://stackoverflow.com/questions/131 ... xpire-time

PHPBB cookies have a short lifetime but are not session based. They are necessary for the functionality of PHPBB and therefore the GDPR doesn't apply (it's only for tracking cookies).
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

rowild

Re: Dark/Light theme in the backend - configurable?

Post by rowild » 08 Mar 2023, 11:53

Thank you! I forgot that I have my browser set to use the dark theme by default.

(It is a pity that there is always a flash... the light theme can be seen for a short moment before the dark theme is active whenever one navigates to another page...)

However: As for the PHPBB cookies: why are there even PHPBB cookies in aimeos? That is what I do not understand! Just to make it clear: Those cookies are placed when I open my TYPO3/aimeos instance, on my domain – I am NOT talking about the forum! On my site there is not PHPBB...

User avatar
aimeos
Administrator
Posts: 7866
Joined: 01 Jan 1970, 00:00

Re: Dark/Light theme in the backend - configurable?

Post by aimeos » 08 Mar 2023, 12:14

rowild wrote: 08 Mar 2023, 11:53 (It is a pity that there is always a flash... the light theme can be seen for a short moment before the dark theme is active whenever one navigates to another page...)
This is due to the JS code that runs after the browser painted the elements with the light styling ...
rowild wrote: 08 Mar 2023, 11:53 However: As for the PHPBB cookies: why are there even PHPBB cookies in aimeos? That is what I do not understand! Just to make it clear: Those cookies are placed when I open my TYPO3/aimeos instance, on my domain – I am NOT talking about the forum! On my site there is not PHPBB...
The PHPBB cookies are from the aimeos.org web site. There can't be any PHPBB cookies at your own domain if you haven't installed PHPBB there too. Maybe the browser sends all cookies for aimeos.org due to the version check that occurs when you open the admin backend (check if there's a newer version available for security reasons).
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

rowild

Re: Dark/Light theme in the backend - configurable?

Post by rowild » 08 Mar 2023, 12:49

To get rid of the flash, the decision which theme should load could already be met where the css files are loaded (instead of setting a var in the body tag).

The PHPBB cookies are indeed only set, when I open the forum. It is weird that they are shown on my domain. No other cookies (like Gmail, Google Maps, etc) are shown under the application tab. Why is that? (Just updated to the latest packages via composer...)

User avatar
aimeos
Administrator
Posts: 7866
Joined: 01 Jan 1970, 00:00

Re: Dark/Light theme in the backend - configurable?

Post by aimeos » 09 Mar 2023, 11:01

rowild wrote: 08 Mar 2023, 12:49 To get rid of the flash, the decision which theme should load could already be met where the css files are loaded (instead of setting a var in the body tag).
That would require loading the CSS after the code JS decided about the theme and is not really preferable.
rowild wrote: 08 Mar 2023, 12:49 The PHPBB cookies are indeed only set, when I open the forum. It is weird that they are shown on my domain. No other cookies (like Gmail, Google Maps, etc) are shown under the application tab. Why is that? (Just updated to the latest packages via composer...)
Don't know.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

rowild

Re: Dark/Light theme in the backend - configurable?

Post by rowild » 09 Mar 2023, 15:54

aimeos wrote: 09 Mar 2023, 11:01 That would require loading the CSS after the code JS decided about the theme and is not really preferable.
Well, not really, if the light/dark-related CSS (that's mainly colors) would be split into their respective css files. But it's not a big deal.

Post Reply