@marigold/components 0.1.0 → 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 (112) 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 +16 -1
  4. package/dist/Box/Box.d.ts +2 -1
  5. package/dist/Button/Button.d.ts +4 -6
  6. package/dist/Card/Card.d.ts +9 -0
  7. package/dist/Card/index.d.ts +1 -0
  8. package/dist/Checkbox/Checkbox.d.ts +3 -0
  9. package/dist/Checkbox/CheckboxIcons.d.ts +9 -0
  10. package/dist/Column/Column.d.ts +3 -1
  11. package/dist/Dialog/Dialog.d.ts +8 -1
  12. package/dist/Dialog/ModalDialog.d.ts +5 -0
  13. package/dist/Field/Field.d.ts +4 -2
  14. package/dist/Label/Label.d.ts +2 -1
  15. package/dist/Provider/MarigoldProvider.d.ts +3 -0
  16. package/dist/Provider/index.d.ts +3 -0
  17. package/dist/Radio/Radio.d.ts +3 -0
  18. package/dist/Radio/RadioIcons.d.ts +9 -0
  19. package/dist/Select/ListBox.d.ts +8 -0
  20. package/dist/Select/ListBoxSection.d.ts +8 -0
  21. package/dist/Select/Option.d.ts +8 -0
  22. package/dist/Select/Popover.d.ts +9 -0
  23. package/dist/Select/Select.d.ts +11 -4
  24. package/dist/Stack/Stack.d.ts +1 -3
  25. package/dist/Textarea/Textarea.d.ts +2 -1
  26. package/dist/components.cjs.development.js +868 -357
  27. package/dist/components.cjs.development.js.map +1 -1
  28. package/dist/components.cjs.production.min.js +1 -1
  29. package/dist/components.cjs.production.min.js.map +1 -1
  30. package/dist/components.esm.js +837 -359
  31. package/dist/components.esm.js.map +1 -1
  32. package/dist/index.d.ts +4 -0
  33. package/package.json +18 -3
  34. package/src/ActionGroup/ActionGroup.stories.mdx +62 -0
  35. package/src/ActionGroup/ActionGroup.test.tsx +83 -0
  36. package/src/ActionGroup/ActionGroup.tsx +43 -0
  37. package/src/ActionGroup/index.ts +1 -0
  38. package/src/Alert/Alert.stories.mdx +28 -38
  39. package/src/Alert/Alert.test.tsx +1 -1
  40. package/src/Alert/Alert.tsx +11 -33
  41. package/src/Badge/Badge.stories.mdx +48 -34
  42. package/src/Badge/Badge.test.tsx +7 -15
  43. package/src/Badge/Badge.tsx +1 -2
  44. package/src/Box/Box.stories.mdx +322 -26
  45. package/src/Box/Box.tsx +58 -50
  46. package/src/Button/Button.stories.mdx +54 -166
  47. package/src/Button/Button.test.tsx +48 -8
  48. package/src/Button/Button.tsx +47 -18
  49. package/src/Card/Card.stories.mdx +49 -0
  50. package/src/Card/Card.test.tsx +66 -0
  51. package/src/Card/Card.tsx +36 -0
  52. package/src/Card/index.ts +1 -0
  53. package/src/Checkbox/Checkbox.stories.mdx +76 -71
  54. package/src/Checkbox/Checkbox.test.tsx +70 -24
  55. package/src/Checkbox/Checkbox.tsx +68 -49
  56. package/src/Checkbox/CheckboxIcons.tsx +49 -0
  57. package/src/Column/Column.stories.mdx +39 -64
  58. package/src/Column/Column.test.tsx +8 -0
  59. package/src/Column/Column.tsx +12 -2
  60. package/src/Columns/Columns.stories.mdx +58 -240
  61. package/src/Container/Container.stories.mdx +8 -25
  62. package/src/Dialog/Dialog.stories.mdx +65 -56
  63. package/src/Dialog/Dialog.test.tsx +64 -24
  64. package/src/Dialog/Dialog.tsx +64 -12
  65. package/src/Dialog/ModalDialog.tsx +47 -0
  66. package/src/Divider/Divider.stories.mdx +28 -34
  67. package/src/Field/Field.stories.mdx +88 -48
  68. package/src/Field/Field.test.tsx +31 -40
  69. package/src/Field/Field.tsx +26 -21
  70. package/src/Heading/Heading.stories.mdx +30 -82
  71. package/src/Hidden/Hidden.stories.mdx +29 -54
  72. package/src/Image/Image.stories.mdx +26 -30
  73. package/src/Input/Input.stories.mdx +52 -36
  74. package/src/Label/Label.stories.mdx +47 -29
  75. package/src/Label/Label.test.tsx +15 -1
  76. package/src/Label/Label.tsx +20 -7
  77. package/src/Link/Link.stories.mdx +36 -29
  78. package/src/Menu/Menu.stories.mdx +71 -39
  79. package/src/Menu/Menu.test.tsx +4 -4
  80. package/src/Menu/Menu.tsx +12 -14
  81. package/src/MenuItem/MenuItem.stories.mdx +32 -27
  82. package/src/MenuItem/MenuItem.test.tsx +15 -11
  83. package/src/MenuItem/MenuItem.tsx +7 -10
  84. package/src/Message/Message.stories.mdx +35 -35
  85. package/src/Message/Message.tsx +2 -10
  86. package/src/Provider/MarigoldProvider.test.tsx +126 -0
  87. package/src/Provider/MarigoldProvider.tsx +29 -0
  88. package/src/Provider/index.ts +3 -0
  89. package/src/Radio/Radio.stories.mdx +78 -92
  90. package/src/Radio/Radio.test.tsx +57 -15
  91. package/src/Radio/Radio.tsx +71 -51
  92. package/src/Radio/RadioIcons.tsx +39 -0
  93. package/src/Select/ListBox.tsx +39 -0
  94. package/src/Select/ListBoxSection.tsx +40 -0
  95. package/src/Select/Option.tsx +48 -0
  96. package/src/Select/Popover.tsx +50 -0
  97. package/src/Select/Select.stories.mdx +70 -36
  98. package/src/Select/Select.test.tsx +279 -35
  99. package/src/Select/Select.tsx +151 -18
  100. package/src/Slider/Slider.stories.mdx +22 -49
  101. package/src/Stack/Stack.stories.mdx +40 -94
  102. package/src/Stack/Stack.test.tsx +84 -65
  103. package/src/Stack/Stack.tsx +25 -41
  104. package/src/Text/Text.stories.mdx +52 -52
  105. package/src/Text/Text.tsx +13 -14
  106. package/src/Textarea/Textarea.stories.mdx +65 -56
  107. package/src/Textarea/Textarea.test.tsx +4 -5
  108. package/src/Textarea/Textarea.tsx +28 -37
  109. package/src/ValidationMessage/ValidationMessage.stories.mdx +26 -26
  110. package/src/ValidationMessage/ValidationMessage.test.tsx +4 -4
  111. package/src/ValidationMessage/ValidationMessage.tsx +11 -12
  112. package/src/index.ts +5 -0
