@monolith-forensics/monolith-ui 1.2.36 → 1.2.37

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.
@@ -5,11 +5,17 @@ export * from "styled-components";
5
5
  import { Themes, getTheme } from "../theme";
6
6
  import { createContext, 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
- setColorSchemeState((prev) => prev === Themes.LIGHT ? Themes.DARK : Themes.LIGHT);
14
+ setColorSchemeState((prev) => {
15
+ const newState = prev === Themes.LIGHT ? Themes.DARK : Themes.LIGHT;
16
+ localStorage.setItem(LocalStorageTheme, newState);
17
+ return newState;
18
+ });
13
19
  };
14
20
  const _scheme = colorScheme || colorSchemeState;
15
21
  const defaultTheme = getTheme(_scheme);
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.37",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "author": "Matt Danner (Monolith Forensics LLC)",