akeneo-design-system 0.1.217 → 0.1.219
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/components/SectionTitle/SectionTitle.js +1 -5
- package/lib/components/SectionTitle/SectionTitle.js.map +1 -1
- package/lib/components/Tiles/Tiles.d.ts +9 -2
- package/lib/components/Tiles/Tiles.js +23 -19
- package/lib/components/Tiles/Tiles.js.map +1 -1
- package/package.json +1 -1
- package/src/__image_snapshots__/all-visual-tsx-visual-tests-renders-components-tiles-inline-correctly-1-snap.png +0 -0
- package/src/__image_snapshots__/all-visual-tsx-visual-tests-renders-components-tiles-size-correctly-1-snap.png +0 -0
- package/src/components/SectionTitle/SectionTitle.stories.mdx +1 -1
- package/src/components/SectionTitle/SectionTitle.tsx +1 -0
- package/src/components/Tiles/Tiles.stories.mdx +21 -0
- package/src/components/Tiles/Tiles.tsx +72 -29
- package/src/components/Tiles/Tiles.unit.tsx +36 -0
@@ -76,11 +76,7 @@ var SectionTitle = function (_a) {
|
|
76
76
|
});
|
77
77
|
}
|
78
78
|
if ((0, react_1.isValidElement)(child) && child.type === components_1.Button) {
|
79
|
-
return (0, react_1.cloneElement)(child, {
|
80
|
-
level: 'tertiary',
|
81
|
-
size: 'small',
|
82
|
-
ghost: true,
|
83
|
-
});
|
79
|
+
return (0, react_1.cloneElement)(child, __assign({ level: 'tertiary', size: 'small', ghost: true }, child.props));
|
84
80
|
}
|
85
81
|
return child;
|
86
82
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"SectionTitle.js","sourceRoot":"","sources":["../../../src/components/SectionTitle/SectionTitle.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA+F;AAC/F,qEAA8C;AAC9C,qCAAqE;AACrE,+CAAkF;AAGlF,IAAM,qBAAqB,GAAG,2BAAM,CAAC,GAAG,kOAAuC,8IAOlD,EAAqB,SAE9C,EAOC,IACJ,KAV4B,IAAA,gBAAQ,EAAC,MAAM,EAAE,G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;gBACzB,KAAK,EAAE,UAAU;gBACjB,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,YAAY;aACpB,CAAC,CAAC;SACJ;QAED,IAAI,IAAA,sBAAc,EAAc,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,mBAAM,EAAE;YAC/D,OAAO,IAAA,oBAAY,EAAC,KAAK,aACvB,KAAK,EAAE,UAAU,EACjB,IAAI,EAAE,OAAO,EACb,KAAK,EAAE,IAAI,IACR,KAAK,CAAC,KAAK,EACd,CAAC;SACJ;QAED,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;IAEH,OAAO,8BAAC,qBAAqB,eAAK,IAAI,GAAG,iBAAiB,CAAyB,CAAC;AACtF,CAAC,CAAC;AAOM,oCAAY;AALpB,YAAY,CAAC,KAAK,GAAG,KAAK,CAAC;AAC3B,YAAY,CAAC,MAAM,GAAG,MAAM,CAAC;AAC7B,YAAY,CAAC,SAAS,GAAG,SAAS,CAAC;AACnC,YAAY,CAAC,WAAW,GAAG,WAAW,CAAC"}
|
@@ -5,10 +5,17 @@ declare type Size = 'small' | 'big';
|
|
5
5
|
declare type TilesProps = {
|
6
6
|
children?: ReactNode;
|
7
7
|
size?: Size;
|
8
|
+
inline?: boolean;
|
8
9
|
};
|
9
|
-
declare type TileProps = Override<React.HTMLAttributes<HTMLDivElement>, {
|
10
|
+
declare type TileProps = Override<React.HTMLAttributes<HTMLDivElement>, ({
|
10
11
|
icon: React.ReactElement<IconProps>;
|
11
|
-
size?:
|
12
|
+
size?: 'big' | 'small';
|
13
|
+
inline?: false;
|
14
|
+
} | {
|
15
|
+
size?: 'big' | 'small';
|
16
|
+
icon?: undefined;
|
17
|
+
inline?: true;
|
18
|
+
}) & {
|
12
19
|
selected?: boolean;
|
13
20
|
onClick?: () => void;
|
14
21
|
}>;
|
@@ -50,51 +50,55 @@ var react_1 = __importStar(require("react"));
|
|
50
50
|
var styled_components_1 = __importStar(require("styled-components"));
|
51
51
|
var theme_1 = require("../../theme");
|
52
52
|
var __1 = require("../../");
|
53
|
-
var TilesContainer = styled_components_1.default.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n display: grid;\n ", "
|
53
|
+
var TilesContainer = styled_components_1.default.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n display: grid;\n ", ";\n"], ["\n display: grid;\n ", ";\n"])), function (_a) {
|
54
54
|
var size = _a.size;
|
55
55
|
return size === 'small'
|
56
56
|
? (0, styled_components_1.css)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n gap: 20px;\n grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));\n "], ["\n gap: 20px;\n grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));\n "]))) : (0, styled_components_1.css)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n gap: 30px;\n grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));\n "], ["\n gap: 30px;\n grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));\n "])));
|
57
57
|
});
|
58
|
-
var TileContainer = styled_components_1.default.div(
|
59
|
-
var size = _a.size;
|
60
|
-
|
61
|
-
|
58
|
+
var TileContainer = styled_components_1.default.div(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n margin: 1px;\n ", "\n transition: border-color 0.2s, color 0.2s, background 0.2s;\n ", "\n ", "\n &:hover {\n border: 2px solid ", ";\n color: ", ";\n margin: 0;\n background: ", ";\n }\n box-sizing: border-box;\n"], ["\n margin: 1px;\n ", "\n transition: border-color 0.2s, color 0.2s, background 0.2s;\n ", "\n ", "\n &:hover {\n border: 2px solid ", ";\n color: ", ";\n margin: 0;\n background: ", ";\n }\n box-sizing: border-box;\n"])), function (_a) {
|
59
|
+
var size = _a.size, inline = _a.inline;
|
60
|
+
if (!inline) {
|
61
|
+
return size === 'small'
|
62
|
+
? (0, styled_components_1.css)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n height: 130px;\n text-align: center;\n "], ["\n height: 130px;\n text-align: center;\n "]))) : (0, styled_components_1.css)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n height: 200px;\n text-align: center;\n "], ["\n height: 200px;\n text-align: center;\n "])));
|
63
|
+
}
|
64
|
+
return (0, styled_components_1.css)(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n height: auto;\n "], ["\n height: auto;\n "])));
|
62
65
|
}, function (_a) {
|
63
66
|
var onClick = _a.onClick;
|
64
|
-
return onClick !== undefined && (0, styled_components_1.css)(
|
67
|
+
return onClick !== undefined && (0, styled_components_1.css)(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n cursor: pointer;\n "], ["\n cursor: pointer;\n "])));
|
65
68
|
}, function (_a) {
|
66
69
|
var selected = _a.selected;
|
67
70
|
return selected
|
68
|
-
? (0, styled_components_1.css)(
|
71
|
+
? (0, styled_components_1.css)(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n border: 2px solid ", ";\n color: ", ";\n margin: 0;\n background: ", ";\n "], ["\n border: 2px solid ", ";\n color: ", ";\n margin: 0;\n background: ", ";\n "])), (0, theme_1.getColor)('blue', 100), (0, theme_1.getColor)('blue', 100), (0, theme_1.getColor)('blue', 10)) : (0, styled_components_1.css)(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n border: 1px solid ", ";\n "], ["\n border: 1px solid ", ";\n "])), (0, theme_1.getColor)('grey', 80));
|
69
72
|
}, (0, theme_1.getColor)('blue', 100), (0, theme_1.getColor)('blue', 100), (0, theme_1.getColor)('blue', 10));
|
70
|
-
var IconContainer = styled_components_1.default.div(
|
73
|
+
var IconContainer = styled_components_1.default.div(templateObject_13 || (templateObject_13 = __makeTemplateObject(["\n box-sizing: content-box;\n ", "\n"], ["\n box-sizing: content-box;\n ", "\n"])), function (_a) {
|
71
74
|
var size = _a.size;
|
72
75
|
return size === 'small'
|
73
|
-
? (0, styled_components_1.css)(
|
76
|
+
? (0, styled_components_1.css)(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n padding: 25px 0 0 0;\n height: 54px;\n "], ["\n padding: 25px 0 0 0;\n height: 54px;\n "]))) : (0, styled_components_1.css)(templateObject_12 || (templateObject_12 = __makeTemplateObject(["\n padding: 40px 0 0 0;\n height: 100px;\n "], ["\n padding: 40px 0 0 0;\n height: 100px;\n "])));
|
74
77
|
});
|
75
|
-
var LabelContainer = styled_components_1.default.div(
|
78
|
+
var LabelContainer = styled_components_1.default.div(templateObject_14 || (templateObject_14 = __makeTemplateObject(["\n margin: 10px;\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n overflow: hidden;\n line-height: 1.3;\n"], ["\n margin: 10px;\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n overflow: hidden;\n line-height: 1.3;\n"])));
|
79
|
+
var InlineContainer = styled_components_1.default.div(templateObject_15 || (templateObject_15 = __makeTemplateObject(["\n margin: 10px;\n display: flex;\n align-items: center;\n justify-content: space-between;\n"], ["\n margin: 10px;\n display: flex;\n align-items: center;\n justify-content: space-between;\n"])));
|
76
80
|
var Tile = function (_a) {
|
77
|
-
var icon = _a.icon, _b = _a.selected, selected = _b === void 0 ? false : _b, _c = _a.size, size = _c === void 0 ? 'small' : _c, onClick = _a.onClick, children = _a.children, rest = __rest(_a, ["icon", "selected", "size", "onClick", "children"]);
|
81
|
+
var icon = _a.icon, _b = _a.selected, selected = _b === void 0 ? false : _b, _c = _a.size, size = _c === void 0 ? 'small' : _c, _d = _a.inline, inline = _d === void 0 ? false : _d, onClick = _a.onClick, children = _a.children, rest = __rest(_a, ["icon", "selected", "size", "inline", "onClick", "children"]);
|
78
82
|
var handleKeyDown = (0, react_1.useCallback)(function (event) {
|
79
83
|
if (null !== event.currentTarget && event.key === __1.Key.Enter) {
|
80
84
|
onClick === null || onClick === void 0 ? void 0 : onClick();
|
81
85
|
event.preventDefault();
|
82
86
|
}
|
83
|
-
}, []);
|
84
|
-
return (react_1.default.createElement(TileContainer, __assign({ selected: selected, size: size, onClick: onClick, onKeyDown: handleKeyDown, tabIndex: '0' }, rest),
|
85
|
-
react_1.default.createElement(IconContainer, { size: size }, react_1.default.cloneElement(icon, { size: size === 'small' ? 54 : 100 })),
|
86
|
-
react_1.default.createElement(LabelContainer, null, children)));
|
87
|
+
}, [onClick]);
|
88
|
+
return (react_1.default.createElement(TileContainer, __assign({ selected: selected, size: size, inline: inline, onClick: onClick, onKeyDown: handleKeyDown, tabIndex: '0' }, rest),
|
89
|
+
!inline && icon && (react_1.default.createElement(IconContainer, { size: size }, react_1.default.cloneElement(icon, { size: size === 'small' ? 54 : 100 }))),
|
90
|
+
inline ? react_1.default.createElement(InlineContainer, null, children) : react_1.default.createElement(LabelContainer, null, children)));
|
87
91
|
};
|
88
92
|
exports.Tile = Tile;
|
89
93
|
var Tiles = react_1.default.forwardRef(function (_a, forwardedRef) {
|
90
|
-
var _b = _a.size, size = _b === void 0 ? 'small' : _b, children = _a.children, rest = __rest(_a, ["size", "children"]);
|
91
|
-
return (react_1.default.createElement(TilesContainer, __assign({ size: size, ref: forwardedRef }, rest), react_1.default.Children.map(children, function (child) {
|
94
|
+
var _b = _a.size, size = _b === void 0 ? 'small' : _b, _c = _a.inline, inline = _c === void 0 ? false : _c, children = _a.children, rest = __rest(_a, ["size", "inline", "children"]);
|
95
|
+
return (react_1.default.createElement(TilesContainer, __assign({ size: size, inline: inline, ref: forwardedRef }, rest), react_1.default.Children.map(children, function (child) {
|
92
96
|
if ((0, react_1.isValidElement)(child) && child.type === Tile) {
|
93
|
-
return react_1.default.cloneElement(child, { size: size });
|
97
|
+
return react_1.default.cloneElement(child, { size: size, inline: inline });
|
94
98
|
}
|
95
99
|
throw new Error('A Tiles element can only have Tile children');
|
96
100
|
})));
|
97
101
|
});
|
98
102
|
exports.Tiles = Tiles;
|
99
|
-
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11, templateObject_12, templateObject_13;
|
103
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11, templateObject_12, templateObject_13, templateObject_14, templateObject_15;
|
100
104
|
//# sourceMappingURL=Tiles.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Tiles.js","sourceRoot":"","sources":["../../../src/components/Tiles/Tiles.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA4F;AAC5F,qEAA8C;AAE9C,qCAAwD;AACxD,4BAAqC;AAIrC,IAAM,cAAc,GAAG,2BAAM,CAAC,GAAG,
|
1
|
+
{"version":3,"file":"Tiles.js","sourceRoot":"","sources":["../../../src/components/Tiles/Tiles.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA4F;AAC5F,qEAA8C;AAE9C,qCAAwD;AACxD,4BAAqC;AAIrC,IAAM,cAAc,GAAG,2BAAM,CAAC,GAAG,kGAAkC,wBAE/D,EASK,KACR,KAVG,UAAC,EAAM;QAAL,IAAI,UAAA;IACN,OAAA,IAAI,KAAK,OAAO;QACd,CAAC,KAAC,uBAAG,+KAAA,2GAGF,KACH,CAAC,KAAC,uBAAG,+KAAA,2GAGF,IAAA;AARL,CAQK,CACR,CAAC;AAEF,IAAM,aAAa,GAAG,2BAAM,CAAC,GAAG,mTAE/B,sBAEG,EAeD,qEAEC,EAIC,MACD,EAUK,uCAEe,EAAqB,gBAChC,EAAqB,qCAEhB,EAAoB,qCAGrC,KAxCG,UAAC,EAAc;QAAb,IAAI,UAAA,EAAE,MAAM,YAAA;IACd,IAAI,CAAC,MAAM,EAAE;QACX,OAAO,IAAI,KAAK,OAAO;YACrB,CAAC,KAAC,uBAAG,+IAAA,2EAGF,KACH,CAAC,KAAC,uBAAG,+IAAA,2EAGF,IAAA,CAAC;KACP;IACD,WAAO,uBAAG,iGAA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IACjD,OAAO,CACL,8BAAC,cAAc,aAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,YAAY,IAAM,IAAI,GACpE,eAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,UAAA,KAAK;QACjC,IAAI,IAAA,sBAAc,EAAY,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI,EAAE;YAC3D,OAAO,eAAK,CAAC,YAAY,CAAC,KAAK,EAAE,EAAC,IAAI,MAAA,EAAE,MAAM,QAAA,EAAC,CAAC,CAAC;SAClD;QACD,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;IACjE,CAAC,CAAC,CACa,CAClB,CAAC;AACJ,CAAC,CACF,CAAC;AAEM,sBAAK"}
|
package/package.json
CHANGED
Binary file
|
Binary file
|
@@ -51,7 +51,7 @@ Use this component only for title, not for description or help message.
|
|
51
51
|
<SectionTitle.Information>10 results</SectionTitle.Information>
|
52
52
|
<SectionTitle.Separator />
|
53
53
|
<Button>Action</Button>
|
54
|
-
<Button>Action</Button>
|
54
|
+
<Button level="danger">Action</Button>
|
55
55
|
<IconButton icon={<MoreIcon />} title="More" />
|
56
56
|
</SectionTitle>
|
57
57
|
</Story>
|
@@ -11,6 +11,7 @@ import {
|
|
11
11
|
AssetsIcon,
|
12
12
|
} from '../../icons';
|
13
13
|
import {useTabBar} from "../../hooks/useTabBar";
|
14
|
+
import { Tooltip } from '../Tooltip/Tooltip';
|
14
15
|
|
15
16
|
<Meta
|
16
17
|
title="Components/Tiles"
|
@@ -93,6 +94,26 @@ The component is displayed in a configurable responsive grid (width and gap). Ti
|
|
93
94
|
Big Date
|
94
95
|
</Tile>
|
95
96
|
</Tiles>
|
97
|
+
<Tiles size={'small'} inline={true}>
|
98
|
+
<Tile>
|
99
|
+
Big Assets collection
|
100
|
+
<Tooltip direction={'bottom'}>Big Assets collection</Tooltip>
|
101
|
+
</Tile>
|
102
|
+
<Tile>
|
103
|
+
Big Date
|
104
|
+
<Tooltip direction={'bottom'}>Big Date</Tooltip>
|
105
|
+
</Tile>
|
106
|
+
</Tiles>
|
107
|
+
<Tiles size={'big'} inline={true}>
|
108
|
+
<Tile>
|
109
|
+
Big Assets collection
|
110
|
+
<Tooltip direction={'bottom'}>Big Assets collection</Tooltip>
|
111
|
+
</Tile>
|
112
|
+
<Tile>
|
113
|
+
Big Date
|
114
|
+
<Tooltip direction={'bottom'}>Big Date</Tooltip>
|
115
|
+
</Tile>
|
116
|
+
</Tiles>
|
96
117
|
</>
|
97
118
|
);
|
98
119
|
}}
|
@@ -17,26 +17,35 @@ const TilesContainer = styled.div<{size: Size} & AkeneoThemedProps>`
|
|
17
17
|
: css`
|
18
18
|
gap: 30px;
|
19
19
|
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
|
20
|
-
`}
|
20
|
+
`};
|
21
21
|
`;
|
22
22
|
|
23
|
-
const TileContainer = styled.div<
|
23
|
+
const TileContainer = styled.div<
|
24
|
+
{selected: boolean; size: Size; inline: boolean; onClick?: () => void} & AkeneoThemedProps
|
25
|
+
>`
|
24
26
|
margin: 1px;
|
25
|
-
${({size}) =>
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
`
|
27
|
+
${({size, inline}) => {
|
28
|
+
if (!inline) {
|
29
|
+
return size === 'small'
|
30
|
+
? css`
|
31
|
+
height: 130px;
|
32
|
+
text-align: center;
|
33
|
+
`
|
34
|
+
: css`
|
35
|
+
height: 200px;
|
36
|
+
text-align: center;
|
37
|
+
`;
|
38
|
+
}
|
39
|
+
return css`
|
40
|
+
height: auto;
|
41
|
+
`;
|
42
|
+
}}
|
33
43
|
transition: border-color 0.2s, color 0.2s, background 0.2s;
|
34
44
|
${({onClick}) =>
|
35
45
|
onClick !== undefined &&
|
36
46
|
css`
|
37
47
|
cursor: pointer;
|
38
48
|
`}
|
39
|
-
text-align: center;
|
40
49
|
${({selected}) =>
|
41
50
|
selected
|
42
51
|
? css`
|
@@ -79,6 +88,13 @@ const LabelContainer = styled.div`
|
|
79
88
|
line-height: 1.3;
|
80
89
|
`;
|
81
90
|
|
91
|
+
const InlineContainer = styled.div`
|
92
|
+
margin: 10px;
|
93
|
+
display: flex;
|
94
|
+
align-items: center;
|
95
|
+
justify-content: space-between;
|
96
|
+
`;
|
97
|
+
|
82
98
|
type TilesProps = {
|
83
99
|
/**
|
84
100
|
* Children are Tile components only
|
@@ -86,33 +102,60 @@ type TilesProps = {
|
|
86
102
|
children?: ReactNode;
|
87
103
|
|
88
104
|
/**
|
89
|
-
* The size can be 'small' (by default) or 'big'
|
105
|
+
* The size can be 'small' (by default), or 'big'
|
90
106
|
*/
|
91
107
|
size?: Size;
|
108
|
+
|
109
|
+
/**
|
110
|
+
* Inline (false by default), make the height auto and the content horizontal
|
111
|
+
*/
|
112
|
+
inline?: boolean;
|
92
113
|
};
|
93
114
|
|
94
115
|
type TileProps = Override<
|
95
116
|
React.HTMLAttributes<HTMLDivElement>,
|
96
|
-
|
97
|
-
|
98
|
-
|
117
|
+
(
|
118
|
+
| {
|
119
|
+
icon: React.ReactElement<IconProps>;
|
120
|
+
size?: 'big' | 'small';
|
121
|
+
inline?: false;
|
122
|
+
}
|
123
|
+
| {
|
124
|
+
size?: 'big' | 'small';
|
125
|
+
icon?: undefined;
|
126
|
+
inline?: true;
|
127
|
+
}
|
128
|
+
) & {
|
99
129
|
selected?: boolean;
|
100
130
|
onClick?: () => void;
|
101
131
|
}
|
102
132
|
>;
|
103
133
|
|
104
|
-
const Tile: FC<TileProps> = ({icon, selected = false, size = 'small', onClick, children, ...rest}) => {
|
105
|
-
const handleKeyDown = useCallback(
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
134
|
+
const Tile: FC<TileProps> = ({icon, selected = false, size = 'small', inline = false, onClick, children, ...rest}) => {
|
135
|
+
const handleKeyDown = useCallback(
|
136
|
+
(event: KeyboardEvent<HTMLDivElement>) => {
|
137
|
+
if (null !== event.currentTarget && event.key === Key.Enter) {
|
138
|
+
onClick?.();
|
139
|
+
event.preventDefault();
|
140
|
+
}
|
141
|
+
},
|
142
|
+
[onClick]
|
143
|
+
);
|
111
144
|
|
112
145
|
return (
|
113
|
-
<TileContainer
|
114
|
-
|
115
|
-
|
146
|
+
<TileContainer
|
147
|
+
selected={selected}
|
148
|
+
size={size}
|
149
|
+
inline={inline}
|
150
|
+
onClick={onClick}
|
151
|
+
onKeyDown={handleKeyDown}
|
152
|
+
tabIndex={'0'}
|
153
|
+
{...rest}
|
154
|
+
>
|
155
|
+
{!inline && icon && (
|
156
|
+
<IconContainer size={size}>{React.cloneElement(icon, {size: size === 'small' ? 54 : 100})}</IconContainer>
|
157
|
+
)}
|
158
|
+
{inline ? <InlineContainer>{children}</InlineContainer> : <LabelContainer>{children}</LabelContainer>}
|
116
159
|
</TileContainer>
|
117
160
|
);
|
118
161
|
};
|
@@ -120,15 +163,15 @@ const Tile: FC<TileProps> = ({icon, selected = false, size = 'small', onClick, c
|
|
120
163
|
/**
|
121
164
|
* The Tiles component provides the user a list of choices, for example, an attribute type, a template, or an export
|
122
165
|
* format.
|
123
|
-
* It is a visual component made up of an icon and a label
|
166
|
+
* It is a visual component made up of an icon and a label.
|
124
167
|
*/
|
125
168
|
const Tiles = React.forwardRef<HTMLDivElement, TilesProps>(
|
126
|
-
({size = 'small', children, ...rest}: TilesProps, forwardedRef: Ref<HTMLDivElement>) => {
|
169
|
+
({size = 'small', inline = false, children, ...rest}: TilesProps, forwardedRef: Ref<HTMLDivElement>) => {
|
127
170
|
return (
|
128
|
-
<TilesContainer size={size} ref={forwardedRef} {...rest}>
|
171
|
+
<TilesContainer size={size} inline={inline} ref={forwardedRef} {...rest}>
|
129
172
|
{React.Children.map(children, child => {
|
130
173
|
if (isValidElement<TileProps>(child) && child.type === Tile) {
|
131
|
-
return React.cloneElement(child, {size});
|
174
|
+
return React.cloneElement(child, {size, inline});
|
132
175
|
}
|
133
176
|
throw new Error('A Tiles element can only have Tile children');
|
134
177
|
})}
|
@@ -40,6 +40,42 @@ test('Tiles supports ...rest props', () => {
|
|
40
40
|
expect(screen.getByTestId('my_value')).toBeInTheDocument();
|
41
41
|
});
|
42
42
|
|
43
|
+
test('It can be small', () => {
|
44
|
+
render(
|
45
|
+
<Tiles size={'small'}>
|
46
|
+
<Tile icon={<AssetCollectionIcon />}>small</Tile>
|
47
|
+
</Tiles>
|
48
|
+
);
|
49
|
+
expect(screen.getByText('small')).toBeInTheDocument();
|
50
|
+
});
|
51
|
+
|
52
|
+
test('It can be big', () => {
|
53
|
+
render(
|
54
|
+
<Tiles size={'big'}>
|
55
|
+
<Tile icon={<AssetCollectionIcon />}>big</Tile>
|
56
|
+
</Tiles>
|
57
|
+
);
|
58
|
+
expect(screen.getByText('big')).toBeInTheDocument();
|
59
|
+
});
|
60
|
+
|
61
|
+
test('It can be inline and small', () => {
|
62
|
+
render(
|
63
|
+
<Tiles size={'small'} inline={true}>
|
64
|
+
<Tile>inline</Tile>
|
65
|
+
</Tiles>
|
66
|
+
);
|
67
|
+
expect(screen.getByText('inline')).toBeInTheDocument();
|
68
|
+
});
|
69
|
+
|
70
|
+
test('It can be inline and big', () => {
|
71
|
+
render(
|
72
|
+
<Tiles size={'small'} inline={true}>
|
73
|
+
<Tile>inline</Tile>
|
74
|
+
</Tiles>
|
75
|
+
);
|
76
|
+
expect(screen.getByText('inline')).toBeInTheDocument();
|
77
|
+
});
|
78
|
+
|
43
79
|
test('it triggers onclick when pressing enter with focus', () => {
|
44
80
|
const handleClick = jest.fn();
|
45
81
|
|