@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.
Files changed (147) hide show
  1. package/_internal/types.d.ts +16 -5
  2. package/index.d.ts +45 -4
  3. package/index.js +632 -423
  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 +131 -293
  19. package/src/components/dialog/Dialog.test.tsx +0 -32
  20. package/src/components/dropdown/Dropdown.stories.tsx +1 -186
  21. package/src/components/flag/Flag.stories.tsx +33 -18
  22. package/src/components/flag/Flag.test.tsx +1 -8
  23. package/src/components/flex-box/FlexBox.stories.tsx +151 -238
  24. package/src/components/flex-box/FlexBox.test.tsx +9 -49
  25. package/src/components/generic-block/GenericBlock.stories.jsx +1 -1
  26. package/src/components/grid-column/GridColumn.stories.tsx +46 -0
  27. package/src/components/heading/Heading.stories.tsx +57 -95
  28. package/src/components/icon/Icon.stories.tsx +67 -70
  29. package/src/components/image-block/ImageBlock.stories.tsx +103 -47
  30. package/src/components/image-block/ImageBlock.test.tsx +12 -17
  31. package/src/components/inline-list/InlineList.stories.tsx +45 -29
  32. package/src/components/input-helper/InputHelper.stories.tsx +31 -25
  33. package/src/components/input-label/InputLabel.stories.tsx +33 -10
  34. package/src/components/lightbox/Lightbox.stories.tsx +39 -77
  35. package/src/components/lightbox/Lightbox.test.tsx +12 -17
  36. package/src/components/link/Link.stories.tsx +98 -128
  37. package/src/components/link-preview/LinkPreview.stories.tsx +48 -75
  38. package/src/components/list/List.stories.tsx +59 -84
  39. package/src/components/list/List.test.tsx +8 -17
  40. package/src/components/list/ListDivider.stories.tsx +9 -4
  41. package/src/components/list/ListDivider.test.tsx +12 -17
  42. package/src/components/list/ListItem.stories.tsx +97 -59
  43. package/src/components/list/ListItem.test.tsx +12 -17
  44. package/src/components/list/ListSubheader.stories.tsx +8 -5
  45. package/src/components/list/ListSubheader.test.tsx +12 -18
  46. package/src/components/message/Message.stories.tsx +51 -22
  47. package/src/components/mosaic/Mosaic.stories.tsx +78 -74
  48. package/src/components/mosaic/Mosaic.test.tsx +0 -31
  49. package/src/components/navigation/Navigation.stories.tsx +67 -0
  50. package/src/components/navigation/Navigation.test.tsx +58 -0
  51. package/src/components/navigation/Navigation.tsx +62 -0
  52. package/src/components/navigation/NavigationItem.test.tsx +37 -0
  53. package/src/components/navigation/NavigationItem.tsx +89 -0
  54. package/src/components/navigation/NavigationSection.test.tsx +126 -0
  55. package/src/components/navigation/NavigationSection.tsx +109 -0
  56. package/src/components/navigation/context.tsx +6 -0
  57. package/src/components/navigation/index.ts +1 -0
  58. package/src/components/notification/Notifications.stories.tsx +52 -47
  59. package/src/components/popover/Popover.stories.tsx +68 -201
  60. package/src/components/popover/Popover.tsx +7 -9
  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/select/SelectMultiple.stories.tsx +105 -2
  68. package/src/components/select/WithSelectContext.tsx +10 -4
  69. package/src/components/skeleton/SkeletonCircle.stories.tsx +37 -21
  70. package/src/components/skeleton/SkeletonCircle.test.tsx +12 -17
  71. package/src/components/skeleton/SkeletonRectangle.stories.tsx +74 -99
  72. package/src/components/skeleton/SkeletonRectangle.test.tsx +12 -17
  73. package/src/components/skeleton/SkeletonTypography.test.tsx +12 -17
  74. package/src/components/slider/Slider.stories.tsx +41 -25
  75. package/src/components/slider/Slider.test.tsx +12 -18
  76. package/src/components/slideshow/Slideshow.stories.tsx +31 -61
  77. package/src/components/slideshow/Slideshow.test.tsx +15 -23
  78. package/src/components/slideshow/SlideshowControls.stories.tsx +4 -6
  79. package/src/components/switch/Switch.stories.tsx +35 -32
  80. package/src/components/table/Table.test.tsx +12 -17
  81. package/src/components/tabs/Tabs.stories.tsx +4 -3
  82. package/src/components/text/Text.stories.tsx +130 -0
  83. package/src/components/text-field/TextField.stories.tsx +114 -148
  84. package/src/components/thumbnail/Thumbnail.stories.tsx +106 -255
  85. package/src/components/thumbnail/Thumbnail.test.tsx +12 -35
  86. package/src/components/tooltip/Tooltip.stories.tsx +51 -136
  87. package/src/components/user-block/UserBlock.stories.tsx +67 -56
  88. package/src/components/user-block/UserBlock.test.tsx +1 -5
  89. package/src/hooks/useFocusTrap.ts +2 -2
  90. package/src/index.ts +1 -0
  91. package/src/stories/controls/color.ts +6 -0
  92. package/src/stories/controls/element.ts +6 -0
  93. package/src/stories/controls/focusPoint.ts +1 -0
  94. package/src/stories/controls/icons.ts +6 -0
  95. package/src/stories/{knobs → controls}/image.ts +6 -16
  96. package/src/stories/controls/selectArgType.ts +4 -0
  97. package/src/stories/controls/theme.ts +3 -0
  98. package/src/stories/controls/typography.ts +5 -0
  99. package/src/stories/controls/withUndefined.ts +1 -0
  100. package/src/stories/decorators/withChromaticForceScreenSize.tsx +8 -0
  101. package/src/stories/decorators/withCombinations.tsx +99 -0
  102. package/src/stories/decorators/withNestedProps.tsx +23 -0
  103. package/src/stories/{withResizableBox.tsx → decorators/withResizableBox.tsx} +6 -10
  104. package/src/stories/decorators/withValueOnChange.tsx +18 -0
  105. package/src/stories/decorators/withWrapper.tsx +19 -0
  106. package/src/stories/utils/CustomLink.tsx +8 -2
  107. package/src/stories/{knobs → utils}/lorem.ts +9 -9
  108. package/src/testing/utils/commonTestsSuiteRTL.ts +2 -3
  109. package/src/testing/utils/index.ts +0 -2
  110. package/src/untypped-modules.d.ts +0 -2
  111. package/src/utils/MaterialThemeSwitcher/MaterialThemeSwitcher.tsx +1 -1
  112. package/src/utils/ThemeContext.ts +4 -0
  113. package/src/utils/forwardRefPolymorphic.ts +9 -0
  114. package/src/utils/type.ts +28 -4
  115. package/src/components/alert-dialog/__snapshots__/AlertDialog.test.tsx.snap +0 -558
  116. package/src/components/avatar/__snapshots__/Avatar.test.tsx.snap +0 -681
  117. package/src/components/comment-block/__snapshots__/CommentBlock.test.tsx.snap +0 -92
  118. package/src/components/dialog/__snapshots__/Dialog.test.tsx.snap +0 -1133
  119. package/src/components/expansion-panel/ExpansionPanel.stories.tsx +0 -65
  120. package/src/components/flag/__snapshots__/Flag.test.tsx.snap +0 -133
  121. package/src/components/flex-box/__snapshots__/FlexBox.test.tsx.snap +0 -492
  122. package/src/components/grid-column/GridColumn.stories.jsx +0 -56
  123. package/src/components/image-block/__snapshots__/ImageBlock.test.tsx.snap +0 -64
  124. package/src/components/lightbox/__snapshots__/Lightbox.test.tsx.snap +0 -194
  125. package/src/components/list/__snapshots__/List.test.tsx.snap +0 -360
  126. package/src/components/list/__snapshots__/ListDivider.test.tsx.snap +0 -7
  127. package/src/components/list/__snapshots__/ListItem.test.tsx.snap +0 -160
  128. package/src/components/list/__snapshots__/ListSubheader.test.tsx.snap +0 -9
  129. package/src/components/mosaic/__snapshots__/Mosaic.test.tsx.snap +0 -357
  130. package/src/components/post-block/__snapshots__/PostBlock.test.tsx.snap +0 -139
  131. package/src/components/skeleton/__snapshots__/SkeletonCircle.test.tsx.snap +0 -54
  132. package/src/components/skeleton/__snapshots__/SkeletonRectangle.test.tsx.snap +0 -177
  133. package/src/components/skeleton/__snapshots__/SkeletonTypography.test.tsx.snap +0 -174
  134. package/src/components/slider/__snapshots__/Slider.test.tsx.snap +0 -122
  135. package/src/components/slideshow/__snapshots__/Slideshow.test.tsx.snap +0 -157
  136. package/src/components/table/__snapshots__/Table.test.tsx.snap +0 -263
  137. package/src/components/text/Text.stories.jsx +0 -75
  138. package/src/components/thumbnail/__snapshots__/Thumbnail.test.tsx.snap +0 -130
  139. package/src/components/user-block/__snapshots__/UserBlock.test.tsx.snap +0 -362
  140. package/src/stories/chromaticForceScreenSize.tsx +0 -7
  141. package/src/stories/knobs/buttonKnob.ts +0 -9
  142. package/src/stories/knobs/emphasisKnob.ts +0 -8
  143. package/src/stories/knobs/enumKnob.ts +0 -14
  144. package/src/stories/knobs/focusKnob.ts +0 -3
  145. package/src/stories/knobs/sizeKnob.ts +0 -5
  146. package/src/stories/knobs/thumbnailsKnob.ts +0 -9
  147. package/src/testing/utils/itShouldRenderStories.tsx +0 -103
