@monolith-forensics/monolith-ui 1.2.36 → 1.2.38

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.
@@ -3,10 +3,12 @@ import merge from "deepmerge";
3
3
  import { ThemeProvider } from "styled-components";
4
4
  export * 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
+ const LocalStorageTheme = "Monolith Theme";
8
9
  export const MonolithUIContext = createContext(undefined);
9
- export const MonolithUIProvider = ({ children, theme, defaultColorScheme = Themes.DARK, colorScheme, }) => {
10
+ export const MonolithUIProvider = ({ children, theme, defaultColorScheme = localStorage.getItem(LocalStorageTheme) ||
11
+ Themes.DARK, colorScheme, }) => {
10
12
  const [colorSchemeState, setColorSchemeState] = useState(defaultColorScheme);
11
13
  const toggleColorScheme = () => {
12
14
  setColorSchemeState((prev) => prev === Themes.LIGHT ? Themes.DARK : Themes.LIGHT);
@@ -15,6 +17,9 @@ export const MonolithUIProvider = ({ children, theme, defaultColorScheme = Theme
15
17
  const defaultTheme = getTheme(_scheme);
16
18
  // override default theme with the provided theme
17
19
  const _theme = merge(defaultTheme, theme || {});
20
+ useEffect(() => {
21
+ localStorage.setItem(LocalStorageTheme, _scheme);
22
+ }, [_scheme]);
18
23
  return (_jsx(MonolithUIContext.Provider, { value: {
19
24
  theme: _theme,
20
25
  Themes,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monolith-forensics/monolith-ui",
3
- "version": "1.2.36",
3
+ "version": "1.2.38",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "author": "Matt Danner (Monolith Forensics LLC)",