@wonderflow/react-components 2.18.7 → 2.18.11
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/index.d.ts +1 -1
- package/index.js +1 -1
- package/package.json +3 -3
- package/theme-switch/index.d.ts +0 -2
- package/theme-switch/index.js +0 -2
- package/theme-switch/theme-switch.d.ts +5 -2
- package/theme-switch/theme-switch.js +5 -22
- package/themes/dark.css +1 -1
- package/themes/light.css +1 -1
- package/themes.css +3 -3
- package/theme-switch/theme-provider.d.ts +0 -13
- package/theme-switch/theme-provider.js +0 -23
- package/theme-switch/use-theme-context.d.ts +0 -1
- package/theme-switch/use-theme-context.js +0 -9
package/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export { Textfield } from './textfield';
|
|
|
13
13
|
export { Snackbar } from './snackbar';
|
|
14
14
|
export { ClampText } from './clamp-text';
|
|
15
15
|
export { Checkbox, Radio, Toggle } from './selection-controls';
|
|
16
|
-
export {
|
|
16
|
+
export { ThemeSwitch } from './theme-switch';
|
|
17
17
|
export { Elevator } from './elevator';
|
|
18
18
|
export { Card } from './card';
|
|
19
19
|
export { StarMeter } from './star-meter';
|
package/index.js
CHANGED
|
@@ -13,7 +13,7 @@ export { Textfield } from './textfield';
|
|
|
13
13
|
export { Snackbar } from './snackbar';
|
|
14
14
|
export { ClampText } from './clamp-text';
|
|
15
15
|
export { Checkbox, Radio, Toggle } from './selection-controls';
|
|
16
|
-
export {
|
|
16
|
+
export { ThemeSwitch } from './theme-switch';
|
|
17
17
|
export { Elevator } from './elevator';
|
|
18
18
|
export { Card } from './card';
|
|
19
19
|
export { StarMeter } from './star-meter';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wonderflow/react-components",
|
|
3
3
|
"description": "UI components from Wonderflow's Wanda design system",
|
|
4
|
-
"version": "2.18.
|
|
4
|
+
"version": "2.18.11",
|
|
5
5
|
"author": "Wonderflow",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "index.js",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"clsx": "1.1.1",
|
|
64
64
|
"flat": "5.0.2",
|
|
65
65
|
"framer-motion": "4.1.17",
|
|
66
|
-
"postcss": "8.3.
|
|
66
|
+
"postcss": "8.3.8",
|
|
67
67
|
"react": ">=17.0.2",
|
|
68
68
|
"react-dom": ">=17.0.2",
|
|
69
69
|
"react-popper-tooltip": "4.3.0",
|
|
@@ -124,6 +124,6 @@
|
|
|
124
124
|
"svgstore": "3.0.0-2",
|
|
125
125
|
"typescript": "4.4.3",
|
|
126
126
|
"typescript-plugin-css-modules": "3.4.0",
|
|
127
|
-
"yargs": "17.2.
|
|
127
|
+
"yargs": "17.2.1"
|
|
128
128
|
}
|
|
129
129
|
}
|
package/theme-switch/index.d.ts
CHANGED
package/theme-switch/index.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { SelectProps } from '../select';
|
|
3
3
|
import { Except } from 'type-fest';
|
|
4
|
-
export declare type ThemeSwitchProps = Except<SelectProps, 'children'
|
|
5
|
-
|
|
4
|
+
export declare type ThemeSwitchProps = Except<SelectProps, 'children'> & {
|
|
5
|
+
currentTheme?: string;
|
|
6
|
+
onChange: SelectProps['onChange'];
|
|
7
|
+
};
|
|
8
|
+
export declare const ThemeSwitch: ({ className, currentTheme, onChange }: ThemeSwitchProps) => JSX.Element;
|
|
@@ -1,31 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
|
-
import React, { useCallback } from 'react';
|
|
1
|
+
import React from 'react';
|
|
13
2
|
import { Select } from '../select';
|
|
14
|
-
import { useThemeContext } from './use-theme-context';
|
|
15
3
|
import clsx from 'clsx';
|
|
16
|
-
export const ThemeSwitch = (
|
|
17
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
18
|
-
const { theme, setTheme } = useThemeContext();
|
|
19
|
-
const changeTheme = useCallback((theme) => {
|
|
20
|
-
setTheme(theme);
|
|
21
|
-
}, [setTheme]);
|
|
4
|
+
export const ThemeSwitch = ({ className, currentTheme = 'system', onChange }) => {
|
|
22
5
|
const icon = {
|
|
23
6
|
light: 'sun-bright',
|
|
24
|
-
|
|
7
|
+
system: 'pc',
|
|
25
8
|
dark: 'moon'
|
|
26
9
|
};
|
|
27
|
-
return (React.createElement(Select,
|
|
10
|
+
return (React.createElement(Select, { onChange: onChange, icon: currentTheme === 'system' ? icon.system : icon[currentTheme], defaultValue: currentTheme, className: clsx(className), "aria-label": "Change color scheme" },
|
|
28
11
|
React.createElement("option", { value: "light" }, "Light"),
|
|
29
|
-
React.createElement("option", { value: "
|
|
12
|
+
React.createElement("option", { value: "system" }, "System"),
|
|
30
13
|
React.createElement("option", { value: "dark" }, "Dark")));
|
|
31
14
|
};
|
package/themes/dark.css
CHANGED
package/themes/light.css
CHANGED
package/themes.css
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
color: var(--global-foreground);
|
|
5
5
|
/**
|
|
6
6
|
* Do not edit directly
|
|
7
|
-
* Generated on Mon, 27 Sep 2021
|
|
7
|
+
* Generated on Mon, 27 Sep 2021 12:23:06 GMT
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
color: var(--global-foreground);
|
|
52
52
|
/**
|
|
53
53
|
* Do not edit directly
|
|
54
|
-
* Generated on Mon, 27 Sep 2021
|
|
54
|
+
* Generated on Mon, 27 Sep 2021 12:23:06 GMT
|
|
55
55
|
*/
|
|
56
56
|
|
|
57
57
|
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
color: var(--global-foreground);
|
|
100
100
|
/**
|
|
101
101
|
* Do not edit directly
|
|
102
|
-
* Generated on Mon, 27 Sep 2021
|
|
102
|
+
* Generated on Mon, 27 Sep 2021 12:23:06 GMT
|
|
103
103
|
*/
|
|
104
104
|
|
|
105
105
|
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import React, { FunctionComponent } from 'react';
|
|
2
|
-
export declare type ThemeType = 'light' | 'dark' | 'auto' | undefined;
|
|
3
|
-
export declare type ThemeContextType = {
|
|
4
|
-
theme: ThemeType;
|
|
5
|
-
setTheme: React.Dispatch<React.SetStateAction<ThemeType>>;
|
|
6
|
-
};
|
|
7
|
-
declare type ThemeProviderProps = {
|
|
8
|
-
theme?: ThemeType;
|
|
9
|
-
persistState?: boolean;
|
|
10
|
-
};
|
|
11
|
-
export declare const ThemeContext: React.Context<ThemeContextType>;
|
|
12
|
-
export declare const ThemeProvider: FunctionComponent<ThemeProviderProps>;
|
|
13
|
-
export {};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import React, { createContext, useState, useEffect } from 'react';
|
|
2
|
-
export const ThemeContext = createContext({ theme: 'auto', setTheme: () => { } });
|
|
3
|
-
export const ThemeProvider = ({ children, theme: initialTheme = 'auto', persistState = true }) => {
|
|
4
|
-
const [theme, setTheme] = useState(initialTheme);
|
|
5
|
-
const value = { theme, setTheme };
|
|
6
|
-
useEffect(() => {
|
|
7
|
-
if (persistState) {
|
|
8
|
-
const persistedTheme = localStorage.getItem('theme');
|
|
9
|
-
if (persistedTheme) {
|
|
10
|
-
setTheme(persistedTheme);
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
}, [persistState]);
|
|
14
|
-
useEffect(() => {
|
|
15
|
-
if (theme) {
|
|
16
|
-
document.documentElement.dataset.theme = theme;
|
|
17
|
-
if (persistState) {
|
|
18
|
-
localStorage.setItem('theme', theme);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}, [persistState, theme]);
|
|
22
|
-
return React.createElement(ThemeContext.Provider, { value: value }, children);
|
|
23
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const useThemeContext: () => import("./theme-provider").ThemeContextType;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { useContext } from 'react';
|
|
2
|
-
import { ThemeContext } from './theme-provider';
|
|
3
|
-
export const useThemeContext = () => {
|
|
4
|
-
const context = useContext(ThemeContext);
|
|
5
|
-
if (!context) {
|
|
6
|
-
throw new Error('To use `useThemeContext`, component must be within a ThemeProvider');
|
|
7
|
-
}
|
|
8
|
-
return context;
|
|
9
|
-
};
|