@marigold/components 0.0.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (194) hide show
  1. package/dist/ActionGroup/ActionGroup.d.ts +9 -0
  2. package/dist/ActionGroup/index.d.ts +1 -0
  3. package/dist/Alert/Alert.d.ts +20 -2
  4. package/dist/Badge/Badge.d.ts +8 -0
  5. package/dist/Badge/index.d.ts +1 -0
  6. package/dist/Box/Box.d.ts +47 -0
  7. package/dist/Box/index.d.ts +1 -0
  8. package/dist/Button/Button.d.ts +4 -3
  9. package/dist/Card/Card.d.ts +9 -0
  10. package/dist/Card/index.d.ts +1 -0
  11. package/dist/Checkbox/Checkbox.d.ts +14 -2
  12. package/dist/Checkbox/CheckboxIcons.d.ts +9 -0
  13. package/dist/Column/Column.d.ts +8 -0
  14. package/dist/Column/index.d.ts +1 -0
  15. package/dist/Columns/Columns.d.ts +10 -0
  16. package/dist/Columns/index.d.ts +1 -0
  17. package/dist/Container/Container.d.ts +6 -0
  18. package/dist/Container/index.d.ts +1 -0
  19. package/dist/Dialog/Dialog.d.ts +14 -0
  20. package/dist/Dialog/ModalDialog.d.ts +5 -0
  21. package/dist/Dialog/index.d.ts +1 -0
  22. package/dist/Divider/Divider.d.ts +7 -0
  23. package/dist/Divider/index.d.ts +1 -0
  24. package/dist/Field/Field.d.ts +11 -0
  25. package/dist/Field/index.d.ts +1 -0
  26. package/dist/Heading/Heading.d.ts +7 -5
  27. package/dist/Hidden/Hidden.d.ts +5 -0
  28. package/dist/Hidden/index.d.ts +1 -0
  29. package/dist/Image/Image.d.ts +7 -0
  30. package/dist/Image/index.d.ts +1 -0
  31. package/dist/Input/Input.d.ts +6 -0
  32. package/dist/Input/index.d.ts +1 -0
  33. package/dist/Label/Label.d.ts +8 -5
  34. package/dist/Link/Link.d.ts +7 -3
  35. package/dist/Menu/Menu.d.ts +12 -0
  36. package/dist/Menu/index.d.ts +1 -0
  37. package/dist/MenuItem/MenuItem.d.ts +7 -0
  38. package/dist/MenuItem/index.d.ts +1 -0
  39. package/dist/Message/Message.d.ts +7 -0
  40. package/dist/Message/index.d.ts +1 -0
  41. package/dist/Provider/MarigoldProvider.d.ts +3 -0
  42. package/dist/Provider/index.d.ts +3 -0
  43. package/dist/Radio/Radio.d.ts +14 -2
  44. package/dist/Radio/RadioIcons.d.ts +9 -0
  45. package/dist/Select/ListBox.d.ts +8 -0
  46. package/dist/Select/ListBoxSection.d.ts +8 -0
  47. package/dist/Select/Option.d.ts +8 -0
  48. package/dist/Select/Popover.d.ts +9 -0
  49. package/dist/Select/Select.d.ts +13 -3
  50. package/dist/Slider/Slider.d.ts +6 -3
  51. package/dist/Stack/Stack.d.ts +7 -0
  52. package/dist/Stack/index.d.ts +1 -0
  53. package/dist/Text/Text.d.ts +12 -3
  54. package/dist/Textarea/Textarea.d.ts +11 -3
  55. package/dist/ValidationMessage/ValidationMessage.d.ts +6 -0
  56. package/dist/ValidationMessage/index.d.ts +1 -0
  57. package/dist/components.cjs.development.js +1308 -195
  58. package/dist/components.cjs.development.js.map +1 -1
  59. package/dist/components.cjs.production.min.js +1 -1
  60. package/dist/components.cjs.production.min.js.map +1 -1
  61. package/dist/components.esm.js +1267 -185
  62. package/dist/components.esm.js.map +1 -1
  63. package/dist/index.d.ts +21 -4
  64. package/dist/theme.d.ts +24 -4
  65. package/package.json +24 -4
  66. package/src/ActionGroup/ActionGroup.stories.mdx +62 -0
  67. package/src/ActionGroup/ActionGroup.test.tsx +83 -0
  68. package/src/ActionGroup/ActionGroup.tsx +43 -0
  69. package/src/ActionGroup/index.ts +1 -0
  70. package/src/Alert/Alert.stories.mdx +30 -42
  71. package/src/Alert/Alert.test.tsx +37 -22
  72. package/src/Alert/Alert.tsx +31 -21
  73. package/src/Badge/Badge.stories.mdx +57 -0
  74. package/src/Badge/Badge.test.tsx +61 -0
  75. package/src/Badge/Badge.tsx +25 -0
  76. package/src/Badge/index.ts +1 -0
  77. package/src/Box/Box.stories.mdx +334 -0
  78. package/src/Box/Box.test.tsx +133 -0
  79. package/src/Box/Box.tsx +165 -0
  80. package/src/Box/index.ts +1 -0
  81. package/src/Button/Button.stories.mdx +58 -134
  82. package/src/Button/Button.test.tsx +65 -23
  83. package/src/Button/Button.tsx +48 -14
  84. package/src/Card/Card.stories.mdx +49 -0
  85. package/src/Card/Card.test.tsx +66 -0
  86. package/src/Card/Card.tsx +36 -0
  87. package/src/Card/index.ts +1 -0
  88. package/src/Checkbox/Checkbox.stories.mdx +79 -101
  89. package/src/Checkbox/Checkbox.test.tsx +73 -32
  90. package/src/Checkbox/Checkbox.tsx +114 -35
  91. package/src/Checkbox/CheckboxIcons.tsx +49 -0
  92. package/src/Column/Column.stories.mdx +49 -0
  93. package/src/Column/Column.test.tsx +32 -0
  94. package/src/Column/Column.tsx +27 -0
  95. package/src/Column/index.ts +1 -0
  96. package/src/Columns/Columns.stories.mdx +65 -0
  97. package/src/Columns/Columns.test.tsx +102 -0
  98. package/src/Columns/Columns.tsx +69 -0
  99. package/src/Columns/index.ts +1 -0
  100. package/src/Container/Container.stories.mdx +19 -0
  101. package/src/Container/Container.test.tsx +26 -0
  102. package/src/Container/Container.tsx +13 -0
  103. package/src/Container/index.ts +1 -0
  104. package/src/Dialog/Dialog.stories.mdx +73 -0
  105. package/src/Dialog/Dialog.test.tsx +87 -0
  106. package/src/Dialog/Dialog.tsx +84 -0
  107. package/src/Dialog/ModalDialog.tsx +47 -0
  108. package/src/Dialog/index.ts +1 -0
  109. package/src/Divider/Divider.stories.mdx +37 -0
  110. package/src/Divider/Divider.test.tsx +63 -0
  111. package/src/Divider/Divider.tsx +13 -0
  112. package/src/Divider/index.ts +1 -0
  113. package/src/Field/Field.stories.mdx +97 -0
  114. package/src/Field/Field.test.tsx +80 -0
  115. package/src/Field/Field.tsx +54 -0
  116. package/src/Field/index.ts +1 -0
  117. package/src/Heading/Heading.stories.mdx +36 -76
  118. package/src/Heading/Heading.test.tsx +31 -17
  119. package/src/Heading/Heading.tsx +15 -12
  120. package/src/Hidden/Hidden.stories.mdx +39 -0
  121. package/src/Hidden/Hidden.test.tsx +24 -0
  122. package/src/Hidden/Hidden.tsx +16 -0
  123. package/src/Hidden/index.ts +1 -0
  124. package/src/Image/Image.stories.mdx +36 -0
  125. package/src/Image/Image.test.tsx +70 -0
  126. package/src/Image/Image.tsx +13 -0
  127. package/src/Image/index.ts +1 -0
  128. package/src/Input/Input.stories.mdx +61 -0
  129. package/src/Input/Input.test.tsx +70 -0
  130. package/src/Input/Input.tsx +13 -0
  131. package/src/Input/index.ts +1 -0
  132. package/src/Label/Label.stories.mdx +50 -34
  133. package/src/Label/Label.test.tsx +45 -16
  134. package/src/Label/Label.tsx +26 -17
  135. package/src/Link/Link.stories.mdx +40 -31
  136. package/src/Link/Link.test.tsx +53 -28
  137. package/src/Link/Link.tsx +32 -14
  138. package/src/Menu/Menu.stories.mdx +81 -0
  139. package/src/Menu/Menu.test.tsx +79 -0
  140. package/src/Menu/Menu.tsx +41 -0
  141. package/src/Menu/index.ts +1 -0
  142. package/src/MenuItem/MenuItem.stories.mdx +37 -0
  143. package/src/MenuItem/MenuItem.test.tsx +63 -0
  144. package/src/MenuItem/MenuItem.tsx +23 -0
  145. package/src/MenuItem/index.ts +1 -0
  146. package/src/Message/Message.stories.mdx +44 -0
  147. package/src/Message/Message.test.tsx +87 -0
  148. package/src/Message/Message.tsx +43 -0
  149. package/src/Message/index.ts +1 -0
  150. package/src/Provider/MarigoldProvider.test.tsx +126 -0
  151. package/src/Provider/MarigoldProvider.tsx +29 -0
  152. package/src/Provider/index.ts +3 -0
  153. package/src/Radio/Radio.stories.mdx +80 -83
  154. package/src/Radio/Radio.test.tsx +63 -22
  155. package/src/Radio/Radio.tsx +110 -35
  156. package/src/Radio/RadioIcons.tsx +39 -0
  157. package/src/Select/ListBox.tsx +39 -0
  158. package/src/Select/ListBoxSection.tsx +40 -0
  159. package/src/Select/Option.tsx +48 -0
  160. package/src/Select/Popover.tsx +50 -0
  161. package/src/Select/Select.stories.mdx +72 -37
  162. package/src/Select/Select.test.tsx +271 -28
  163. package/src/Select/Select.tsx +158 -23
  164. package/src/Slider/Slider.stories.mdx +26 -54
  165. package/src/Slider/Slider.test.tsx +13 -13
  166. package/src/Slider/Slider.tsx +20 -18
  167. package/src/Stack/Stack.stories.mdx +51 -0
  168. package/src/Stack/Stack.test.tsx +129 -0
  169. package/src/Stack/Stack.tsx +39 -0
  170. package/src/Stack/index.ts +1 -0
  171. package/src/Text/Text.stories.mdx +53 -47
  172. package/src/Text/Text.test.tsx +55 -15
  173. package/src/Text/Text.tsx +44 -10
  174. package/src/Textarea/Textarea.stories.mdx +68 -21
  175. package/src/Textarea/Textarea.test.tsx +47 -16
  176. package/src/Textarea/Textarea.tsx +46 -14
  177. package/src/ValidationMessage/ValidationMessage.stories.mdx +36 -0
  178. package/src/ValidationMessage/ValidationMessage.test.tsx +63 -0
  179. package/src/ValidationMessage/ValidationMessage.tsx +28 -0
  180. package/src/ValidationMessage/index.ts +1 -0
  181. package/src/index.ts +22 -4
  182. package/src/theme.ts +24 -4
  183. package/dist/Svg/Svg.d.ts +0 -5
  184. package/dist/Svg/index.d.ts +0 -1
  185. package/dist/TextInput/TextInput.d.ts +0 -3
  186. package/dist/TextInput/index.d.ts +0 -1
  187. package/src/Svg/Svg.stories.mdx +0 -47
  188. package/src/Svg/Svg.test.tsx +0 -58
  189. package/src/Svg/Svg.tsx +0 -25
  190. package/src/Svg/index.ts +0 -1
  191. package/src/TextInput/TextInput.stories.mdx +0 -37
  192. package/src/TextInput/TextInput.test.tsx +0 -71
  193. package/src/TextInput/TextInput.tsx +0 -21
  194. package/src/TextInput/index.ts +0 -1
