@szum-tech/design-system 1.1.4 → 1.1.6
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
|
|
@@ -50,7 +52,7 @@ module.exports = {
|
|
|
50
52
|
extend: {}
|
|
51
53
|
},
|
|
52
54
|
plugins: [],
|
|
53
|
-
presets: [require("@szum-tech/design-system/
|
|
55
|
+
presets: [require("@szum-tech/design-system/tailwindcss/main-preset")]
|
|
54
56
|
};
|
|
55
57
|
```
|
|
56
58
|
|
|
@@ -59,7 +61,7 @@ module.exports = {
|
|
|
59
61
|
> Import CSS file from `@szum-tech/design-system/theme` with colors palette for dark and light theme and default styles (see file with [theme styles](https://github.com/JanSzewczyk/design-system/blob/main/src/theme/global.css))
|
|
60
62
|
|
|
61
63
|
```css
|
|
62
|
-
@import "@szum-tech/design-system/
|
|
64
|
+
@import "@szum-tech/design-system/tailwindcss/global.css";
|
|
63
65
|
|
|
64
66
|
@tailwind base;
|
|
65
67
|
@tailwind components;
|
|
@@ -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
|
-
|
|
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
|
@@ -12,23 +12,23 @@ var React2__default = /*#__PURE__*/_interopDefaultLegacy(React2);
|
|
|
12
12
|
// src/components/index.tsx
|
|
13
13
|
function Button() {
|
|
14
14
|
return /* @__PURE__ */ jsxRuntime.jsx("button", {
|
|
15
|
-
className: "rounded-lg border border-red-800 bg-red-300 p-4",
|
|
15
|
+
className: "scroll rounded-lg border border-red-800 bg-red-300 p-4",
|
|
16
16
|
children: "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 [
|
|
31
|
-
|
|
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(
|
|
45
|
-
}, [
|
|
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
|
@@ -4,23 +4,23 @@ import React2 from 'react';
|
|
|
4
4
|
// src/components/index.tsx
|
|
5
5
|
function Button() {
|
|
6
6
|
return /* @__PURE__ */ jsx("button", {
|
|
7
|
-
className: "rounded-lg border border-red-800 bg-red-300 p-4",
|
|
7
|
+
className: "scroll rounded-lg border border-red-800 bg-red-300 p-4",
|
|
8
8
|
children: "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 [
|
|
23
|
-
|
|
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(
|
|
37
|
-
}, [
|
|
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
|
@@ -50,8 +50,7 @@
|
|
|
50
50
|
},
|
|
51
51
|
"files": [
|
|
52
52
|
"dist/**",
|
|
53
|
-
"
|
|
54
|
-
"theme/**"
|
|
53
|
+
"tailwindcss/**"
|
|
55
54
|
],
|
|
56
55
|
"homepage": "https://github.com/JanSzewczyk/design-system#readme",
|
|
57
56
|
"keywords": [
|
|
@@ -83,17 +82,16 @@
|
|
|
83
82
|
"clean": "rm -rf node_modules && rm -rf dist",
|
|
84
83
|
"dev": "concurrently \"npm run dev:css\" \"npm run dev:build\"",
|
|
85
84
|
"dev:build": "tsup src/index.tsx --format esm,cjs --watch --dts --external react",
|
|
86
|
-
"dev:css": "tailwindcss -w -i
|
|
87
|
-
"postbuild": "cpy './theme' '../' --cwd='src'",
|
|
85
|
+
"dev:css": "tailwindcss -w -i tailwindcss/global.css -o src/styles/default.css",
|
|
88
86
|
"storybook": "start-storybook -p 6006",
|
|
89
87
|
"semantic-release": "semantic-release",
|
|
90
88
|
"build:storybook": "build-storybook",
|
|
91
89
|
"build:storybook:docs": "build-storybook --docs",
|
|
92
|
-
"prebuild:storybook": "tailwindcss -i
|
|
90
|
+
"prebuild:storybook": "tailwindcss -i tailwindcss/global.css -o src/styles/default.css"
|
|
93
91
|
},
|
|
94
92
|
"sideEffects": false,
|
|
95
93
|
"types": "./dist/index.d.ts",
|
|
96
|
-
"version": "1.1.
|
|
94
|
+
"version": "1.1.6",
|
|
97
95
|
"peerDependencies": {
|
|
98
96
|
"react": "^18.2.0",
|
|
99
97
|
"tailwind-scrollbar": "^2.0.1",
|
|
@@ -121,12 +121,6 @@
|
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
body {
|
|
124
|
-
@apply
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
@layer components {
|
|
129
|
-
.app-scroll {
|
|
130
|
-
@apply scrollbar scrollbar-thin scrollbar-thumb-gray-600/100 hover:scrollbar-thumb-gray-600/80;
|
|
124
|
+
@apply scroll bg-gray-900 font-sans text-typography-primary antialiased;
|
|
131
125
|
}
|
|
132
126
|
}
|