@@ -0,0 +1,47 @@
1
+ import React, { RefObject } from 'react';
2
+ import {
3
+ useOverlay,
4
+ usePreventScroll,
5
+ useModal,
6
+ OverlayProps,
7
+ } from '@react-aria/overlays';
8
+ import { useDialog } from '@react-aria/dialog';
9
+ import { FocusScope } from '@react-aria/focus';
10
+ import { AriaDialogProps } from '@react-types/dialog';
11
+
12
+ import { Box } from '../Box';
13
+
14
+ export type ModalDialogProps = OverlayProps & AriaDialogProps;
15
+
16
+ export const ModalDialog: React.FC<ModalDialogProps> = ({
17
+ children,
18
+ ...props
19
+ }) => {
20
+ // Handle interacting outside the dialog and pressing
21
+ // the Escape key to close the modal.
22
+ const ref = React.useRef<HTMLElement>() as RefObject<HTMLElement>;
23
+ const { overlayProps, underlayProps } = useOverlay(props, ref);
24
+
25
+ // Prevent scrolling while the modal is open, and hide content
26
+ // outside the modal from screen readers.
27
+ usePreventScroll();
28
+
29
+ const { modalProps } = useModal();
30
+ const { dialogProps } = useDialog(props, ref);
31
+
32
+ return (
33
+ <Box variant="dialog.modalWrapper" {...underlayProps}>
34
+ <FocusScope contain restoreFocus autoFocus>
35
+ <Box
36
+ {...overlayProps}
37
+ {...dialogProps}
38
+ {...modalProps}
39
+ ref={ref}
40
+ variant="dialog.modalBody"
41
+ >
42
+ {children}
43
+ </Box>
44
+ </FocusScope>
45
+ </Box>
46
+ );
47
+ };
@@ -1,43 +1,37 @@
1
- import { Meta, Story, Canvas } from '@storybook/addon-docs/blocks';
1
+ import { ArgsTable, Canvas, Meta, Story } from '@storybook/addon-docs';
2
2
  import { Divider } from './Divider';
