Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dark/light theme toggle #1154

Closed
wants to merge 12 commits into from
Closed

Update dark/light theme toggle #1154

wants to merge 12 commits into from

Conversation

Shubham-Patel07
Copy link
Contributor

@Shubham-Patel07 Shubham-Patel07 commented Dec 20, 2023

What kind of changes does this PR include?

Description

New enhancement done, Updated the radiio button based toggle switch to checkbox based toggle switch

from

228714471-d7090e59-a36e-4f45-9211-037ba0b8fed3

updated one,

291900265-fdc20c9c-03f0-4069-b7eb-21807f62dc9f 291900167-272802da-daf5-4b44-b1ce-22612c098d18

…tring is not empty, in ChallangeController and ChallengeUI
@commjoen commjoen changed the title Fix/issue721 Update dark/light theme toggle Dec 21, 2023
Copy link
Collaborator

@commjoen commjoen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Shubham-Patel07 , the icons look awesome! There are just a few things that will need some move love and then we are good to go, can you please:

  • make sure the toggle only renders a switch when clicked/tapped
  • make sure the attributes are back so the cypress tests can run (and/or adapt the cypress test for the toggle switching)

Cheers!

src/main/resources/templates/index.html Outdated Show resolved Hide resolved
<label>
<span class="visually-hidden">Dark</span>
<input type="radio" value="dark" name="theme">
<span class="checkmark" th:attr="data-cy='dark-mode-radio'">🌜</span>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the attributes are required for people who have trouble seeing and are required for the cypress tests to run. Can you add the data-cy attrs to your new implementation please?
And the cypress tests need updating to use the new labels to be able to switch themes

initialTheme = localStorage.getItem('darkMode') === 'true'
} else {
initialTheme = darkModeMediaQuery.matches
}
Copy link
Collaborator

@commjoen commjoen Dec 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we prevent the switch from "animating" every time we load a page in dark mode please? this makes the rendering time quite lengthy . I rather only have the animation when somethiing changes by the user.
This is also one of the reasons why the cypress tests are failing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i tried but i am not able to resolve that flickering issue every time we navigate to different page, but about the cypress test its failing cause they are written as respect to radio button logic and i have updated to checkbox hence they are failing. so i am tweaking the test script a bit

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the flickering issue: might that have to do with how you load the initial state and how you render it ;-)?
Happy to review again when you have the tests fixed and the attributes th:attr="data-cy='dark-mode-<widgettype>'" back again.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cypress seems to work, i guess there are 2 things left:

  • In the console of the browser, I now get an error: "Error: attribute d: Expected number, "…7.18492 13.0678 ..."."
  • it seems that when we set it to "checked" in the dom it only animates when we want to go to light mode. @mikewoudenberg would you know what to do here?

@Shubham-Patel07
Copy link
Contributor Author

I have pushed the test scripts please look into flickering issue

@commjoen
Copy link
Collaborator

I have looked into it, but could not find a solution. Will have to postpone that for a while unless @bendehaan finds a solution maybe. I am also not sure if this control is usable for the people with visibility issues.

@Shubham-Patel07 Shubham-Patel07 closed this by deleting the head repository Feb 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update the dark mode switch by adding a toggle switch button
2 participants