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

Theme fix #2219

Merged
merged 1 commit into from
May 1, 2021
Merged

Theme fix #2219

merged 1 commit into from
May 1, 2021

Conversation

DukeManh
Copy link
Contributor

@DukeManh DukeManh commented Apr 28, 2021

Issue This PR Addresses

Type of Change

  • Bugfix: Change which fixes an issue
  • New Feature: Change which adds functionality
  • Documentation Update: Change which improves documentation
  • UI: Change which improves UI

Description

I wanted to steal how Telescope does dark theme and noticed some changes can be made.
This PR does the following:

  • Use system theme by default
  • Add theme switch color transition to avoid flash
  • Fix <li> cannot appear as a descendant of <li> error

Checklist

  • Quality: This PR builds and passes our npm test and works locally
  • Tests: This PR includes thorough tests or an explanation of why it does not
  • Screenshots: This PR includes screenshots or GIFs of the changes made or an explanation of why it does not (if applicable)
  • Documentation: This PR includes updated/added documentation to user exposed functionality or configuration variables are added/changed or an explanation of why it does not(if applicable)

Copy link
Contributor

@humphd humphd left a comment

Choose a reason for hiding this comment

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

I think this works well, but a few things I notice:

  1. When we toggle the theme, the entire side-bar animates again. I think the transition is applying to too many elements. This isn't new, but I just noticed it:

toggle

  1. When you are in dark mode, close the window, and re-open, it starts out in light mode and transitions to dark vs. beginning with dark.

@DukeManh
Copy link
Contributor Author

DukeManh commented Apr 28, 2021

@humphd I noticed that too but wasn't sure how to fix it, maybe I should file an issue.

The background color starts out white until the page is styled and becomes dark. Maybe we should apply the style in the document level? It's interesting to see pages like MUI or NodeJS also have this problem.

@huyxgit
Copy link

huyxgit commented Apr 28, 2021

@DukeManh don't need to use transition while switching between light/dark (+it's laggy already everytime we switch, adding transitions will make it even worse), I recommend you to remove those transition lines you added. which also causes some weird black/white color fading.

@DukeManh
Copy link
Contributor Author

@huynguyez details?

@DukeManh
Copy link
Contributor Author

@huynguyez Interesting, I think adding transition makes it feel less laggy.

@DukeManh
Copy link
Contributor Author

@humphd, I just updated. Can you test it again.

@huyxgit
Copy link

huyxgit commented Apr 28, 2021

@DukeManh the theme seems it cannot be changed immediately but need to refresh everytime

@DukeManh
Copy link
Contributor Author

@huynguyez I forgot to stage changes. It should be ok now.

@DukeManh
Copy link
Contributor Author

DukeManh commented Apr 28, 2021

It seems to still start out in light mode unfortunately.

@PedroFonsecaDEV
Copy link
Contributor

2021-04-29 07 26 26

I would suggest you go a bit slow:

Fixing the <li> cannot appear as a descendant of <li> error seems to be a good start point in this PR. And then investigate the solution for the transitions and so on in follow-ups.

@DukeManh
Copy link
Contributor Author

DukeManh commented Apr 29, 2021

@PedroFonsecaDEV I see. I filed #2222 and #2223 to investigate the issues which exist before my PR. And this PR will do 2 things only:

  • Use system theme by default, @tonyvugithub did this but for some reason, MUI's useMediaQuery weren't working but React-use's useMedia will.
  • Fix <li> cannot appear as a descendant of <li> error

@humphd , @huynguyez

@DukeManh DukeManh requested a review from humphd April 29, 2021 22:46
@huyxgit
Copy link

huyxgit commented Apr 29, 2021

@DukeManh the default theme fix is good, but whtat is Fix <li> cannot appear as a descendant of <li> error? You meant nested <li>?

which post/where can I test it? I saw some posts with nested <li> without problem

@DukeManh
Copy link
Contributor Author

@huynguyez the error doesn't always appear. It's a quick fix so I didn't mind taking screenshots. People have this problem too mui/material-ui#19827

Copy link
Contributor

@PedroFonsecaDEV PedroFonsecaDEV left a comment

Choose a reason for hiding this comment

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

LGTM.

@humphd
Copy link
Contributor

humphd commented Apr 30, 2021

@tonyvugithub can you take a quick look at this, since you wrote so much of the theme code?

@DukeManh DukeManh merged commit bcf9c4a into Seneca-CDOT:master May 1, 2021
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.

4 participants