3
3
  import { Text } from '../Text';
4
4
 
5
- <Meta title="Components/Divider" />
5
+ <Meta
6
+ title="Components/Divider"
7
+ argTypes={{
8
+ variant: {
9
+ control: {
10
+ type: 'select',
11
+ },
12
+ options: ['regular', 'bold'],
13
+ description: 'Thick or thin line',
14
+ table: {
15
+ defaultValue: {
16
+ summary: 'regular',
17
+ },
18
+ },
19
+ },
20
+ }}
21
+ />
6
22
 
7
23
  # Divider
8
24
 
9
- ## Description
10
-
11
- A divider is a layout or list element to group content or separate elements.
12
- The themeSection is `divider` and the variant can be added with the variant prop which is `regular` per default.
13
-
14
- ## Properties
15
-
16
- | Property | Type | Default |
17
- | :------------------- | :------- | :-------- |
18
- | `variant` (optional) | `string` | `regular` |
19
-
20
- ## Import
21
-
22
- ```tsx
23
- import { Divider } from '@marigold/components';
24
- ```
25
-
26
- ## Usage
25
+ export const Template = args => (
26
+ <div>
27
+ <Text>Above</Text>
28
+ <Divider {...args} />
29
+ <Text>Below</Text>
30
+ </div>
31
+ );
27
32
 
28
33
  <Canvas>
29
- <Story name="Divider/regular">
30
- <div>
31
- <Text>Some text</Text>
32
- <Divider />
33
- <Text>Some other text to show regular divider</Text>
34
- </div>
35
- </Story>
36
- <Story name="Divider/bold">
37
- <div>
38
- <Text>Some text</Text>
39
- <Divider variant="bold" />
40
- <Text>Some other text to show strong divider</Text>
41
- </div>
42
- </Story>
34
+ <Story name="Default">{Template.bind({})}</Story>
43
35
  </Canvas>
36
+
37
+ <ArgsTable story="Default" />
@@ -1,57 +1,97 @@
1
- import { Meta, Story, Canvas } from '@storybook/addon-docs/blocks';
1
+ import { ArgsTable, Canvas, Meta, Story } from '@storybook/addon-docs';
2
2
  import { Field } from './Field';
3
- import { useStyles } from '@marigold/system';
4
3
 
