@monolith-forensics/monolith-ui 1.1.37 → 1.1.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.
@@ -1,18 +1,20 @@
1
1
  import { DefaultTheme } from "styled-components";
2
2
  import { Themes } from "../theme";
3
3
  import React from "react";
4
+ type ColorScheme = "LIGHT" | "DARK" | "DEFAULT";
4
5
  export interface MonolithUIContextType {
5
6
  theme: DefaultTheme;
6
7
  Themes: typeof Themes;
7
- colorScheme: "LIGHT" | "DARK";
8
+ colorScheme: ColorScheme;
8
9
  toggleColorScheme: () => void;
9
- setColorScheme: React.Dispatch<React.SetStateAction<"LIGHT" | "DARK">>;
10
+ setColorScheme: React.Dispatch<React.SetStateAction<ColorScheme>>;
10
11
  }
11
12
  export declare const MonolithUIContext: React.Context<MonolithUIContextType | undefined>;
12
13
  interface MonolithUIProviderProps {
13
14
  children: React.ReactNode | React.ReactNode[];
14
15
  theme?: DefaultTheme;
15
- defaultColorScheme?: "LIGHT" | "DARK";
16
+ defaultColorScheme?: ColorScheme;
17
+ colorScheme?: ColorScheme;
16
18
  }
17
- declare const MonolithUIProvider: ({ children, theme, defaultColorScheme, }: MonolithUIProviderProps) => import("react/jsx-runtime").JSX.Element;
19
+ declare const MonolithUIProvider: ({ children, theme, defaultColorScheme, colorScheme, }: MonolithUIProviderProps) => import("react/jsx-runtime").JSX.Element;
18
20
  export default MonolithUIProvider;
@@ -5,20 +5,21 @@ import getTheme, { Themes } from "../theme";
5
5
  import { createContext, useState } from "react";
6
6
  import GlobalStyle from "./GlobalStyle";
7
7
  export const MonolithUIContext = createContext(undefined);
8
- const MonolithUIProvider = ({ children, theme = {}, defaultColorScheme = "DARK", }) => {
9
- const [colorScheme, setColorScheme] = useState(defaultColorScheme);
8
+ const MonolithUIProvider = ({ children, theme = {}, defaultColorScheme = "DARK", colorScheme, }) => {
9
+ const [colorSchemeState, setColorSchemeState] = useState(defaultColorScheme);
10
10
  const toggleColorScheme = () => {
11
- setColorScheme(colorScheme === "LIGHT" ? "DARK" : "LIGHT");
11
+ setColorSchemeState((prev) => (prev === "LIGHT" ? "DARK" : "LIGHT"));
12
12
  };
13
- const defaultTheme = getTheme(colorScheme);
13
+ const _scheme = colorScheme || colorSchemeState;
14
+ const defaultTheme = getTheme(_scheme);
14
15
  // override default theme with the provided theme
15
16
  const _theme = merge(defaultTheme, theme);
16
17
  return (_jsx(MonolithUIContext.Provider, { value: {
17
18
  theme: _theme,
18
19
  Themes,
19
- colorScheme,
20
+ colorScheme: _scheme,
20
21
  toggleColorScheme,
21
- setColorScheme,
22
+ setColorScheme: setColorSchemeState,
22
23
  }, children: _jsxs(ThemeProvider, { theme: _theme, children: [_jsx(GlobalStyle, { theme: _theme }), children] }) }));
23
24
  };
24
25
  export default MonolithUIProvider;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monolith-forensics/monolith-ui",
3
- "version": "1.1.37",
3
+ "version": "1.1.38",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "author": "Matt Danner (Monolith Forensics LLC)",