@automattic/vip-design-system 0.26.1 → 0.26.3

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 (38) hide show
  1. package/.storybook/preview.js +6 -0
  2. package/build/system/Accordion/Accordion.js +36 -25
  3. package/build/system/Form/Checkbox.stories.js +85 -0
  4. package/build/system/Form/Input.js +55 -31
  5. package/build/system/Form/Input.stories.js +34 -4
  6. package/build/system/Form/MultiSelect.js +38 -0
  7. package/build/system/Form/Radio.stories.js +95 -0
  8. package/build/system/Form/Select.stories.js +1 -1
  9. package/build/system/Form/Textarea.js +14 -53
  10. package/build/system/Form/Textarea.stories.js +67 -0
  11. package/build/system/Form/Validation.js +17 -10
  12. package/build/system/NewConfirmationDialog/NewConfirmationDialog.stories.js +1 -1
  13. package/build/system/NewDialog/NewDialog.stories.js +1 -1
  14. package/build/system/NewForm/index.js +12 -0
  15. package/build/system/NewTabs/Tabs.stories.js +11 -5
  16. package/build/system/NewTabs/TabsList.js +1 -1
  17. package/build/system/ResourceList/ResourceList.js +1 -1
  18. package/build/system/Tabs/Tabs.stories.js +1 -1
  19. package/build/system/UsageChart/UsageChart.js +60 -0
  20. package/build/system/UsageChart/index.js +7 -0
  21. package/build/system/theme/index.js +7 -0
  22. package/package.json +1 -1
  23. package/src/system/Accordion/Accordion.js +8 -5
  24. package/src/system/Form/Checkbox.stories.jsx +54 -0
  25. package/src/system/Form/Input.js +44 -27
  26. package/src/system/Form/Input.stories.jsx +29 -4
  27. package/src/system/Form/Radio.stories.jsx +66 -0
  28. package/src/system/Form/Select.stories.jsx +1 -1
  29. package/src/system/Form/Textarea.js +4 -49
  30. package/src/system/Form/Textarea.stories.jsx +40 -0
  31. package/src/system/Form/Validation.js +14 -8
  32. package/src/system/NewConfirmationDialog/NewConfirmationDialog.stories.jsx +1 -1
  33. package/src/system/NewDialog/NewDialog.stories.jsx +1 -1
  34. package/src/system/NewForm/index.js +4 -1
  35. package/src/system/NewTabs/Tabs.stories.jsx +7 -3
  36. package/src/system/NewTabs/TabsList.js +1 -1
  37. package/src/system/Tabs/Tabs.stories.jsx +1 -1
  38. package/src/system/theme/index.js +8 -0
@@ -13,30 +13,36 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
13
13
 
14
14
  var _md = require("react-icons/md");
15
15
 
16
- var _ = require("..");
17
-
18
16
  var _jsxRuntime = require("theme-ui/jsx-runtime");
19
17
 
20
- var _excluded = ["children", "isValid"];
18
+ var _excluded = ["children", "isValid", "describedId"];
21
19
 
