theme: add support for setting default theme via global variable

This commit is contained in:
Abdullah Atta
2024-10-01 16:13:35 +05:00
parent 83a663da2b
commit c8648659c7
2 changed files with 8 additions and 2 deletions

View File

@@ -18,7 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import {
SchemeColors,
SchemeColorsAsCSSVariables
SchemeColorsAsCSSVariables,
ThemeDefinition
} from "./theme-engine/types.js";
export * from "./theme/index.js";
@@ -26,6 +27,11 @@ export * from "./theme-engine/index.js";
export * from "./theme-engine/types.js";
export * from "./emotion/index.js";
declare global {
// eslint-disable-next-line no-var
var DEFAULT_THEME: ThemeDefinition | undefined;
}
declare module "csstype" {
interface Properties {
backgroundColor?:

View File

@@ -43,7 +43,7 @@ type ThemeEngineState = {
setTheme: (theme: ThemeDefinition) => void;
};
const useThemeEngineStore = create<ThemeEngineState>((set) => ({
theme: ThemeLight,
theme: globalThis.DEFAULT_THEME || ThemeLight,
setTheme: (theme) => set({ theme })
}));