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

Apply user's system color-scheme preference as the default site theme #3061

Open
2 of 17 tasks
nickcombs32 opened this issue Mar 13, 2024 · 3 comments · May be fixed by #3371
Open
2 of 17 tasks

Apply user's system color-scheme preference as the default site theme #3061

nickcombs32 opened this issue Mar 13, 2024 · 3 comments · May be fixed by #3371
Labels
Area:Accessibility Category for accessibility related features and bugs Enhancement

Comments

@nickcombs32
Copy link

Increasing access

Brings site up to modern CSS accessibility standards by reducing eye strain.

Most appropriate sub-area of p5.js?

  • Accessibility
  • Color
  • Core/Environment/Rendering
  • Data
  • DOM
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • WebGL
  • Build process
  • Unit testing
  • Internationalization
  • Friendly errors
  • Other (specify if possible)

Feature enhancement details

CSS media feature is available to detect user's preference:
https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme

If feasible, apply to both the editor and the resource pages. Changing the theme in options overrides the default.

Copy link

welcome bot commented Mar 13, 2024

Welcome! 👋 Thanks for opening your first issue here! And to ensure the community is able to respond to your issue, please make sure to fill out the inputs in the issue forms. Thank you!

@github-actions github-actions bot added the Area:Accessibility Category for accessibility related features and bugs label Mar 13, 2024
@limzykenneth limzykenneth transferred this issue from processing/p5.js Mar 14, 2024
Copy link

welcome bot commented Mar 14, 2024

Welcome! 👋 Thanks for opening your first issue here! And to ensure the community is able to respond to your issue, be sure to follow the issue template if you haven't already.

@rohanjadhav05
Copy link
Contributor

rohanjadhav05 commented Jun 14, 2024

Hi @raclim, @lindapaiste, @nickcombs32 we can get the system's mode and initialise the mode with the reducer we are using to set the theme.

Which will help us to get the system mode by default and when user select the mode from the option we will change the mode. below I have added the dummy code for it, also will be raising a PR for this issue.

// will get system mode from this function
const getSystemTheme = () => {
const prefersDarkMode = window.matchMedia('(prefers-color-scheme: dark)')
.matches;
return prefersDarkMode ? 'dark' : 'light';
};

// system mode is present in variable systemTheme
const systemTheme = getSystemTheme();

// initialising the theme variable with the system's mode
theme: systemTheme

Please do let me know if there is anything to improve...

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area:Accessibility Category for accessibility related features and bugs Enhancement
Projects
None yet
2 participants