icssc / AntAlmanac

A course exploration and scheduling tool for UCI Anteaters
https://antalmanac.com
MIT License
54 stars 64 forks source link

isDarkMode() should be deprecated in favor of ThemeStore #812

Closed KevinWu098 closed 7 months ago

KevinWu098 commented 9 months ago

Issue

          This shouldn't exist anymore, and it's consumers should refactor to use the store directly. Up to you to include it in this PR.

_Originally posted by @MinhxNguyen7 in https://github.com/icssc/AntAlmanac/pull/810#discussion_r1405330346_

export function isDarkMode() {
    switch (useThemeStore.getState().appTheme) {
        case 'light':
            return false;
        case 'dark':
            return true;
        default:
            return window.matchMedia('(prefers-color-scheme: dark)').matches;
    }
}

isDarkMode, found in helpers.ts should be removed in favor of having components directly subscribe to the ThemeStore.

Good First Taskers

For any good first task doers, relevant code can be found in helpers.ts as noted above. If you're using VSCode, you can find all instances of isDarkMode() by right-clicking and looking for "Find All References."

In each of those files, you'll want to import the ThemeStore's value, and use that instead!

    const appTheme = useThemeStore((store) => store.appTheme);
KevinWu098 commented 9 months ago

Just a quick note @srukelman that this issue is blocked by #810, which will implement the ThemeStore and SettingsStore!

KevinWu098 commented 9 months ago

Just a quick note @srukelman that this issue is blocked by #810, which will implement the ThemeStore and SettingsStore!

Unblocked! #810 is merged :)