@lumx/react 3.1.5 → 3.2.1-alpha.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 +45 -4
- package/index.js +632 -423
- 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 +131 -293
- package/src/components/dialog/Dialog.test.tsx +0 -32
- 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/Popover.tsx +7 -9
- 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/select/SelectMultiple.stories.tsx +105 -2
- package/src/components/select/WithSelectContext.tsx +10 -4
- 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/hooks/useFocusTrap.ts +2 -2
- 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 -558
- 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 -1133
- 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,108 +1,70 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { headingElementArgType, HEADING_ELEMENTS } from '@lumx/react/stories/controls/element';
|
|
3
|
+
import { withCombinations } from '@lumx/react/stories/decorators/withCombinations';
|
|
4
|
+
import { ALL_TYPOGRAPHY } from '@lumx/react/stories/controls/typography';
|
|
4
5
|
import { Heading, HeadingLevelProvider } from '.';
|
|
5
|
-
import
|
|
6
|
-
import { GenericBlock } from '../generic-block';
|
|
7
|
-
import { Thumbnail } from '../thumbnail';
|
|
6
|
+
import TextStories from '../text/Text.stories';
|
|
8
7
|
|
|
9
|
-
export default {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
<Heading>Second Level</Heading>
|
|
19
|
-
<HeadingLevelProvider>
|
|
20
|
-
{/* This will render a h3 */}
|
|
21
|
-
<Heading>Third Level</Heading>
|
|
22
|
-
{/* This will also render a h3 */}
|
|
23
|
-
<Heading>Other Third Level</Heading>
|
|
24
|
-
<HeadingLevelProvider>
|
|
25
|
-
{/* This will render a h4 */}
|
|
26
|
-
<Heading>Fourth Level</Heading>
|
|
27
|
-
<HeadingLevelProvider>
|
|
28
|
-
{/* This will render a h5 */}
|
|
29
|
-
<Heading>Fifth Level</Heading>
|
|
30
|
-
</HeadingLevelProvider>
|
|
31
|
-
</HeadingLevelProvider>
|
|
32
|
-
</HeadingLevelProvider>
|
|
33
|
-
</HeadingLevelProvider>
|
|
34
|
-
</div>
|
|
35
|
-
);
|
|
8
|
+
export default {
|
|
9
|
+
title: 'LumX components/heading/Heading',
|
|
10
|
+
component: Heading,
|
|
11
|
+
args: Heading.defaultProps,
|
|
12
|
+
argTypes: {
|
|
13
|
+
...TextStories.argTypes,
|
|
14
|
+
as: headingElementArgType,
|
|
15
|
+
children: { control: 'text' },
|
|
16
|
+
},
|
|
36
17
|
};
|
|
37
18
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
<HeadingLevelProvider>
|
|
44
|
-
{/* This will render a h2 */}
|
|
45
|
-
<Heading>Second Level</Heading>
|
|
46
|
-
<HeadingLevelProvider level={2}>
|
|
47
|
-
{/* This will also render a h2 */}
|
|
48
|
-
<Heading>Lorem ipsum</Heading>
|
|
49
|
-
<Heading>Dolor sit amet</Heading>
|
|
50
|
-
<Heading>Reprehenderit et aute</Heading>
|
|
51
|
-
</HeadingLevelProvider>
|
|
52
|
-
</HeadingLevelProvider>
|
|
53
|
-
</div>
|
|
54
|
-
);
|
|
19
|
+
/**
|
|
20
|
+
* Default heading with text
|
|
21
|
+
*/
|
|
22
|
+
export const Default = {
|
|
23
|
+
args: { children: 'Some heading text' },
|
|
55
24
|
};
|
|
56
25
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
<Heading as="h2">Forced second Level</Heading>
|
|
65
|
-
<Heading as="h3">Forced third Level</Heading>
|
|
66
|
-
<Heading as="h4">Forced fourth Level</Heading>
|
|
67
|
-
</HeadingLevelProvider>
|
|
68
|
-
</div>
|
|
69
|
-
);
|
|
26
|
+
/**
|
|
27
|
+
* All supported heading elements
|
|
28
|
+
*/
|
|
29
|
+
export const AllLevels = {
|
|
30
|
+
...Default,
|
|
31
|
+
argTypes: { as: { control: false } },
|
|
32
|
+
decorators: [withCombinations({ combinations: { rows: { key: 'as', options: HEADING_ELEMENTS } } })],
|
|
70
33
|
};
|
|
71
34
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
<GenericBlock figure={<Thumbnail image={imageKnob()} alt="First Item" size={Size.l} />}>
|
|
80
|
-
<Heading typography={Typography.subtitle2}>Second item</Heading>
|
|
81
|
-
</GenericBlock>
|
|
82
|
-
<GenericBlock figure={<Thumbnail image={imageKnob()} alt="First Item" size={Size.l} />}>
|
|
83
|
-
<Heading typography={Typography.subtitle2}>Third item</Heading>
|
|
84
|
-
</GenericBlock>
|
|
85
|
-
</FlexBox>
|
|
86
|
-
</HeadingLevelProvider>
|
|
87
|
-
);
|
|
35
|
+
/**
|
|
36
|
+
* All typography
|
|
37
|
+
*/
|
|
38
|
+
export const AllTypography = {
|
|
39
|
+
...Default,
|
|
40
|
+
argTypes: { typography: { control: false } },
|
|
41
|
+
decorators: [withCombinations({ combinations: { rows: { key: 'typography', options: ALL_TYPOGRAPHY } } })],
|
|
88
42
|
};
|
|
89
43
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
44
|
+
/**
|
|
45
|
+
* Nest HeadingLevelProvider to increment heading levels
|
|
46
|
+
*/
|
|
47
|
+
export const NestedHeadingLevelProvider = () => (
|
|
48
|
+
<>
|
|
49
|
+
{/* This will render a h1 */}
|
|
50
|
+
<Heading>First level</Heading>
|
|
51
|
+
<HeadingLevelProvider>
|
|
52
|
+
{/* This will render a h2 */}
|
|
53
|
+
<Heading>Second Level</Heading>
|
|
54
|
+
<HeadingLevelProvider>
|
|
55
|
+
{/* This will render a h3 */}
|
|
56
|
+
<Heading>Third Level</Heading>
|
|
57
|
+
{/* This will also render a h3 */}
|
|
58
|
+
<Heading>Other Third Level</Heading>
|
|
59
|
+
<HeadingLevelProvider>
|
|
60
|
+
{/* This will render a h4 */}
|
|
61
|
+
<Heading>Fourth Level</Heading>
|
|
99
62
|
<HeadingLevelProvider>
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
<ListWithSubElements />
|
|
63
|
+
{/* This will render a h5 */}
|
|
64
|
+
<Heading>Fifth Level</Heading>
|
|
103
65
|
</HeadingLevelProvider>
|
|
104
|
-
</
|
|
105
|
-
</
|
|
106
|
-
</
|
|
107
|
-
|
|
108
|
-
|
|
66
|
+
</HeadingLevelProvider>
|
|
67
|
+
</HeadingLevelProvider>
|
|
68
|
+
</HeadingLevelProvider>
|
|
69
|
+
</>
|
|
70
|
+
);
|
|
@@ -1,76 +1,73 @@
|
|
|
1
|
-
import React, { Fragment } from 'react';
|
|
2
|
-
|
|
3
1
|
import { mdiEmail } from '@lumx/icons';
|
|
4
|
-
import { ColorPalette, ColorVariant,
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
undefined,
|
|
11
|
-
Size.xxs,
|
|
12
|
-
Size.xs,
|
|
13
|
-
Size.s,
|
|
14
|
-
Size.m,
|
|
15
|
-
Size.l,
|
|
16
|
-
Size.xl,
|
|
17
|
-
Size.xxl,
|
|
18
|
-
];
|
|
19
|
-
|
|
20
|
-
const TemplateSizeVariants = ({ hasShape, theme }: any) => (
|
|
21
|
-
<FlexBox orientation={Orientation.horizontal}>
|
|
22
|
-
{iconSizes.map((size) => (
|
|
23
|
-
<FlexBox fillSpace key={`${size}`}>
|
|
24
|
-
<h2>Size: {size || 'undefined'}</h2>
|
|
25
|
-
<Icon icon={mdiEmail} size={size} hasShape={hasShape} theme={theme} />
|
|
26
|
-
</FlexBox>
|
|
27
|
-
))}
|
|
28
|
-
</FlexBox>
|
|
29
|
-
);
|
|
2
|
+
import { ColorPalette, ColorVariant, GridColumn, Icon, IconSizes, Size } from '@lumx/react';
|
|
3
|
+
import { withCombinations } from '@lumx/react/stories/decorators/withCombinations';
|
|
4
|
+
import { withUndefined } from '@lumx/react/stories/controls/withUndefined';
|
|
5
|
+
import { iconArgType } from '@lumx/react/stories/controls/icons';
|
|
6
|
+
import { colorArgType, colorVariantArgType } from '@lumx/react/stories/controls/color';
|
|
7
|
+
import { withWrapper } from '@lumx/react/stories/decorators/withWrapper';
|
|
30
8
|
|
|
31
|
-
|
|
9
|
+
const iconSizes: Array<IconSizes> = [Size.xxs, Size.xs, Size.s, Size.m, Size.l, Size.xl, Size.xxl];
|
|
32
10
|
|
|
33
|
-
export
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
{withUndefined(Object.values(ColorVariant).reverse()).map((colorVariant) => (
|
|
44
|
-
<Fragment key={`${colorVariant}`}>
|
|
45
|
-
{!colorVariant && (
|
|
46
|
-
<>
|
|
47
|
-
<small>No theme</small>
|
|
48
|
-
<Icon
|
|
49
|
-
icon={mdiEmail}
|
|
50
|
-
color={color}
|
|
51
|
-
colorVariant={colorVariant}
|
|
52
|
-
size="m"
|
|
53
|
-
hasShape={hasShape}
|
|
54
|
-
/>
|
|
55
|
-
</>
|
|
56
|
-
)}
|
|
57
|
-
<small>Variant: {colorVariant || 'undefined'}</small>
|
|
58
|
-
<Icon
|
|
59
|
-
icon={mdiEmail}
|
|
60
|
-
color={color}
|
|
61
|
-
colorVariant={colorVariant}
|
|
62
|
-
size="m"
|
|
63
|
-
theme={theme}
|
|
64
|
-
hasShape={hasShape}
|
|
65
|
-
/>
|
|
66
|
-
</Fragment>
|
|
67
|
-
))}
|
|
68
|
-
</FlexBox>
|
|
69
|
-
))}
|
|
70
|
-
</FlexBox>
|
|
71
|
-
);
|
|
11
|
+
export default {
|
|
12
|
+
title: 'LumX components/icon/Icon',
|
|
13
|
+
component: Icon,
|
|
14
|
+
args: Icon.defaultProps,
|
|
15
|
+
argTypes: {
|
|
16
|
+
icon: iconArgType,
|
|
17
|
+
hasShape: { control: 'boolean' },
|
|
18
|
+
color: colorArgType,
|
|
19
|
+
colorVariant: colorVariantArgType,
|
|
20
|
+
},
|
|
72
21
|
};
|
|
73
22
|
|
|
74
|
-
|
|
23
|
+
/**
|
|
24
|
+
* All combinations of size and shape
|
|
25
|
+
*/
|
|
26
|
+
export const SizeAndShape = {
|
|
27
|
+
args: {
|
|
28
|
+
icon: mdiEmail,
|
|
29
|
+
},
|
|
30
|
+
argTypes: {
|
|
31
|
+
hasShape: { control: false },
|
|
32
|
+
size: { control: false },
|
|
33
|
+
},
|
|
34
|
+
decorators: [
|
|
35
|
+
withCombinations({
|
|
36
|
+
combinations: {
|
|
37
|
+
cols: { key: 'size', options: withUndefined(iconSizes) },
|
|
38
|
+
rows: {
|
|
39
|
+
Default: {},
|
|
40
|
+
'Has shape': { hasShape: true },
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
}),
|
|
44
|
+
],
|
|
45
|
+
};
|
|
75
46
|
|
|
76
|
-
|
|
47
|
+
/**
|
|
48
|
+
* All combinations of size and shape
|
|
49
|
+
*/
|
|
50
|
+
export const AllColors = {
|
|
51
|
+
args: {
|
|
52
|
+
size: Size.m,
|
|
53
|
+
icon: mdiEmail,
|
|
54
|
+
},
|
|
55
|
+
argTypes: {
|
|
56
|
+
hasShape: { control: false },
|
|
57
|
+
color: { control: false },
|
|
58
|
+
colorVariant: { control: false },
|
|
59
|
+
},
|
|
60
|
+
decorators: [
|
|
61
|
+
withCombinations({
|
|
62
|
+
combinations: {
|
|
63
|
+
rows: { key: 'color', options: withUndefined(ColorPalette) },
|
|
64
|
+
cols: { key: 'colorVariant', options: withUndefined(ColorVariant) },
|
|
65
|
+
sections: {
|
|
66
|
+
Default: {},
|
|
67
|
+
'Has shape': { hasShape: true },
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
}),
|
|
71
|
+
withWrapper({ maxColumns: 2, itemMinWidth: 500 }, GridColumn),
|
|
72
|
+
],
|
|
73
|
+
};
|
|
@@ -1,52 +1,108 @@
|
|
|
1
|
-
import { LANDSCAPE_IMAGES, landscapeImageKnob } from '@lumx/react/stories/knobs/image';
|
|
2
1
|
import React from 'react';
|
|
3
2
|
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
3
|
+
import {
|
|
4
|
+
Alignment,
|
|
5
|
+
AspectRatio,
|
|
6
|
+
Chip,
|
|
7
|
+
ChipGroup,
|
|
8
|
+
HorizontalAlignment,
|
|
9
|
+
IconButton,
|
|
10
|
+
ImageBlock,
|
|
11
|
+
ImageBlockCaptionPosition,
|
|
12
|
+
ImageBlockSize,
|
|
13
|
+
Size,
|
|
14
|
+
} from '@lumx/react';
|
|
15
|
+
import { getSelectArgType } from '@lumx/react/stories/controls/selectArgType';
|
|
16
|
+
import { imageArgType, PORTRAIT_IMAGES, LANDSCAPE_IMAGES } from '@lumx/react/stories/controls/image';
|
|
17
|
+
import { mdiFileEdit } from '@lumx/icons';
|
|
18
|
+
import { toNestedProps } from '@lumx/react/stories/decorators/withNestedProps';
|
|
19
|
+
import { focusPoint } from '@lumx/react/stories/controls/focusPoint';
|
|
20
|
+
|
|
21
|
+
export default {
|
|
22
|
+
title: 'LumX components/image-block/Image Block',
|
|
23
|
+
argTypes: {
|
|
24
|
+
size: getSelectArgType<ImageBlockSize>([Size.xl, Size.xxl]),
|
|
25
|
+
image: imageArgType,
|
|
26
|
+
captionPosition: getSelectArgType(ImageBlockCaptionPosition),
|
|
27
|
+
'thumbnailProps.aspectRatio': getSelectArgType(AspectRatio),
|
|
28
|
+
align: getSelectArgType<HorizontalAlignment>([Alignment.left, Alignment.center, Alignment.right]),
|
|
29
|
+
},
|
|
30
|
+
args: { ...ImageBlock.defaultProps, image: LANDSCAPE_IMAGES.landscape1 },
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const Default = (props: any) => {
|
|
34
|
+
const nestedProps = toNestedProps(props) as any;
|
|
35
|
+
return <ImageBlock {...nestedProps} />;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const WithCaptionBelow: any = Default.bind({});
|
|
39
|
+
WithCaptionBelow.args = {
|
|
40
|
+
captionPosition: ImageBlockCaptionPosition.below,
|
|
41
|
+
size: Size.xxl,
|
|
42
|
+
title: 'Image block title',
|
|
43
|
+
description: 'Image block description',
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export const WithCaptionOver: any = Default.bind({});
|
|
47
|
+
WithCaptionOver.args = {
|
|
48
|
+
captionPosition: ImageBlockCaptionPosition.over,
|
|
49
|
+
size: Size.xxl,
|
|
50
|
+
title: 'Image block title',
|
|
51
|
+
description: 'Image block description',
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const WithAlign: any = Default.bind({});
|
|
55
|
+
WithAlign.args = {
|
|
56
|
+
...WithCaptionBelow.args,
|
|
57
|
+
image: LANDSCAPE_IMAGES.landscape1s200,
|
|
58
|
+
size: undefined,
|
|
59
|
+
align: Alignment.center,
|
|
60
|
+
};
|
|
23
61
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
62
|
+
export const WithTags: any = Default.bind({});
|
|
63
|
+
WithTags.argTypes = {
|
|
64
|
+
tags: { control: false },
|
|
65
|
+
};
|
|
66
|
+
WithTags.args = {
|
|
67
|
+
size: Size.xxl,
|
|
68
|
+
tags: (
|
|
69
|
+
<ChipGroup align={Alignment.left}>
|
|
70
|
+
<Chip size={Size.s}>Tag 1</Chip>
|
|
71
|
+
<Chip size={Size.s}>Tag 2</Chip>
|
|
27
72
|
</ChipGroup>
|
|
28
|
-
)
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
73
|
+
),
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export const WithActions: any = Default.bind({});
|
|
77
|
+
WithActions.argTypes = {
|
|
78
|
+
actions: { control: false },
|
|
79
|
+
};
|
|
80
|
+
WithActions.args = {
|
|
81
|
+
size: Size.xxl,
|
|
82
|
+
actions: <IconButton label="Edit" icon={mdiFileEdit} />,
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export const WithFocusPointHorizontal: any = Default.bind({});
|
|
86
|
+
WithFocusPointHorizontal.args = {
|
|
87
|
+
size: Size.xxl,
|
|
88
|
+
'thumbnailProps.aspectRatio': AspectRatio.vertical,
|
|
89
|
+
'thumbnailProps.focusPoint.x': 1,
|
|
90
|
+
'thumbnailProps.focusPoint.y': 0,
|
|
91
|
+
};
|
|
92
|
+
WithFocusPointHorizontal.argTypes = {
|
|
93
|
+
'thumbnailProps.focusPoint.x': focusPoint,
|
|
94
|
+
'thumbnailProps.focusPoint.y': focusPoint,
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export const WithFocusPointVertical: any = Default.bind({});
|
|
98
|
+
WithFocusPointVertical.args = {
|
|
99
|
+
size: Size.xxl,
|
|
100
|
+
image: PORTRAIT_IMAGES.portrait1,
|
|
101
|
+
'thumbnailProps.aspectRatio': AspectRatio.horizontal,
|
|
102
|
+
'thumbnailProps.focusPoint.x': 0,
|
|
103
|
+
'thumbnailProps.focusPoint.y': 1,
|
|
104
|
+
};
|
|
105
|
+
WithFocusPointVertical.argTypes = {
|
|
106
|
+
'thumbnailProps.focusPoint.x': focusPoint,
|
|
107
|
+
'thumbnailProps.focusPoint.y': focusPoint,
|
|
52
108
|
};
|
|
@@ -1,28 +1,23 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import 'jest-enzyme';
|
|
4
|
-
import { commonTestsSuite, itShouldRenderStories } from '@lumx/react/testing/utils';
|
|
2
|
+
import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
|
|
5
3
|
|
|
4
|
+
import { render } from '@testing-library/react';
|
|
5
|
+
import { queryByClassName } from '@lumx/react/testing/utils/queries';
|
|
6
6
|
import { ImageBlock, ImageBlockProps } from './ImageBlock';
|
|
7
|
-
import * as stories from './ImageBlock.stories';
|
|
8
7
|
|
|
9
8
|
const CLASSNAME = ImageBlock.className as string;
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const renderer: any = shallowRendering ? shallow : mount;
|
|
16
|
-
const wrapper: any = renderer(<ImageBlock {...(props as any)} />);
|
|
17
|
-
return { props, wrapper };
|
|
10
|
+
const setup = (props: Partial<ImageBlockProps> = {}) => {
|
|
11
|
+
render(<ImageBlock {...(props as any)} />);
|
|
12
|
+
const imageBlock = queryByClassName(document.body, CLASSNAME);
|
|
13
|
+
return { props, imageBlock };
|
|
18
14
|
};
|
|
19
15
|
|
|
20
16
|
describe(`<${ImageBlock.displayName}>`, () => {
|
|
21
|
-
// 1. Test render via snapshot.
|
|
22
|
-
describe('Snapshots and structure', () => {
|
|
23
|
-
itShouldRenderStories(stories, ImageBlock);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
17
|
// Common tests suite.
|
|
27
|
-
|
|
18
|
+
commonTestsSuiteRTL(setup, {
|
|
19
|
+
baseClassName: CLASSNAME,
|
|
20
|
+
forwardClassName: 'imageBlock',
|
|
21
|
+
forwardAttributes: 'imageBlock',
|
|
22
|
+
});
|
|
28
23
|
});
|
|
@@ -1,40 +1,56 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { mdiEarth } from '@lumx/icons';
|
|
3
|
-
import {
|
|
4
|
-
import { withResizableBox } from '@lumx/react/stories/withResizableBox';
|
|
3
|
+
import { Icon, Text } from '@lumx/react';
|
|
4
|
+
import { withResizableBox } from '@lumx/react/stories/decorators/withResizableBox';
|
|
5
|
+
import { allTypographyArgType } from '@lumx/react/stories/controls/typography';
|
|
6
|
+
import { colorArgType, colorVariantArgType } from '@lumx/react/stories/controls/color';
|
|
5
7
|
import { InlineList } from '.';
|
|
6
8
|
|
|
7
|
-
const ALL_TYPOGRAPHY = [undefined, ...Object.values(TypographyInterface), ...Object.values(TypographyCustom)];
|
|
8
|
-
|
|
9
9
|
export default {
|
|
10
10
|
title: 'LumX components/inline-list/InlineList',
|
|
11
|
+
component: InlineList,
|
|
11
12
|
argTypes: {
|
|
12
|
-
typography:
|
|
13
|
-
color:
|
|
14
|
-
colorVariant:
|
|
13
|
+
typography: allTypographyArgType,
|
|
14
|
+
color: colorArgType,
|
|
15
|
+
colorVariant: colorVariantArgType,
|
|
16
|
+
children: { control: false },
|
|
15
17
|
},
|
|
16
18
|
};
|
|
17
19
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Inline list with three simple text elements
|
|
22
|
+
*/
|
|
23
|
+
export const WithElements = {
|
|
24
|
+
args: {
|
|
25
|
+
children: [
|
|
26
|
+
<span key="1">Some text</span>,
|
|
27
|
+
<span key="2">Some other text</span>,
|
|
28
|
+
<span key="3">Some other other text</span>,
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
};
|
|
25
32
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Using color, typography and more complex elements
|
|
35
|
+
*/
|
|
36
|
+
export const MixedNoWrapAndTruncate = {
|
|
37
|
+
args: {
|
|
38
|
+
typography: 'body1',
|
|
39
|
+
color: 'dark',
|
|
40
|
+
colorVariant: 'L2',
|
|
41
|
+
style: { width: '100%' },
|
|
42
|
+
children: [
|
|
43
|
+
<Text key="1" as="span" truncate>
|
|
44
|
+
Very very very very very long text
|
|
45
|
+
</Text>,
|
|
46
|
+
<Text key="2" as="span" noWrap>
|
|
47
|
+
<Icon icon={mdiEarth} />
|
|
48
|
+
Some text
|
|
49
|
+
</Text>,
|
|
50
|
+
<Text key="3" as="span" truncate>
|
|
51
|
+
Very very very very very long text
|
|
52
|
+
</Text>,
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
decorators: [withResizableBox({ width: 400 })],
|
|
56
|
+
};
|
|
@@ -1,29 +1,35 @@
|
|
|
1
1
|
import { InputHelper, Kind } from '@lumx/react';
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
2
|
+
import { getSelectArgType } from '@lumx/react/stories/controls/selectArgType';
|
|
3
|
+
import { withCombinations } from '@lumx/react/stories/decorators/withCombinations';
|
|
4
|
+
import { withUndefined } from '@lumx/react/stories/controls/withUndefined';
|
|
4
5
|
|
|
5
|
-
export default {
|
|
6
|
+
export default {
|
|
7
|
+
title: 'LumX components/input-helper/Input Helper',
|
|
8
|
+
component: InputHelper,
|
|
9
|
+
argTypes: {
|
|
10
|
+
kind: getSelectArgType(Kind),
|
|
11
|
+
},
|
|
12
|
+
args: {
|
|
13
|
+
...InputHelper.defaultProps,
|
|
14
|
+
children: 'Some helper text',
|
|
15
|
+
},
|
|
16
|
+
};
|
|
6
17
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
);
|
|
18
|
+
/**
|
|
19
|
+
* Default input helper
|
|
20
|
+
*/
|
|
21
|
+
export const Default = {};
|
|
12
22
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
)
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
<InputHelper kind={Kind.warning} theme={theme}>
|
|
27
|
-
{text('Text', 'This should be used carefuly')}
|
|
28
|
-
</InputHelper>
|
|
29
|
-
);
|
|
23
|
+
/**
|
|
24
|
+
* All `kind` variants
|
|
25
|
+
*/
|
|
26
|
+
export const AllKinds = {
|
|
27
|
+
argTypes: { kind: { control: false } },
|
|
28
|
+
decorators: [
|
|
29
|
+
withCombinations({
|
|
30
|
+
combinations: {
|
|
31
|
+
rows: { key: 'kind', options: withUndefined(Kind) },
|
|
32
|
+
},
|
|
33
|
+
}),
|
|
34
|
+
],
|
|
35
|
+
};
|