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

Minor changes to fix compatibility with older browsers #2355

Merged
merged 1 commit into from
Dec 6, 2024

Conversation

Jazzzny
Copy link
Contributor

@Jazzzny Jazzzny commented Oct 26, 2024

This PR provides 2 changes to fix compatibility with older browsers.

  1. Older browsers that do not support the prefers-color-scheme media query will fail to load any CSS when the dark/light mode code is enabled.

Additionally, the W3 Specification states that the light theme should be loaded as a fallback if no preference is given.

This can trivially be resolved by removing the prefers-color-scheme: light media query from the light theme, to set it as the default if the browser does not handle the query.

Screen.Recording.2024-10-26.at.1.51.18.PM.mov

This does not impact browsers that support the query, as prefers-color-scheme takes priority over the "base" stylesheet:
Screenshot 2024-10-26 at 2 04 33 PM

  1. Older browsers do not support addEventListener on matchMedia, instead add a fallback using addListener.

@Jazzzny
Copy link
Contributor Author

Jazzzny commented Oct 26, 2024

Appended with a fallback for addEventListener. This makes the editor fully functional on every browser I have tested, back to Safari 5.1.7.

@Jazzzny Jazzzny changed the title Fix CSS compatibility with older browsers that do not support prefers-color-scheme & adhere to W3 specification Fix compatibility with older browsers that do not support prefers-color-scheme & adhere to W3 specification Oct 26, 2024
@Jazzzny Jazzzny changed the title Fix compatibility with older browsers that do not support prefers-color-scheme & adhere to W3 specification Minor changes to fix compatibility with older browsers Oct 27, 2024
Copy link
Member

@Ninjaclasher Ninjaclasher left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@Ninjaclasher
Copy link
Member

@Jazzzny could you squash your commits into one?

@codecov-commenter
Copy link

codecov-commenter commented Dec 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 46.72%. Comparing base (fd7fb05) to head (07e9d9f).
Report is 23 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2355      +/-   ##
==========================================
- Coverage   46.76%   46.72%   -0.05%     
==========================================
  Files         251      253       +2     
  Lines       13317    13390      +73     
==========================================
+ Hits         6228     6256      +28     
- Misses       7089     7134      +45     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Jazzzny Jazzzny force-pushed the css-compat branch 2 times, most recently from c2000d0 to 2563342 Compare December 6, 2024 23:11
- Remove prefers-color-scheme from light stylesheet
- Add fallback for addEventListener
@Jazzzny
Copy link
Contributor Author

Jazzzny commented Dec 6, 2024

Yep, squashed 👍 (At least I think so, my local tree was a mess)

@Ninjaclasher Ninjaclasher added this pull request to the merge queue Dec 6, 2024
Merged via the queue into DMOJ:master with commit d97a56f Dec 6, 2024
3 checks passed
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.

3 participants