@smart-react-components/ui 2.0.0-alpha-27 → 2.0.0-alpha-29
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/Alert/AlertIcon.js
CHANGED
|
@@ -9,7 +9,7 @@ const react_1 = __importDefault(require("react"));
|
|
|
9
9
|
const AlertIconElement_1 = __importDefault(require("../components/Alert/AlertIconElement"));
|
|
10
10
|
const AlertIcon = (props) => {
|
|
11
11
|
var _a;
|
|
12
|
-
return (react_1.default.createElement(AlertIconElement_1.default, Object.assign({ alertPalette: props.alertPalette, alertIconSize: props.size, alertIconSizeSm: props.sizeSm, alertIconSizeMd: props.sizeMd, alertIconSizeLg: props.sizeLg, alertIconSizeXl: props.sizeXl, hasBackground: props.hasBackground, hasHover: props.hasHover, isSoft: props.isSoft, palette: (_a = props.palette) !== null && _a !== void 0 ? _a : props.alertPalette }, (0, element_props_1.default)(props, [click_events_1.default])), props.children));
|
|
12
|
+
return (react_1.default.createElement(AlertIconElement_1.default, Object.assign({ alertPalette: props.alertPalette, alertIconSize: props.size, alertIconSizeSm: props.sizeSm, alertIconSizeMd: props.sizeMd, alertIconSizeLg: props.sizeLg, alertIconSizeXl: props.sizeXl, hasBackground: props.hasBackground, hasHover: props.hasHover, isOutline: props.isOutline, isSoft: props.isSoft, palette: (_a = props.palette) !== null && _a !== void 0 ? _a : props.alertPalette }, (0, element_props_1.default)(props, [click_events_1.default])), props.children));
|
|
13
13
|
};
|
|
14
14
|
AlertIcon.displayName = 'SRCAlertIcon';
|
|
15
15
|
exports.default = AlertIcon;
|
package/Alert/index.js
CHANGED
|
@@ -44,6 +44,7 @@ const Alert = props => {
|
|
|
44
44
|
if (((_a = item.type) === null || _a === void 0 ? void 0 : _a.displayName) === 'SRCAlertIcon') {
|
|
45
45
|
const iconEl = react_1.default.cloneElement(item, {
|
|
46
46
|
alertPalette: props.palette,
|
|
47
|
+
isOutline: props.isOutline,
|
|
47
48
|
isSoft: props.isSoft,
|
|
48
49
|
size: props.size,
|
|
49
50
|
sizeSm: props.sizeSm,
|
|
@@ -68,13 +69,14 @@ const Alert = props => {
|
|
|
68
69
|
iconRight && iconRight)),
|
|
69
70
|
hasIconLeft: !!iconLeft,
|
|
70
71
|
hasIconRight: !!iconRight,
|
|
72
|
+
hasThickBorder: !(iconLeft && (iconLeft.props.hasBackground || (iconLeft.props.palette && iconLeft.props.palette !== props.palette))),
|
|
71
73
|
};
|
|
72
74
|
};
|
|
73
|
-
const [{ children, hasIconLeft, hasIconRight }, setContent] = react_1.default.useState(() => getContent());
|
|
75
|
+
const [{ children, hasIconLeft, hasIconRight, hasThickBorder }, setContent] = react_1.default.useState(() => getContent());
|
|
74
76
|
(0, useChangeEffect_1.default)(() => {
|
|
75
77
|
setContent(getContent());
|
|
76
78
|
}, [props.children]);
|
|
77
|
-
return (react_1.default.createElement(AlertElement_1.default, Object.assign({ alertSize: props.size, alertSizeSm: props.sizeSm, alertSizeMd: props.sizeMd, alertSizeLg: props.sizeLg, alertSizeXl: props.sizeXl, hasIconLeft: hasIconLeft, hasIconRight: hasIconRight, isOutline: props.isOutline, isSoft: props.isSoft, palette: props.palette, shape: props.shape }, (0, element_props_1.default)(props, [click_events_1.default, intrinsic_styled_props_1.default])), children));
|
|
79
|
+
return (react_1.default.createElement(AlertElement_1.default, Object.assign({ alertSize: props.size, alertSizeSm: props.sizeSm, alertSizeMd: props.sizeMd, alertSizeLg: props.sizeLg, alertSizeXl: props.sizeXl, hasIconLeft: hasIconLeft, hasIconRight: hasIconRight, hasThickBorder: hasThickBorder, isOutline: props.isOutline, isSoft: props.isSoft, palette: props.palette, shape: props.shape }, (0, element_props_1.default)(props, [click_events_1.default, intrinsic_styled_props_1.default])), children));
|
|
78
80
|
};
|
|
79
81
|
Alert.defaultProps = {
|
|
80
82
|
palette: 'primary',
|
|
@@ -4,6 +4,7 @@ export declare const Content: import("styled-components").StyledComponent<"div",
|
|
|
4
4
|
interface Props extends StyledProps, ResponsiveProp<'alertSize', SizeProp> {
|
|
5
5
|
hasIconLeft: boolean;
|
|
6
6
|
hasIconRight: boolean;
|
|
7
|
+
hasThickBorder: boolean;
|
|
7
8
|
isOutline: boolean;
|
|
8
9
|
isSoft: boolean;
|
|
9
10
|
palette: PaletteProp;
|
|
@@ -6,20 +6,33 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.Content = void 0;
|
|
7
7
|
const Div_1 = __importDefault(require("@smart-react-components/core/Element/Div"));
|
|
8
8
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
9
|
+
const css_1 = require("../../util/css");
|
|
9
10
|
exports.Content = styled_components_1.default.div `
|
|
10
11
|
flex: 1 1 auto;
|
|
11
12
|
`;
|
|
12
|
-
exports.default = (0, styled_components_1.default)(Div_1.default).attrs({
|
|
13
|
+
exports.default = (0, styled_components_1.default)(Div_1.default).attrs(({ hasIconLeft, hasIconRight }) => ({
|
|
13
14
|
getAlertSize: (v, t) => `
|
|
14
15
|
font-size: ${t.$.size.alert[v].fontSize};
|
|
15
16
|
|
|
16
17
|
${exports.Content} {
|
|
17
18
|
padding: ${t.$.size.alert[v].padding.y} ${t.$.size.alert[v].padding.x};
|
|
19
|
+
|
|
20
|
+
${hasIconLeft
|
|
21
|
+
? `
|
|
22
|
+
padding-left: ${(0, css_1.toCSSValue)(t.$.size.alert[v].padding.x)(v => v / 2)};
|
|
23
|
+
`
|
|
24
|
+
: ''}
|
|
25
|
+
|
|
26
|
+
${hasIconRight
|
|
27
|
+
? `
|
|
28
|
+
padding-right: ${(0, css_1.toCSSValue)(t.$.size.alert[v].padding.x)(v => v / 2)};
|
|
29
|
+
`
|
|
30
|
+
: ''}
|
|
31
|
+
|
|
18
32
|
}
|
|
19
33
|
`,
|
|
20
|
-
})(({ theme,
|
|
34
|
+
}))(({ theme, hasThickBorder, isOutline, isSoft, palette, shape }) => `
|
|
21
35
|
border: solid 1px;
|
|
22
|
-
border-left-width: 10px;
|
|
23
36
|
border-radius: ${theme.$.radius.alert[shape]};
|
|
24
37
|
box-sizing: border-box;
|
|
25
38
|
display: flex;
|
|
@@ -54,21 +67,9 @@ exports.default = (0, styled_components_1.default)(Div_1.default).attrs({
|
|
|
54
67
|
`}
|
|
55
68
|
`}
|
|
56
69
|
|
|
57
|
-
${
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
padding-left: 0;
|
|
61
|
-
}
|
|
62
|
-
`
|
|
63
|
-
: ''}
|
|
64
|
-
|
|
65
|
-
${hasIconRight
|
|
66
|
-
? `
|
|
67
|
-
> ${exports.Content} {
|
|
68
|
-
padding-right: 0;
|
|
69
|
-
}
|
|
70
|
-
`
|
|
71
|
-
: ''}
|
|
70
|
+
${hasThickBorder && `
|
|
71
|
+
border-left-width: 10px;
|
|
72
|
+
`}
|
|
72
73
|
|
|
73
74
|
${exports.Content} > {
|
|
74
75
|
header, h1, h2, h3, h4, h5, h6, p, hr {
|
|
@@ -5,9 +5,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const Div_1 = __importDefault(require("@smart-react-components/core/Element/Div"));
|
|
7
7
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
8
|
+
const css_1 = require("../../util/css");
|
|
8
9
|
exports.default = (0, styled_components_1.default)(Div_1.default).attrs({
|
|
9
10
|
getAlertIconSize: (v, t) => `
|
|
10
|
-
padding: 0 ${t.$.size.alert[v].padding.x};
|
|
11
|
+
padding: 0 ${(0, css_1.toCSSValue)(t.$.size.alert[v].padding.x)(v => v / 2)};
|
|
11
12
|
|
|
12
13
|
> svg {
|
|
13
14
|
height: ${t.$.size.alert[v].iconSize};
|
|
@@ -18,27 +19,28 @@ exports.default = (0, styled_components_1.default)(Div_1.default).attrs({
|
|
|
18
19
|
font-size: ${t.$.size.alert[v].iconSize};
|
|
19
20
|
}
|
|
20
21
|
`,
|
|
21
|
-
})(({ theme, alertPalette, hasBackground, hasHover, isSoft, palette }) => `
|
|
22
|
+
})(({ theme, alertPalette, hasBackground, hasHover, isOutline, isSoft, palette }) => `
|
|
22
23
|
align-items: center;
|
|
23
24
|
align-self: stretch;
|
|
24
25
|
display: flex;
|
|
26
|
+
fill: currentcolor;
|
|
25
27
|
flex: 0 0 auto;
|
|
26
28
|
justify-content: center;
|
|
27
29
|
|
|
28
30
|
${(palette === alertPalette || hasBackground)
|
|
29
31
|
? `
|
|
30
|
-
|
|
31
|
-
fill: ${!isSoft ? theme.$.palette[palette].font : theme.$.palette[palette].softFont};
|
|
32
|
-
|
|
33
|
-
${palette !== alertPalette
|
|
32
|
+
${!isSoft
|
|
34
33
|
? `
|
|
35
|
-
background: ${
|
|
34
|
+
background: ${(palette !== alertPalette || isOutline) ? theme.$.palette[palette].main : theme.$.palette[palette].darkest};
|
|
35
|
+
color: ${theme.$.palette[palette].font};
|
|
36
36
|
`
|
|
37
|
-
:
|
|
37
|
+
: `
|
|
38
|
+
background: ${(palette !== alertPalette || isOutline) ? theme.$.palette[palette].soft : theme.$.palette[palette].softDarkest};
|
|
39
|
+
color: ${theme.$.palette[palette].softFont};
|
|
40
|
+
`}
|
|
38
41
|
`
|
|
39
42
|
: `
|
|
40
43
|
color: ${!isSoft ? theme.$.palette[palette].main : theme.$.palette[palette].soft};
|
|
41
|
-
fill: ${!isSoft ? theme.$.palette[palette].main : theme.$.palette[palette].soft};
|
|
42
44
|
`}
|
|
43
45
|
|
|
44
46
|
${hasHover
|