20
+ /**
21
+ * Internal dependencies
22
+ */
22
23
  var Validation = function Validation(_ref) {
23
24
  var children = _ref.children,
24
25
  isValid = _ref.isValid,
26
+ _ref$describedId = _ref.describedId,
27
+ describedId = _ref$describedId === void 0 ? null : _ref$describedId,
25
28
  props = (0, _objectWithoutPropertiesLoose2["default"])(_ref, _excluded);
26
29
  var Icon = isValid ? _md.MdCheckCircle : _md.MdErrorOutline;
27
- return (0, _jsxRuntime.jsxs)(_.Heading, (0, _extends2["default"])({
28
- variant: "h5",
29
- as: "p",
30
+ var IconLabel = isValid ? 'Valid' : 'Invalid';
31
+ return (0, _jsxRuntime.jsxs)("p", (0, _extends2["default"])({
30
32
  sx: {
31
33
  color: isValid ? 'success' : 'error',
32
34
  display: 'flex',
33
- alignItems: 'center'
34
- }
35
+ alignItems: 'center',
36
+ m: 0,
37
+ fontSize: 1
38
+ },
39
+ id: describedId ? "describe-" + describedId + "-validation" : undefined
35
40
  }, props, {
36
41
  children: [(0, _jsxRuntime.jsx)(Icon, {
37
42
  sx: {
38
43
  mr: 1
39
- }
44
+ },
45
+ "aria-label": IconLabel
40
46
  }), children]
41
47
  }));
42
48
  };
@@ -44,5 +50,6 @@ var Validation = function Validation(_ref) {
44
50
  exports.Validation = Validation;
45
51
  Validation.propTypes = {
46
52
  children: _propTypes["default"].node,
47
- isValid: _propTypes["default"].bool
53
+ isValid: _propTypes["default"].bool,
54
+ describedId: _propTypes["default"].string
48
55
  };
@@ -15,7 +15,7 @@ var _jsxRuntime = require("theme-ui/jsx-runtime");
15
15
  * Internal dependencies
16
16
  */
17
17
  var _default = {
18
- title: 'NewConfirmationDialog',
18
+ title: 'Dialog/NewConfirmationDialog',
19
19
  component: _.NewConfirmationDialog
20
20
  };
21
21
  exports["default"] = _default;
@@ -32,7 +32,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
32
32
  * Internal dependencies
33
33
  */
34
34
  var _default = {
35
- title: 'NewDialog',
35
+ title: 'Dialog/NewDialog',
36
36
  component: NewDialog.Root
37
37
  };
38
38
  exports["default"] = _default;
@@ -7,8 +7,20 @@ var _FormSelect = require("./FormSelect");
7
7
 
8
8
  var _FormAutocomplete = require("./FormAutocomplete");
9
9
 
10
+ var _Textarea = require("../Form/Textarea");
11
+
12
+ exports.Textarea = _Textarea.Textarea;
13
+
14
+ var _Input = require("../Form/Input");
15
+
16
+ exports.Input = _Input.Input;
17
+
10
18
  var _Form = require("./Form");
11
19
 
20
+ var _Label = require("../Form/Label");
21
+
22
+ exports.Label = _Label.Label;
23
+
12
24
  /**
13
25
  * Internal dependencies
14
26
  */
@@ -11,7 +11,7 @@ var _jsxRuntime = require("theme-ui/jsx-runtime");
11
11
  * Internal dependencies
12
12
  */
13
13
  var _default = {
14
- title: 'NewTabs',
14
+ title: 'Tabs',
15
15
  component: _.NewTabs
16
16
  };
17
17
  exports["default"] = _default;
@@ -37,16 +37,22 @@ var Default = function Default() {
37
37
  })]
38
38
  }), (0, _jsxRuntime.jsx)(_.TabsContent, {
39
39
  value: "all",
40
- children: (0, _jsxRuntime.jsx)(_.Text, {
41
- children: "All content"
40
+ children: (0, _jsxRuntime.jsxs)(_.Text, {
41
+ children: ["All content ", (0, _jsxRuntime.jsx)("a", {
42
+ href: "https://google.com",
43
+ children: "https://google.com"
44
+ })]
42
45
  })
43
46
  }), (0, _jsxRuntime.jsx)(_.TabsContent, {
44
47
  value: "live",
45
48
  children: "Live content"
46
49
  }), (0, _jsxRuntime.jsx)(_.TabsContent, {
47
50
  value: "dev",
48
- children: (0, _jsxRuntime.jsx)(_.Text, {
49
- children: "In Development content"
51
+ children: (0, _jsxRuntime.jsxs)(_.Text, {
52
+ children: ["In Development content ", (0, _jsxRuntime.jsx)("button", {
53
+ type: "button",
54
+ children: "Hey I am a button"
55
+ }), ' ']
50
56
  })
51
57
  })]
52
58
  });
@@ -36,7 +36,7 @@ var TabsList = function TabsList(_ref) {
36
36
  borderColor: 'border',
37
37
  display: 'flex'
38
38
  }, sx),
39
- title: title,
39
+ "aria-label": title,
40
40
  children: children
41
41
  });
42
42
  };
