@lumx/react 3.1.4 → 3.2.0

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.
Files changed (144) hide show
  1. package/_internal/types.d.ts +16 -5
  2. package/index.d.ts +51 -4
  3. package/index.js +621 -417
  4. package/index.js.map +1 -1
  5. package/package.json +3 -3
  6. package/src/components/alert-dialog/AlertDialog.stories.tsx +96 -165
  7. package/src/components/alert-dialog/AlertDialog.test.tsx +15 -23
  8. package/src/components/avatar/Avatar.stories.tsx +91 -62
  9. package/src/components/avatar/Avatar.test.tsx +9 -24
  10. package/src/components/badge/Badge.stories.tsx +63 -38
  11. package/src/components/button/Button.stories.tsx +147 -139
  12. package/src/components/button/IconButton.stories.tsx +45 -0
  13. package/src/components/checkbox/Checkbox.stories.tsx +37 -30
  14. package/src/components/chip/Chip.stories.tsx +77 -15
  15. package/src/components/comment-block/CommentBlock.stories.tsx +90 -25
  16. package/src/components/comment-block/CommentBlock.test.tsx +12 -17
  17. package/src/components/date-picker/DatePickerField.stories.tsx +52 -83
  18. package/src/components/dialog/Dialog.stories.tsx +132 -240
  19. package/src/components/dialog/Dialog.test.tsx +6 -30
  20. package/src/components/dialog/Dialog.tsx +17 -3
  21. package/src/components/dropdown/Dropdown.stories.tsx +1 -186
  22. package/src/components/flag/Flag.stories.tsx +33 -18
  23. package/src/components/flag/Flag.test.tsx +1 -8
  24. package/src/components/flex-box/FlexBox.stories.tsx +151 -238
  25. package/src/components/flex-box/FlexBox.test.tsx +9 -49
  26. package/src/components/generic-block/GenericBlock.stories.jsx +1 -1
  27. package/src/components/grid-column/GridColumn.stories.tsx +46 -0
  28. package/src/components/heading/Heading.stories.tsx +57 -95
  29. package/src/components/icon/Icon.stories.tsx +67 -70
  30. package/src/components/image-block/ImageBlock.stories.tsx +103 -47
  31. package/src/components/image-block/ImageBlock.test.tsx +12 -17
  32. package/src/components/inline-list/InlineList.stories.tsx +45 -29
  33. package/src/components/input-helper/InputHelper.stories.tsx +31 -25
  34. package/src/components/input-label/InputLabel.stories.tsx +33 -10
  35. package/src/components/lightbox/Lightbox.stories.tsx +39 -77
  36. package/src/components/lightbox/Lightbox.test.tsx +12 -17
  37. package/src/components/link/Link.stories.tsx +98 -128
  38. package/src/components/link-preview/LinkPreview.stories.tsx +48 -75
  39. package/src/components/list/List.stories.tsx +59 -84
  40. package/src/components/list/List.test.tsx +8 -17
  41. package/src/components/list/ListDivider.stories.tsx +9 -4
  42. package/src/components/list/ListDivider.test.tsx +12 -17
  43. package/src/components/list/ListItem.stories.tsx +97 -59
  44. package/src/components/list/ListItem.test.tsx +12 -17
  45. package/src/components/list/ListSubheader.stories.tsx +8 -5
  46. package/src/components/list/ListSubheader.test.tsx +12 -18
  47. package/src/components/message/Message.stories.tsx +51 -22
  48. package/src/components/mosaic/Mosaic.stories.tsx +78 -74
  49. package/src/components/mosaic/Mosaic.test.tsx +0 -31
  50. package/src/components/navigation/Navigation.stories.tsx +67 -0
  51. package/src/components/navigation/Navigation.test.tsx +58 -0
  52. package/src/components/navigation/Navigation.tsx +62 -0
  53. package/src/components/navigation/NavigationItem.test.tsx +37 -0
  54. package/src/components/navigation/NavigationItem.tsx +89 -0
  55. package/src/components/navigation/NavigationSection.test.tsx +126 -0
  56. package/src/components/navigation/NavigationSection.tsx +109 -0
  57. package/src/components/navigation/context.tsx +6 -0
  58. package/src/components/navigation/index.ts +1 -0
  59. package/src/components/notification/Notifications.stories.tsx +52 -47
  60. package/src/components/popover/Popover.stories.tsx +68 -201
  61. package/src/components/popover-dialog/PopoverDialog.stories.tsx +26 -65
  62. package/src/components/post-block/PostBlock.test.tsx +12 -17
  63. package/src/components/progress/ProgressCircular.stories.tsx +24 -12
  64. package/src/components/progress/ProgressLinear.stories.tsx +6 -2
  65. package/src/components/radio-button/RadioButton.stories.tsx +35 -24
  66. package/src/components/select/Select.stories.tsx +19 -23
  67. package/src/components/skeleton/SkeletonCircle.stories.tsx +37 -21
  68. package/src/components/skeleton/SkeletonCircle.test.tsx +12 -17
  69. package/src/components/skeleton/SkeletonRectangle.stories.tsx +74 -99
  70. package/src/components/skeleton/SkeletonRectangle.test.tsx +12 -17
  71. package/src/components/skeleton/SkeletonTypography.test.tsx +12 -17
  72. package/src/components/slider/Slider.stories.tsx +41 -25
  73. package/src/components/slider/Slider.test.tsx +12 -18
  74. package/src/components/slideshow/Slideshow.stories.tsx +31 -61
  75. package/src/components/slideshow/Slideshow.test.tsx +15 -23
  76. package/src/components/slideshow/SlideshowControls.stories.tsx +4 -6
  77. package/src/components/switch/Switch.stories.tsx +35 -32
  78. package/src/components/table/Table.test.tsx +12 -17
  79. package/src/components/tabs/Tabs.stories.tsx +4 -3
  80. package/src/components/text/Text.stories.tsx +130 -0
  81. package/src/components/text-field/TextField.stories.tsx +114 -148
  82. package/src/components/thumbnail/Thumbnail.stories.tsx +106 -255
  83. package/src/components/thumbnail/Thumbnail.test.tsx +12 -35
  84. package/src/components/tooltip/Tooltip.stories.tsx +51 -136
  85. package/src/components/user-block/UserBlock.stories.tsx +67 -56
  86. package/src/components/user-block/UserBlock.test.tsx +1 -5
  87. package/src/index.ts +1 -0
  88. package/src/stories/controls/color.ts +6 -0
  89. package/src/stories/controls/element.ts +6 -0
  90. package/src/stories/controls/focusPoint.ts +1 -0
  91. package/src/stories/controls/icons.ts +6 -0
  92. package/src/stories/{knobs → controls}/image.ts +6 -16
  93. package/src/stories/controls/selectArgType.ts +4 -0
  94. package/src/stories/controls/theme.ts +3 -0
  95. package/src/stories/controls/typography.ts +5 -0
  96. package/src/stories/controls/withUndefined.ts +1 -0
  97. package/src/stories/decorators/withChromaticForceScreenSize.tsx +8 -0
  98. package/src/stories/decorators/withCombinations.tsx +99 -0
  99. package/src/stories/decorators/withNestedProps.tsx +23 -0
  100. package/src/stories/{withResizableBox.tsx → decorators/withResizableBox.tsx} +6 -10
  101. package/src/stories/decorators/withValueOnChange.tsx +18 -0
  102. package/src/stories/decorators/withWrapper.tsx +19 -0
  103. package/src/stories/utils/CustomLink.tsx +8 -2
  104. package/src/stories/{knobs → utils}/lorem.ts +9 -9
  105. package/src/testing/utils/commonTestsSuiteRTL.ts +2 -3
  106. package/src/testing/utils/index.ts +0 -2
  107. package/src/untypped-modules.d.ts +0 -2
  108. package/src/utils/MaterialThemeSwitcher/MaterialThemeSwitcher.tsx +1 -1
  109. package/src/utils/ThemeContext.ts +4 -0
  110. package/src/utils/forwardRefPolymorphic.ts +9 -0
  111. package/src/utils/type.ts +28 -4
  112. package/src/components/alert-dialog/__snapshots__/AlertDialog.test.tsx.snap +0 -551
  113. package/src/components/avatar/__snapshots__/Avatar.test.tsx.snap +0 -681
  114. package/src/components/comment-block/__snapshots__/CommentBlock.test.tsx.snap +0 -92
  115. package/src/components/dialog/__snapshots__/Dialog.test.tsx.snap +0 -960
  116. package/src/components/expansion-panel/ExpansionPanel.stories.tsx +0 -65
  117. package/src/components/flag/__snapshots__/Flag.test.tsx.snap +0 -133
  118. package/src/components/flex-box/__snapshots__/FlexBox.test.tsx.snap +0 -492
  119. package/src/components/grid-column/GridColumn.stories.jsx +0 -56
  120. package/src/components/image-block/__snapshots__/ImageBlock.test.tsx.snap +0 -64
  121. package/src/components/lightbox/__snapshots__/Lightbox.test.tsx.snap +0 -194
  122. package/src/components/list/__snapshots__/List.test.tsx.snap +0 -360
  123. package/src/components/list/__snapshots__/ListDivider.test.tsx.snap +0 -7
  124. package/src/components/list/__snapshots__/ListItem.test.tsx.snap +0 -160
  125. package/src/components/list/__snapshots__/ListSubheader.test.tsx.snap +0 -9
  126. package/src/components/mosaic/__snapshots__/Mosaic.test.tsx.snap +0 -357
  127. package/src/components/post-block/__snapshots__/PostBlock.test.tsx.snap +0 -139
  128. package/src/components/skeleton/__snapshots__/SkeletonCircle.test.tsx.snap +0 -54
  129. package/src/components/skeleton/__snapshots__/SkeletonRectangle.test.tsx.snap +0 -177
  130. package/src/components/skeleton/__snapshots__/SkeletonTypography.test.tsx.snap +0 -174
  131. package/src/components/slider/__snapshots__/Slider.test.tsx.snap +0 -122
  132. package/src/components/slideshow/__snapshots__/Slideshow.test.tsx.snap +0 -157
  133. package/src/components/table/__snapshots__/Table.test.tsx.snap +0 -263
  134. package/src/components/text/Text.stories.jsx +0 -75
  135. package/src/components/thumbnail/__snapshots__/Thumbnail.test.tsx.snap +0 -130
  136. package/src/components/user-block/__snapshots__/UserBlock.test.tsx.snap +0 -362
  137. package/src/stories/chromaticForceScreenSize.tsx +0 -7
  138. package/src/stories/knobs/buttonKnob.ts +0 -9
  139. package/src/stories/knobs/emphasisKnob.ts +0 -8
  140. package/src/stories/knobs/enumKnob.ts +0 -14
  141. package/src/stories/knobs/focusKnob.ts +0 -3
  142. package/src/stories/knobs/sizeKnob.ts +0 -5
  143. package/src/stories/knobs/thumbnailsKnob.ts +0 -9
  144. package/src/testing/utils/itShouldRenderStories.tsx +0 -103