@@ -1,42 +1,117 @@
1
1
  import React from 'react';
2
- import { Box, system } from '@marigold/system';
3
- import { CircleUnchecked, CircleChecked } from '@marigold/icons';
2
+ import { ComponentProps } from '@marigold/types';
3
+ import { Exclamation } from '@marigold/icons';
4
4
 
5
- type RadioProps = {};
5
+ import { Box } from '../Box';
6
+ import { Label } from '../Label';
7
+ import { ValidationMessage } from '../ValidationMessage';
6
8
 
7
- export const Radio = system<RadioProps, 'input'>(
8
- ({ variant = 'radio', ...props }) => {
9
+ import { RadioChecked, RadioUnchecked } from './RadioIcons';
10
+
11
+ // Radio Icon
12
+ // ---------------
13
+ type RadioIconProps = {
14
+ variant?: string;
15
+ checked?: boolean;
16
+ disabled?: boolean;
17
+ error?: boolean;
18
+ children?: never;
19
+ };
20
+
21
+ const RadioIcon: React.FC<RadioIconProps> = ({
22
+ variant,
23
+ checked,
24
+ disabled,
25
+ error,
26
+ }) => {
27
+ if (checked) {
9
28
  return (
10
- <Box css={{ display: 'inline-block' }}>
11
- <Box
12
- as="input"
13
- type="radio"
14
- {...props}
15
- css={{
16
- position: 'absolute',
17
- opacity: 0,
18
- zIndex: -1,
19
- width: 1,
20
- height: 1,
21
- overflow: 'hidden',
22
- }}
23
- />
24
- <Box
25
- as={props.checked ? CircleChecked : CircleUnchecked}
26
- aria-hidden="true"
27
- themeSection="form"
28
- variant={variant}
29
- css={{
30
- mr: 2,
31
- verticalAlign: 'middle',
32
- ':hover': { cursor: 'pointer' },
33
- 'input:disabled ~ &': {
34
- color: 'muted',
35
- cursor: 'not-allowed',
36
- },
37
- }}
38
- />
39
- </Box>
29
+ <Box as={RadioChecked} variant={`radio.${variant}`} disabled={disabled} />
40
30
  );
41
31
  }
32
+ return (
33
+ <Box
34
+ as={RadioUnchecked}
35
+ variant={`radio.${variant}`}
36
+ disabled={disabled}
37
+ error={error}
38
+ />
39
+ );
40
+ };
41
+
42
+ // Radio Input
43
+ // ---------------
44
+ type RadioInputProps = {
45
+ variant?: string;
46
+ error?: boolean;
47
+ } & ComponentProps<'input'>;
48
+
49
+ const RadioInput: React.FC<RadioInputProps> = ({
50
+ className,
51
+ variant = 'default',
52
+ error,
53
+ ...props
54
+ }) => (
55
+ <Box display="inline-block" className={className}>
56
+ <Box
57
+ as="input"
58
+ type="radio"
59
+ css={{
60
+ position: 'absolute',
61
+ opacity: 0,
62
+ zIndex: -1,
63
+ width: 1,
64
+ height: 1,
65
+ overflow: 'hidden',
66
+ }}
67
+ {...props}
68
+ />
69
+ <RadioIcon
70
+ checked={props.checked}
71
+ variant={variant}
72
+ disabled={props.disabled}
73
+ error={error}
74
+ />
75
+ </Box>
42
76
  );
77
+
78
+ // Radio
79
+ // ---------------
80
+ export type RadioProps = {
81
+ id: string;
82
+ label?: string;
83
+ required?: boolean;
84
+ error?: boolean;
85
+ errorMessage?: string;
86
+ } & RadioInputProps;
87
+
88
+ export const Radio: React.FC<RadioProps> = ({
89
+ label,
90
+ required,
91
+ error,
92
+ errorMessage,
93
+ ...props
94
+ }) => {
95
+ if (label) {
96
+ return (
97
+ <>
98
+ <Label
99
+ htmlFor={props.id}
100
+ required={required}
101
+ variant={props.disabled ? 'disabled' : 'inline'}
102
+ >
103
+ <Box as={RadioInput} pr="8px" error={error} {...props} />
104
+ {label}
105
+ </Label>
106
+ {error && errorMessage && (
107
+ <ValidationMessage>
108
+ <Exclamation size={16} />
109
+ {errorMessage}
110
+ </ValidationMessage>
111
+ )}
112
+ </>
113
+ );
114
+ }
115
+
116
+ return <RadioInput {...props} />;
117
+ };
@@ -0,0 +1,39 @@
1
+ import React from 'react';
2
+ import { SVG } from '@marigold/icons';
3
+
4
+ import { Box } from '../Box';
5
+
6
+ export const RadioChecked = ({ disabled = false, ...props }) => (
7
+ <SVG width="16" height="32" viewBox="0 0 16 32" fill="none" {...props}>
8
+ <Box
9
+ as="circle"
10
+ cx="8"
11
+ cy="16"
12
+ r="7.5"
13
+ variant={disabled ? 'radio.checked.disabled' : 'radio.checked'}
14
+ />
15
+ <Box as="circle" cx="8" cy="16" r="3" variant="radio.checked.circle" />
16
+ </SVG>
17
+ );
18
+
19
+ export const RadioUnchecked = ({
20
+ disabled = false,
21
+ error = false,
22
+ ...props
23
+ }) => (
24
+ <SVG width="16" height="32" viewBox="0 0 16 32" fill="none" {...props}>
25
+ <Box
26
+ as="circle"
27
+ cx="8"
28
+ cy="16"
29
+ r="7.5"
30
+ variant={
31
+ disabled
32
+ ? 'radio.unchecked.disabled'
33
+ : error
34
+ ? 'radio.unchecked.error'
35
+ : 'radio.unchecked'
36
+ }
37
+ />
38
+ </SVG>
39
+ );
@@ -0,0 +1,39 @@
1
+ import React, { useRef } from 'react';
2
+ import { useListBox } from '@react-aria/listbox';
3
+ import type { AriaListBoxOptions } from '@react-aria/listbox';
4
+ import type { ListState } from '@react-stately/list';
5
+
6
+ import { Box } from '../Box';
7
+ import { Option } from './Option';
8
+ import { ListBoxSection } from './ListBoxSection';
9
+
10
+ interface ListBoxProps extends AriaListBoxOptions<unknown> {
11
+ state: ListState<unknown>;
12
+ error?: boolean;
13
+ }
14
+
15
+ export const ListBox = (props: ListBoxProps) => {
16
+ const ref = useRef<HTMLUListElement>(null);
17
+ const { state, error } = props;
18
+ const { listBoxProps } = useListBox(props, state, ref);
19
+
20
+ return (
21
+ <Box
22
+ as="ul"
23
+ css={{
24
+ listStyle: 'none',
25
+ }}
26
+ {...listBoxProps}
27
+ variant={error ? 'select.listbox.error' : 'select.listbox'}
28
+ ref={ref}
29
+ >
30
+ {[...state.collection].map(item =>
31
+ item.type === 'section' ? (
32
+ <ListBoxSection key={item.key} section={item} state={state} />
33
+ ) : (
34
+ <Option key={item.key} item={item} state={state} />
35
+ )
36
+ )}
37
+ </Box>
38
+ );
39
+ };
@@ -0,0 +1,40 @@
1
+ import React from 'react';
2
+ import { useListBoxSection } from '@react-aria/listbox';
3
+ import type { ListState } from '@react-stately/list';
4
+ import type { Node } from '@react-types/shared';
5
+
6
+ import { Box } from '../Box';
7
+ import { Option } from './Option';
8
+
9
+ interface SectionProps {
10
+ section: Node<unknown>;
11
+ state: ListState<unknown>;
12
+ }
13
+
14
+ export const ListBoxSection = ({ section, state }: SectionProps) => {
15
+ const { itemProps, headingProps, groupProps } = useListBoxSection({
16
+ heading: section.rendered,
17
+ 'aria-label': section['aria-label'],
18
+ });
19
+
20
+ return (
21
+ <Box
22
+ as="li"
23
+ {...itemProps}
24
+ css={{
25
+ cursor: 'not-allowed',
26
+ }}
27
+ >
28
+ {section.rendered && (
29
+ <Box as="span" {...headingProps} variant={'select.section'}>
30
+ {section.rendered}
31
+ </Box>
32
+ )}
33
+ <Box as="ul" {...groupProps}>
34
+ {[...section.childNodes].map(node => (
35
+ <Option key={node.key} item={node} state={state} />
36
+ ))}
37
+ </Box>
38
+ </Box>
39
+ );
40
+ };
@@ -0,0 +1,48 @@
1
+ import React, { useEffect, useRef, useState } from 'react';
2
+ import type { ListState } from '@react-stately/list';
3
+ import type { Node } from '@react-types/shared';
4
+ import { useOption } from '@react-aria/listbox';
5
+
6
+ import { Box } from '../Box';
7
+
8
+ interface OptionProps {
9
+ item: Node<unknown>;
10
+ state: ListState<unknown>;
11
+ }
12
+
13
+ export const Option = ({ item, state }: OptionProps) => {
14
+ const ref = useRef<HTMLLIElement>(null);
15
+ const [disabled, setDisabled] = useState(false);
16
+ const { optionProps, isSelected } = useOption(
17
+ {
18
+ key: item.key,
19
+ },
20
+ state,
21
+ ref
22
+ );
23
+
24
+ useEffect(() => {
25
+ for (const key of state.disabledKeys.values()) {
26
+ if (key === item.key) {
27
+ setDisabled(true);
28
+ }
29
+ }
30
+ }, [state.disabledKeys, item.key]);
31
+
32
+ return (
33
+ <Box
34
+ as="li"
35
+ {...optionProps}
36
+ ref={ref}
37
+ variant={
38
+ isSelected
39
+ ? 'select.option.selected'
40
+ : disabled
41
+ ? 'select.option.disabled'
42
+ : 'select.option'
43
+ }
44
+ >
45
+ {item.rendered}
46
+ </Box>
47
+ );
48
+ };
@@ -0,0 +1,50 @@
1
+ import React, { forwardRef, RefObject } from 'react';
2
+ import { FocusScope } from '@react-aria/focus';
3
+ import {
4
+ DismissButton,
5
+ OverlayContainer,
6
+ useModal,
7
+ useOverlay,
8
+ } from '@react-aria/overlays';
9
+ import { mergeProps } from '@react-aria/utils';
10
+
11
+ import { Box } from '../Box';
12
+
13
+ interface PopoverProps {
14
+ isOpen?: boolean;
15
+ onClose?: () => void;
16
+ ref?: React.Ref<HTMLDivElement>;
17
+ className?: string;
18
+ }
19
+
20
+ export const Popover: React.FC<PopoverProps> = forwardRef(
21
+ ({ children, className, isOpen, onClose, ...otherProps }, ref) => {
22
+ // Handle events that should cause the popup to close,
23
+ const { overlayProps } = useOverlay(
24
+ {
25
+ isOpen,
26
+ onClose,
27
+ shouldCloseOnBlur: true,
28
+ isDismissable: true,
29
+ },
30
+ ref as RefObject<HTMLElement>
31
+ );
32
+ // Hide content outside the modal from screen readers.
33
+ const { modalProps } = useModal();
34
+
35
+ return (
36
+ <OverlayContainer>
37
+ <FocusScope restoreFocus>
38
+ <Box
39
+ {...mergeProps(overlayProps, otherProps, modalProps)}
40
+ className={className}
41
+ ref={ref}
42
+ >
43
+ {children}
44
+ <DismissButton onDismiss={onClose} />
45
+ </Box>
46
+ </FocusScope>
47
+ </OverlayContainer>
48
+ );
49
+ }
50
+ );
@@ -1,43 +1,78 @@
1
- import { Meta, Story, Preview } from '@storybook/addon-docs/blocks';
2
- import { Label, Select } from '@marigold/components';
1
+ import { ArgsTable, Canvas, Meta, Story } from '@storybook/addon-docs';
2
+ import { Select } from './Select';
3
+ import { Item } from '@marigold/components';
3
4
 
4
- <Meta title="Components/Form/Select" />
5
+ <Meta
6
+ title="Components/Select"
7
+ argTypes={{
8
+ placeholder: {
9
+ control: {
10
+ type: 'text',
11
+ },
12
+ table: {
13
+ defaultValue: {
14
+ summary: 'Select an option',
15
+ },
16
+ },
17
+ },
18
+ disabled: {
19
+ control: {
20
+ type: 'boolean',
21
+ },
22
+ options: [true, false],
23
+ table: {
24
+ defaultValue: {
25
+ summary: false,
26
+ },
27
+ },
28
+ },
29
+ required: {
30
+ control: {
31
+ type: 'boolean',
32
+ },
33
+ options: [true, false],
34
+ table: {
35
+ defaultValue: {
36
+ summary: false,
37
+ },
38
+ },
39
+ },
40
+ error: {
41
+ control: {
42
+ type: 'boolean',
43
+ },
44
+ description: 'Error',
45
+ table: {
46
+ defaultValue: {
47
+ summary: false,
48
+ },
49
+ },
50
+ },
51
+ errorMessage: {
52
+ control: {
53
+ type: 'text',
54
+ },
55
+ description: 'Error Message',
56
+ },
57
+ width: {
58
+ control: 'number',
59
+ },
60
+ }}
61
+ />
5
62
 
6
63
  # Select
7
64
 
8
- ## Description
65
+ export const Template = args => (
66
+ <Select label="Favorite Color" htmlFor="id" {...args}>
67
+ {/* Storybook crashes with imported <Item> component
68
+ <Item>Red</Item>
69
+ <Item>Orange</Item>
70
+ <Item>Yellow</Item> */}
71
+ </Select>
72
+ );
9
73
 
10
- Dropdown for selecting a value among different options.
74
+ <Canvas>
75
+ <Story name="Default">{Template.bind({})}</Story>
76
+ </Canvas>
11
77
 
12
- ## Import
13
-
14
- ```tsx
15
- import { Select } from '@marigold/components';
16
- ```
17
-
18
- ## Usage
19
-
20
- <Preview>
21
- <Story name="Select">
22
- <Label htmlFor="select">
23
- Dropdown
24
- <Select id="select">
25
- <option selected>Choose here</option>
26
- <option>Hi</option>
27
- <option>Hey</option>
28
- <option>Blubb</option>
29
- </Select>
30
- </Label>
31
- </Story>
32
- <Story name="Select disabled">
33
- <Label htmlFor="select2">
34
- Dropdown disabled
35
- <Select disabled>
36
- <option selected>Can't choose here</option>
37
- <option>Hi</option>
38
- <option>Hey</option>
39
- <option>Blubb</option>
40
- </Select>
41
- </Label>
42
- </Story>
43
- </Preview>
78
+ <ArgsTable story="Default" />