5
- <Meta title="Components/Field" />
4
+ <Meta
5
+ title="Components/Field"
6
+ argTypes={{
7
+ htmlFor: {
8
+ control: {
9
+ type: 'text',
10
+ },
11
+ type: { required: true },
12
+ },
13
+ label: {
14
+ control: {
15
+ type: 'text',
16
+ },
17
+ type: { required: true },
18
+ },
19
+ error: {
20
+ control: {
21
+ type: 'boolean',
22
+ },
23
+ description: 'Error',
24
+ table: {
25
+ defaultValue: {
26
+ summary: false,
27
+ },
28
+ },
29
+ },
30
+ errorMessage: {
31
+ control: {
32
+ type: 'text',
33
+ },
34
+ description: 'Error Message',
35
+ },
36
+ required: {
37
+ control: {
38
+ type: 'boolean',
39
+ },
40
+ options: [true, false],
41
+ table: {
42
+ defaultValue: {
43
+ summary: false,
44
+ },
45
+ },
46
+ },
47
+ disabled: {
48
+ control: {
49
+ type: 'boolean',
50
+ },
51
+ options: [true, false],
52
+ table: {
53
+ defaultValue: {
54
+ summary: false,
55
+ },
56
+ },
57
+ },
58
+ type: {
59
+ control: {
60
+ type: 'select',
61
+ },
62
+ options: [
63
+ 'date',
64
+ 'datetime-local',
65
+ 'email',
66
+ 'month',
67
+ 'number',
68
+ 'password',
69
+ 'search',
70
+ 'tel',
71
+ 'text',
72
+ 'time',
73
+ 'time',
74
+ 'url',
75
+ 'week',
76
+ ],
77
+ type: { required: true },
78
+ table: {
79
+ defaultValue: {
80
+ summary: 'text',
81
+ },
82
+ },
83
+ },
84
+ }}
85
+ />
6
86
 
7
87
  # Field
8
88
 
9
- ## Description
10
-
11
- With the Field component you can add a HTML `<label>` and `<input>` element to your form.
12
- The element uses always the themeSection with the name: `field` in your given theme. The variant in your section can be added with the variant prop.
13
- The default variant is `default`.
14
-
15
- ## Properties
16
-
17
- | Property | Type | Default |
18
- | :------------------- | :----------------------------------------------------------------------------------------- | :-------- |
19
- | `variant` (optional) | `string` | `default` |
20
- | `htmlFor` | `string` | |
21
- | `label` | `string` | |
22
- | `error` (optional) | `string` | |
23
- | `type` | `date, datetime-local, email, month, number, password, search, tel, text, time, url, week` | `text` |
24
-
25
- ## Import
26
-
27
- ```tsx
28
- import { Field } from '@marigold/components';
29
- ```
30
-
31
- ## Usage
89
+ export const Template = args => (
90
+ <Field htmlFor="id" label="A label" type="text" {...args} />
91
+ );
32
92
 
33
93
  <Canvas>
34
- <Story name="Field1">
35
- <div>
36
- <Field label="Firstname" htmlFor="myId" />
37
- <br />
38
- <Field label="Name" htmlFor="myId" error="Validation message" />
39
- </div>
40
- </Story>
94
+ <Story name="Default">{Template.bind({})}</Story>
41
95
  </Canvas>
42
96
 
43
- <Canvas>
44
- <Story name="Field2">
45
- <div>
46
- <Field
47
- label="Pick your date"
48
- type="date"
49
- htmlFor="myId"
50
- error="ERROR!"
51
- className={useStyles({ color: '#dd4142' })}
52
- />
53
- <br />
54
- <Field label="Choose the week" type="week" htmlFor="myId" />
55
- </div>
56
- </Story>
57
- </Canvas>
97
+ <ArgsTable story="Default" />
@@ -2,7 +2,6 @@ import React from 'react';
2
2
  import { render, screen } from '@testing-library/react';
3
3
  import { ThemeProvider } from '@marigold/system';
4
4
  import { Field } from './Field';
5
- import { useStyles } from '@marigold/system';
6
5
 
