@uni-design-system/uni-react 0.0.13 → 0.0.14
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,5 +1,5 @@
|
|
|
1
1
|
import React, { CSSProperties, ReactNode } from 'react';
|
|
2
|
-
import { ButtonType } from '@uni-design-system/uni-core';
|
|
2
|
+
import { ButtonType, ContentColorToken } from '@uni-design-system/uni-core';
|
|
3
3
|
import { IconName } from '../../core/icon';
|
|
4
4
|
export interface ButtonProps {
|
|
5
5
|
text?: string;
|
|
@@ -8,8 +8,9 @@ export interface ButtonProps {
|
|
|
8
8
|
active?: boolean;
|
|
9
9
|
disabled?: boolean;
|
|
10
10
|
iconName?: IconName;
|
|
11
|
+
contentColor?: ContentColorToken;
|
|
11
12
|
onClick?: React.MouseEventHandler<HTMLButtonElement>;
|
|
12
13
|
disableRipple?: boolean;
|
|
13
14
|
style?: CSSProperties;
|
|
14
15
|
}
|
|
15
|
-
export declare const Button: ({ text, children, buttonType, disabled, iconName, onClick, disableRipple, style: userStyle, ...rest }: ButtonProps) => JSX.Element;
|
|
16
|
+
export declare const Button: ({ text, children, buttonType, disabled, iconName, contentColor: overrideContentColor, onClick, disableRipple, style: userStyle, ...rest }: ButtonProps) => JSX.Element;
|
|
@@ -43,20 +43,16 @@ const core_1 = require("../../core");
|
|
|
43
43
|
const icon_text_row_1 = require("../icon-text-row");
|
|
44
44
|
const use_ripple_hook_1 = __importDefault(require("use-ripple-hook"));
|
|
45
45
|
const Button = (_a) => {
|
|
46
|
-
var { text, children, buttonType = 'filled', disabled = false, iconName, onClick, disableRipple = false, style: userStyle } = _a, rest = __rest(_a, ["text", "children", "buttonType", "disabled", "iconName", "onClick", "disableRipple", "style"]);
|
|
46
|
+
var { text, children, buttonType = 'filled', disabled = false, iconName, contentColor: overrideContentColor, onClick, disableRipple = false, style: userStyle } = _a, rest = __rest(_a, ["text", "children", "buttonType", "disabled", "iconName", "contentColor", "onClick", "disableRipple", "style"]);
|
|
47
47
|
const { deviceSize } = (0, core_1.useLayout)();
|
|
48
48
|
const theme = (0, core_1.useTheme)();
|
|
49
49
|
const [ref, createRipple] = (0, use_ripple_hook_1.default)({ disabled: disableRipple || buttonType === 'elevated' });
|
|
50
50
|
const buttonProps = theme.buttons[buttonType];
|
|
51
51
|
const getOnColorToken = (color) => `on-${color}`;
|
|
52
|
-
const
|
|
52
|
+
const contentColor = overrideContentColor || getOnColorToken(buttonProps.color);
|
|
53
53
|
const [hover, setHover] = (0, react_1.useState)(false);
|
|
54
54
|
const [click, setClick] = (0, react_1.useState)(false);
|
|
55
|
-
const [contentColor, setContentColor] = (0, react_1.useState)(defaultContentColor);
|
|
56
55
|
const style = Style(theme, buttonType, deviceSize, hover, disabled, click);
|
|
57
|
-
(0, react_1.useEffect)(() => {
|
|
58
|
-
setContentColor(getOnColorToken(disabled ? 'inverse-on-surface' : buttonProps.color));
|
|
59
|
-
}, [disabled]);
|
|
60
56
|
(0, react_1.useEffect)(() => {
|
|
61
57
|
setTimeout(() => {
|
|
62
58
|
setClick(false);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { CSSProperties, ReactNode } from 'react';
|
|
2
|
-
import { ButtonType } from '@uni-design-system/uni-core';
|
|
2
|
+
import { ButtonType, ContentColorToken } from '@uni-design-system/uni-core';
|
|
3
3
|
import { IconName } from '../../core/icon';
|
|
4
4
|
export interface ButtonProps {
|
|
5
5
|
text?: string;
|
|
@@ -8,8 +8,9 @@ export interface ButtonProps {
|
|
|
8
8
|
active?: boolean;
|
|
9
9
|
disabled?: boolean;
|
|
10
10
|
iconName?: IconName;
|
|
11
|
+
contentColor?: ContentColorToken;
|
|
11
12
|
onClick?: React.MouseEventHandler<HTMLButtonElement>;
|
|
12
13
|
disableRipple?: boolean;
|
|
13
14
|
style?: CSSProperties;
|
|
14
15
|
}
|
|
15
|
-
export declare const Button: ({ text, children, buttonType, disabled, iconName, onClick, disableRipple, style: userStyle, ...rest }: ButtonProps) => JSX.Element;
|
|
16
|
+
export declare const Button: ({ text, children, buttonType, disabled, iconName, contentColor: overrideContentColor, onClick, disableRipple, style: userStyle, ...rest }: ButtonProps) => JSX.Element;
|
|
@@ -14,20 +14,16 @@ import { BoxShadow, Text, useLayout, useTheme } from '../../core';
|
|
|
14
14
|
import { IconTextRow } from '../icon-text-row';
|
|
15
15
|
import useRipple from 'use-ripple-hook';
|
|
16
16
|
export const Button = (_a) => {
|
|
17
|
-
var { text, children, buttonType = 'filled', disabled = false, iconName, onClick, disableRipple = false, style: userStyle } = _a, rest = __rest(_a, ["text", "children", "buttonType", "disabled", "iconName", "onClick", "disableRipple", "style"]);
|
|
17
|
+
var { text, children, buttonType = 'filled', disabled = false, iconName, contentColor: overrideContentColor, onClick, disableRipple = false, style: userStyle } = _a, rest = __rest(_a, ["text", "children", "buttonType", "disabled", "iconName", "contentColor", "onClick", "disableRipple", "style"]);
|
|
18
18
|
const { deviceSize } = useLayout();
|
|
19
19
|
const theme = useTheme();
|
|
20
20
|
const [ref, createRipple] = useRipple({ disabled: disableRipple || buttonType === 'elevated' });
|
|
21
21
|
const buttonProps = theme.buttons[buttonType];
|
|
22
22
|
const getOnColorToken = (color) => `on-${color}`;
|
|
23
|
-
const
|
|
23
|
+
const contentColor = overrideContentColor || getOnColorToken(buttonProps.color);
|
|
24
24
|
const [hover, setHover] = useState(false);
|
|
25
25
|
const [click, setClick] = useState(false);
|
|
26
|
-
const [contentColor, setContentColor] = useState(defaultContentColor);
|
|
27
26
|
const style = Style(theme, buttonType, deviceSize, hover, disabled, click);
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
setContentColor(getOnColorToken(disabled ? 'inverse-on-surface' : buttonProps.color));
|
|
30
|
-
}, [disabled]);
|
|
31
27
|
useEffect(() => {
|
|
32
28
|
setTimeout(() => {
|
|
33
29
|
setClick(false);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uni-design-system/uni-react",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.14",
|
|
4
4
|
"description": "React component library for the UNI Design System.",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@dnd-kit/core": "^6.0.7",
|
|
37
37
|
"@dnd-kit/modifiers": "^6.0.1",
|
|
38
38
|
"@dnd-kit/sortable": "^7.0.2",
|
|
39
|
-
"@uni-design-system/uni-core": "^0.0.
|
|
39
|
+
"@uni-design-system/uni-core": "^0.0.34",
|
|
40
40
|
"@uni-design-system/uni-react-icons": "^0.1.2",
|
|
41
41
|
"framer-motion": "4.1.17",
|
|
42
42
|
"use-ripple-hook": "^1.0.22"
|