@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.
- package/_internal/types.d.ts +16 -5
- package/index.d.ts +51 -4
- package/index.js +621 -417
- package/index.js.map +1 -1
- package/package.json +3 -3
- package/src/components/alert-dialog/AlertDialog.stories.tsx +96 -165
- package/src/components/alert-dialog/AlertDialog.test.tsx +15 -23
- package/src/components/avatar/Avatar.stories.tsx +91 -62
- package/src/components/avatar/Avatar.test.tsx +9 -24
- package/src/components/badge/Badge.stories.tsx +63 -38
- package/src/components/button/Button.stories.tsx +147 -139
- package/src/components/button/IconButton.stories.tsx +45 -0
- package/src/components/checkbox/Checkbox.stories.tsx +37 -30
- package/src/components/chip/Chip.stories.tsx +77 -15
- package/src/components/comment-block/CommentBlock.stories.tsx +90 -25
- package/src/components/comment-block/CommentBlock.test.tsx +12 -17
- package/src/components/date-picker/DatePickerField.stories.tsx +52 -83
- package/src/components/dialog/Dialog.stories.tsx +132 -240
- package/src/components/dialog/Dialog.test.tsx +6 -30
- package/src/components/dialog/Dialog.tsx +17 -3
- package/src/components/dropdown/Dropdown.stories.tsx +1 -186
- package/src/components/flag/Flag.stories.tsx +33 -18
- package/src/components/flag/Flag.test.tsx +1 -8
- package/src/components/flex-box/FlexBox.stories.tsx +151 -238
- package/src/components/flex-box/FlexBox.test.tsx +9 -49
- package/src/components/generic-block/GenericBlock.stories.jsx +1 -1
- package/src/components/grid-column/GridColumn.stories.tsx +46 -0
- package/src/components/heading/Heading.stories.tsx +57 -95
- package/src/components/icon/Icon.stories.tsx +67 -70
- package/src/components/image-block/ImageBlock.stories.tsx +103 -47
- package/src/components/image-block/ImageBlock.test.tsx +12 -17
- package/src/components/inline-list/InlineList.stories.tsx +45 -29
- package/src/components/input-helper/InputHelper.stories.tsx +31 -25
- package/src/components/input-label/InputLabel.stories.tsx +33 -10
- package/src/components/lightbox/Lightbox.stories.tsx +39 -77
- package/src/components/lightbox/Lightbox.test.tsx +12 -17
- package/src/components/link/Link.stories.tsx +98 -128
- package/src/components/link-preview/LinkPreview.stories.tsx +48 -75
- package/src/components/list/List.stories.tsx +59 -84
- package/src/components/list/List.test.tsx +8 -17
- package/src/components/list/ListDivider.stories.tsx +9 -4
- package/src/components/list/ListDivider.test.tsx +12 -17
- package/src/components/list/ListItem.stories.tsx +97 -59
- package/src/components/list/ListItem.test.tsx +12 -17
- package/src/components/list/ListSubheader.stories.tsx +8 -5
- package/src/components/list/ListSubheader.test.tsx +12 -18
- package/src/components/message/Message.stories.tsx +51 -22
- package/src/components/mosaic/Mosaic.stories.tsx +78 -74
- package/src/components/mosaic/Mosaic.test.tsx +0 -31
- package/src/components/navigation/Navigation.stories.tsx +67 -0
- package/src/components/navigation/Navigation.test.tsx +58 -0
- package/src/components/navigation/Navigation.tsx +62 -0
- package/src/components/navigation/NavigationItem.test.tsx +37 -0
- package/src/components/navigation/NavigationItem.tsx +89 -0
- package/src/components/navigation/NavigationSection.test.tsx +126 -0
- package/src/components/navigation/NavigationSection.tsx +109 -0
- package/src/components/navigation/context.tsx +6 -0
- package/src/components/navigation/index.ts +1 -0
- package/src/components/notification/Notifications.stories.tsx +52 -47
- package/src/components/popover/Popover.stories.tsx +68 -201
- package/src/components/popover-dialog/PopoverDialog.stories.tsx +26 -65
- package/src/components/post-block/PostBlock.test.tsx +12 -17
- package/src/components/progress/ProgressCircular.stories.tsx +24 -12
- package/src/components/progress/ProgressLinear.stories.tsx +6 -2
- package/src/components/radio-button/RadioButton.stories.tsx +35 -24
- package/src/components/select/Select.stories.tsx +19 -23
- package/src/components/skeleton/SkeletonCircle.stories.tsx +37 -21
- package/src/components/skeleton/SkeletonCircle.test.tsx +12 -17
- package/src/components/skeleton/SkeletonRectangle.stories.tsx +74 -99
- package/src/components/skeleton/SkeletonRectangle.test.tsx +12 -17
- package/src/components/skeleton/SkeletonTypography.test.tsx +12 -17
- package/src/components/slider/Slider.stories.tsx +41 -25
- package/src/components/slider/Slider.test.tsx +12 -18
- package/src/components/slideshow/Slideshow.stories.tsx +31 -61
- package/src/components/slideshow/Slideshow.test.tsx +15 -23
- package/src/components/slideshow/SlideshowControls.stories.tsx +4 -6
- package/src/components/switch/Switch.stories.tsx +35 -32
- package/src/components/table/Table.test.tsx +12 -17
- package/src/components/tabs/Tabs.stories.tsx +4 -3
- package/src/components/text/Text.stories.tsx +130 -0
- package/src/components/text-field/TextField.stories.tsx +114 -148
- package/src/components/thumbnail/Thumbnail.stories.tsx +106 -255
- package/src/components/thumbnail/Thumbnail.test.tsx +12 -35
- package/src/components/tooltip/Tooltip.stories.tsx +51 -136
- package/src/components/user-block/UserBlock.stories.tsx +67 -56
- package/src/components/user-block/UserBlock.test.tsx +1 -5
- package/src/index.ts +1 -0
- package/src/stories/controls/color.ts +6 -0
- package/src/stories/controls/element.ts +6 -0
- package/src/stories/controls/focusPoint.ts +1 -0
- package/src/stories/controls/icons.ts +6 -0
- package/src/stories/{knobs → controls}/image.ts +6 -16
- package/src/stories/controls/selectArgType.ts +4 -0
- package/src/stories/controls/theme.ts +3 -0
- package/src/stories/controls/typography.ts +5 -0
- package/src/stories/controls/withUndefined.ts +1 -0
- package/src/stories/decorators/withChromaticForceScreenSize.tsx +8 -0
- package/src/stories/decorators/withCombinations.tsx +99 -0
- package/src/stories/decorators/withNestedProps.tsx +23 -0
- package/src/stories/{withResizableBox.tsx → decorators/withResizableBox.tsx} +6 -10
- package/src/stories/decorators/withValueOnChange.tsx +18 -0
- package/src/stories/decorators/withWrapper.tsx +19 -0
- package/src/stories/utils/CustomLink.tsx +8 -2
- package/src/stories/{knobs → utils}/lorem.ts +9 -9
- package/src/testing/utils/commonTestsSuiteRTL.ts +2 -3
- package/src/testing/utils/index.ts +0 -2
- package/src/untypped-modules.d.ts +0 -2
- package/src/utils/MaterialThemeSwitcher/MaterialThemeSwitcher.tsx +1 -1
- package/src/utils/ThemeContext.ts +4 -0
- package/src/utils/forwardRefPolymorphic.ts +9 -0
- package/src/utils/type.ts +28 -4
- package/src/components/alert-dialog/__snapshots__/AlertDialog.test.tsx.snap +0 -551
- package/src/components/avatar/__snapshots__/Avatar.test.tsx.snap +0 -681
- package/src/components/comment-block/__snapshots__/CommentBlock.test.tsx.snap +0 -92
- package/src/components/dialog/__snapshots__/Dialog.test.tsx.snap +0 -960
- package/src/components/expansion-panel/ExpansionPanel.stories.tsx +0 -65
- package/src/components/flag/__snapshots__/Flag.test.tsx.snap +0 -133
- package/src/components/flex-box/__snapshots__/FlexBox.test.tsx.snap +0 -492
- package/src/components/grid-column/GridColumn.stories.jsx +0 -56
- package/src/components/image-block/__snapshots__/ImageBlock.test.tsx.snap +0 -64
- package/src/components/lightbox/__snapshots__/Lightbox.test.tsx.snap +0 -194
- package/src/components/list/__snapshots__/List.test.tsx.snap +0 -360
- package/src/components/list/__snapshots__/ListDivider.test.tsx.snap +0 -7
- package/src/components/list/__snapshots__/ListItem.test.tsx.snap +0 -160
- package/src/components/list/__snapshots__/ListSubheader.test.tsx.snap +0 -9
- package/src/components/mosaic/__snapshots__/Mosaic.test.tsx.snap +0 -357
- package/src/components/post-block/__snapshots__/PostBlock.test.tsx.snap +0 -139
- package/src/components/skeleton/__snapshots__/SkeletonCircle.test.tsx.snap +0 -54
- package/src/components/skeleton/__snapshots__/SkeletonRectangle.test.tsx.snap +0 -177
- package/src/components/skeleton/__snapshots__/SkeletonTypography.test.tsx.snap +0 -174
- package/src/components/slider/__snapshots__/Slider.test.tsx.snap +0 -122
- package/src/components/slideshow/__snapshots__/Slideshow.test.tsx.snap +0 -157
- package/src/components/table/__snapshots__/Table.test.tsx.snap +0 -263
- package/src/components/text/Text.stories.jsx +0 -75
- package/src/components/thumbnail/__snapshots__/Thumbnail.test.tsx.snap +0 -130
- package/src/components/user-block/__snapshots__/UserBlock.test.tsx.snap +0 -362
- package/src/stories/chromaticForceScreenSize.tsx +0 -7
- package/src/stories/knobs/buttonKnob.ts +0 -9
- package/src/stories/knobs/emphasisKnob.ts +0 -8
- package/src/stories/knobs/enumKnob.ts +0 -14
- package/src/stories/knobs/focusKnob.ts +0 -3
- package/src/stories/knobs/sizeKnob.ts +0 -5
- package/src/stories/knobs/thumbnailsKnob.ts +0 -9
- 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
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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
|
-
|
|
78
|
-
|
|
79
|
-
export const
|
|
80
|
-
|
|
81
|
-
<
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
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
|
|
2
|
-
import '
|
|
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
|
-
|
|
22
|
-
const
|
|
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
|
-
|
|
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
|
+
};
|