@monolith-forensics/monolith-ui 1.1.36 → 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;
@@ -1,5 +1,5 @@
1
1
  export { THEMES as Themes } from "./variants";
2
- declare const getTheme: (scheme: "LIGHT" | "DARK") => {
2
+ declare const getTheme: (scheme: "LIGHT" | "DARK" | "DEFAULT") => {
3
3
  name: string;
4
4
  typography: {
5
5
  fontFamily: string;
@@ -1,7 +1,10 @@
1
1
  import variants from "./variants";
2
2
  export { THEMES as Themes } from "./variants";
3
3
  const getTheme = (scheme) => {
4
- let themeConfig = variants.find((variant) => variant.name === scheme);
4
+ let _scheme = scheme;
5
+ if (scheme === "DEFAULT")
6
+ _scheme = "LIGHT"; // Default theme is light theme
7
+ let themeConfig = variants.find((variant) => variant.name === _scheme);
5
8
  if (!themeConfig) {
6
9
  themeConfig = variants[0];
7
10
  }
@@ -1,6 +1,7 @@
1
1
  export declare const THEMES: {
2
2
  DARK: string;
3
3
  LIGHT: string;
4
+ DEFAULT: string;
4
5
  };
5
6
  declare const variants: {
6
7
  name: string;
@@ -4,6 +4,7 @@ import typography from "./typography";
4
4
  export const THEMES = {
5
5
  DARK: "DARK",
6
6
  LIGHT: "LIGHT",
7
+ DEFAULT: "DEFAULT",
7
8
  };
8
9
  const customBlue = {
9
10
  50: "#e9f0fb",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monolith-forensics/monolith-ui",
3
- "version": "1.1.36",
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)",
@@ -15,6 +15,9 @@
15
15
  "scripts": {
16
16
  "clean": "rm -r ./dist",
17
17
  "build": "tsc",
18
+ "patch": "yarn version --patch",
19
+ "minor": "yarn version --minor",
20
+ "major": "yarn version --major",
18
21
  "release": "yarn version --patch --deferred && yarn build && npm publish && yarn clean"
19
22
  },
20
23
  "dependencies": {