@@ -1,45 +1,70 @@
1
1
  import { mdiHeart } from '@lumx/icons';
2
2
  import { AspectRatio, Badge, ColorPalette, Icon, Size, Thumbnail, ThumbnailVariant } from '@lumx/react';
3
- import { select, text } from '@storybook/addon-knobs';
4
- import React, { Fragment } from 'react';
3
+ import React from 'react';
4
+ import { colorArgType } from '@lumx/react/stories/controls/color';
5
+ import { withCombinations } from '@lumx/react/stories/decorators/withCombinations';
6
+ import { withUndefined } from '@lumx/react/stories/controls/withUndefined';
5
7
 
6
- export default { title: 'LumX components/badge/Badge' };
8
+ export default {
9
+ title: 'LumX components/badge/Badge',
10
+ component: Badge,
11
+ argTypes: {
12
+ color: colorArgType,
13
+ children: { control: false },
14
+ },
15
+ };
7
16
 
8
- export const WithText = () => (
9
- <Badge color={select('Colors', ColorPalette, ColorPalette.blue)}>
10
- <span>{text('Value', '30')}</span>
11
- </Badge>
12
- );
17
+ /**
18
+ * Using badge with text children
19
+ */
20
+ export const WithText = {
21
+ args: { children: <span>30</span> },
22
+ };
13
23
 