@@ -1,245 +1,158 @@
1
- import { mdiPencil } from '@lumx/icons';
2
- import { Alignment, Button, Icon, Orientation, Size } from '@lumx/react';
3
- import { boolean, number, select, text } from '@storybook/addon-knobs';
4
- import fromPairs from 'lodash/fromPairs';
5
1
  import React from 'react';
6
2
 
7
- import isArray from 'lodash/isArray';
8
- import { FlexBox, FlexBoxProps } from './FlexBox';
9
-
10
- export default { title: 'LumX components/flex-box/FlexBox' };
11
-
12
- const DEFAULT_PROPS: any = {};
13
-
14
- type FlexBoxPropName = keyof FlexBoxProps;
15
- const flexViewKnobConfigs: Array<
16
- [FlexBoxPropName, typeof boolean] | [string & FlexBoxPropName, typeof select, any[] | Record<any, any>]
17
- > = [
18
- ['fillSpace', boolean],
19
- ['noShrink', boolean],
20
- ['wrap', boolean],
21
- ['gap', select, [DEFAULT_PROPS.gap, Size.tiny, Size.regular, Size.medium, Size.big, Size.huge]],
22
- [
23
- 'hAlign',
24
- select,
25
- [
26
- DEFAULT_PROPS.hAlign,
27
- Alignment.center,
28
- Alignment.top,
29
- Alignment.bottom,
30
- Alignment.spaceAround,
31
- Alignment.spaceBetween,
32
- Alignment.spaceEvenly,
3
+ import { Alignment, Button, IconButton, Orientation, Size, Text } from '@lumx/react';
4
+
5
+ import { getSelectArgType } from '@lumx/react/stories/controls/selectArgType';
6
+ import { withCombinations } from '@lumx/react/stories/decorators/withCombinations';
7
+ import { withUndefined } from '@lumx/react/stories/controls/withUndefined';
8
+ import { withWrapper } from '@lumx/react/stories/decorators/withWrapper';
9
+ import { mdiAtom } from '@lumx/icons';
10
+ import mergeWith from 'lodash/fp/mergeWith';
11
+ import castArray from 'lodash/castArray';
12
+ import { FlexBox } from './FlexBox';
13
+
14
+ const gapSizes = [Size.tiny, Size.regular, Size.medium, Size.big, Size.huge];
15
+ const spaceAlignments = [Alignment.spaceBetween, Alignment.spaceEvenly, Alignment.spaceAround];
16
+ const verticalAlignments = [...spaceAlignments, Alignment.top, Alignment.center, Alignment.bottom];
17
+ const horizontalAlignments = [...spaceAlignments, Alignment.left, Alignment.center, Alignment.right];
18
+
19
+ export default {
20
+ title: 'LumX components/flex-box/FlexBox',
21
+ component: FlexBox,
22
+ args: FlexBox.defaultProps,
23
+ argTypes: {
24
+ orientation: getSelectArgType(Orientation),
25
+ fillSpace: { control: 'boolean' },
26
+ wrap: { control: 'boolean' },
27
+ noShrink: { control: 'boolean' },
28
+ hAlign: getSelectArgType(verticalAlignments),
29
+ vAlign: getSelectArgType(horizontalAlignments),
30
+ gap: getSelectArgType(gapSizes),
31
+ },
32
+ };
33
+
34
+ /** Without config, FlexBox acts as a simple <div> */
35
+ export const NoConfig = {
36
+ args: {
37
+ style: { width: '100%', height: '100%' },
38
+ children: [
39
+ <Button key="1">Button 1</Button>,
40
+ <Text key="2" as="p">
41
+ Some paragraph
42
+ </Text>,
43
+ <Button key="3">Button 3</Button>,
33
44
  ],
45
+ },
46
+ decorators: [withWrapper({ style: { border: '1px dashed red' } })],
47
+ };
48
+
49
+ /** Horizontal orientation with all possible item alignments */
50
+ export const Horizontal = {
51
+ ...NoConfig,
52
+ args: {
53
+ ...NoConfig.args,
54
+ orientation: Orientation.horizontal,
55
+ },
56
+ decorators: [
57
+ withCombinations({
58
+ cellStyle: { border: '1px dashed red' },
59
+ firstColStyle: { whiteSpace: 'nowrap', width: '1%' },
60
+ combinations: { rows: { key: 'vAlign', options: withUndefined(horizontalAlignments) } },
61
+ }),
34
62
  ],
35
- [
36
- 'vAlign',
37
- select,
38
- [
39
- DEFAULT_PROPS.vAlign,
40
- Alignment.center,
41
- Alignment.right,
42
- Alignment.left,
43
- Alignment.spaceAround,
44
- Alignment.spaceBetween,
45
- Alignment.spaceEvenly,
46
- ],
63
+ };
64
+
65
+ /** Vertical orientation with all possible item alignments */
66
+ export const Vertical = {
67
+ ...NoConfig,
68
+ args: {
69
+ ...NoConfig.args,
70
+ orientation: Orientation.vertical,
71
+ },
72
+ decorators: [
73
+ withCombinations({
74
+ cellStyle: { border: '1px dashed red', height: '200px' },
75
+ firstColStyle: { whiteSpace: 'nowrap', width: '1%' },
76
+ combinations: { rows: { key: 'hAlign', options: withUndefined(verticalAlignments) } },
77
+ }),
47
78
  ],
48
- ['orientation', select, [undefined, Orientation.horizontal, Orientation.vertical]],
49
- [
50
- 'marginAuto',
51
- select,
52
- {
53
- default: DEFAULT_PROPS.marginAuto,
54
- bottom: Alignment.bottom,
55
- top: Alignment.top,
56
- right: Alignment.right,
57
- left: Alignment.left,
58
- 'left & right': [Alignment.left, Alignment.right],
59
- 'top & bottom': [Alignment.top, Alignment.bottom],
60
- 'all around': [Alignment.top, Alignment.bottom, Alignment.left, Alignment.right],
61
- },
79
+ };
80
+
81
+ /** All gap sizes */
82
+ export const GapSizes = {
83
+ ...Horizontal,
84
+ argTypes: {
85
+ gap: { control: false },
86
+ },
87
+ decorators: [
88
+ ...NoConfig.decorators,
89
+ withCombinations({
90
+ combinations: {
91
+ rows: { key: 'gap', options: withUndefined(gapSizes) },
92
+ },
93
+ }),
62
94
  ],
63
- ];
64
-
65
- const setupFlexBoxKnobs = (group: string, knobs: FlexBoxPropName[] = []) =>
66
- fromPairs(
67
- knobs.map((knob: FlexBoxPropName) => {
68
- const [prop, knobFn, selectOptions] = flexViewKnobConfigs.find(([k]) => k === knob) as any;
69
- if (selectOptions) {
70
- const defaultValue = isArray(selectOptions) ? selectOptions[0] : DEFAULT_PROPS[prop];
71
- return [prop, knobFn(prop, selectOptions, defaultValue, group)];
72
- }
73
- return [prop, knobFn(prop, DEFAULT_PROPS[prop], group)];
95
+ };
96
+
97
+ /** Wrap items in new row or column */
98
+ export const Wrap = {
99
+ args: {
100
+ ...NoConfig.args,
101
+ orientation: Orientation.horizontal,
102
+ wrap: true,
103
+ },
104
+ argTypes: {
105
+ wrap: { control: false },
106
+ },
107
+ decorators: [
108
+ withWrapper({ style: { border: '1px dashed red', width: '100px', height: '100px', margin: '20px auto' } }),
109
+ withCombinations({
110
+ cellStyle: { width: '50%' },
111
+ combinations: {
112
+ cols: { key: 'orientation', options: Object.values(Orientation) },
113
+ rows: { 'No wrap': { wrap: false }, Wrap: { wrap: true } },
114
+ },
74
115
  }),
75
- );
76
-
77
- const flexChildKnobs: FlexBoxPropName[] = ['fillSpace', 'noShrink', 'marginAuto'];
78
-
79
- export const Flex = () => (
80
- <FlexBox {...setupFlexBoxKnobs('-flex container', ['orientation', 'hAlign', 'vAlign', 'wrap', 'gap'])}>
81
- <FlexBox {...setupFlexBoxKnobs('start', flexChildKnobs)}>
82
- <Icon icon={mdiPencil} />
83
- </FlexBox>
84
- <FlexBox {...setupFlexBoxKnobs('middle', flexChildKnobs)}>
85
- {text('Text content', 'Some text in a div', 'middle')}
86
- </FlexBox>
87
- <FlexBox {...setupFlexBoxKnobs('end', flexChildKnobs)}>
88
- <Button>OK</Button>
89
- </FlexBox>
90
- </FlexBox>
91
- );
92
-
93
- const hAlign = (prefix?: string) =>
94
- select(
95
- `${prefix ? `${prefix}: ` : ''}Horizontal align`,
96
- [
97
- Alignment.center,
98
- Alignment.top,
99
- Alignment.bottom,
100
- Alignment.spaceAround,
101
- Alignment.spaceBetween,
102
- Alignment.spaceEvenly,
103
- ],
104
- Alignment.center,
105
- );
106
- const vAlign = (prefix?: string) =>
107
- select(
108
- `${prefix ? `${prefix}: ` : ''}Vertical align`,
109
- [
110
- Alignment.center,
111
- Alignment.left,
112
- Alignment.right,
113
- Alignment.spaceAround,
114
- Alignment.spaceBetween,
115
- Alignment.spaceEvenly,
116
- ],
117
- Alignment.center,
118
- );
119
-
120
- const orientation = (prefix?: string) =>
121
- select(
122
- `${prefix ? `${prefix}: ` : ''}Set orientation`,
123
- [Orientation.vertical, Orientation.horizontal],
124
- Orientation.vertical,
125
- );
126
-
127
- const gapSize = (prefix?: string) =>
128
- select(`${prefix ? `${prefix}: ` : ''}Gap size`, [Size.regular, Size.medium, Size.big, Size.huge], Size.regular);
129
-
130
- export const HorizontalFlex = () => (
131
- <FlexBox
132
- orientation={Orientation.horizontal}
133
- style={{ height: `${number('height (px)', 300)}px`, border: '1px solid red' }}
134
- >
135
- <Button>Default</Button>
136
- <FlexBox hAlign={Alignment.top}>
137
- <Button>Top</Button>
138
- </FlexBox>
139
- <FlexBox
140
- fillSpace={boolean('Center button: fill space', true)}
141
- hAlign={hAlign('Center button')}
142
- vAlign={vAlign('Center button')}
143
- >
144
- <Button>Center button</Button>
145
- </FlexBox>
146
- <FlexBox hAlign={Alignment.bottom}>
147
- <Button>Bottom</Button>
148
- </FlexBox>
149
- </FlexBox>
150
- );
151
-
152
- export const VerticalFlex = () => (
153
- <FlexBox
154
- orientation={Orientation.vertical}
155
- style={{ height: `${number('height (px)', 300)}px`, border: '1px solid red' }}
156
- >
157
- <Button>Default</Button>
158
- <FlexBox vAlign={Alignment.left}>
159
- <Button>Left</Button>
160
- </FlexBox>
161
- <FlexBox
162
- fillSpace={boolean('Center button: fill space', true)}
163
- hAlign={hAlign('Center button')}
164
- vAlign={vAlign('Center button')}
165
- >
166
- <Button>Center button</Button>
167
- </FlexBox>
168
- <FlexBox vAlign={Alignment.right}>
169
- <Button>Right</Button>
170
- </FlexBox>
171
- </FlexBox>
172
- );
173
-
174
- export const GapSizeFlex = () => (
175
- <FlexBox orientation={orientation()} gap={gapSize()}>
176
- <Button>Item 1</Button>
177
- <FlexBox vAlign={Alignment.left}>
178
- <Button>Item 2</Button>
179
- </FlexBox>
180
- <FlexBox>
181
- <Button>Item 3</Button>
182
- </FlexBox>
183
- <FlexBox vAlign={Alignment.right}>
184
- <Button>Item 4</Button>
185
- </FlexBox>
186
- </FlexBox>
187
- );
188
-
189
- export const WrapFlex = () => (
190
- <FlexBox
191
- orientation={Orientation.horizontal}
192
- wrap={boolean('wrap', true)}
193
- style={{ width: `${number('width (px)', 150)}px`, border: '1px solid red' }}
194
- >
195
- <FlexBox fillSpace orientation={Orientation.vertical}>
196
- <Button>Button</Button>
197
- </FlexBox>
198
- <Button>Button</Button>
199
- <Button>Button</Button>
200
- </FlexBox>
201
- );
202
-
203
- export const NoShrinkFlex = () => (
204
- <FlexBox
205
- orientation={Orientation.horizontal}
206
- style={{ width: `${number('width (px)', 150)}px`, border: '1px solid red' }}
207
- >
208
- <Button>Button</Button>
209
- <FlexBox noShrink={boolean('no shrink', true)}>{text('Center text', 'Some long text')}</FlexBox>
210
- <Button>Button</Button>
211
- </FlexBox>
212
- );
213
-
214
- export const Align = () => (
215
- <FlexBox orientation={Orientation.horizontal} vAlign={vAlign()} hAlign={hAlign()}>
216
- <Button style={{ height: 200 }}>Button</Button>
217
- <FlexBox style={{ height: 'fit-content' }}>Some text</FlexBox>
218
- </FlexBox>
219
- );
220
-
221
- export const Distribution = () => (
222
- <FlexBox
223
- style={{
224
- width: `${number('width (px)', 720)}px`,
225
- height: `${number('height (px)', 300)}px`,
226
- border: '1px solid red',
227
- }}
228
- orientation={orientation()}
229
- gap={gapSize()}
230
- vAlign={vAlign()}
231
- hAlign={hAlign()}
232
- >
233
- <Button>Button 1</Button>
234
- <Button>Button 2</Button>
235
- <Button>Button 3</Button>
236
- </FlexBox>
237
- );
238
-
239
- export const CustomizeElement = () => (
240
- <FlexBox as="header" orientation="horizontal" gap="regular">
241
- <div>Element 1</div>
242
- <div>Element 2</div>
243
- <div>Element 2</div>
244
- </FlexBox>
245
- );
116
+ ],
117
+ };
118
+
119
+ /** Prevent FlexBox from shrinking into a parent flex box */
120
+ export const NoShrink = {
121
+ args: {
122
+ children: <Text as="p">Some paragraph</Text>,
123
+ noShrink: true,
124
+ },
125
+ decorators: [
126
+ withWrapper({
127
+ style: { display: 'flex', border: '1px dashed red', width: 100, height: 100, margin: '20px auto' },
128
+ }),
129
+ ],
130
+ };
131
+
132
+ /** All combinations of margin auto values */
133
+ export const MarginAuto = {
134
+ args: { children: <IconButton label="" icon={mdiAtom} /> },
135
+ decorators: [
136
+ withWrapper({
137
+ style: { display: 'flex', border: '1px dashed red', width: 100, height: 100, margin: '20px auto' },
138
+ }),
139
+ withCombinations({
140
+ combinations: {
141
+ rows: {
142
+ key: 'marginAuto',
143
+ options: [undefined, Alignment.left, Alignment.top, [Alignment.left, Alignment.top]],
144
+ },
145
+ cols: {
146
+ key: 'marginAuto',
147
+ options: [undefined, Alignment.right, Alignment.bottom, [Alignment.right, Alignment.bottom]],
148
+ },
149
+ },
150
+ combinator: mergeWith((a, b) => {
151
+ if (a && b) {
152
+ return [...castArray(a), ...castArray(b)].filter(Boolean);
153
+ }
154
+ return undefined;
155
+ }),
156
+ }),
157
+ ],
158
+ };
@@ -1,65 +1,25 @@
1
- import { mount, shallow } from 'enzyme';
2
- import 'jest-enzyme';
3
- import React, { ReactElement } from 'react';
4
- import { commonTestsSuite, itShouldRenderStories, Wrapper } from '@lumx/react/testing/utils';
1
+ import React from 'react';
2
+ import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
5
3
 
4
+ import { queryByClassName } from '@lumx/react/testing/utils/queries';
5
+ import { render } from '@testing-library/react';
6
6
  import { FlexBox, FlexBoxProps } from './FlexBox';
7
- import * as stories from './FlexBox.stories';
8
7
 
9
8
  const CLASSNAME = FlexBox.className as string;
10
9
 
11
10
  type SetupProps = Partial<FlexBoxProps>;
12
11
 
13
- /**
14
- * Mounts the component and returns common DOM elements / data needed in multiple tests further down.
15
- */
16
- const setup = (propsOverride: SetupProps = {}, shallowRendering = true) => {
12
+ const setup = (propsOverride: SetupProps = {}) => {
17
13
  const props: FlexBoxProps = {
18
14
  children: null,
19
15
  ...propsOverride,
20
16
  };
21
- const renderer: (el: ReactElement) => Wrapper = shallowRendering ? shallow : mount;
22
- const wrapper = renderer(<FlexBox {...props} />);
23
-
24
- return { props, wrapper };
17
+ render(<FlexBox {...props} />);
18
+ const flexBox = queryByClassName(document.body, CLASSNAME);
19
+ return { props, flexBox };
25
20
  };
26
21
 
27
22
  describe(`<${FlexBox.displayName}>`, () => {
28
- // 1. Test render via snapshot.
29
- describe('Snapshots and structure', () => {
30
- itShouldRenderStories(stories, FlexBox);
31
- });
32
-
33
- /////////////////////////////
34
-
35
- // 2. Test defaultProps value and important props custom values.
36
- describe('Props', () => {
37
- // Nothing to do here.
38
- });
39
-
40
- /////////////////////////////
41
-
42
- // 3. Test events.
43
- describe('Events', () => {
44
- // Nothing to do here.
45
- });
46
-
47
- /////////////////////////////
48
-
49
- // 4. Test conditions (i.e. things that display or not in the UI based on props).
50
- describe('Conditions', () => {
51
- // Nothing to do here.
52
- });
53
-
54
- /////////////////////////////
55
-
56
- // 5. Test state.
57
- describe('State', () => {
58
- // Nothing to do here.
59
- });
60
-
61
- /////////////////////////////
62
-
63
23
  // Common tests suite.
64
- commonTestsSuite(setup, { className: 'wrapper', prop: 'wrapper' }, { className: CLASSNAME });
24
+ commonTestsSuiteRTL(setup, { baseClassName: CLASSNAME, forwardClassName: 'flexBox', forwardAttributes: 'flexBox' });
65
25
  });
@@ -1,7 +1,7 @@
1
- import { IMAGES } from '@lumx/react/stories/knobs/image';
2
1
  import React from 'react';
3
2
  import { mdiPencil } from '@lumx/icons';
4
3
  import { GenericBlock, Button, Icon, Size, Thumbnail } from '@lumx/react';
4
+ import { IMAGES } from '@lumx/react/stories/controls/image';
5
5
 
6
6
  export default { title: 'LumX components/generic-block/GenericBlock' };
7
7
 
@@ -0,0 +1,46 @@
1
+ /* eslint-disable react/display-name */
2
+ import React from 'react';
3
+ import range from 'lodash/range';
4
+
5
+ import { GridColumn, GridColumnProps } from '@lumx/react/components/grid-column/GridColumn';
6
+ import { getSelectArgType } from '@lumx/react/stories/controls/selectArgType';
7
+ import { Size } from '@lumx/react';
8
+ import { loremIpsum } from '@lumx/react/stories/utils/lorem';
9
+
10
+ const genericBlockStyle = { border: '1px solid red', padding: '2px 8px' };
11
+
12
+ const gapSizes: Array<GridColumnProps['gap']> = [Size.tiny, Size.regular, Size.big, Size.huge];
13
+
14
+ const getItems = (nb: number) =>
15
+ range(nb).map((key) => (
16
+ // eslint-disable-next-line react/jsx-key
17
+ <div style={genericBlockStyle}>
18
+ <h2>Column {key}</h2>
19
+ <p>{loremIpsum('tiny')}</p>
20
+ </div>
21
+ ));
22
+
23
+ export default {
24
+ title: 'LumX components/grid-column/GridColumn',
25
+ component: GridColumn,
26
+ argTypes: {
27
+ nbItems: { control: 'number', min: 0 },
28
+ gap: getSelectArgType(gapSizes),
29
+ itemMinWidth: { control: 'number', defaultValue: 200 },
30
+ maxColumns: { control: 'number' },
31
+ },
32
+ args: GridColumn.defaultProps,
33
+ render: ({ nbItems = 5, ...props }) => <GridColumn {...props}>{getItems(nbItems)}</GridColumn>,
34
+ };
35
+
36
+ /**
37
+ * Default grid column displaying a single column
38
+ */
39
+ export const Default = {};
40
+
41
+ /**
42
+ * Grid column with max 4 columns (responsive)
43
+ */
44
+ export const Columns = {
45
+ args: { maxColumns: 4 },
46
+ };