@automattic/vip-design-system 0.9.0 → 0.9.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 (35) hide show
  1. package/build/system/Avatar/Avatar.test.js +41 -22
  2. package/build/system/Badge/Badge.test.js +73 -0
  3. package/build/system/BlankState/BlankState.js +12 -9
  4. package/build/system/BlankState/BlankState.test.js +124 -0
  5. package/build/system/Button/Button.test.js +44 -0
  6. package/build/system/Card/Card.js +5 -7
  7. package/build/system/Card/Card.test.js +78 -0
  8. package/build/system/Code/Code.js +11 -8
  9. package/build/system/Code/Code.test.js +167 -0
  10. package/build/system/Dialog/DialogContent.js +3 -1
  11. package/build/system/Form/Input.js +7 -9
  12. package/build/system/Form/Select.js +29 -12
  13. package/build/system/Form/Textarea.js +5 -7
  14. package/build/system/Timeline/index.js +11 -9
  15. package/build/system/index.js +4 -0
  16. package/build/system/theme/index.js +1 -1
  17. package/package.json +15 -4
  18. package/src/system/Avatar/Avatar.test.js +9 -10
  19. package/src/system/Badge/Badge.test.js +30 -0
  20. package/src/system/BlankState/BlankState.js +13 -5
  21. package/src/system/BlankState/BlankState.test.js +58 -0
  22. package/src/system/Button/Button.test.js +21 -0
  23. package/src/system/Card/Card.js +16 -14
  24. package/src/system/Card/Card.test.js +33 -0
  25. package/src/system/Code/Code.js +12 -9
  26. package/src/system/Code/Code.stories.js +2 -0
  27. package/src/system/Code/Code.test.js +69 -0
  28. package/src/system/Dialog/DialogContent.js +2 -0
  29. package/src/system/Form/Input.js +6 -6
  30. package/src/system/Form/Select.js +16 -6
  31. package/src/system/Form/Select.stories.js +52 -24
  32. package/src/system/Form/Textarea.js +4 -4
  33. package/src/system/Timeline/index.js +46 -0
  34. package/src/system/index.js +2 -0
  35. package/src/system/theme/index.js +1 -1
@@ -133,6 +133,8 @@ const DialogMotion = ( { variant, position, ...props } ) => {
133
133
  padding: 0,
134
134
  display: 'inline-block',
135
135
  variant: `dialog.${ variant }`,
136
+ overflow: 'auto',
137
+ maxHeight: variant === 'modal' ? '90%' : '',
136
138
  } }
137
139
  />
138
140
  );
@@ -11,7 +11,7 @@ import PropTypes from 'prop-types';
11
11
  */
12
12
  import { Validation, Label } from '../';
13
13
 
