Dark mode different image?

So we must start doing some tests to see where the problem is…

I would really like to know what do you se at your browser at the picture’s place…
Is it empty? Is there a sign of image missing?

Anyway, the first test we can do is to add a heading in your page and set a dmx-bind:text=“var_autoTheme.value” to it.

Then run your page and see what is the value of the heading inside your page

At the moment, when the automatic mode is chosen, nothing is displayed.
Even the variable is not displayed.

I’m afraid I cannot help you more…
I have to know what you see, what is going on on your page…

I already showed you that it is working fine for me my friend

If you don’t want to show a screenshot of your project, at least tell me what you see on your page

The green box is the picture…
What do you see there on your browser?

I’m checking because now I receive an error
Then I will let you know

1 Like

The variable is not attributed and is not displayed
If by default I give any value appears, but from an error in the search for the image
Schermata 2024-05-10 alle 10.47.17

If set DEFAULT VARIABLE —> assets/Images/Logo_250.png
the image is displayed.
So the problem is in the update of the variable

Your App root is Page?

Please try:

Add an alert inside your function to check that it is called…
alert("function works...");

Then when you run the page on browser do you get the alert message?

Function alert response = Ok it work

What do you think of this alternative?

https://medium.com/hypersphere-codes/detecting-system-theme-in-javascript-css-react-f6b961916d48

Then I assume that the javascript dmx.parse…

Please create a click event on whatever element and by USING the UI bind the value for the variable…

And then go to code view and copy the code of the click event

Then go to the javascript function and paste it
Just modify the image name to what you want for each case (dark / light)

Try and tell me

I think I did everything correct, but the variable is not visible
note that if I enter the correct value in the default variable, the display is correct
It’s the function that isn’t working properly

Wappler reports an error when in design mode, but no problem when in code mode



replace the outer single quotes (’) with double quotes (")
dmx.parse("…");

Now the errors are gone and it seems to work
Now I’m trying to change the theme on my Mac to see if it works correctly

1 Like

you could just reverse the if condition and see the picture you get…

I mean swap the pictures inside the if condition (the whole dmx.parse())

At the opening of the page he recognizes the PC (Dark or Light) state
But the variable (for automatic mode) is always the dark one and does not change
Consequently the image is always the dark one
Even if I replace the function

So, let me understand…

It initially understand and set the user preferred theme.

Then when you change theme from the theme-switch dropdown it ignores your new selection?
image

Please have open the developer console and check while changing themes
Which condition is true and have child (logo image)?
image