14
- export const WithIcon = () => (
15
- <Badge color={select('Colors', ColorPalette, ColorPalette.red)}>
16
- <Icon icon={mdiHeart} />
17
- </Badge>
18
- );
24
+ /**
25
+ * Using badge with icon children
26
+ */
27
+ export const WithIcon = {
28
+ args: { children: <Icon icon={mdiHeart} /> },
29
+ };
19
30
 
20
- export const WithThumbnail = () => (
21
- <Badge color={select('Colors', ColorPalette, ColorPalette.light)}>
22
- <Thumbnail
23
- alt="Logo"
24
- aspectRatio={AspectRatio.square}
25
- image="/logo.svg"
26
- size={Size.xxs}
27
- variant={ThumbnailVariant.rounded}
28
- />
29
- </Badge>
30
- );
31
+ /**
32
+ * Using badge with thumbnail children
33
+ */
34
+ export const WithThumbnail = {
35
+ args: {
36
+ children: (
37
+ <Thumbnail
38
+ alt="Logo"
39
+ aspectRatio={AspectRatio.square}
40
+ image="/logo.svg"
41
+ size={Size.xxs}
42
+ variant={ThumbnailVariant.rounded}
43
+ />
44
+ ),
45
+ },
46
+ };
31
47
 
32
- export const AllColors = () => (
33
- <dl>
34
- {Object.values(ColorPalette).map((color) => (
35
- <Fragment key={color}>
36
- <dt>{color}</dt>
37
- <dd>
38
- <Badge color={color}>
39
- <Icon icon={mdiHeart} />
40
- </Badge>
41
- </dd>
42
- </Fragment>
43
- ))}
44
- </dl>
45
- );
48
+ /**
49
+ * All combinations of colors and children types
50
+ */
51
+ export const AllColors = {
52
+ argTypes: {
53
+ color: { control: false },
54
+ },
55
+ decorators: [
56
+ withCombinations({
57
+ combinations: {
58
+ cols: {
59
+ key: 'color',
60
+ options: withUndefined(ColorPalette),
61
+ },
62
+ rows: {
63
+ 'With text': WithText.args,
64
+ 'With icon': WithIcon.args,
65
+ 'With thumbnail': WithThumbnail.args,
66
+ },
67
+ },
68
+ }),
69
+ ],
70
+ };
@@ -1,156 +1,164 @@
1
- import React, { Fragment } from 'react';
2
- import { mdiSend } from '@lumx/icons';
3
- import { Button, ColorPalette, IconButton, Text } from '@lumx/react';
4
- import { squareImageKnob } from '@lumx/react/stories/knobs/image';
5
- import { buttonSize } from '@lumx/react/stories/knobs/buttonKnob';
6
- import { emphasis } from '@lumx/react/stories/knobs/emphasisKnob';
7
- import { boolean, select, text } from '@storybook/addon-knobs';
8
-
9
- export default { title: 'LumX components/button/Button' };
10
-
11
- const DEFAULT_PROPS = Button.defaultProps as any;
12
-
13
- export const SimpleButton = ({ theme }: any) => {
14
- return (
15
- <Button
16
- aria-pressed={boolean('isSelected', Boolean(DEFAULT_PROPS.isSelected))}
17
- emphasis={emphasis('Emphasis', DEFAULT_PROPS.emphasis)}
18
- theme={theme}
19
- rightIcon={select('Right icon', { none: undefined, mdiSend }, undefined)}
20
- leftIcon={select('Left icon', { none: undefined, mdiSend }, undefined)}
21
- size={buttonSize()}
22
- isSelected={boolean('isSelected', Boolean(DEFAULT_PROPS.isSelected))}
23
- isDisabled={boolean('isDisabled', Boolean(DEFAULT_PROPS.isDisabled))}
24
- color={select('color', ColorPalette, DEFAULT_PROPS.color)}
25
- href={text('Button link', '')}
26
- hasBackground={boolean('hasBackground', Boolean(DEFAULT_PROPS.hasBackground))}
27
- >
28
- {text('Button content', 'Simple button')}
29
- </Button>
30
- );
1
+ import React from 'react';
2
+ import { Button, ButtonSize, Emphasis, Size, Text } from '@lumx/react';
3
+ import { iconArgType } from '@lumx/react/stories/controls/icons';
4
+ import { colorArgType } from '@lumx/react/stories/controls/color';
5
+ import { getSelectArgType } from '@lumx/react/stories/controls/selectArgType';
6
+ import { withCombinations } from '@lumx/react/stories/decorators/withCombinations';
7
+ import { mdiAccountBox } from '@lumx/icons';
8
+
9
+ const buttonSizes = [Size.m, Size.s];
10
+ const buttonEmphasis = [Emphasis.low, Emphasis.medium, Emphasis.high];
11
+
12
+ export default {
13
+ title: 'LumX components/button/Button',
14
+ component: Button,
15
+ argTypes: {
16
+ isSelected: { control: 'boolean' },
17
+ isDisabled: { control: 'boolean' },
18
+ hasBackground: { control: 'boolean' },
19
+ emphasis: getSelectArgType(buttonEmphasis),
20
+ size: getSelectArgType<ButtonSize>(buttonSizes),
21
+ rightIcon: iconArgType,
22
+ leftIcon: iconArgType,
23
+ color: colorArgType,
24
+ onClick: { action: true },
25
+ },
26
+ args: Button.defaultProps,
31
27
  };
32
28
 
33
- export const SimpleButtonWithTruncatedText = ({ theme }: any) => {
34
- const buttonText =
35
- 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Potenti nullam ac tortor vitae. Lorem ipsum dolor sit amet. Diam sollicitudin tempor id eu nisl nunc mi ipsum. Elementum facilisis leo vel fringilla est ullamcorper eget nulla. Mollis aliquam ut porttitor leo a diam sollicitudin tempor. Ultrices tincidunt arcu non sodales neque sodales.';
36
- return (
37
- <Button
38
- aria-pressed={boolean('isSelected', Boolean(DEFAULT_PROPS.isSelected))}
39
- emphasis={emphasis('Emphasis', DEFAULT_PROPS.emphasis)}
40
- theme={theme}
41
- rightIcon={select('Right icon', { none: undefined, mdiSend }, undefined)}
42
- leftIcon={select('Left icon', { none: undefined, mdiSend }, undefined)}
43
- size={buttonSize()}
44
- isSelected={boolean('isSelected', Boolean(DEFAULT_PROPS.isSelected))}
45
- isDisabled={boolean('isDisabled', Boolean(DEFAULT_PROPS.isDisabled))}
46
- color={select('color', ColorPalette, DEFAULT_PROPS.color)}
47
- href={text('Button link', '')}
48
- hasBackground={boolean('hasBackground', Boolean(DEFAULT_PROPS.hasBackground))}
49
- fullWidth
50
- title={buttonText}
51
- >
52
- <Text as="span" truncate>
53
- {text('Button content', buttonText)}
54
- </Text>
55
- </Button>
56
- );
29
+ /**
30
+ * Default button
31
+ */
32
+ export const Default = {
33
+ args: {
34
+ children: 'Default button',
35
+ },
57
36
  };
58
37
 
59
- export const WithHref = () => <Button href="https://google.com">Button with redirection</Button>;
60
-
61
- export const Disabled = () => <Button isDisabled>Disabled button</Button>;
62
-
63
- export const DisabledWithHref = () => (
64
- <Button href="https://google.com" isDisabled>
65
- Disabled button with redirection
66
- </Button>
67
- );
68
-
69
- export const IconButtonWithImage = ({ theme }: any) => (
70
- <div>
71
- <IconButton
72
- theme={theme}
73
- label="Image label"
74
- image={squareImageKnob()}
75
- size={buttonSize()}
76
- hasBackground={boolean('Has background', false)}
77
- emphasis={emphasis('Emphasis', DEFAULT_PROPS.emphasis)}
78
- color={select('color', ColorPalette, DEFAULT_PROPS.color)}
79
- />
80
- </div>
81
- );
82
-
83
- export const FullWidthButton = () => <Button fullWidth>Full width button</Button>;
84
-
85
38
  /**
86
- * Template story to generate all variants for button and icon button.
39
+ * Disabled button
87
40
  */
88
- const AllVariantTemplate = (Component: any, props: any) => () => {
89
- // Major variants.
90
- const variants = {
91
- 'Default (emphasis high)': {},
92
- 'Full width': { fullWidth: true },
93
- 'Emphasis medium': { emphasis: 'medium' },
94
- 'Emphasis low': { emphasis: 'low' },
95
- 'Has background (emphasis low)': { emphasis: 'low', hasBackground: true },
96
- 'Has background + Full width': { emphasis: 'low', hasBackground: true, fullWidth: true },
97
- } as const;
41
+ export const Disabled = {
42
+ args: {
43
+ isDisabled: true,
44
+ children: 'Default button (disabled)',
45
+ },
46
+ };
98
47
 
99
- // Color modifiers.
100
- const colorModifiers = {
101
- Default: {},
102
- 'Color: light': { color: 'light' },
103
- 'Color: dark': { color: 'dark' },
104
- 'Color: red': { color: 'red' },
105
- 'Theme: dark': { theme: 'dark' },
106
- } as const;
48
+ /**
49
+ * All combinations of size, emphasis and hasBackground
50
+ */
51
+ export const SizeEmphasisAndBackground = {
52
+ args: {
53
+ children: 'Button',
54
+ },
55
+ decorators: [
56
+ withCombinations({
57
+ tableStyle: { background: 'lightgray' },
58
+ cellStyle: { padding: '10px' },
59
+ combinations: {
60
+ rows: { medium: { size: Size.m }, small: { size: Size.s } },
61
+ cols: { key: 'emphasis', options: buttonEmphasis },
62
+ sections: {
63
+ 'hasBackground: false': { hasBackground: false },
64
+ 'hasBackground: true': { hasBackground: true },
65
+ },
66
+ },
67
+ }),
68
+ ],
69
+ };
107
70
 
108
- // State modifiers.
109
- const stateModifiers = {
110
- 'Default state': {},
111
- Selected: { isSelected: true },
112
- Hovered: { isHovered: true },
113
- Focused: { isFocused: true },
114
- Active: { isActive: true },
115
- Disabled: { isDisabled: true },
116
- };
71
+ /**
72
+ * Setting a href to transform the button into a link.
73
+ */
74
+ export const LinkButton = {
75
+ args: {
76
+ href: 'https://example.com',
77
+ children: 'Link button',
78
+ },
79
+ };
117
80
 
118
- return (
119
- <div style={{ background: 'lightgray' }}>
120
- {Object.entries(stateModifiers).map(([stateKey, state]) => (
121
- <Fragment key={stateKey}>
122
- <h2>{stateKey}</h2>
123
- <table style={{ width: '100%' }}>
124
- <tr>
125
- <td style={{ whiteSpace: 'nowrap', width: 200 }} />
126
- {Object.keys(colorModifiers).map((colorKey) => (
127
- <td key={colorKey}>{colorKey}</td>
128
- ))}
129
- </tr>
81
+ /**
82
+ * Setting a href to transform the button into a link.
83
+ */
84
+ export const LinkButtonDisabled = {
85
+ args: {
86
+ href: 'https://example.com',
87
+ children: 'Link button (disabled)',
88
+ isDisabled: true,
89
+ },
90
+ };
130
91
 
131
- {Object.entries(variants).map(([variantKey, variant]: any) => (
132
- <tr key={variantKey}>
133
- <td>{variantKey}</td>
134
- {Object.entries(colorModifiers).map(([colorKey, color]) => (
135
- <td key={colorKey}>
136
- <Component {...props} {...variant} {...color} {...state} />
137
- </td>
138
- ))}
139
- </tr>
140
- ))}
141
- </table>
142
- </Fragment>
143
- ))}
144
- </div>
145
- );
92
+ /**
93
+ * Full width button
94
+ */
95
+ export const FullWidth = {
96
+ args: {
97
+ fullWidth: true,
98
+ children: 'Full width button',
99
+ },
146
100
  };
147
101
 
148
102
  /**
149
- * Check button style variations (color, states, emphasis, etc.)
103
+ * Full width button with long text truncated
150
104
  */
151
- export const ButtonVariations = AllVariantTemplate(Button, { children: 'Button' });
105
+ export const FullWidthTruncated = {
106
+ argTypes: {
107
+ children: { control: false },
108
+ },
109
+ args: {
110
+ fullWidth: true,
111
+ children: (
112
+ <Text as="span" truncate>
113
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et
114
+ dolore magna aliqua. Potenti nullam ac tortor vitae. Lorem ipsum dolor sit amet. Diam sollicitudin
115
+ tempor id eu nisl nunc mi ipsum. Elementum facilisis leo vel fringilla est ullamcorper eget nulla.
116
+ Mollis aliquam ut porttitor leo a diam sollicitudin tempor. Ultrices tincidunt arcu non sodales neque
117
+ sodales.
118
+ </Text>
119
+ ),
120
+ },
121
+ };
152
122
 
153
123
  /**
154
- * Check icon button style variations (color, states, emphasis, etc.)
124
+ * Check button style variations (color, states, emphasis, etc.)
155
125
  */
156
- export const IconButtonVariations = AllVariantTemplate(IconButton, { label: 'Send', icon: mdiSend });
126
+ export const ButtonVariations = {
127
+ args: {
128
+ children: 'Button',
129
+ rightIcon: mdiAccountBox,
130
+ },
131
+ decorators: [
132
+ withCombinations({
133
+ tableStyle: { background: 'lightgray', width: '100%' },
134
+ firstColStyle: { whiteSpace: 'nowrap', width: '1%' },
135
+ combinations: {
136
+ // Colors
137
+ rows: {
138
+ Default: {},
139
+ 'Color: red': { color: 'red' },
140
+ 'Theme: dark': { theme: 'dark' },
141
+ 'Theme: dark & color: green': { theme: 'dark', color: 'green' },
142
+ },
143
+ // States
144
+ cols: {
145
+ 'Default state': {},
146
+ Selected: { isSelected: true },
147
+ Hovered: { isHovered: true },
148
+ Focused: { isFocused: true },
149
+ Active: { isActive: true },
150
+ Disabled: { isDisabled: true },
151
+ },
152
+ // Emphasis/Background
153
+ sections: {
154
+ 'Default (emphasis high)': {},
155
+ 'Emphasis medium': { emphasis: 'medium' },
156
+ 'Emphasis low': { emphasis: 'low' },
157
+ 'Full width': { fullWidth: true },
158
+ 'Has background (emphasis low)': { emphasis: 'low', hasBackground: true },
159
+ 'Has background + Full width': { emphasis: 'low', hasBackground: true, fullWidth: true },
160
+ },
161
+ },
162
+ }),
163
+ ],
164
+ };
@@ -0,0 +1,45 @@
1
+ import { mdiSend } from '@lumx/icons';
2
+ import { ButtonSize, Emphasis, IconButton, Size } from '@lumx/react';
3
+ import { iconArgType } from '@lumx/react/stories/controls/icons';
4
+ import { colorArgType } from '@lumx/react/stories/controls/color';
5
+ import { SQUARE_IMAGES, squareImageArgType } from '@lumx/react/stories/controls/image';
6
+ import { getSelectArgType } from '@lumx/react/stories/controls/selectArgType';
7
+ import { ButtonVariations } from './Button.stories';
8
+
9
+ export default {
10
+ title: 'LumX components/button/IconButton',
11
+ component: IconButton,
12
+ argTypes: {
13
+ isSelected: { control: 'boolean' },
14
+ isDisabled: { control: 'boolean' },
15
+ hasBackground: { control: 'boolean' },
16
+ emphasis: getSelectArgType(Emphasis),
17
+ size: getSelectArgType<ButtonSize>([Size.s, Size.m]),
18
+ icon: iconArgType,
19
+ color: colorArgType,
20
+ },
21
+ args: IconButton.defaultProps,
22
+ };
23
+
24
+ /**
25
+ * Default IconButton
26
+ */
27
+ export const Default = {
28
+ args: { icon: mdiSend },
29
+ };
30
+
31
+ /**
32
+ * IconButton using an image
33
+ */
34
+ export const WithImage = {
35
+ argTypes: squareImageArgType,
36
+ args: { image: SQUARE_IMAGES.square1 },
37
+ };
38
+
39
+ /**
40
+ * Check icon button style variations (color, states, emphasis, etc.)
41
+ */
42
+ export const IconButtonVariations = {
43
+ ...Default,
44
+ decorators: ButtonVariations.decorators,
45
+ };
@@ -1,37 +1,44 @@
1
1
  import { Checkbox } from '@lumx/react';
2
- import { text } from '@storybook/addon-knobs';
3
- import noop from 'lodash/noop';
4
- import React, { useState } from 'react';
2
+ import { withValueOnChange } from '@lumx/react/stories/decorators/withValueOnChange';
3
+ import { loremIpsum } from '@lumx/react/stories/utils/lorem';
5
4
 
6
- export default { title: 'LumX components/checkbox/Checkbox' };
7
-
8
- export const SimpleSelect = ({ theme }: any) => {
9
- const [value, setValue] = useState(false);
10
- return <Checkbox isChecked={value} label={text('Label', 'My label')} theme={theme} onChange={setValue} />;
5
+ export default {
6
+ title: 'LumX components/checkbox/Checkbox',
7
+ component: Checkbox,
8
+ decorators: [withValueOnChange({ valueProp: 'isChecked' })],
9
+ args: {
10
+ isChecked: false,
11
+ name: 'checkbox-html-name',
12
+ value: 'checkbox-html-value',
13
+ },
14
+ argTypes: {
15
+ onChange: { action: true },
16
+ name: { control: false },
17
+ value: { control: false },
18
+ },
11
19
  };
12
20
 
13
- export const DisabledSelect = ({ theme }: any) => {
14
- return (
15
- <Checkbox
16
- isChecked={false}
17
- label={text('Label', 'My label')}
18
- helper={text('Helper', 'You will receive our newsletter each month')}
19
- theme={theme}
20
- onChange={noop}
21
- isDisabled
22
- />
23
- );
21
+ /**
22
+ * Default checkbox
23
+ */
24
+ export const Default = {};
25
+
26
+ /**
27
+ * With label and helper
28
+ */
29
+ export const LabelAndHelper = {
30
+ args: {
31
+ label: 'Checkbox label',
32
+ helper: loremIpsum('tiny'),
33
+ },
24
34
  };
25
35
 
26
- export const WithHelperSelect = ({ theme }: any) => {
27
- const [value, setValue] = useState(false);
28
- return (
29
- <Checkbox
30
- isChecked={value}
31
- label={text('Label', 'My label')}
32
- helper={text('Helper', 'You will receive our newsletter each month')}
33
- theme={theme}
34
- onChange={setValue}
35
- />
36
- );
36
+ /**
37
+ * Disabled
38
+ */
39
+ export const Disabled = {
40
+ args: {
41
+ ...LabelAndHelper.args,
42
+ isDisabled: true,
43
+ },
37
44
  };
@@ -1,21 +1,83 @@
1
1
  import React from 'react';
2
2
 
3
3
  import { mdiClose, mdiViewList } from '@lumx/icons';
4
- import { Chip, Icon } from '@lumx/react';
4
+ import { Chip, ChipProps, ColorPalette, GridColumn, Icon, Size } from '@lumx/react';
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';
5
9
 
6
- export default { title: 'LumX components/chip/Chip' };
10
+ const chipSizes = [Size.m, Size.s];
11
+ export default {
12
+ title: 'LumX components/chip/Chip',
13
+ component: Chip,
14
+ args: Chip.defaultProps,
15
+ argTypes: {
16
+ size: getSelectArgType<ChipProps['size']>(chipSizes),
17
+ before: { control: false },
18
+ after: { control: false },
19
+ },
20
+ };
7
21
 
8
- export const Simple = ({ theme }: any) => <Chip theme={theme}>The chip</Chip>;
22
+ /**
23
+ * Default chip with label
24
+ */
25
+ export const Default = {
26
+ args: { children: 'Chip label' },
27
+ };
9
28
 
10
- export const WithAfterAndBefore = ({ theme }: any) => (
11
- <Chip
12
- theme={theme}
13
- after={<Icon icon={mdiClose} />}
14
- onAfterClick={() => alert('clicked on close')}
15
- before={<Icon icon={mdiViewList} />}
16
- onClick={() => alert('clicked on chip')}
17
- isClickable
18
- >
19
- content
20
- </Chip>
21
- );
29
+ /**
30
+ * Clickable chip
31
+ */
32
+ export const ChipButton = {
33
+ args: { children: 'Chip label' },
34
+ argTypes: { onClick: { action: true } },
35
+ };
36
+
37
+ /**
38
+ * Link chip
39
+ */
40
+ export const ChipLink = {
41
+ args: {
42
+ children: 'Chip link',
43
+ href: 'https://example.com',
44
+ target: '_blank',
45
+ },
46
+ };
47
+
48
+ /**
49
+ * With custom elements at the start and end of the chip
50
+ */
51
+ export const WithAfterAndBefore = {
52
+ argTypes: {
53
+ onBeforeClick: { action: true },
54
+ onClick: { action: true },
55
+ onAfterClick: { action: true },
56
+ },
57
+ args: {
58
+ before: <Icon icon={mdiViewList} />,
59
+ children: 'Chip label',
60
+ after: <Icon icon={mdiClose} />,
61
+ },
62
+ };
63
+
64
+ /**
65
+ * All combinations of color, size and states.
66
+ */
67
+ export const Variants = {
68
+ ...WithAfterAndBefore,
69
+ decorators: [
70
+ withCombinations({
71
+ combinations: {
72
+ rows: { key: 'color', options: withUndefined(ColorPalette) },
73
+ cols: { key: 'size', options: chipSizes },
74
+ sections: {
75
+ Default: {},
76
+ Disabled: { isDisabled: true },
77
+ Highlighted: { isHighlighted: true },
78
+ },
79
+ },
80
+ }),
81
+ withWrapper({ maxColumns: 3, itemMinWidth: 350 }, GridColumn),
82
+ ],
83
+ };