14
- const InputComponent = ( { variant, label, forLabel, hasError, required, errorMessage, ...props }, ref ) => (
14
+ const Input = React.forwardRef( ( { variant, label, forLabel, hasError, required, errorMessage, ...props }, ref ) => (
15
15
  <React.Fragment>
16
16
  { label &&
17
17
  <Label htmlFor={ forLabel }>
@@ -28,7 +28,7 @@ const InputComponent = ( { variant, label, forLabel, hasError, required, errorMe
28
28
  required={ required }
29
29
  sx={ {
30
30
  border: '1px solid',
31
- borderColor: 'grey.60',
31
+ borderColor: 'border',
32
32
  backgroundColor: 'card',
33
33
  borderRadius: 1,
34
34
  lineHeight: 'inherit',
@@ -47,7 +47,7 @@ const InputComponent = ( { variant, label, forLabel, hasError, required, errorMe
47
47
  bg: 'backgroundSecondary',
48
48
  },
49
49
  '&::placeholder': {
50
- color: 'grey.30',
50
+ color: 'placeholder',
51
51
  },
52
52
  } }
53
53
  />
@@ -55,9 +55,9 @@ const InputComponent = ( { variant, label, forLabel, hasError, required, errorMe
55
55
  <Validation>{ errorMessage }</Validation>
56
56
  }
57
57
  </React.Fragment>
58
- );
58
+ ) );
59
59
 
60
- InputComponent.propTypes = {
60
+ Input.propTypes = {
61
61
  variant: PropTypes.string,
62
62
  label: PropTypes.string,
63
63
  hasError: PropTypes.bool,
@@ -66,6 +66,6 @@ InputComponent.propTypes = {
66
66
  errorMessage: PropTypes.string,
67
67
  };
68
68
 
69
- const Input = React.forwardRef( InputComponent );
69
+ Input.displayName = 'Input';
70
70
 
71
71
  export { Input };
@@ -3,19 +3,28 @@
3
3
  /**
4
4
  * External dependencies
5
5
  */
6
+ import React from 'react';
6
7
  import PropTypes from 'prop-types';
7
8
 
8
9
  /**
9
- * Internal dependencies
10
- */
10
+ * Internal dependencies
11
+ */
11
12
  import { SearchSelect } from './SearchSelect';
12
13
  import { InlineSelect } from './InlineSelect';
13
14
 
14
- const Select = ( { isMulti = false, isInline, options, label, isSearch, ...props } ) => {
15
- if ( isInline ) {
16
- return <InlineSelect isMulti={ isMulti } label={ label } options={ options } { ...props } />;
15
+ const Select = ( { isMulti = false, isInline, options, label, isSearch, usePortal, ...props } ) => {
16
+ const selectRef = React.useRef();
17
+ const portalProps = {};
18
+
19
+ if ( usePortal !== undefined ) {
20
+ portalProps.menuPortalTarget =
21
+ selectRef?.current?.querySelector( '.select__control' ).parentElement;
22
+ portalProps.styles = { menuPortal: base => ( { ...base, position: 'fixed' } ) };
17
23
  }
18
- return <SearchSelect isMulti={ isMulti } label={ label } options={ options } { ...props } />;
24
+
25
+ const Component = isInline ? InlineSelect : SearchSelect;
26
+
27
+ return <div ref={selectRef}><Component isMulti={isMulti} label={label} options={options} {...portalProps} {...props} /></div>;
19
28
  };
20
29
 
21
30
  Select.propTypes = {
@@ -24,6 +33,7 @@ Select.propTypes = {
24
33
  isSearch: PropTypes.bool,
25
34
  label: PropTypes.string,
26
35
  options: PropTypes.array,
36
+ usePortal: PropTypes.bool,
27
37
  };
28
38
 
29
39
  export { Select };
@@ -6,15 +6,7 @@ import { useState } from 'react';
6
6
  /**
7
7
  * Internal dependencies
8
8
  */
9
- import {
10
- Box,
11
- Dialog,
12
- DialogMenu,
13
- DialogMenuItem,
14
- DialogDivider,
15
- Select,
16
- Button,
17
- } from '..';
9
+ import { Box, Dialog, DialogMenu, DialogMenuItem, DialogDivider, Select, Button } from '..';
18
10
 
19
11
  export default {
20
12
  title: 'Select',
@@ -44,43 +36,79 @@ const DropdownContent = (
44
36
  const DropdownTrigger = <Button variant="secondary">Trigger Dropdown</Button>;
45
37
 
46
38
  export const Multi = () => {
47
- const [ value, setValue ] = useState( [ ] );
39
+ const [ value, setValue ] = useState( [] );
48
40
 
49
41
  return (
50
- <Box sx={ { mr: 2, width: 400 } }>
51
- <Select label="Type" value={ value } isMulti placeholder="Select domains..." options={ options } onChange={ newValue => setValue( newValue ) } />
42
+ <Box sx={{ mr: 2, width: 400 }}>
43
+ <Select
44
+ label="Type"
45
+ value={value}
46
+ isMulti
47
+ placeholder="Select domains..."
48
+ options={options}
49
+ onChange={newValue => setValue( newValue )}
50
+ />
51
+ </Box>
52
+ );
53
+ };
54
+
55
+ export const usePortal = () => {
56
+ const [ value, setValue ] = useState( [] );
57
+
58
+ return (
59
+ <Box sx={{ mr: 2, width: 400 }}>
60
+ <Select
61
+ label="Type"
62
+ value={value}
63
+ isMulti
64
+ placeholder="Select domains..."
65
+ usePortal
66
+ options={options}
67
+ onChange={newValue => setValue( newValue )}
68
+ />
52
69
  </Box>
53
70
  );
54
71
  };
55
72
 
56
73
  export const Single = () => {
57
- const [ value, setValue ] = useState( [ ] );
74
+ const [ value, setValue ] = useState( [] );
58
75
 
59
76
  return (
60
- <Box sx={ { mr: 2, width: 200 } }>
61
- <Select label="User" value={ value } placeholder="Select a domain..." options={ options } onChange={ newValue => setValue( newValue ) } />
77
+ <Box sx={{ mr: 2, width: 200 }}>
78
+ <Select
79
+ label="User"
80
+ value={value}
81
+ placeholder="Select a domain..."
82
+ options={options}
83
+ onChange={newValue => setValue( newValue )}
84
+ />
62
85
  </Box>
63
86
  );
64
87
  };
65
88
 
66
89
  export const Inline = () => {
67
- const [ value, setValue ] = useState( [ ] );
90
+ const [ value, setValue ] = useState( [] );
68
91
 
69
92
  return (
70
- <Box sx={ { mr: 2, width: 200 } }>
71
- <Select label="User" value={ value } isInline isMulti noneLabel="Everyone" placeholder="Filter by user..." options={ options } onChange={ newValue => setValue( newValue ) } />
93
+ <Box sx={{ mr: 2, width: 200 }}>
94
+ <Select
95
+ label="User"
96
+ value={value}
97
+ isInline
98
+ isMulti
99
+ noneLabel="Everyone"
100
+ placeholder="Filter by user..."
101
+ options={options}
102
+ onChange={newValue => setValue( newValue )}
103
+ />
72
104
  </Box>
73
105
  );
74
106
  };
75
107
 
76
108
  export const DropdownMenu = () => {
77
109
  return (
78
- <Box sx={ { mr: 2, width: 200 } }>
79
- <Dialog
80
- trigger={DropdownTrigger}
81
- content={DropdownContent}
82
- sx={{ width: 200 }}
83
- />
110
+ <Box sx={{ mr: 2, width: 200 }}>
111
+ <Dialog trigger={DropdownTrigger} content={DropdownContent} sx={{ width: 200 }} />
84
112
  </Box>
85
113
  );
86
114
  };
@@ -11,7 +11,7 @@ import PropTypes from 'prop-types';
11
11
  */
12
12
  import { Validation, Label } from '../';
13
13
 
14
- const TextareaComponent = ( { variant, label, forLabel, hasError, required, errorMessage, ...props }, ref ) => (
14
+ const Textarea = React.forwardRef( ( { variant, label, forLabel, hasError, required, errorMessage, ...props }, ref ) => (
15
15
  <React.Fragment>
16
16
  { label &&
17
17
  <Label htmlFor={ forLabel }>
@@ -50,9 +50,9 @@ const TextareaComponent = ( { variant, label, forLabel, hasError, required, erro
50
50
  <Validation>{ errorMessage }</Validation>
51
51
  }
52
52
  </React.Fragment>
53
- );
53
+ ) );
54
54
 
55
- TextareaComponent.propTypes = {
55
+ Textarea.propTypes = {
56
56
  variant: PropTypes.string,
57
57
  label: PropTypes.string,
58
58
  hasError: PropTypes.bool,
@@ -61,6 +61,6 @@ TextareaComponent.propTypes = {
61
61
  errorMessage: PropTypes.string,
62
62
  };
63
63
 
64
- const Textarea = React.forwardRef( TextareaComponent );
64
+ Textarea.displayName = 'Textarea';
65
65
 
66
66
  export { Textarea };
@@ -0,0 +1,46 @@
1
+ /** @jsxImportSource theme-ui */
2
+
3
+ /**
4
+ * External dependencies
5
+ */
6
+ import { Flex } from 'theme-ui';
7
+ import { MdWatchLater } from 'react-icons/md';
8
+ import PropTypes from 'prop-types';
9
+
10
+ const VerticalLine = () => {
11
+ return (
12
+ <div
13
+ sx={ {
14
+ borderLeft: '2px solid',
15
+ borderColor: 'border',
16
+ height: 'calc( 50% - 16px )',
17
+ borderRadius: '2px',
18
+ } }>
19
+ </div>
20
+ );
21
+ };
22
+
23
+ const Timeline = ( { time, first = false, last = false, ...props } ) => (
24
+ <Flex { ...props }>
25
+ <Flex sx={ { flexDirection: 'column', justifyContent: 'space-evenly', alignItems: 'center' } }>
26
+ { ! first && (
27
+ <VerticalLine />
28
+ ) }
29
+ <MdWatchLater sx={ { color: 'border' } } size={ 18 }/>
30
+ { ! last && (
31
+ <VerticalLine />
32
+ ) }
33
+ </Flex>
34
+ <Flex sx={ { alignItems: 'center', ml: 2 } }>
35
+ <span>{ time }</span>
36
+ </Flex>
37
+ </Flex>
38
+ );
39
+
40
+ Timeline.propTypes = {
41
+ first: PropTypes.bool,
42
+ time: PropTypes.string,
43
+ last: PropTypes.bool,
44
+ };
45
+
46
+ export { Timeline };
@@ -41,6 +41,7 @@ import { Spinner } from './Spinner';
41
41
  import { ResourceList, ResourceItem } from './ResourceList';
42
42
  import { Tooltip } from './Tooltip';
43
43
  import { Time } from './Time';
44
+ import { Timeline } from './Timeline';
44
45
  import { Notification } from './Notification';
45
46
  import { OptionRow } from './OptionRow';
46
47
  import { Table, TableRow } from './Table';
@@ -93,6 +94,7 @@ export {
93
94
  ToggleGroup,
94
95
  TabItem,
95
96
  Time,
97
+ Timeline,
96
98
  Validation,
97
99
  Wizard,
98
100
  WizardStep,
@@ -88,7 +88,7 @@ export default {
88
88
  muted: light.grey[ '90' ],
89
89
  link: light.brand[ '90' ],
90
90
  card: '#fff',
91
- border: light.grey[ '20' ],
91
+ border: light.grey[ '60' ],
92
92
  hover: 'rgba(0,0,0,.02)',
93
93
  lightenBackground: 'rgba(255,255,255,.5)',
94
94
  darken: 'rgba(0,0,0,.05)',