@szum-tech/design-system 1.1.4 → 1.1.5

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.
package/README.md CHANGED
@@ -23,12 +23,14 @@ Szum-Tech Design System is available as an [npm package](https://www.npmjs.com/p
23
23
 
24
24
  ```sh
25
25
  npm install @szum-tech/design-system
26
+ npm install -D tailwindcss tailwind-scrollbar
26
27
  ```
27
28
 
28
29
  **yarn:**
29
30
 
30
31
  ```sh
31
32
  yarn add @szum-tech/design-system
33
+ yarn add -D tailwindcss tailwind-scrollbar
32
34
  ```
33
35
 
34
36
  ## Configuration
@@ -83,8 +85,6 @@ function Providers({children}) {
83
85
  }
84
86
  ```
85
87
 
86
-
87
-
88
88
  ## Documentation
89
89
 
90
90
  [Szum-Tech Design System](https://janszewczyk.github.io/design-system)
package/dist/index.d.ts CHANGED
@@ -11,10 +11,20 @@ interface ThemeContextType {
11
11
  declare const ThemeContext: React.Context<ThemeContextType>;
12
12
 
13
13
  interface ThemeProviderProps {
14
- defaultTheme?: ThemeType;
14
+ /**
15
+ * Children Components using theming.
16
+ */
15
17
  children?: React.ReactNode;
18
+ /**
19
+ * Define the default theme which is set at the beginning if neither local storage nor media is defined.
20
+ */
21
+ defaultTheme?: ThemeType;
22
+ /**
23
+ * Define theme that is always set initially.
24
+ */
25
+ theme?: ThemeType;
16
26
  }
17
- declare function ThemeProvider({ children, defaultTheme }: ThemeProviderProps): JSX.Element;
27
+ declare function ThemeProvider({ children, defaultTheme, theme }: ThemeProviderProps): JSX.Element;
18
28
 
19
29
  declare const useTheme: () => ThemeContextType;
20
30
 
package/dist/index.js CHANGED
@@ -17,18 +17,18 @@ function Button() {
17
17
  });
18
18
  }
19
19
  var ThemeContext = React2__default["default"].createContext({});
20
- function getInitialTheme() {
20
+ function getInitialTheme(defaultTheme) {
21
21
  if (typeof window !== "undefined" && window.localStorage) {
22
22
  const storageTheme = window.localStorage.getItem("theme");
23
23
  if (storageTheme === "dark" || !storageTheme && window.matchMedia("(prefers-color-scheme: dark)").matches) {
24
24
  return "dark";
25
25
  }
26
26
  }
27
- return "light";
27
+ return defaultTheme ?? "light";
28
28
  }
29
- function ThemeProvider({ children, defaultTheme }) {
30
- const [theme, setTheme] = React2__default["default"].useState(
31
- defaultTheme ? defaultTheme : getInitialTheme
29
+ function ThemeProvider({ children, defaultTheme, theme }) {
30
+ const [themeState, setThemeState] = React2__default["default"].useState(
31
+ theme ? theme : getInitialTheme(defaultTheme)
32
32
  );
33
33
  function rawSetTheme(rawTheme) {
34
34
  if (typeof window !== "undefined" && window.localStorage) {
@@ -41,10 +41,10 @@ function ThemeProvider({ children, defaultTheme }) {
41
41
  }
42
42
  }
43
43
  React2__default["default"].useEffect(() => {
44
- rawSetTheme(theme);
45
- }, [theme]);
44
+ rawSetTheme(themeState);
45
+ }, [themeState]);
46
46
  return /* @__PURE__ */ jsxRuntime.jsx(ThemeContext.Provider, {
47
- value: { theme, setTheme },
47
+ value: { theme: themeState, setTheme: setThemeState },
48
48
  children
49
49
  });
50
50
  }
package/dist/index.mjs CHANGED
@@ -9,18 +9,18 @@ function Button() {
9
9
  });
10
10
  }
11
11
  var ThemeContext = React2.createContext({});
12
- function getInitialTheme() {
12
+ function getInitialTheme(defaultTheme) {
13
13
  if (typeof window !== "undefined" && window.localStorage) {
14
14
  const storageTheme = window.localStorage.getItem("theme");
15
15
  if (storageTheme === "dark" || !storageTheme && window.matchMedia("(prefers-color-scheme: dark)").matches) {
16
16
  return "dark";
17
17
  }
18
18
  }
19
- return "light";
19
+ return defaultTheme ?? "light";
20
20
  }
21
- function ThemeProvider({ children, defaultTheme }) {
22
- const [theme, setTheme] = React2.useState(
23
- defaultTheme ? defaultTheme : getInitialTheme
21
+ function ThemeProvider({ children, defaultTheme, theme }) {
22
+ const [themeState, setThemeState] = React2.useState(
23
+ theme ? theme : getInitialTheme(defaultTheme)
24
24
  );
25
25
  function rawSetTheme(rawTheme) {
26
26
  if (typeof window !== "undefined" && window.localStorage) {
@@ -33,10 +33,10 @@ function ThemeProvider({ children, defaultTheme }) {
33
33
  }
34
34
  }
35
35
  React2.useEffect(() => {
36
- rawSetTheme(theme);
37
- }, [theme]);
36
+ rawSetTheme(themeState);
37
+ }, [themeState]);
38
38
  return /* @__PURE__ */ jsx(ThemeContext.Provider, {
39
- value: { theme, setTheme },
39
+ value: { theme: themeState, setTheme: setThemeState },
40
40
  children
41
41
  });
42
42
  }
package/package.json CHANGED
@@ -93,7 +93,7 @@
93
93
  },
94
94
  "sideEffects": false,
95
95
  "types": "./dist/index.d.ts",
96
- "version": "1.1.4",
96
+ "version": "1.1.5",
97
97
  "peerDependencies": {
98
98
  "react": "^18.2.0",
99
99
  "tailwind-scrollbar": "^2.0.1",