Skip to content

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

Open
@nickcombs32

Description

@nickcombs32

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.

Activity

welcome

welcome commented on Mar 13, 2024

@welcome

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!

welcome

welcome commented on Mar 14, 2024

@welcome

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

rohanjadhav05 commented on Jun 14, 2024

@rohanjadhav05
Contributor

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area:AccessibilityCategory for accessibility related features and bugsEnhancementImprovement to an existing feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @nickcombs32@rohanjadhav05

      Issue actions

        Apply user's system color-scheme preference as the default site theme · Issue #3061 · processing/p5.js-web-editor