Skip to content

automatic theme detection from the system #84

@fab2713

Description

@fab2713

Hey,

When all our project is already detecting the system theme using CSS media queries, it might be useful for Overtype to do the same.
So, it would therefore be interesting to add a new theme named auto for example which could automatically switch between solar and cave themes depending on the system configuration.
On my side, i use something like this to do it manually:

const isDarkThemeQuery = window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)");
const defaultTheme = isDarkThemeQuery && isDarkThemeQuery.matches ? "cave" : "solar";

const [editor] = new OverType(".overtype-editor", {
  theme: defaultTheme,
});

if (isDarkThemeQuery) {
    isDarkThemeQuery.addEventListener("change", event => {
        editor.setTheme(event.matches ? "cave" : "solar");
    });
}

Feel free to adapt and include this or not.

Thank you for this project.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions