@monolith-forensics/monolith-ui 1.2.37 → 1.2.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DefaultTheme } from "styled-components";
|
|
2
|
-
export
|
|
2
|
+
export { styled, useTheme, createGlobalStyle, css } from "styled-components";
|
|
3
3
|
import { Themes } from "../theme";
|
|
4
4
|
import React from "react";
|
|
5
5
|
import typography from "../theme/typography";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import merge from "deepmerge";
|
|
3
3
|
import { ThemeProvider } from "styled-components";
|
|
4
|
-
export
|
|
4
|
+
export { styled, useTheme, createGlobalStyle, css } from "styled-components";
|
|
5
5
|
import { Themes, getTheme } from "../theme";
|
|
6
|
-
import { createContext, useState } from "react";
|
|
6
|
+
import { createContext, useEffect, useState } from "react";
|
|
7
7
|
import GlobalStyle from "./GlobalStyle";
|
|
8
8
|
const LocalStorageTheme = "Monolith Theme";
|
|
9
9
|
export const MonolithUIContext = createContext(undefined);
|
|
@@ -11,16 +11,15 @@ export const MonolithUIProvider = ({ children, theme, defaultColorScheme = local
|
|
|
11
11
|
Themes.DARK, colorScheme, }) => {
|
|
12
12
|
const [colorSchemeState, setColorSchemeState] = useState(defaultColorScheme);
|
|
13
13
|
const toggleColorScheme = () => {
|
|
14
|
-
setColorSchemeState((prev) =>
|
|
15
|
-
const newState = prev === Themes.LIGHT ? Themes.DARK : Themes.LIGHT;
|
|
16
|
-
localStorage.setItem(LocalStorageTheme, newState);
|
|
17
|
-
return newState;
|
|
18
|
-
});
|
|
14
|
+
setColorSchemeState((prev) => prev === Themes.LIGHT ? Themes.DARK : Themes.LIGHT);
|
|
19
15
|
};
|
|
20
16
|
const _scheme = colorScheme || colorSchemeState;
|
|
21
17
|
const defaultTheme = getTheme(_scheme);
|
|
22
18
|
// override default theme with the provided theme
|
|
23
19
|
const _theme = merge(defaultTheme, theme || {});
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
localStorage.setItem(LocalStorageTheme, _scheme);
|
|
22
|
+
}, [_scheme]);
|
|
24
23
|
return (_jsx(MonolithUIContext.Provider, { value: {
|
|
25
24
|
theme: _theme,
|
|
26
25
|
Themes,
|