@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:
|
|
8
|
+
colorScheme: ColorScheme;
|
|
8
9
|
toggleColorScheme: () => void;
|
|
9
|
-
setColorScheme: React.Dispatch<React.SetStateAction<
|
|
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?:
|
|
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 [
|
|
8
|
+
const MonolithUIProvider = ({ children, theme = {}, defaultColorScheme = "DARK", colorScheme, }) => {
|
|
9
|
+
const [colorSchemeState, setColorSchemeState] = useState(defaultColorScheme);
|
|
10
10
|
const toggleColorScheme = () => {
|
|
11
|
-
|
|
11
|
+
setColorSchemeState((prev) => (prev === "LIGHT" ? "DARK" : "LIGHT"));
|
|
12
12
|
};
|
|
13
|
-
const
|
|
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/dist/theme/index.d.ts
CHANGED
package/dist/theme/index.js
CHANGED
|
@@ -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
|
|
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
|
}
|
package/dist/theme/variants.d.ts
CHANGED
package/dist/theme/variants.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@monolith-forensics/monolith-ui",
|
|
3
|
-
"version": "1.1.
|
|
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": {
|