@via-profit/ui-kit 0.1.0-rc.20 → 0.1.0-rc.21
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/Button/ButtonPlain.js +14 -26
- package/package.json +1 -1
package/Button/ButtonPlain.js
CHANGED
|
@@ -29,24 +29,19 @@ const StyledPlainButton = (0, styled_1.default)(ButtonBase_1.default) `
|
|
|
29
29
|
return $color.toString();
|
|
30
30
|
}
|
|
31
31
|
}};
|
|
32
|
-
background
|
|
33
|
-
|
|
34
|
-
case disabled:
|
|
35
|
-
return $background.darken(10).toString();
|
|
36
|
-
default:
|
|
37
|
-
return $background.toString();
|
|
38
|
-
}
|
|
39
|
-
}};
|
|
40
|
-
${({ disabled, $background, theme }) => !disabled &&
|
|
32
|
+
background: none;
|
|
33
|
+
${({ disabled, theme, $color }) => !disabled &&
|
|
41
34
|
(0, react_2.css) `
|
|
42
35
|
&:hover {
|
|
43
|
-
|
|
36
|
+
color: ${$color.darken(30).toString()};
|
|
37
|
+
background-color: ${$color.alpha(0.1).toString()};
|
|
44
38
|
}
|
|
45
39
|
&:active {
|
|
46
|
-
|
|
40
|
+
color: ${$color.darken(80).toString()};
|
|
41
|
+
background-color: ${$color.alpha(0.3).toString()};
|
|
47
42
|
}
|
|
48
43
|
&:focus-visible {
|
|
49
|
-
outline-color: ${$
|
|
44
|
+
outline-color: ${$color.rgbString() === theme.color.accentPrimary.rgbString()
|
|
50
45
|
? theme.color.textPrimary.toString()
|
|
51
46
|
: theme.color.accentPrimary.toString()};
|
|
52
47
|
}
|
|
@@ -55,48 +50,41 @@ const StyledPlainButton = (0, styled_1.default)(ButtonBase_1.default) `
|
|
|
55
50
|
const ButtonPlain = (props, ref) => {
|
|
56
51
|
const { children, disabled, color } = props, restProps = __rest(props, ["children", "disabled", "color"]);
|
|
57
52
|
const theme = (0, react_2.useTheme)();
|
|
58
|
-
const { $
|
|
53
|
+
const { $color } = react_1.default.useMemo(() => {
|
|
59
54
|
switch (true) {
|
|
60
55
|
case color === 'primary':
|
|
61
56
|
return {
|
|
62
|
-
$color: theme.color.
|
|
63
|
-
$background: theme.color.accentPrimary,
|
|
57
|
+
$color: theme.color.accentPrimary,
|
|
64
58
|
};
|
|
65
59
|
case color === 'secondary':
|
|
66
60
|
return {
|
|
67
|
-
$color: theme.color.
|
|
68
|
-
$background: theme.color.accentSecondary,
|
|
61
|
+
$color: theme.color.accentSecondary,
|
|
69
62
|
};
|
|
70
63
|
case typeof color === 'undefined':
|
|
71
64
|
case color === 'default':
|
|
72
65
|
return {
|
|
73
|
-
$background: theme.color.surface,
|
|
74
66
|
$color: theme.color.textPrimary,
|
|
75
67
|
};
|
|
76
68
|
case typeof color === 'string': {
|
|
77
|
-
let $
|
|
69
|
+
let $color = theme.color.textPrimary;
|
|
78
70
|
try {
|
|
79
71
|
if (color) {
|
|
80
|
-
$
|
|
72
|
+
$color = new Color_1.default(color);
|
|
81
73
|
}
|
|
82
74
|
}
|
|
83
75
|
catch (err) {
|
|
84
76
|
console.error(`invalid color value «${color}»`);
|
|
85
77
|
}
|
|
86
78
|
return {
|
|
87
|
-
$
|
|
88
|
-
$color: $background.contrast(theme.color.textPrimary.rgbString()) > 5
|
|
89
|
-
? theme.color.textPrimary
|
|
90
|
-
: theme.color.surface,
|
|
79
|
+
$color,
|
|
91
80
|
};
|
|
92
81
|
}
|
|
93
82
|
default:
|
|
94
83
|
return {
|
|
95
|
-
$background: theme.color.surface,
|
|
96
84
|
$color: theme.color.textPrimary,
|
|
97
85
|
};
|
|
98
86
|
}
|
|
99
87
|
}, [color, theme.color]);
|
|
100
|
-
return (react_1.default.createElement(StyledPlainButton, Object.assign({ "$color": $color,
|
|
88
|
+
return (react_1.default.createElement(StyledPlainButton, Object.assign({ "$color": $color, disabled: disabled }, restProps, { ref: ref }), children));
|
|
101
89
|
};
|
|
102
90
|
exports.default = react_1.default.forwardRef(ButtonPlain);
|