7
6
  const theme = {
8
7
  field: {
@@ -15,28 +14,6 @@ const theme = {
15
14
  },
16
15
  };
17
16
 
18
- test('supports default variant and themeSection', () => {
19
- render(
20
- <ThemeProvider theme={theme}>
21
- <Field htmlFor="myId" label="label" />
22
- </ThemeProvider>
23
- );
24
- const field = screen.getByText(/label/);
25
-
26
- expect(field).toHaveStyle(`padding: 4px`);
27
- });
28
-
29
- test('accepts other variant than default', () => {
30
- render(
31
- <ThemeProvider theme={theme}>
32
- <Field htmlFor="myId" label="inputField" variant="inputField" />
33
- </ThemeProvider>
34
- );
35
- const inputField = screen.getByText(/inputField/);
36
-
37
- expect(inputField).toHaveStyle(`padding: 8px`);
38
- });
39
-
40
17
  test('renders correct HTML element', () => {
41
18
  render(
42
19
  <ThemeProvider theme={theme}>
@@ -56,34 +33,48 @@ test('supports label prop', () => {
56
33
  });
57
34
 
58
35
  test('supports htmlFor prop', () => {
59
- render(<Field htmlFor="myId" label="Name" error="Validation error" />);
36
+ render(<Field htmlFor="myId" label="Name" />);
60
37
  const field = screen.getByText(/Name/);
61
38
 
62
39
  expect(field).toHaveAttribute('for');
63
40
  });
64
41
 
65
- test('supports error prop', () => {
66
- render(<Field htmlFor="myId" label="label" error="Validation error" />);
67
- const field = screen.getByText(/Validation/);
42
+ test('supports required prop', () => {
43
+ render(<Field htmlFor="myId" label="label" required />);
44
+ const fieldLabel = screen.getByText(/label/);
68
45
 
69
- expect(field).toBeDefined();
46
+ expect(fieldLabel.nextSibling).toBeDefined();
47
+ expect(fieldLabel.nextSibling instanceof SVGElement).toBeTruthy();
70
48
  });
71
49
 
72
- test('accepts custom styles prop className', () => {
73
- const TestComponent: React.FC = ({ children, ...props }) => {
74
- const classNames = useStyles({ css: { fontSize: '8px' } });
75
- return (
76
- <Field htmlFor="myId" label="label" className={classNames} {...props} />
77
- );
78
- };
50
+ test('supports error and errorMessage prop', () => {
51
+ render(
52
+ <Field htmlFor="myId" label="label" error errorMessage="Validation error" />
53
+ );
79
54
 
80
- const { getByText } = render(
55
+ const errorMessage = screen.getByText(/Validation/);
56
+ expect(errorMessage).toBeDefined();
57
+ });
58
+
59
+ test('supports disabled prop', () => {
60
+ render(<Field htmlFor="myId" label="label" disabled />);
61
+ const fieldLabel = screen.getByText(/label/);
62
+ expect(fieldLabel.nextSibling).toHaveAttribute('disabled');
63
+ });
64
+
65
+ test('accepts custom styles prop className', () => {
66
+ render(
81
67
  <ThemeProvider theme={theme}>
82
- <TestComponent />
68
+ <Field
69
+ htmlFor="myId"
70
+ label="label"
71
+ className="custom-class-name"
72
+ title="field"
73
+ data-testid="field"
74
+ />
83
75
  </ThemeProvider>
84
76
  );
85
- const testelem = getByText('label');
86
- const field = getComputedStyle(testelem);
77
+ const field = screen.getByTestId(/field/);
87
78
 
88
- expect(field.fontSize).toEqual('8px');
79
+ expect(field.className).toMatch('custom-class-name');
89
80
  });
@@ -1,6 +1,5 @@
1
1
  import React from 'react';
2
- import { useStyles } from '@marigold/system';
3
- import { Exclamation, Required } from '@marigold/icons';
2
+ import { Exclamation } from '@marigold/icons';
4
3
  import { ComponentProps } from '@marigold/types';
5
4
 
6
5
  import { Input } from '../Input';
@@ -8,42 +7,48 @@ import { Label } from '../Label';
8
7
  import { ValidationMessage } from '../ValidationMessage';
9
8
 
10
9
  export type FieldProps = {
11
- variant?: string;
12
10
  htmlFor: string;
13
11
  label: string;
14
- error?: string;
12
+ required?: boolean;
13
+ error?: boolean;
14
+ errorMessage?: string;
15
+ disabled?: boolean;
15
16
  } & ComponentProps<'input'>;
16
17
 
17
18
  export const Field: React.FC<FieldProps> = ({
18
- variant = 'default',
19
19
  type = 'text',
20
- className = '',
20
+ className,
21
21
  htmlFor,
22
22
  label,
23
+ required,
23
24
  error,
25
+ errorMessage,
26
+ disabled,
24
27
  ...props
25
28
  }) => {
26
- const labelClassName = useStyles({
27
- variant: `field.${variant}`,
28
- className,
29
- });
30
- const errorClassName = useStyles({ css: { color: 'red60' } });
31
-
32
29
  return (
33
- <div>
34
- <Label className={labelClassName} htmlFor={htmlFor}>
30
+ <>
31
+ <Label
32
+ variant={disabled ? 'disabled' : 'above'}
33
+ htmlFor={htmlFor}
34
+ required={required}
35
+ >
35
36
  {label}
36
- {error ? <Required size={16} className={errorClassName} /> : ''}
37
37
  </Label>
38
- <Input {...props} type={type} id={htmlFor} />
39
- {error ? (
38
+ <Input
39
+ {...props}
40
+ type={type}
41
+ id={htmlFor}
42
+ disabled={disabled}
43
+ variant={error ? 'error' : 'default'}
44
+ className={className}
45
+ />
46
+ {error && errorMessage && (
40
47
  <ValidationMessage>
41
48
  <Exclamation size={16} />
42
- {error}
49
+ {errorMessage}
43
50
  </ValidationMessage>
44
- ) : (
45
- ''
46
51
  )}
47
- </div>
52
+ </>
48
53
  );
49
54
  };
@@ -1,91 +1,39 @@
1
- import { Meta, Story, Canvas } from '@storybook/addon-docs/blocks';
1
+ import { ArgsTable, Canvas, Meta, Story } from '@storybook/addon-docs';
2
2
  import { Heading } from './Heading';
3
3
  import { Text } from '../Text';
4
4
 
5
- <Meta title="Components/Heading" />
5
+ <Meta
6
+ title="Components/Heading"
7
+ argTypes={{
8
+ variant: {
9
+ control: {
10
+ type: 'select',
11
+ },
12
+ options: ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'],
13
+ description: 'HTML element style',
14
+ table: {
15
+ defaultValue: {
16
+ summary: 'h2',
17
+ },
18
+ },
19
+ },
20
+ }}
21
+ />
6
22
 
7
23
  # Heading
8
24
 
9
- ## Description
10
-
11
- Use the Heading component for headings of texts. Predefined variants are `h1`, `h2`, `h3`, `h4`, `h5` and `h6`.
12
-
13
- ## Properties
14
-
15
- | Property | Type | Default |
16
- | :-------- | :--------------------------------- | :------ |
17
- | `as` | `h1`, `h2`, `h3`, `h4`, `h5`, `h6` | `h2` |
18
- | `variant` | `string` | `h2` |
19
-
20
- ## Import
21
-
22
- ```tsx
23
- import { Heading } from '@marigold/components';
24
- ```
25
-
26
- ## Usage
25
+ export const Template = args => (
26
+ <div>
27
+ <Heading {...args}>Heading</Heading>
28
+ <Text>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse
29
+ dignissim dapibus elit, vel egestas felis pharetra non. Cras
30
+ malesuada, massa nec ultricies efficitur, lectus ante consequat magna,
31
+ a porttitor massa ex ut quam.</Text>
32
+ </div>
33
+ );
27
34
 
28
35
  <Canvas>
29
- <Story name="Headings">
30
- <div>
31
- <Heading as="h2" variant="h1">
32
- H1 amazing heading
33
- </Heading>
34
- <Text as="p" variant="heading">
35
- Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
36
- eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
37
- voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet
38
- clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit
39
- amet.
40
- </Text>
41
- <Heading>H2 amazing heading</Heading>
42
- <Text as="p" variant="heading">
43
- Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
44
- eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
45
- voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet
46
- clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit
47
- amet.
48
- </Text>
49
- <Heading as="h3" variant="h3">
50
- H3 amazing heading
51
- </Heading>
52
- <Text as="p" variant="heading">
53
- Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
54
- eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
55
- voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet
56
- clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit
57
- amet.
58
- </Text>
59
- <Heading as="h4" variant="h4">
60
- H4 amazing heading
61
- </Heading>
62
- <Text as="p" variant="heading">
63
- Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
64
- eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
65
- voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet
66
- clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit
67
- amet.
68
- </Text>
69
- <Heading as="h5" variant="h5">
70
- H5 amazing heading
71
- </Heading>
72
- <Text as="p" variant="heading">
73
- Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
74
- eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
75
- voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet
76
- clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit
77
- amet.
78
- </Text>
79
- <Heading as="h6" variant="h6">
80
- H6 amazing heading
81
- </Heading>
82
- <Text as="p" variant="heading">
83
- Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
84
- eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
85
- voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet
86
- clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit
87
- amet.
88
- </Text>
89
- </div>
90
- </Story>
36
+ <Story name="Default">{Template.bind({})}</Story>
91
37
  </Canvas>
38
+
39
+ <ArgsTable story="Default" />
@@ -1,64 +1,39 @@
1
- import { Meta, Story, Canvas } from '@storybook/addon-docs/blocks';
2
- import { Button } from '../Button';
1
+ import { ArgsTable, Canvas, Meta, Story } from '@storybook/addon-docs';
3
2
  import { Hidden } from './Hidden';
4
3
  import { Text } from '../Text';
5
- import { useState } from 'react';
6
4
 
7
- <Meta title="Components/Hidden" />
5
+ <Meta
6
+ title="Components/Hidden"
7
+ argTypes={{
8
+ show: {
9
+ control: {
10
+ type: 'boolean',
11
+ },
12
+ options: [true, false],
13
+ description: 'Show or hide',
14
+ table: {
15
+ defaultValue: {
16
+ summary: false,
17
+ },
18
+ },
19
+ },
20
+ }}
21
+ />
8
22
 
9
23
  # Hidden
10
24
 
11
- ## Description
12
-
13
- With the Hidden component you can hide elements or components. E.g. to hide some text in specific cases, for groups or platforms.
14
-
15
- ## Properties
16
-
17
- | Property | Type | Default |
18
- | :---------------- | :-------- | :------ |
19
- | `show` (optional) | `boolean` | `false` |
20
-
21
- ## Import
22
-
23
- ```tsx
24
- import { Hidden } from '@marigold/components';
25
- ```
26
-
27
- ## Usage
25
+ export const Template = args => (
26
+ <div>
27
+ <Text>Change the "show" switch to "true"</Text>
28
+ <Hidden {...args}>
29
+ <br />
30
+ <Text>Hello here I am!</Text>
31
+ </Hidden>
32
+ </div>
33
+ );
28
34
 
29
35
  <Canvas>
30
- <Story name="HiddenText">
31
- <div>
32
- <Text>Hello, I am visible</Text>
33
- <Hidden>
34
- <Text>Hello, I am invisible</Text>
35
- </Hidden>
36
- </div>
37
- </Story>
36
+ <Story name="Default">{Template.bind({})}</Story>
38
37
  </Canvas>
39
38
 
40
- <Canvas>
41
- <Story name="HiddenButton">
42
- {() => {
43
- const [state, setState] = React.useState({
44
- showButton: false,
45
- });
46
- const handleToggleClick = () => {
47
- setState(prevState => ({
48
- showButton: !prevState.showButton,
49
- }));
50
- };
51
- return (
52
- <div>
53
- <Button variant="primary.small" onClick={handleToggleClick}>
54
- {state.showButton ? 'Hide Text' : 'Show Text'}
55
- </Button>
56
- <Hidden show={state.showButton}>
57
- <br />
58
- <Text>Hello, now I am visible</Text>
59
- </Hidden>
60
- </div>
61
- );
62
- }}
63
- </Story>
64
- </Canvas>
39
+ <ArgsTable story="Default" />