@lumx/react 3.1.5 → 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 +45 -4
- package/index.js +609 -411
- 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-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 -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,29 +1,45 @@
|
|
|
1
1
|
import { Slider } from '@lumx/react';
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import React from 'react';
|
|
2
|
+
import { loremIpsum } from '@lumx/react/stories/utils/lorem';
|
|
3
|
+
import { withValueOnChange } from '@lumx/react/stories/decorators/withValueOnChange';
|
|
5
4
|
|
|
6
|
-
export default {
|
|
5
|
+
export default {
|
|
6
|
+
title: 'LumX components/slider/Slider',
|
|
7
|
+
component: Slider,
|
|
8
|
+
args: {
|
|
9
|
+
...Slider.defaultProps,
|
|
10
|
+
min: 0,
|
|
11
|
+
max: 30,
|
|
12
|
+
value: 15,
|
|
13
|
+
name: 'slider-html-name',
|
|
14
|
+
},
|
|
15
|
+
argTypes: {
|
|
16
|
+
onChange: { action: true },
|
|
17
|
+
},
|
|
18
|
+
decorators: [withValueOnChange({})],
|
|
19
|
+
};
|
|
7
20
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
min={number('min', 0)}
|
|
13
|
-
theme={theme}
|
|
14
|
-
value={5}
|
|
15
|
-
onChange={noop}
|
|
16
|
-
/>
|
|
17
|
-
);
|
|
21
|
+
/**
|
|
22
|
+
* Default slider with required props
|
|
23
|
+
*/
|
|
24
|
+
export const Default = {};
|
|
18
25
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
/**
|
|
27
|
+
* With label and helper
|
|
28
|
+
*/
|
|
29
|
+
export const WithLabelAndHelper = {
|
|
30
|
+
args: { label: 'Slider label', helper: loremIpsum('tiny') },
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* With steps
|
|
35
|
+
*/
|
|
36
|
+
export const WithSteps = {
|
|
37
|
+
args: { steps: 5 },
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* With precision (three digits after the decimal point)
|
|
42
|
+
*/
|
|
43
|
+
export const WithPrecision = {
|
|
44
|
+
args: { steps: 0, precision: 3 },
|
|
45
|
+
};
|
|
@@ -1,31 +1,25 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import '
|
|
5
|
-
import {
|
|
6
|
-
|
|
3
|
+
import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
|
|
4
|
+
import { render } from '@testing-library/react';
|
|
5
|
+
import { queryByClassName } from '@lumx/react/testing/utils/queries';
|
|
7
6
|
import { Slider, SliderProps } from './Slider';
|
|
8
|
-
import * as stories from './Slider.stories';
|
|
9
7
|
|
|
10
8
|
const CLASSNAME = Slider.className as string;
|
|
11
9
|
|
|
12
10
|
jest.mock('uid', () => ({ uid: () => 'uid' }));
|
|
13
11
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const renderer: any = shallowRendering ? shallow : mount;
|
|
19
|
-
const wrapper: any = renderer(<Slider {...(props as any)} />);
|
|
20
|
-
return { props, wrapper };
|
|
12
|
+
const setup = (props: Partial<SliderProps> = {}) => {
|
|
13
|
+
render(<Slider {...(props as any)} />);
|
|
14
|
+
const slider = queryByClassName(document.body, CLASSNAME);
|
|
15
|
+
return { props, slider };
|
|
21
16
|
};
|
|
22
17
|
|
|
23
18
|
describe(`<${Slider.displayName}>`, () => {
|
|
24
|
-
// 1. Test render via snapshot.
|
|
25
|
-
describe('Snapshots and structure', () => {
|
|
26
|
-
itShouldRenderStories(stories, Slider);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
19
|
// Common tests suite.
|
|
30
|
-
|
|
20
|
+
commonTestsSuiteRTL(setup, {
|
|
21
|
+
baseClassName: CLASSNAME,
|
|
22
|
+
forwardClassName: 'slider',
|
|
23
|
+
forwardAttributes: 'slider',
|
|
24
|
+
});
|
|
31
25
|
});
|
|
@@ -1,39 +1,39 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import range from 'lodash/range';
|
|
3
3
|
import { AspectRatio, Button, FlexBox, ImageBlock, Slideshow, SlideshowItem, Orientation } from '@lumx/react';
|
|
4
|
-
import {
|
|
5
|
-
import { thumbnailsKnob } from '@lumx/react/stories/knobs/thumbnailsKnob';
|
|
4
|
+
import { IMAGES, LANDSCAPE_IMAGES } from '@lumx/react/stories/controls/image';
|
|
6
5
|
|
|
7
|
-
export default {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
export default {
|
|
7
|
+
title: 'LumX components/slideshow/Slideshow',
|
|
8
|
+
component: Slideshow,
|
|
9
|
+
args: Slideshow.defaultProps,
|
|
10
|
+
argTypes: {
|
|
11
|
+
activeIndex: { control: 'number' },
|
|
12
|
+
groupBy: { control: 'number' },
|
|
13
|
+
autoPlay: { control: 'boolean' },
|
|
14
|
+
interval: { control: 'number' },
|
|
15
|
+
},
|
|
16
|
+
};
|
|
15
17
|
|
|
18
|
+
export const Simple = ({ theme, images = Object.values(LANDSCAPE_IMAGES), ...props }: any) => {
|
|
16
19
|
return (
|
|
17
20
|
<Slideshow
|
|
18
21
|
aria-label="Simple carousel example"
|
|
19
|
-
activeIndex={activeIndex}
|
|
20
|
-
autoPlay={autoPlay}
|
|
21
|
-
interval={interval}
|
|
22
22
|
slideshowControlsProps={{
|
|
23
23
|
nextButtonProps: { label: 'Next' },
|
|
24
24
|
previousButtonProps: { label: 'Previous' },
|
|
25
25
|
}}
|
|
26
26
|
theme={theme}
|
|
27
|
-
|
|
27
|
+
{...props}
|
|
28
28
|
style={{ width: '50%' }}
|
|
29
29
|
slideGroupLabel={(currentGroup, totalGroup) => `${currentGroup} of ${totalGroup}`}
|
|
30
30
|
>
|
|
31
|
-
{images.map((
|
|
31
|
+
{images.map((image: string, index: number) => (
|
|
32
32
|
<SlideshowItem key={`${image}-${index}`}>
|
|
33
33
|
<ImageBlock
|
|
34
34
|
thumbnailProps={{ aspectRatio: AspectRatio.horizontal, loading: 'eager' }}
|
|
35
35
|
image={image}
|
|
36
|
-
alt=
|
|
36
|
+
alt=""
|
|
37
37
|
theme={theme}
|
|
38
38
|
/>
|
|
39
39
|
</SlideshowItem>
|
|
@@ -42,41 +42,8 @@ export const Simple = ({ theme }: any) => {
|
|
|
42
42
|
);
|
|
43
43
|
};
|
|
44
44
|
|
|
45
|
-
export const SimpleWithAutoPlay = ({
|
|
46
|
-
|
|
47
|
-
const activeIndex = number('Active index', 0);
|
|
48
|
-
const groupBy = number('Group by', 1);
|
|
49
|
-
const interval = number('Autoplay interval (in milliseconds)', 1000);
|
|
50
|
-
|
|
51
|
-
return (
|
|
52
|
-
<Slideshow
|
|
53
|
-
aria-label="Simple with autoplay example"
|
|
54
|
-
activeIndex={activeIndex}
|
|
55
|
-
autoPlay
|
|
56
|
-
interval={interval}
|
|
57
|
-
slideshowControlsProps={{
|
|
58
|
-
nextButtonProps: { label: 'Next' },
|
|
59
|
-
previousButtonProps: { label: 'Previous' },
|
|
60
|
-
playButtonProps: { label: 'Play/Pause' },
|
|
61
|
-
}}
|
|
62
|
-
theme={theme}
|
|
63
|
-
groupBy={groupBy}
|
|
64
|
-
style={{ width: '50%' }}
|
|
65
|
-
slideGroupLabel={(currentGroup, totalGroup) => `${currentGroup} of ${totalGroup}`}
|
|
66
|
-
>
|
|
67
|
-
{images.map(({ image, alt }, index) => (
|
|
68
|
-
<SlideshowItem key={`${image}-${index}`}>
|
|
69
|
-
<ImageBlock
|
|
70
|
-
thumbnailProps={{ aspectRatio: AspectRatio.horizontal, loading: 'eager' }}
|
|
71
|
-
image={image}
|
|
72
|
-
alt={alt}
|
|
73
|
-
theme={theme}
|
|
74
|
-
/>
|
|
75
|
-
</SlideshowItem>
|
|
76
|
-
))}
|
|
77
|
-
</Slideshow>
|
|
78
|
-
);
|
|
79
|
-
};
|
|
45
|
+
export const SimpleWithAutoPlay: any = Simple.bind({});
|
|
46
|
+
SimpleWithAutoPlay.args = { autoPlay: true };
|
|
80
47
|
|
|
81
48
|
export const ResponsiveSlideShowSwipe = () => {
|
|
82
49
|
const slides = range(5);
|
|
@@ -124,7 +91,7 @@ export const ResponsiveSlideShowSwipe = () => {
|
|
|
124
91
|
const slides = [
|
|
125
92
|
{
|
|
126
93
|
id: 0,
|
|
127
|
-
src:
|
|
94
|
+
src: IMAGES.landscape1,
|
|
128
95
|
alt: 'A man in a suit and fedora and a woman with coiffed hair look sternly into the camera.',
|
|
129
96
|
title: 'Foyle’s War Revisited',
|
|
130
97
|
subtitle: '8 pm Sunday, March 8, on TV: Sneak peek at the final season',
|
|
@@ -132,14 +99,14 @@ const slides = [
|
|
|
132
99
|
},
|
|
133
100
|
{
|
|
134
101
|
id: 1,
|
|
135
|
-
src:
|
|
102
|
+
src: IMAGES.landscape2,
|
|
136
103
|
alt: 'British flag with WILL-TV host David Thiel.',
|
|
137
104
|
title: 'Great Britain Vote: 7 pm Sat.',
|
|
138
105
|
link: '#',
|
|
139
106
|
},
|
|
140
107
|
{
|
|
141
108
|
id: 2,
|
|
142
|
-
src:
|
|
109
|
+
src: IMAGES.landscape3,
|
|
143
110
|
alt: 'Mid-American Gardener panelists on the set.',
|
|
144
111
|
title: 'Mid-American Gardener: Thursdays at 7 pm',
|
|
145
112
|
subtitle: 'Watch the latest episode',
|
|
@@ -147,7 +114,7 @@ const slides = [
|
|
|
147
114
|
},
|
|
148
115
|
{
|
|
149
116
|
id: 3,
|
|
150
|
-
src:
|
|
117
|
+
src: IMAGES.portrait1,
|
|
151
118
|
alt: 'A man in a suit and fedora and a woman with coiffed hair look sternly into the camera.',
|
|
152
119
|
title: 'Foyle’s War Revisited',
|
|
153
120
|
subtitle: '8 pm Sunday, March 8, on TV: Sneak peek at the final season',
|
|
@@ -155,25 +122,23 @@ const slides = [
|
|
|
155
122
|
},
|
|
156
123
|
{
|
|
157
124
|
id: 4,
|
|
158
|
-
src:
|
|
125
|
+
src: IMAGES.portrait2,
|
|
159
126
|
alt: 'British flag with WILL-TV host David Thiel.',
|
|
160
127
|
title: 'Great Britain Vote: 7 pm Sat.',
|
|
161
128
|
link: '#',
|
|
162
129
|
},
|
|
163
130
|
{
|
|
164
131
|
id: 5,
|
|
165
|
-
src:
|
|
132
|
+
src: IMAGES.portrait3,
|
|
166
133
|
alt: 'Mid-American Gardener panelists on the set.',
|
|
167
134
|
title: 'Mid-American Gardener: Thursdays at 7 pm',
|
|
168
135
|
subtitle: 'Watch the latest episode',
|
|
169
136
|
link: '#',
|
|
170
137
|
},
|
|
171
138
|
];
|
|
172
|
-
export const WithComplexContent = () => (
|
|
139
|
+
export const WithComplexContent = ({ slideCount, ...props }: any) => (
|
|
173
140
|
<Slideshow
|
|
174
141
|
aria-label="Carousel with complex content"
|
|
175
|
-
activeIndex={0}
|
|
176
|
-
groupBy={2}
|
|
177
142
|
slideshowControlsProps={{
|
|
178
143
|
nextButtonProps: { label: 'Next' },
|
|
179
144
|
previousButtonProps: { label: 'Previous' },
|
|
@@ -181,8 +146,9 @@ export const WithComplexContent = () => (
|
|
|
181
146
|
paginationItemProps: (index) => ({ label: `Slide ${index + 1}` }),
|
|
182
147
|
}}
|
|
183
148
|
slideGroupLabel={(currentGroup, totalGroup) => `${currentGroup} of ${totalGroup}`}
|
|
149
|
+
{...props}
|
|
184
150
|
>
|
|
185
|
-
{range(
|
|
151
|
+
{range(slideCount).map((nb) => {
|
|
186
152
|
const slide = slides[nb % slides.length];
|
|
187
153
|
|
|
188
154
|
return (
|
|
@@ -210,3 +176,7 @@ export const WithComplexContent = () => (
|
|
|
210
176
|
})}
|
|
211
177
|
</Slideshow>
|
|
212
178
|
);
|
|
179
|
+
WithComplexContent.args = {
|
|
180
|
+
groupBy: 2,
|
|
181
|
+
slideCount: 6,
|
|
182
|
+
};
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import pick from 'lodash/pick';
|
|
1
|
+
import React from 'react';
|
|
3
2
|
|
|
4
|
-
import {
|
|
5
|
-
import '
|
|
6
|
-
|
|
7
|
-
import { commonTestsSuite, itShouldRenderStories, Wrapper } from '@lumx/react/testing/utils';
|
|
3
|
+
import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
|
|
4
|
+
import { render } from '@testing-library/react';
|
|
5
|
+
import { queryByClassName } from '@lumx/react/testing/utils/queries';
|
|
8
6
|
import { Slideshow, SlideshowProps } from './Slideshow';
|
|
9
|
-
import {
|
|
10
|
-
import * as stories from './Slideshow.stories';
|
|
7
|
+
import { Slides } from './Slides';
|
|
11
8
|
|
|
12
|
-
const CLASSNAME =
|
|
9
|
+
const CLASSNAME = Slides.className as string;
|
|
13
10
|
|
|
14
|
-
const setup = (
|
|
11
|
+
const setup = (propsOverride: Partial<SlideshowProps> = {}) => {
|
|
15
12
|
const props: SlideshowProps = {
|
|
16
13
|
slideshowControlsProps: {
|
|
17
14
|
nextButtonProps: { label: 'Next' },
|
|
@@ -19,21 +16,16 @@ const setup = ({ ...propsOverride }: Partial<SlideshowProps> = {}, shallowRender
|
|
|
19
16
|
},
|
|
20
17
|
...propsOverride,
|
|
21
18
|
};
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return { props, wrapper };
|
|
19
|
+
render(<Slideshow {...props} />);
|
|
20
|
+
const slideShow = queryByClassName(document.body, CLASSNAME);
|
|
21
|
+
return { props, slideShow };
|
|
27
22
|
};
|
|
28
23
|
|
|
29
24
|
describe(`<${Slideshow.displayName}>`, () => {
|
|
30
|
-
// 1. Test render via snapshot.
|
|
31
|
-
describe('Snapshots and structure', () => {
|
|
32
|
-
itShouldRenderStories(pick(stories, ['default', 'Simple']), {
|
|
33
|
-
or: [Slideshow, { path: [Slideshow, SlideshowControls] }],
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
|
|
37
25
|
// Common tests suite.
|
|
38
|
-
|
|
26
|
+
commonTestsSuiteRTL(setup, {
|
|
27
|
+
baseClassName: CLASSNAME,
|
|
28
|
+
forwardClassName: 'slideShow',
|
|
29
|
+
forwardAttributes: 'slideShow',
|
|
30
|
+
});
|
|
39
31
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
3
|
import { AspectRatio, ImageBlock, Slides, SlideshowControls, SlideshowItem } from '@lumx/react';
|
|
4
|
-
import { thumbnailsKnob } from '@lumx/react/stories/knobs/thumbnailsKnob';
|
|
5
4
|
import { useFocusWithin } from '@lumx/react/hooks/useFocusWithin';
|
|
5
|
+
import { LANDSCAPE_IMAGES } from '@lumx/react/stories/controls/image';
|
|
6
6
|
|
|
7
7
|
export default { title: 'LumX components/slideshow/Slideshow controls' };
|
|
8
8
|
|
|
@@ -31,9 +31,7 @@ export const Simple = () => {
|
|
|
31
31
|
);
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
-
export const ControllingSlideshow = ({ theme }: any) => {
|
|
35
|
-
const images = thumbnailsKnob(6);
|
|
36
|
-
|
|
34
|
+
export const ControllingSlideshow = ({ images = Object.values(LANDSCAPE_IMAGES), theme }: any) => {
|
|
37
35
|
const {
|
|
38
36
|
activeIndex: currentIndex,
|
|
39
37
|
slideshowId,
|
|
@@ -97,12 +95,12 @@ export const ControllingSlideshow = ({ theme }: any) => {
|
|
|
97
95
|
</div>
|
|
98
96
|
}
|
|
99
97
|
>
|
|
100
|
-
{images.map((
|
|
98
|
+
{images.map((image: string, index: number) => (
|
|
101
99
|
<SlideshowItem key={`${image}-${index}`}>
|
|
102
100
|
<ImageBlock
|
|
103
101
|
thumbnailProps={{ aspectRatio: AspectRatio.horizontal, loading: 'eager' }}
|
|
104
102
|
image={image}
|
|
105
|
-
alt=
|
|
103
|
+
alt=""
|
|
106
104
|
theme={theme}
|
|
107
105
|
/>
|
|
108
106
|
</SlideshowItem>
|
|
@@ -1,36 +1,39 @@
|
|
|
1
|
-
import { Switch,
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import React from 'react';
|
|
1
|
+
import { Alignment, Switch, SwitchProps } from '@lumx/react';
|
|
2
|
+
import { withValueOnChange } from '@lumx/react/stories/decorators/withValueOnChange';
|
|
3
|
+
import { getSelectArgType } from '@lumx/react/stories/controls/selectArgType';
|
|
5
4
|
|
|
6
|
-
export default {
|
|
5
|
+
export default {
|
|
6
|
+
title: 'LumX components/switch/Switch',
|
|
7
|
+
component: Switch,
|
|
8
|
+
args: {
|
|
9
|
+
...Switch.defaultProps,
|
|
10
|
+
children: 'Switch label',
|
|
11
|
+
name: 'switch-html-name',
|
|
12
|
+
value: 'switch-html-value',
|
|
13
|
+
isChecked: false,
|
|
14
|
+
},
|
|
15
|
+
argTypes: {
|
|
16
|
+
position: getSelectArgType<SwitchProps['position']>([Alignment.left, Alignment.right]),
|
|
17
|
+
onChange: { action: true },
|
|
18
|
+
},
|
|
19
|
+
decorators: [withValueOnChange({ valueProp: 'isChecked' })],
|
|
20
|
+
};
|
|
7
21
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
);
|
|
22
|
+
/**
|
|
23
|
+
* Default switch
|
|
24
|
+
*/
|
|
25
|
+
export const Default = {};
|
|
13
26
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Switch disabled
|
|
29
|
+
*/
|
|
30
|
+
export const Disabled = {
|
|
31
|
+
args: { isDisabled: true },
|
|
32
|
+
};
|
|
19
33
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
export const DisabledSwitch = ({ theme }: any) => (
|
|
27
|
-
<Switch isDisabled onChange={noop} theme={theme}>
|
|
28
|
-
{text('text', 'The switch')}
|
|
29
|
-
</Switch>
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
export const RightPositionSwitch = ({ theme }: any) => (
|
|
33
|
-
<Switch position={Alignment.right} onChange={noop} theme={theme}>
|
|
34
|
-
{text('text', 'The switch')}
|
|
35
|
-
</Switch>
|
|
36
|
-
);
|
|
34
|
+
/**
|
|
35
|
+
* Switch positioned to the right
|
|
36
|
+
*/
|
|
37
|
+
export const PositionRight = {
|
|
38
|
+
args: { position: Alignment.right },
|
|
39
|
+
};
|
|
@@ -1,28 +1,23 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { mount, shallow } from 'enzyme';
|
|
3
|
-
import 'jest-enzyme';
|
|
4
|
-
import { commonTestsSuite, itShouldRenderStories } from '@lumx/react/testing/utils';
|
|
5
2
|
|
|
3
|
+
import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
|
|
4
|
+
import { queryByClassName } from '@lumx/react/testing/utils/queries';
|
|
5
|
+
import { render } from '@testing-library/react';
|
|
6
6
|
import { Table, TableProps } from './Table';
|
|
7
|
-
import * as stories from '../../stories/generated/Table/Demos.stories';
|
|
8
7
|
|
|
9
8
|
const CLASSNAME = Table.className as string;
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const renderer: any = shallowRendering ? shallow : mount;
|
|
16
|
-
const wrapper: any = renderer(<Table {...(props as any)} />);
|
|
17
|
-
return { props, wrapper };
|
|
10
|
+
const setup = (props: Partial<TableProps> = {}) => {
|
|
11
|
+
render(<Table {...(props as any)} />);
|
|
12
|
+
const table = queryByClassName(document.body, CLASSNAME);
|
|
13
|
+
return { props, table };
|
|
18
14
|
};
|
|
19
15
|
|
|
20
16
|
describe(`<${Table.displayName}>`, () => {
|
|
21
|
-
// 1. Test render via snapshot.
|
|
22
|
-
describe('Snapshots and structure', () => {
|
|
23
|
-
itShouldRenderStories(stories, Table);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
17
|
// Common tests suite.
|
|
27
|
-
|
|
18
|
+
commonTestsSuiteRTL(setup, {
|
|
19
|
+
baseClassName: CLASSNAME,
|
|
20
|
+
forwardClassName: 'table',
|
|
21
|
+
forwardAttributes: 'table',
|
|
22
|
+
});
|
|
28
23
|
});
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Button, Dialog, Tab, TabList, TabPanel, TabProvider } from '@lumx/react';
|
|
2
|
-
import { number } from '@storybook/addon-knobs';
|
|
3
2
|
import get from 'lodash/get';
|
|
4
3
|
import times from 'lodash/times';
|
|
5
4
|
import React, { useState } from 'react';
|
|
@@ -114,8 +113,7 @@ export const SplitTabListAndTabPanels = ({ theme }: any) => {
|
|
|
114
113
|
};
|
|
115
114
|
|
|
116
115
|
/* Dynamically generate tabs. */
|
|
117
|
-
export const DynamicTabs = ({ theme }: any) => {
|
|
118
|
-
const tabCount = number('Tab count', 3);
|
|
116
|
+
export const DynamicTabs = ({ theme, tabCount }: any) => {
|
|
119
117
|
return (
|
|
120
118
|
<TabProvider>
|
|
121
119
|
<TabList theme={theme} aria-label="Tab list">
|
|
@@ -132,3 +130,6 @@ export const DynamicTabs = ({ theme }: any) => {
|
|
|
132
130
|
</TabProvider>
|
|
133
131
|
);
|
|
134
132
|
};
|
|
133
|
+
DynamicTabs.args = {
|
|
134
|
+
tabCount: 3,
|
|
135
|
+
};
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { ALL_TYPOGRAPHY, allTypographyArgType } from '@lumx/react/stories/controls/typography';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
import { colorArgType, colorVariantArgType } from '@lumx/react/stories/controls/color';
|
|
5
|
+
import { textElementArgType } from '@lumx/react/stories/controls/element';
|
|
6
|
+
import { withUndefined } from '@lumx/react/stories/controls/withUndefined';
|
|
7
|
+
import { loremIpsum } from '@lumx/react/stories/utils/lorem';
|
|
8
|
+
import { withCombinations } from '@lumx/react/stories/decorators/withCombinations';
|
|
9
|
+
import { ColorPalette, ColorVariant, Icon } from '@lumx/react';
|
|
10
|
+
import { mdiEarth, mdiHeart } from '@lumx/icons';
|
|
11
|
+
import { withResizableBox } from '@lumx/react/stories/decorators/withResizableBox';
|
|
12
|
+
|
|
13
|
+
import { Text } from './Text';
|
|
14
|
+
|
|
15
|
+
export default {
|
|
16
|
+
title: 'LumX components/text/Text',
|
|
17
|
+
component: Text,
|
|
18
|
+
args: Text.defaultProps,
|
|
19
|
+
argTypes: {
|
|
20
|
+
children: { control: false },
|
|
21
|
+
as: textElementArgType,
|
|
22
|
+
typography: allTypographyArgType,
|
|
23
|
+
color: colorArgType,
|
|
24
|
+
colorVariant: colorVariantArgType,
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Default text component as a paragraph
|
|
30
|
+
*/
|
|
31
|
+
export const Default = {
|
|
32
|
+
args: {
|
|
33
|
+
as: 'p',
|
|
34
|
+
children: 'Some text',
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Text containing icons (should match font size)
|
|
40
|
+
*/
|
|
41
|
+
export const WithIcon = {
|
|
42
|
+
args: {
|
|
43
|
+
...Default.args,
|
|
44
|
+
children: (
|
|
45
|
+
<>
|
|
46
|
+
Some text <Icon icon={mdiHeart} /> with icons <Icon icon={mdiEarth} />
|
|
47
|
+
</>
|
|
48
|
+
),
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Long text should wrap by default
|
|
54
|
+
*/
|
|
55
|
+
export const LongText = {
|
|
56
|
+
args: {
|
|
57
|
+
...Default.args,
|
|
58
|
+
children: loremIpsum('tiny'),
|
|
59
|
+
},
|
|
60
|
+
decorators: [withResizableBox()],
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Long text without wrapping
|
|
65
|
+
*/
|
|
66
|
+
export const NoWrap = {
|
|
67
|
+
...LongText,
|
|
68
|
+
args: {
|
|
69
|
+
...LongText.args,
|
|
70
|
+
noWrap: true,
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Long text with single line truncate ellipsis
|
|
76
|
+
*/
|
|
77
|
+
export const Truncate = {
|
|
78
|
+
...LongText,
|
|
79
|
+
args: {
|
|
80
|
+
...LongText.args,
|
|
81
|
+
truncate: true,
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Long text with multi line truncate ellipsis
|
|
87
|
+
*/
|
|
88
|
+
export const TruncateMultiline = {
|
|
89
|
+
...LongText,
|
|
90
|
+
args: {
|
|
91
|
+
...LongText.args,
|
|
92
|
+
truncate: { lines: 2 },
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* All typographies
|
|
98
|
+
*/
|
|
99
|
+
export const AllTypography = {
|
|
100
|
+
...WithIcon,
|
|
101
|
+
argTypes: {
|
|
102
|
+
typography: { control: false },
|
|
103
|
+
},
|
|
104
|
+
decorators: [
|
|
105
|
+
withCombinations({
|
|
106
|
+
combinations: {
|
|
107
|
+
rows: { key: 'typography', options: withUndefined(ALL_TYPOGRAPHY) },
|
|
108
|
+
},
|
|
109
|
+
}),
|
|
110
|
+
],
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* All combinations of color and color variants
|
|
115
|
+
*/
|
|
116
|
+
export const AllColors = {
|
|
117
|
+
...WithIcon,
|
|
118
|
+
argTypes: {
|
|
119
|
+
color: { control: false },
|
|
120
|
+
colorVariant: { control: false },
|
|
121
|
+
},
|
|
122
|
+
decorators: [
|
|
123
|
+
withCombinations({
|
|
124
|
+
combinations: {
|
|
125
|
+
rows: { key: 'color', options: withUndefined(ColorPalette) },
|
|
126
|
+
cols: { key: 'colorVariant', options: withUndefined(ColorVariant) },
|
|
127
|
+
},
|
|
128
|
+
}),
|
|
129
|
+
],
|
|
130
|
+
};
|