@@ -53,7 +53,7 @@ var StyledListItem = function StyledListItem(props) {
53
53
  sx: {
54
54
  py: 2,
55
55
  borderBottom: '1px solid',
56
- borderColor: 'borders.2',
56
+ borderColor: 'border',
57
57
  listStyleType: 'none',
58
58
  margin: 0,
59
59
  px: 0
@@ -11,7 +11,7 @@ var _jsxRuntime = require("theme-ui/jsx-runtime");
11
11
  * Internal dependencies
12
12
  */
13
13
  var _default = {
14
- title: 'Tabs',
14
+ title: 'Deprecated/Tabs',
15
15
  component: _.Tabs
16
16
  };
17
17
  exports["default"] = _default;
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.UsageChart = void 0;
5
+
6
+ var _framerMotion = require("framer-motion");
7
+
8
+ var _propTypes = _interopRequireDefault(require("prop-types"));
9
+
10
+ var _jsxRuntime = require("theme-ui/jsx-runtime");
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
13
+
14
+ /**
15
+ * External dependencies
16
+ */
17
+ var UsageChart = function UsageChart(_ref) {
18
+ var total = _ref.total,
19
+ max = _ref.max,
20
+ _ref$variant = _ref.variant,
21
+ variant = _ref$variant === void 0 ? 'primary' : _ref$variant;
22
+ var width = total / max * 100 + '%';
23
+ var formattedTotal = total;
24
+
25
+ if (total > 1000000) {
26
+ formattedTotal = (total / 1000000).toFixed(2) + "M";
27
+ } else if (total > 1000) {
28
+ formattedTotal = (total / 1000).toFixed(2) + "K";
29
+ }
30
+
31
+ return (0, _jsxRuntime.jsx)("div", {
32
+ sx: {
33
+ height: variant === 'primary' ? 32 : 8,
34
+ overflow: 'hidden',
35
+ backgroundColor: variant === 'primary' ? 'border' : 'transparent'
36
+ },
37
+ children: (0, _jsxRuntime.jsx)(_framerMotion.motion.div, {
38
+ initial: {
39
+ width: 0
40
+ },
41
+ animate: {
42
+ width: width
43
+ },
44
+ transition: {
45
+ duration: 0.7
46
+ },
47
+ sx: {
48
+ height: '100%',
49
+ backgroundColor: variant === 'primary' ? 'primary' : 'grey.40'
50
+ }
51
+ })
52
+ });
53
+ };
54
+
55
+ exports.UsageChart = UsageChart;
56
+ UsageChart.propTypes = {
57
+ total: _propTypes["default"].number,
58
+ max: _propTypes["default"].number,
59
+ variant: _propTypes["default"].string
60
+ };
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+
5
+ var _UsageChart = require("./UsageChart");
6
+
7
+ exports.UsageChart = _UsageChart.UsageChart;
@@ -165,6 +165,13 @@ var _default = {
165
165
  high: // eslint-disable-next-line max-len
166
166
  '0px 2.76726px 2.21381px rgba(0, 0, 0, 0.0196802), 0px 6.6501px 5.32008px rgba(0, 0, 0, 0.0282725), 0px 12.5216px 10.0172px rgba(0, 0, 0, 0.035), 0px 22.3363px 17.869px rgba(0, 0, 0, 0.0417275), 0px 41.7776px 33.4221px rgba(0, 0, 0, 0.0503198), 0px 100px 80px rgba(0, 0, 0, 0.07)'
167
167
  },
168
+ accordion: {
169
+ background: {
170
+ open: (0, _getColor.getVariants)('color.gold')['7'],
171
+ closed: 'transparent',
172
+ hover: (0, _getColor.getVariants)('color.gold')['7']
173
+ }
174
+ },
168
175
  tag: {
169
176
  gold: (0, _getColor.getVariants)('tag.gold')
170
177
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automattic/vip-design-system",
3
- "version": "0.26.1",
3
+ "version": "0.26.3",
4
4
  "main": "build/system/index.js",
5
5
  "scripts": {
6
6
  "build-storybook": "build-storybook",
@@ -81,24 +81,27 @@ export const Trigger = React.forwardRef(
81
81
  fontWeight: 600,
82
82
  textTransform: 'uppercase',
83
83
 
84
- '&[data-state="closed"]': { backgroundColor: 'transparent' },
84
+ '&[data-state="closed"]': {
85
+ backgroundColor: ( { accordion } ) => accordion.background.closed,
86
+ },
85
87
  '&[data-state="open"]': {
86
- backgroundColor: 'backgroundSecondary',
87
- borderBottom: theme => `1px solid ${ theme.colors.border }`,
88
+ backgroundColor: ( { accordion } ) => accordion.background.open,
89
+ borderBottom: ( { colors } ) => `1px solid ${ colors.border }`,
90
+ '.vip-accordion-trigger-indicator': { transform: 'rotate(270deg)' },
88
91
  },
89
- '&:hover': { backgroundColor: 'backgroundSecondary' },
92
+ '&:hover': { backgroundColor: ( { accordion } ) => accordion.background.hover },
90
93
  } }
91
94
  { ...props }
92
95
  ref={ forwardedRef }
93
96
  >
94
97
  { children }
95
98
  <MdChevronRight
99
+ className="vip-accordion-trigger-indicator"
96
100
  sx={ {
97
101
  fontSize: 3,
98
102
  color: 'text',
99
103
  transform: 'rotate(90deg)',
100
104
  transition: 'transform 300ms cubic-bezier(0.87, 0, 0.13, 1)',
101
- '[data-state=open] &': { transform: 'rotate(270deg)' },
102
105
  } }
103
106
  aria-hidden
104
107
  />
@@ -0,0 +1,54 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import { useState } from 'react';
5
+
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+ import { Form } from '..';
10
+ import { Checkbox } from './Checkbox';
11
+ import { Label } from './Label';
12
+ import { Flex } from '../Flex';
13
+
14
+ export default {
15
+ title: 'Form/Checkbox',
16
+ component: Checkbox,
17
+ };
18
+
19
+ export const Default = () => {
20
+ const [ checked, setChecked ] = useState( true );
21
+ const [ checked2, setChecked2 ] = useState( false );
22
+
23
+ return (
24
+ <Form.Root>
25
+ <fieldset>
26
+ <legend>Tell me your prefereces</legend>
27
+
28
+ <Flex sx={ { alignItems: 'center' } }>
29
+ <Checkbox
30
+ id="check1"
31
+ checked={ checked }
32
+ aria-labelledby="label-check1"
33
+ onCheckedChange={ setChecked }
34
+ />
35
+ <Label sx={ { m: 0, ml: 2 } } htmlFor="check1" id="label-check1">
36
+ This option
37
+ </Label>
38
+ </Flex>
39
+
40
+ <Flex sx={ { alignItems: 'center' } }>
41
+ <Checkbox
42
+ id="check2"
43
+ checked={ checked2 }
44
+ aria-labelledby="label-check2"
45
+ onCheckedChange={ setChecked2 }
46
+ />
47
+ <Label sx={ { m: 0, ml: 2 } } htmlFor="check2" id="label-check2">
48
+ This option too
49
+ </Label>
50
+ </Flex>
51
+ </fieldset>
52
+ </Form.Root>
53
+ );
54
+ };
@@ -10,45 +10,61 @@ import PropTypes from 'prop-types';
10
10
  * Internal dependencies
11
11
  */
12
12
  import { Validation, Label } from '../';
13
+ import { Input as ThemeInput } from 'theme-ui';
14
+
15
+ const RequiredLabel = () => (
16
+ <span sx={ { color: 'error', display: 'inline-block', ml: 2, fontSize: 1 } }>(Required)</span>
17
+ );
18
+
19
+ const inputStyles = {
20
+ unset: 'all',
21
+ border: '1px solid',
22
+ borderColor: 'border',
23
+ backgroundColor: 'card',
24
+ borderRadius: 1,
25
+ lineHeight: 'inherit',
26
+ px: 3,
27
+ py: 2,
28
+ fontSize: 2,
29
+ mb: 2,
30
+ color: 'text',
31
+ display: 'block',
32
+ width: '100%',
33
+ '&:focus': theme => theme.outline,
34
+ '&:focus-visible': theme => theme.outline,
35
+ '&:disabled': {
36
+ bg: 'backgroundSecondary',
37
+ },
38
+ '&::placeholder': {
39
+ color: 'placeholder',
40
+ },
41
+ };
13
42
 
14
43
  const Input = React.forwardRef(
15
- ( { variant, label, forLabel, hasError, required, errorMessage, ...props }, ref ) => (
44
+ ( { variant, label, forLabel, hasError, required, sx = {}, errorMessage, ...props }, ref ) => (
16
45
  <React.Fragment>
17
46
  { label && (
18
47
  <Label htmlFor={ forLabel }>
19
48
  { label }
20
- { required && '*' }
49
+ { required && <RequiredLabel /> }
21
50
  </Label>
22
51
  ) }
23
- <input
24
- { ...props }
52
+
53
+ <ThemeInput
25
54
  ref={ ref }
26
55
  id={ forLabel }
27
56
  required={ required }
28
- sx={ {
29
- border: '1px solid',
30
- borderColor: 'border',
31
- backgroundColor: 'card',
32
- borderRadius: 1,
33
- lineHeight: 'inherit',
34
- px: 3,
35
- py: 2,
36
- fontSize: 2,
37
- mb: 2,
38
- color: 'text',
39
- display: 'block',
40
- width: '100%',
41
- '&:focus': theme => theme.outline,
42
- '&:focus-visible': theme => theme.outline,
43
- '&:disabled': {
44
- bg: 'backgroundSecondary',
45
- },
46
- '&::placeholder': {
47
- color: 'placeholder',
48
- },
49
- } }
57
+ noValidate
58
+ aria-describedby={ hasError ? `describe-${ forLabel }-validation` : undefined }
59
+ sx={ { ...inputStyles, ...sx } }
60
+ { ...props }
50
61
  />
51
- { hasError && errorMessage && <Validation>{ errorMessage }</Validation> }
62
+
63
+ { hasError && errorMessage && (
64
+ <Validation isValid={ false } describedId={ forLabel }>
65
+ { errorMessage }
66
+ </Validation>
67
+ ) }
52
68
  </React.Fragment>
53
69
  )
54
70
  );
@@ -60,6 +76,7 @@ Input.propTypes = {
60
76
  required: PropTypes.bool,
61
77
  forLabel: PropTypes.string,
62
78
  errorMessage: PropTypes.string,
79
+ sx: PropTypes.object,
63
80
  };
64
81
 
65
82
  Input.displayName = 'Input';
@@ -3,11 +3,36 @@
3
3
  /**
4
4
  * Internal dependencies
5
5
  */
6
- import { Input } from '..';
6
+ import { Form } from '..';
7
7
 
8
8
  export default {
9
- title: 'Input',
10
- component: Input,
9
+ title: 'Form/Input',
11
10
  };
12
11
 
13
- export const Default = () => <Input placeholder="Your input here..." />;
12
+ export const Default = () => (
13
+ <Form.Root>
14
+ <Form.Input
15
+ placeholder="Your input here..."
16
+ label="Always add a label to inputs"
17
+ forLabel="input-simple"
18
+ />
19
+
20
+ <hr sx={ { my: 4 } } />
21
+
22
+ <Form.Input
23
+ forLabel="input-with-error"
24
+ label="Error Input"
25
+ errorMessage="Please type numeric characters only"
26
+ hasError
27
+ />
28
+
29
+ <hr sx={ { my: 4 } } />
30
+
31
+ <Form.Input forLabel="input-with-required" label="Required" required />
32
+
33
+ <hr sx={ { my: 4 } } />
34
+
35
+ <Form.Label htmlFor="input-with-custom-label">Custom Label outside the Input</Form.Label>
36
+ <Form.Input forLabel="input-with-custom-label" required />
37
+ </Form.Root>
38
+ );
@@ -0,0 +1,66 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import { useState } from 'react';
5
+
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+ import { Form } from '..';
10
+ import { Radio } from './Radio';
11
+ import { Label } from './Label';
12
+ import { Flex } from '../Flex';
13
+
14
+ export default {
15
+ title: 'Form/Radio',
16
+ component: Radio,
17
+ };
18
+
19
+ export const Default = () => {
20
+ const [ checked, setChecked ] = useState( 'a' );
21
+
22
+ return (
23
+ <Form.Root>
24
+ <p>
25
+ Per recommendation, if you have a Radio button, use a Fieldset with a legend as wrapper to
26
+ your options.{ ' ' }
27
+ <a href="https://a11y-collective.github.io/demos/en/accessible-code/form-fieldsets.html">
28
+ Reference to Form fieldsets
29
+ </a>
30
+ </p>
31
+ <fieldset>
32
+ <legend sx={ { mb: 0, fontSize: 2, fontWeight: 'bold' } }>
33
+ Apply the policy to these domains
34
+ </legend>
35
+
36
+ <Flex sx={ { alignItems: 'center' } }>
37
+ <Radio
38
+ name="includeSubdomains"
39
+ id="include-all-domains-opt"
40
+ onChange={ () => setChecked( 'a' ) }
41
+ value={ 'a' }
42
+ checked={ checked === 'a' }
43
+ />
44
+
45
+ <Label htmlFor="include-all-domains-opt" sx={ { mb: 0 } }>
46
+ All domains listed on this environment, and all subdomains
47
+ </Label>
48
+ </Flex>
49
+
50
+ <Flex sx={ { alignItems: 'center', mb: 1 } }>
51
+ <Radio
52
+ name="includeSubdomains"
53
+ id="include-subdomains-opt"
54
+ onChange={ () => setChecked( 'b' ) }
55
+ checked={ checked === 'b' }
56
+ value={ 'b' }
57
+ />
58
+
59
+ <Label id="exclude-subdomains" htmlFor="include-subdomains-opt" sx={ { mb: 0 } }>
60
+ All domains listed on this environment
61
+ </Label>
62
+ </Flex>
63
+ </fieldset>
64
+ </Form.Root>
65
+ );
66
+ };
@@ -9,7 +9,7 @@ import { useState } from 'react';
9
9
  import { Box, Dialog, DialogMenu, DialogMenuItem, DialogDivider, Select, Button } from '..';
10
10
 
11
11
  export default {
12
- title: 'Select',
12
+ title: 'Deprecated/Select',
13
13
  component: Dialog,
14
14
  };
15
15
 
@@ -4,60 +4,15 @@
4
4
  * External dependencies
5
5
  */
6
6
  import React from 'react';
7
- import PropTypes from 'prop-types';
8
7
 
9
8
  /**
10
9
  * Internal dependencies
11
10
  */
12
- import { Validation, Label } from '../';
11
+ import { Input } from './Input';
13
12
 
14
- const Textarea = React.forwardRef(
15
- ( { variant, label, forLabel, hasError, required, errorMessage, ...props }, ref ) => (
16
- <React.Fragment>
17
- { label && (
18
- <Label htmlFor={ forLabel }>
19
- { label }
20
- { required && '*' }
21
- </Label>
22
- ) }
23
- <textarea
24
- { ...props }
25
- ref={ ref }
26
- sx={ {
27
- border: '1px solid',
28
- borderColor: 'border',
29
- backgroundColor: 'card',
30
- borderRadius: 1,
31
- lineHeight: 'inherit',
32
- px: 3,
33
- py: 2,
34
- fontSize: 2,
35
- mb: 2,
36
- color: 'text',
37
- display: 'block',
38
- width: '100%',
39
- '&:focus': {
40
- borderColor: 'brand.60',
41
- outline: 'none',
42
- },
43
- '&:disabled': {
44
- backgroundColor: 'background',
45
- },
46
- } }
47
- />
48
- { hasError && errorMessage && <Validation>{ errorMessage }</Validation> }
49
- </React.Fragment>
50
- )
51
- );
52
-
53
- Textarea.propTypes = {
54
- variant: PropTypes.string,
55
- label: PropTypes.string,
56
- hasError: PropTypes.bool,
57
- required: PropTypes.bool,
58
- forLabel: PropTypes.string,
59
- errorMessage: PropTypes.string,
60
- };
13
+ const Textarea = React.forwardRef( ( props, ref ) => (
14
+ <Input ref={ ref } as="textarea" { ...props } />
15
+ ) );
61
16
 
62
17
  Textarea.displayName = 'Textarea';
63
18
 
@@ -0,0 +1,40 @@
1
+ /** @jsxImportSource theme-ui */
2
+
3
+ /**
4
+ * Internal dependencies
5
+ */
6
+ import * as Form from '../NewForm';
7
+
8
+ export default {
9
+ title: 'Form/Textarea',
10
+ argTypes: {
11
+ placeholder: {
12
+ type: { name: 'string', required: false },
13
+ control: { type: 'text' },
14
+ },
15
+ label: {
16
+ type: { name: 'string', required: false },
17
+ control: { type: 'text' },
18
+ },
19
+ },
20
+ };
21
+
22
+ const DefaultComponent = () => (
23
+ <Form.Root>
24
+ <Form.Textarea forLabel="my-text-area" rows="5" label="Regular textarea" />
25
+
26
+ <hr sx={ { my: 4 } } />
27
+
28
+ <Form.Textarea
29
+ forLabel="my-text-area-error"
30
+ rows="5"
31
+ label="Error textarea"
32
+ errorMessage="Please type numeric characters only"
33
+ required
34
+ hasError
35
+ />
36
+ </Form.Root>
37
+ );
38
+
39
+ export const Default = DefaultComponent.bind( {} );
40
+ Default.args = {};