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

Flicker in default dark theme #1455

Merged
merged 2 commits into from Oct 23, 2023
Merged

Conversation

coder12git
Copy link
Contributor

Description

This PR fixes #1451

Notes for Reviewers

Signed commits

  • Yes, I signed my commits.

@netlify
Copy link

netlify bot commented Oct 9, 2023

Deploy Preview for mesheryio-preview ready!

Name Link
🔨 Latest commit 534738d
🔍 Latest deploy log https://app.netlify.com/sites/mesheryio-preview/deploys/652e7d853cfd8500088484ff
😎 Deploy Preview https://deploy-preview-1455--mesheryio-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@abhijeetgauravm
Copy link

Let's discuss this on website call today at 5:30 PM IST / 7 AM Central time. Please add this as an agenda item in the meeting minutes

@coder12git
Copy link
Contributor Author

coder12git commented Oct 11, 2023

@sudhanshutech please check, and let me know what I am doing wrong, I have done everything similar to docs as you suggested but still it's not working. What, I realize is there is something in css mainly which is causing this, but what css, I still not able to find that?

@iArchitSharma
Copy link
Contributor

@coder12git have you figured out if this is happening due to CSS Rendering or JavaScript Timing?

@coder12git
Copy link
Contributor Author

coder12git commented Oct 12, 2023

@coder12git have you figured out if this is happening due to CSS Rendering or JavaScript Timing?

Yep mainly due to js timing, that's why I added the main logic in starting of the body tag, the main thing is the check whether light mode, dark mode or null should be done in starting, to prevent this which I did, but it doesn't work. I will try again today.

@leecalcote leecalcote added the pr/draft WIP/Draft pull request label Oct 12, 2023
@leecalcote
Copy link
Member

Please remove the draft label when ready for another review.

@iArchitSharma
Copy link
Contributor

@coder12git I have not seen what JS logic has been used but I got some idea by seeing the _includes/header.html
The Initial State of Dark mode is not set correctly, the initial state is set to the light mode which i guess is being manipulated by JS
So I guess we have to set the correct initial state in HTML and optimizing JavaScript logic

@coder12git
Copy link
Contributor Author

coder12git commented Oct 12, 2023

@coder12git I have not seen what JS logic has been used but I got some idea by seeing the _includes/header.html The Initial State of Dark mode is not set correctly, the initial state is set to the light mode which i guess is being manipulated by JS So I guess we have to set the correct initial state in HTML and optimizing JavaScript logic

Hmm i agree, can be fix by using dark-mode class in body which I tried but it doesn't work, will see again :)

@iArchitSharma
Copy link
Contributor

iArchitSharma commented Oct 12, 2023

@coder12git I have not seen what JS logic has been used but I got some idea by seeing the _includes/header.html The Initial State of Dark mode is not set correctly, the initial state is set to the light mode which i guess is being manipulated by JS So I guess we have to set the correct initial state in HTML and optimizing JavaScript logic

Hmm i agree, can be fix by using dark-mode class in body which I tried but it doesn't work, will see again :)

I know that because you not only have to change the 'dark-mode' class in the body but also all the 'images/logos' to their dark versions. I tried it, and it worked; there is no more flickering. However, there is still a problem: the icon of theme toggler itself is not changing on switching it.
Also, I noticed that by doing this, we are actually flipping the problem, not solving it, as the flickering will start occurring in light mode.

@coder12git
Copy link
Contributor Author

Hey @iArchitSharma let's discuss this in slack thread if you want, as this bug need to be fix as soon as possible.

@github-actions github-actions bot added area/ci Continuous integration | Build and release area/docs Improvements or additions to documentation area/catalog area/blog framework/helm component/integrations and removed area/ci Continuous integration | Build and release area/docs Improvements or additions to documentation area/catalog area/blog framework/helm component/integrations labels Oct 15, 2023
@iArchitSharma iArchitSharma removed the pr/draft WIP/Draft pull request label Oct 15, 2023
@abhijeetgauravm
Copy link

Let's discuss this on website call tomorrow at 5:30 PM IST / 7 AM Central time. Please add this as an agenda item in the meeting minutes.

Copy link
Member

Choose a reason for hiding this comment

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

@coder12git no changes are done here,
will you please make sure to retain the original spacings and indentation here in _includes/home-page.html ?

Copy link
Member

Choose a reason for hiding this comment

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

why are we changing this layout ?

@vishalvivekm
Copy link
Member

@coder12git @iArchitSharma
Good work, here.

Good that you've tried to split the code into components and then accordingly putting them in the over-all flow.
I, however, wonder just this one change ( the logic for checking the current set theme and applying effects acc to it) below in _includes/header.html should fix the issue:

Current

<body style="overflow-x: hidden">

After the change:

  <body style="overflow-x: hidden" class="dark-mode">
    <script>
      const body = document.body;
  
      if (localStorage.getItem("mode") === "light-mode") {
        body.classList.remove("dark-mode");
  
        let allLogos = document.querySelectorAll("#logo-dark-light");
        allLogos.forEach(e => e.src = e.dataset.logoForLight);
      }
  
      // Automatically set logos based on initial theme
      window.addEventListener('load', () => {
        let allLogos = document.querySelectorAll("#logo-dark-light");
        allLogos.forEach(e => {
          e.src = body.classList.contains("dark-mode") ? e.dataset.logoForDark : e.dataset.logoForLight;
        });
      });
    </script>
    

@coder12git
Copy link
Contributor Author

coder12git commented Oct 16, 2023

@coder12git @iArchitSharma
Good work, here.

Good that you've tried to split the code into components and then accordingly putting them in the over-all flow.
I, however, wonder just this one change ( the logic for checking the current set theme and applying effects acc to it) below in _includes/header.html should fix the issue:

Current

<body style="overflow-x: hidden">

After the change:

  <body style="overflow-x: hidden" class="dark-mode">
    <script>
      const body = document.body;
  
      if (localStorage.getItem("mode") === "light-mode") {
        body.classList.remove("dark-mode");
  
        let allLogos = document.querySelectorAll("#logo-dark-light");
        allLogos.forEach(e => e.src = e.dataset.logoForLight);
      }
  
      // Automatically set logos based on initial theme
      window.addEventListener('load', () => {
        let allLogos = document.querySelectorAll("#logo-dark-light");
        allLogos.forEach(e => {
          e.src = body.classList.contains("dark-mode") ? e.dataset.logoForDark : e.dataset.logoForLight;
        });
      });
    </script>
    

@vishalvivekm , so should we revert our pr and only change that one file or the current one is fine?

@vishalvivekm
Copy link
Member

@vishalvivekm , so should we revert our pr and only change that one file or the current one is fine?

I remember, on websites call y'day @iArchitSharma saying he'll be PRing the changes he has done locally

Signed-off-by: Archit Sharma <archit8679@gmail.com>
@iArchitSharma
Copy link
Contributor

@vishalvivekm, done. I hope everything is fine now

vishalvivekm

This comment was marked as duplicate.

Copy link
Member

@vishalvivekm vishalvivekm left a comment

Choose a reason for hiding this comment

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

@vishalvivekm vishalvivekm added the hacktoberfest Happy contributing! label Oct 23, 2023
@vishalvivekm vishalvivekm merged commit 6bed334 into meshery:master Oct 23, 2023
7 checks passed
@welcome
Copy link

welcome bot commented Oct 23, 2023

Thanks for your contribution to the Layer5 and Meshery community! 🎉

Meshery Logo
        ⭐ Please leave a star on the project. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Flickering in default dark theme
5 participants