@automattic/vip-design-system 0.10.2 → 0.11.1
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.
- package/.eslines.json +8 -8
- package/.eslintrc.json +9 -4
- package/.github/PULL_REQUEST_TEMPLATE.md +1 -1
- package/.github/workflows/nodejs.yaml +14 -14
- package/.prettierrc +1 -2
- package/.storybook/main.js +1 -1
- package/.storybook/preview.js +4 -8
- package/README.md +1 -0
- package/babel.config.js +1 -1
- package/build/system/Avatar/Avatar.js +2 -1
- package/build/system/BlankState/BlankState.stories.js +3 -3
- package/build/system/BlankState/BlankState.test.js +2 -2
- package/build/system/Card/Card.test.js +0 -2
- package/build/system/Code/Code.js +7 -2
- package/build/system/Code/Code.test.js +22 -57
- package/build/system/Form/Select.stories.js +3 -4
- package/build/system/Form/Select.test.js +2 -2
- package/build/system/Notification/Notification.js +24 -15
- package/build/system/Notification/Notification.stories.js +14 -4
- package/build/system/OptionRow/OptionRow.js +23 -17
- package/build/system/OptionRow/OptionRow.stories.js +5 -5
- package/build/system/OptionRow/OptionRow.test.js +4 -4
- package/build/system/ResourceList/ResourceList.js +34 -25
- package/build/system/ResourceList/ResourceList.stories.js +2 -0
- package/build/system/ScreenReaderText/ScreenReader.test.js +37 -0
- package/build/system/ScreenReaderText/ScreenReaderText.js +49 -0
- package/build/system/ScreenReaderText/index.js +7 -0
- package/build/system/Table/Table.js +15 -15
- package/build/system/Table/Table.stories.js +46 -3
- package/build/system/Table/TableCell.js +57 -0
- package/build/system/Table/TableRow.js +12 -57
- package/build/system/Table/index.js +5 -1
- package/build/system/Time/index.js +1 -1
- package/build/system/Wizard/Wizard.stories.js +1 -1
- package/build/system/index.js +1 -0
- package/package.json +8 -4
- package/src/system/Avatar/Avatar.js +1 -0
- package/src/system/Avatar/index.js +0 -1
- package/src/system/Badge/index.js +0 -1
- package/src/system/BlankState/BlankState.js +8 -5
- package/src/system/BlankState/BlankState.stories.jsx +5 -4
- package/src/system/BlankState/BlankState.test.js +21 -21
- package/src/system/BlankState/index.js +0 -1
- package/src/system/Box/Box.js +7 -1
- package/src/system/Box/index.js +0 -1
- package/src/system/Button/Button.js +3 -3
- package/src/system/Button/Button.stories.jsx +2 -2
- package/src/system/Button/index.js +0 -1
- package/src/system/Card/Card.js +4 -4
- package/src/system/Card/Card.test.js +1 -2
- package/src/system/Card/index.js +0 -1
- package/src/system/Code/Code.js +6 -2
- package/src/system/Code/Code.stories.jsx +10 -5
- package/src/system/Code/Code.test.js +3 -16
- package/src/system/ConfirmationDialog/ConfirmationDialog.js +8 -1
- package/src/system/Dialog/Dialog.js +17 -8
- package/src/system/Dialog/Dialog.stories.jsx +9 -13
- package/src/system/Dialog/DialogButton.js +18 -14
- package/src/system/Dialog/DialogDivider.js +1 -1
- package/src/system/Dialog/DialogMenu.js +1 -5
- package/src/system/Dialog/DialogMenuItem.js +4 -8
- package/src/system/Dialog/DialogTrigger.js +1 -1
- package/src/system/Dialog/index.js +0 -1
- package/src/system/Flex/Flex.js +1 -1
- package/src/system/Flex/index.js +0 -1
- package/src/system/Form/AsyncSearchSelect.js +3 -7
- package/src/system/Form/Checkbox.js +32 -28
- package/src/system/Form/InlineSelect.js +21 -17
- package/src/system/Form/Input.js +43 -45
- package/src/system/Form/Label.js +2 -2
- package/src/system/Form/RadioBoxGroup.js +34 -32
- package/src/system/Form/RadioBoxGroup.stories.jsx +8 -1
- package/src/system/Form/SearchSelect.js +7 -7
- package/src/system/Form/Select.js +21 -2
- package/src/system/Form/Select.stories.jsx +31 -34
- package/src/system/Form/Select.test.js +3 -8
- package/src/system/Form/Textarea.js +38 -40
- package/src/system/Form/Toggle.js +9 -11
- package/src/system/Form/ToggleGroup.js +29 -31
- package/src/system/Form/ToggleGroup.stories.jsx +8 -1
- package/src/system/Form/ToggleRow.js +6 -1
- package/src/system/Form/Validation.js +6 -1
- package/src/system/Form/index.js +13 -1
- package/src/system/Grid/Grid.js +1 -1
- package/src/system/Grid/index.js +0 -1
- package/src/system/Heading/Heading.js +4 -4
- package/src/system/Heading/index.js +0 -1
- package/src/system/Link/index.js +0 -1
- package/src/system/Notice/Notice.js +27 -13
- package/src/system/Notice/Notice.stories.jsx +6 -8
- package/src/system/Notice/index.js +0 -1
- package/src/system/Notification/Notification.js +25 -20
- package/src/system/Notification/Notification.stories.jsx +4 -4
- package/src/system/Notification/index.js +0 -1
- package/src/system/OptionRow/OptionRow.js +46 -44
- package/src/system/OptionRow/OptionRow.stories.jsx +10 -8
- package/src/system/OptionRow/OptionRow.test.js +12 -11
- package/src/system/OptionRow/index.js +0 -1
- package/src/system/Progress/Progress.js +3 -1
- package/src/system/Progress/Progress.stories.jsx +4 -4
- package/src/system/Progress/index.js +0 -1
- package/src/system/ResourceList/ResourceItem.js +15 -15
- package/src/system/ResourceList/ResourceList.js +28 -16
- package/src/system/ResourceList/ResourceList.stories.jsx +77 -71
- package/src/system/ScreenReaderText/ScreenReader.test.js +22 -0
- package/src/system/ScreenReaderText/ScreenReaderText.js +40 -0
- package/src/system/ScreenReaderText/index.js +7 -0
- package/src/system/Spinner/Spinner.js +4 -4
- package/src/system/Spinner/index.js +0 -1
- package/src/system/Table/Table.js +10 -9
- package/src/system/Table/Table.stories.jsx +39 -9
- package/src/system/Table/TableCell.js +48 -0
- package/src/system/Table/TableRow.js +10 -47
- package/src/system/Table/index.js +2 -2
- package/src/system/Tabs/Tabs.js +3 -3
- package/src/system/Tabs/index.js +0 -1
- package/src/system/Text/Text.js +3 -3
- package/src/system/Text/Text.stories.jsx +4 -6
- package/src/system/Text/index.js +0 -1
- package/src/system/Time/Time.stories.jsx +2 -6
- package/src/system/Time/index.js +5 -5
- package/src/system/Timeline/Timeline.js +6 -12
- package/src/system/Timeline/Timeline.stories.jsx +3 -12
- package/src/system/Timeline/index.js +0 -1
- package/src/system/Tooltip/Tooltip.js +4 -8
- package/src/system/Wizard/Wizard.js +23 -21
- package/src/system/Wizard/Wizard.stories.jsx +7 -12
- package/src/system/Wizard/WizardStep.js +8 -8
- package/src/system/Wizard/WizardStepHorizontal.js +4 -4
- package/src/system/Wizard/index.js +0 -1
- package/src/system/index.js +2 -1
- package/src/system/theme/index.js +3 -4
- package/tokens/valet-color.json +1919 -0
- package/build/system/UsageChart/UsageChart.stories.js +0 -20
|
@@ -11,8 +11,8 @@ import { MdContentCopy } from 'react-icons/md';
|
|
|
11
11
|
import { BlankState } from './BlankState';
|
|
12
12
|
import { Link } from '../Link';
|
|
13
13
|
|
|
14
|
-
// eslint-disable-next-line max-len
|
|
15
14
|
const image =
|
|
15
|
+
// eslint-disable-next-line max-len
|
|
16
16
|
"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='79' height='79' viewBox='0 0 79 79' fill='none'%3E%3Cpath d='M66.3001 15.9C66.3001 15.9 66.3 15.8 66.2 15.8C66.1 15.7 66 15.5 65.9001 15.4C65.9001 15.4 65.9001 15.4 65.9001 15.3L44.4001 0.2C44.3001 0.0999998 44.2 0.0999994 44.1 0.0999994C44 0.0999994 44.0001 0 43.9001 0H43.3C43.2 0 43.1 0.0999994 43.1 0.0999994C43 0.0999994 42.9 0.2 42.8 0.2L28.2001 10.3C28.1 10.4 28.0001 10.5 27.9001 10.6C27.9001 10.6 27.9001 10.6 27.9001 10.7C27.8001 10.8 27.7001 11 27.7001 11.2C27.7001 11.2 27.7001 11.2 27.7001 11.3V31.1L13.9 40.8L13.7001 41C13.6001 41.1 13.6 41.1 13.6 41.2L13.5 41.3C13.5 41.4 13.4 41.5 13.4 41.5V41.6C13.4 41.7 13.3 41.8 13.3 42V62.2C13.3 62.4 13.3 62.6 13.4 62.7V62.8C13.5 62.9 13.6001 63.1 13.7001 63.2C13.7001 63.2 13.7 63.2 13.8 63.3L13.9 63.4L35.3 78.6H35.4001C35.4001 78.6 35.5 78.6 35.5 78.7H35.6C35.8 78.8 36 78.8 36.2001 78.8C36.3001 78.8 36.5 78.8 36.6 78.7H36.7001C36.8001 78.7 36.8001 78.7 36.9001 78.6C36.9001 78.6 37 78.6 37 78.5H37.1L66 58.3C66.1 58.2 66.2001 58.1 66.3001 58V15.9ZM34.6 74.5L16.1 61.3V44.7L34.6 57.8V74.5ZM36 55.3L17.2001 41.9L29 33.5L47.9001 46.9L36 55.3ZM49 44.1L30.5 31V14.4L49 27.5V44.1ZM50.5 24.9L31.6 11.5L43.5 3.2L62.4001 16.6L50.5 24.9Z' fill='%23BD9D70'/%3E%3C/svg%3E";
|
|
17
17
|
|
|
18
18
|
const defaultProps = {
|
|
@@ -23,37 +23,37 @@ const defaultProps = {
|
|
|
23
23
|
title: 'Power up your application',
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
describe('<BlankState />', () => {
|
|
27
|
-
it('renders the BlankState component', async () => {
|
|
28
|
-
const { container } = render(<BlankState {...defaultProps} />);
|
|
26
|
+
describe( '<BlankState />', () => {
|
|
27
|
+
it( 'renders the BlankState component', async () => {
|
|
28
|
+
const { container } = render( <BlankState { ...defaultProps } /> );
|
|
29
29
|
|
|
30
|
-
expect(screen.getByText(defaultProps.body)).toBeInTheDocument();
|
|
31
|
-
expect(screen.getByText(defaultProps.title)).toBeInTheDocument();
|
|
32
|
-
expect(screen.getByText('Explore add-ons →')).toBeInTheDocument();
|
|
33
|
-
expect(screen.getByAltText(defaultProps.imageAlt)).toBeInTheDocument();
|
|
30
|
+
expect( screen.getByText( defaultProps.body ) ).toBeInTheDocument();
|
|
31
|
+
expect( screen.getByText( defaultProps.title ) ).toBeInTheDocument();
|
|
32
|
+
expect( screen.getByText( 'Explore add-ons →' ) ).toBeInTheDocument();
|
|
33
|
+
expect( screen.getByAltText( defaultProps.imageAlt ) ).toBeInTheDocument();
|
|
34
34
|
|
|
35
35
|
// Check for accessibility issues
|
|
36
|
-
await expect(await axe(container)).toHaveNoViolations();
|
|
37
|
-
});
|
|
36
|
+
await expect( await axe( container ) ).toHaveNoViolations();
|
|
37
|
+
} );
|
|
38
38
|
|
|
39
|
-
it('renders the BlankState component with default alt text for the given image', async () => {
|
|
39
|
+
it( 'renders the BlankState component with default alt text for the given image', async () => {
|
|
40
40
|
const props = { ...defaultProps, imageAlt: undefined };
|
|
41
|
-
const { container } = render(<BlankState {...props} />);
|
|
41
|
+
const { container } = render( <BlankState { ...props } /> );
|
|
42
42
|
|
|
43
|
-
expect(screen.getByAltText('Image representing the blank state')).toBeInTheDocument();
|
|
43
|
+
expect( screen.getByAltText( 'Image representing the blank state' ) ).toBeInTheDocument();
|
|
44
44
|
|
|
45
45
|
// Check for accessibility issues
|
|
46
|
-
await expect(await axe(container)).toHaveNoViolations();
|
|
47
|
-
});
|
|
46
|
+
await expect( await axe( container ) ).toHaveNoViolations();
|
|
47
|
+
} );
|
|
48
48
|
|
|
49
|
-
it('renders the BlankState component with an icon', async () => {
|
|
49
|
+
it( 'renders the BlankState component with an icon', async () => {
|
|
50
50
|
const icon = <MdContentCopy title="this is an icon" />;
|
|
51
51
|
const props = { ...defaultProps, icon };
|
|
52
|
-
const { container } = render(<BlankState {...props} />);
|
|
52
|
+
const { container } = render( <BlankState { ...props } /> );
|
|
53
53
|
|
|
54
|
-
expect(screen.getByTitle('this is an icon')).toBeInTheDocument();
|
|
54
|
+
expect( screen.getByTitle( 'this is an icon' ) ).toBeInTheDocument();
|
|
55
55
|
|
|
56
56
|
// Check for accessibility issues
|
|
57
|
-
await expect(await axe(container)).toHaveNoViolations();
|
|
58
|
-
});
|
|
59
|
-
});
|
|
57
|
+
await expect( await axe( container ) ).toHaveNoViolations();
|
|
58
|
+
} );
|
|
59
|
+
} );
|
package/src/system/Box/Box.js
CHANGED
|
@@ -8,7 +8,13 @@ import classNames from 'classnames';
|
|
|
8
8
|
import { forwardRef } from 'react';
|
|
9
9
|
import { Box as ThemeBox } from 'theme-ui';
|
|
10
10
|
|
|
11
|
-
const Box = forwardRef( ( props, ref ) =>
|
|
11
|
+
const Box = forwardRef( ( props, ref ) => (
|
|
12
|
+
<ThemeBox
|
|
13
|
+
ref={ ref }
|
|
14
|
+
className={ classNames( 'vip-box-component', props.className ) }
|
|
15
|
+
{ ...props }
|
|
16
|
+
/>
|
|
17
|
+
) );
|
|
12
18
|
|
|
13
19
|
Box.displayName = 'Box';
|
|
14
20
|
Box.propTypes = {
|
package/src/system/Box/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import classNames from 'classnames';
|
|
|
9
9
|
|
|
10
10
|
const Button = ( { sx, ...props } ) => (
|
|
11
11
|
<ThemeButton
|
|
12
|
-
sx={{
|
|
12
|
+
sx={ {
|
|
13
13
|
verticalAlign: 'middle',
|
|
14
14
|
display: 'inline-flex',
|
|
15
15
|
alignItems: 'center',
|
|
@@ -22,9 +22,9 @@ const Button = ( { sx, ...props } ) => (
|
|
|
22
22
|
pointerEvents: 'all',
|
|
23
23
|
},
|
|
24
24
|
...sx,
|
|
25
|
-
}}
|
|
25
|
+
} }
|
|
26
26
|
className={ classNames( 'vip-button-component', props.className ) }
|
|
27
|
-
{...props}
|
|
27
|
+
{ ...props }
|
|
28
28
|
/>
|
|
29
29
|
);
|
|
30
30
|
|
|
@@ -15,8 +15,8 @@ export default {
|
|
|
15
15
|
|
|
16
16
|
export const Default = () => (
|
|
17
17
|
<React.Fragment>
|
|
18
|
-
<Button sx={{ mr: 2 }}>Primary</Button>
|
|
19
|
-
<Button variant="secondary" sx={{ ml: 2 }}>
|
|
18
|
+
<Button sx={ { mr: 2 } }>Primary</Button>
|
|
19
|
+
<Button variant="secondary" sx={ { ml: 2 } }>
|
|
20
20
|
Secondary
|
|
21
21
|
</Button>
|
|
22
22
|
</React.Fragment>
|
package/src/system/Card/Card.js
CHANGED
|
@@ -15,15 +15,15 @@ import classNames from 'classnames';
|
|
|
15
15
|
const Card = React.forwardRef( ( { variant = 'primary', sx = {}, className, ...props }, ref ) => {
|
|
16
16
|
return (
|
|
17
17
|
<Box
|
|
18
|
-
ref={ref}
|
|
19
|
-
sx={{
|
|
18
|
+
ref={ ref }
|
|
19
|
+
sx={ {
|
|
20
20
|
// pass variant prop to sx
|
|
21
21
|
variant: `cards.${ variant }`,
|
|
22
22
|
overflow: 'hidden',
|
|
23
23
|
...sx,
|
|
24
|
-
}}
|
|
24
|
+
} }
|
|
25
25
|
className={ classNames( 'vip-card-component', className ) }
|
|
26
|
-
{...props}
|
|
26
|
+
{ ...props }
|
|
27
27
|
/>
|
|
28
28
|
);
|
|
29
29
|
} );
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { render, screen
|
|
4
|
+
import { render, screen } from '@testing-library/react';
|
|
5
5
|
import { axe } from 'jest-axe';
|
|
6
|
-
import { MdContentCopy } from 'react-icons/md';
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* Internal dependencies
|
package/src/system/Card/index.js
CHANGED
package/src/system/Code/Code.js
CHANGED
|
@@ -50,7 +50,7 @@ const Code = ( { prompt = false, showCopy = false, onCopy = null, className, ...
|
|
|
50
50
|
{ codeDom }
|
|
51
51
|
{
|
|
52
52
|
<button
|
|
53
|
-
aria-label="Copy"
|
|
53
|
+
aria-label="Copy code"
|
|
54
54
|
sx={ {
|
|
55
55
|
bg: 'grey.10',
|
|
56
56
|
borderTopRightRadius: 1,
|
|
@@ -79,7 +79,11 @@ const Code = ( { prompt = false, showCopy = false, onCopy = null, className, ...
|
|
|
79
79
|
}
|
|
80
80
|
} }
|
|
81
81
|
>
|
|
82
|
-
{ copied ?
|
|
82
|
+
{ copied ? (
|
|
83
|
+
<span role="alert">Code copied to clipboard</span>
|
|
84
|
+
) : (
|
|
85
|
+
<MdContentCopy aria-hidden="true" />
|
|
86
|
+
) }
|
|
83
87
|
</button>
|
|
84
88
|
}
|
|
85
89
|
</div>
|
|
@@ -17,11 +17,16 @@ export const Default = () => (
|
|
|
17
17
|
<React.Fragment>
|
|
18
18
|
<Code>Code</Code>
|
|
19
19
|
<br />
|
|
20
|
-
<Code showCopy={true}>Code with Icon</Code>
|
|
20
|
+
<Code showCopy={ true }>Code with Icon</Code>
|
|
21
21
|
<br />
|
|
22
|
-
<Code
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
<Code
|
|
23
|
+
showCopy={ true }
|
|
24
|
+
onCopy={
|
|
25
|
+
// eslint-disable-next-line no-console
|
|
26
|
+
() => console.info( 'Hello world' )
|
|
27
|
+
}
|
|
28
|
+
>
|
|
29
|
+
Code with Icon and Click callback — console.info
|
|
30
|
+
</Code>
|
|
26
31
|
</React.Fragment>
|
|
27
32
|
);
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
|
|
5
5
|
import { axe } from 'jest-axe';
|
|
6
|
-
import { MdContentCopy } from 'react-icons/md';
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* Internal dependencies
|
|
@@ -31,23 +30,11 @@ describe( '<Code />', () => {
|
|
|
31
30
|
await expect( await axe( container ) ).toHaveNoViolations();
|
|
32
31
|
} );
|
|
33
32
|
|
|
34
|
-
// jsdom currently doesn't support pseudo-elements with getComputedStyle
|
|
35
|
-
it.skip( 'renders "$" in front of the code when in prompt mode', async () => {
|
|
36
|
-
const props = { ...defaultProps, prompt: true };
|
|
37
|
-
const { container } = render( <Code { ...props }>This is a code</Code> );
|
|
38
|
-
const codeElement = screen.getByText( 'This is a code' );
|
|
39
|
-
|
|
40
|
-
expect( window.getComputedStyle( codeElement, ':before' ).content ).toEqual( '$' );
|
|
41
|
-
|
|
42
|
-
// Check for accessibility issues
|
|
43
|
-
await expect( await axe( container ) ).toHaveNoViolations();
|
|
44
|
-
} );
|
|
45
|
-
|
|
46
33
|
it( 'renders the Code component with a copy button', async () => {
|
|
47
34
|
const props = { ...defaultProps, showCopy: true };
|
|
48
35
|
const { container } = render( <Code { ...props }>This is a code</Code> );
|
|
49
36
|
|
|
50
|
-
expect( screen.getByRole( 'button', { name: 'Copy' } ) ).toBeInTheDocument();
|
|
37
|
+
expect( screen.getByRole( 'button', { name: 'Copy code' } ) ).toBeInTheDocument();
|
|
51
38
|
|
|
52
39
|
// Check for accessibility issues
|
|
53
40
|
await expect( await axe( container ) ).toHaveNoViolations();
|
|
@@ -57,11 +44,11 @@ describe( '<Code />', () => {
|
|
|
57
44
|
const props = { ...defaultProps, showCopy: true };
|
|
58
45
|
const { container } = render( <Code { ...props }>This is a code</Code> );
|
|
59
46
|
|
|
60
|
-
fireEvent.click( screen.getByRole( 'button', { name: 'Copy' } ) );
|
|
47
|
+
fireEvent.click( screen.getByRole( 'button', { name: 'Copy code' } ) );
|
|
61
48
|
|
|
62
49
|
await waitFor( () => new Promise( res => setTimeout( res, 0 ) ) );
|
|
63
50
|
|
|
64
|
-
expect( screen.getByText( '
|
|
51
|
+
expect( screen.getByText( 'Code copied to clipboard' ) ).toBeInTheDocument();
|
|
65
52
|
|
|
66
53
|
// Check for accessibility issues
|
|
67
54
|
await expect( await axe( container ) ).toHaveNoViolations();
|
|
@@ -12,7 +12,14 @@ import React from 'react';
|
|
|
12
12
|
*/
|
|
13
13
|
import { Dialog, Box, Heading, Text, Flex, Button } from '../';
|
|
14
14
|
|
|
15
|
-
const ConfirmationDialogContent = ( {
|
|
15
|
+
const ConfirmationDialogContent = ( {
|
|
16
|
+
title,
|
|
17
|
+
body,
|
|
18
|
+
onClose,
|
|
19
|
+
label = 'Confirm',
|
|
20
|
+
onConfirm,
|
|
21
|
+
className = null,
|
|
22
|
+
} ) => (
|
|
16
23
|
<Box p={ 4 } className={ classNames( 'vip-confirmation-dialog-component', className ) }>
|
|
17
24
|
<Heading variant="h3" sx={ { mb: 2 } }>
|
|
18
25
|
{ title }
|
|
@@ -8,11 +8,18 @@ import PropTypes from 'prop-types';
|
|
|
8
8
|
import { useEffect, useRef, useState } from 'react';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
* Internal dependencies
|
|
12
|
-
*/
|
|
11
|
+
* Internal dependencies
|
|
12
|
+
*/
|
|
13
13
|
import { DialogContent, DialogTrigger } from '.';
|
|
14
14
|
|
|
15
|
-
const Dialog = ( {
|
|
15
|
+
const Dialog = ( {
|
|
16
|
+
trigger,
|
|
17
|
+
position = 'left',
|
|
18
|
+
startOpen = false,
|
|
19
|
+
content,
|
|
20
|
+
disabled = false,
|
|
21
|
+
...props
|
|
22
|
+
} ) => {
|
|
16
23
|
const [ isOpen, setIsOpen ] = useState( startOpen );
|
|
17
24
|
const dialogRef = useRef( null );
|
|
18
25
|
|
|
@@ -46,7 +53,12 @@ const Dialog = ( { trigger, position = 'left', startOpen = false, content, disab
|
|
|
46
53
|
};
|
|
47
54
|
|
|
48
55
|
return (
|
|
49
|
-
<div
|
|
56
|
+
<div
|
|
57
|
+
onClick={ e => e.stopPropagation() }
|
|
58
|
+
sx={ { position: 'relative' } }
|
|
59
|
+
ref={ dialogRef }
|
|
60
|
+
className="vip-dialog-component"
|
|
61
|
+
>
|
|
50
62
|
<DialogTrigger
|
|
51
63
|
tabIndex="0"
|
|
52
64
|
sx={ { display: 'inline' } }
|
|
@@ -73,10 +85,7 @@ Dialog.propTypes = {
|
|
|
73
85
|
disabled: PropTypes.bool,
|
|
74
86
|
position: PropTypes.string,
|
|
75
87
|
startOpen: PropTypes.bool,
|
|
76
|
-
content: PropTypes.oneOfType( [
|
|
77
|
-
PropTypes.node,
|
|
78
|
-
PropTypes.func,
|
|
79
|
-
] ),
|
|
88
|
+
content: PropTypes.oneOfType( [ PropTypes.node, PropTypes.func ] ),
|
|
80
89
|
};
|
|
81
90
|
|
|
82
91
|
export { Dialog };
|
|
@@ -19,7 +19,7 @@ export default {
|
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
const DropdownTrigger = <Button>Trigger Dropdown</Button>;
|
|
22
|
-
const ModalTrigger = <Button sx={{ mr: 3 }}>Trigger Modal</Button>;
|
|
22
|
+
const ModalTrigger = <Button sx={ { mr: 3 } }>Trigger Modal</Button>;
|
|
23
23
|
|
|
24
24
|
const DropdownContent = (
|
|
25
25
|
<div>
|
|
@@ -36,11 +36,11 @@ const DropdownContent = (
|
|
|
36
36
|
);
|
|
37
37
|
|
|
38
38
|
const ModalContent = (
|
|
39
|
-
<Box p={5}>
|
|
39
|
+
<Box p={ 5 }>
|
|
40
40
|
<Heading>This is a Modal</Heading>
|
|
41
|
-
<Text sx={{ fontSize: 3 }}>
|
|
42
|
-
A modal is used to perform more detailed actions that don‘t
|
|
43
|
-
|
|
41
|
+
<Text sx={ { fontSize: 3 } }>
|
|
42
|
+
A modal is used to perform more detailed actions that don‘t necessarily need the context
|
|
43
|
+
behind.
|
|
44
44
|
</Text>
|
|
45
45
|
</Box>
|
|
46
46
|
);
|
|
@@ -49,16 +49,12 @@ export const Default = () => (
|
|
|
49
49
|
<Flex>
|
|
50
50
|
<Box>
|
|
51
51
|
<Dialog
|
|
52
|
-
trigger={ModalTrigger}
|
|
53
|
-
content={ModalContent}
|
|
54
|
-
sx={{ width: 480 }}
|
|
52
|
+
trigger={ ModalTrigger }
|
|
53
|
+
content={ ModalContent }
|
|
54
|
+
sx={ { width: 480 } }
|
|
55
55
|
variant="modal"
|
|
56
56
|
/>
|
|
57
57
|
</Box>
|
|
58
|
-
<Dialog
|
|
59
|
-
trigger={DropdownTrigger}
|
|
60
|
-
content={DropdownContent}
|
|
61
|
-
sx={{ width: 200 }}
|
|
62
|
-
/>
|
|
58
|
+
<Dialog trigger={ DropdownTrigger } content={ DropdownContent } sx={ { width: 200 } } />
|
|
63
59
|
</Flex>
|
|
64
60
|
);
|
|
@@ -7,26 +7,30 @@ import PropTypes from 'prop-types';
|
|
|
7
7
|
import { MdExpandMore } from 'react-icons/md';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* Internal dependencies
|
|
11
|
-
*/
|
|
10
|
+
* Internal dependencies
|
|
11
|
+
*/
|
|
12
12
|
import { Button, Text } from '../';
|
|
13
13
|
|
|
14
14
|
const DialogButton = ( { label, variant = 'secondary', value, children, ...props } ) => (
|
|
15
|
-
<Button
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
<Button
|
|
16
|
+
variant={ variant }
|
|
17
|
+
sx={ {
|
|
18
|
+
textAlign: 'left',
|
|
19
|
+
display: 'inline-flex',
|
|
20
|
+
py: 2,
|
|
21
|
+
pl: 3,
|
|
22
|
+
pr: 2,
|
|
23
|
+
alignItems: 'center',
|
|
24
|
+
} }
|
|
25
|
+
{ ...props }
|
|
22
26
|
>
|
|
23
27
|
{ children }
|
|
24
|
-
{ label &&
|
|
25
|
-
<Text as="span" sx={{ mb: 0, color: 'muted', mr: 2, flex: '0 0 auto' }}>
|
|
28
|
+
{ label && (
|
|
29
|
+
<Text as="span" sx={ { mb: 0, color: 'muted', mr: 2, flex: '0 0 auto' } }>
|
|
26
30
|
{ label }:
|
|
27
31
|
</Text>
|
|
28
|
-
}
|
|
29
|
-
{ value &&
|
|
32
|
+
) }
|
|
33
|
+
{ value && (
|
|
30
34
|
<Text
|
|
31
35
|
as="span"
|
|
32
36
|
sx={ {
|
|
@@ -40,7 +44,7 @@ const DialogButton = ( { label, variant = 'secondary', value, children, ...props
|
|
|
40
44
|
>
|
|
41
45
|
{ value }
|
|
42
46
|
</Text>
|
|
43
|
-
}
|
|
47
|
+
) }
|
|
44
48
|
<MdExpandMore sx={ { ml: 2, top: 0, display: 'block', flex: '0 0 auto' } } />
|
|
45
49
|
</Button>
|
|
46
50
|
);
|
|
@@ -7,8 +7,8 @@ import PropTypes from 'prop-types';
|
|
|
7
7
|
import { useEffect, useRef } from 'react';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* Internal dependencies
|
|
11
|
-
*/
|
|
10
|
+
* Internal dependencies
|
|
11
|
+
*/
|
|
12
12
|
import { Box, Spinner } from '../';
|
|
13
13
|
|
|
14
14
|
const DialogMenuItem = ( { loading = false, children, ...props } ) => {
|
|
@@ -57,12 +57,8 @@ const DialogMenuItem = ( { loading = false, children, ...props } ) => {
|
|
|
57
57
|
} }
|
|
58
58
|
{ ...props }
|
|
59
59
|
>
|
|
60
|
-
<Box sx={ { flex: '1 1 auto' } }>
|
|
61
|
-
|
|
62
|
-
</Box>
|
|
63
|
-
{ loading &&
|
|
64
|
-
<Spinner sx={ { width: 12 } } />
|
|
65
|
-
}
|
|
60
|
+
<Box sx={ { flex: '1 1 auto' } }>{ children }</Box>
|
|
61
|
+
{ loading && <Spinner sx={ { width: 12 } } /> }
|
|
66
62
|
</Box>
|
|
67
63
|
</li>
|
|
68
64
|
);
|
package/src/system/Flex/Flex.js
CHANGED
package/src/system/Flex/index.js
CHANGED
|
@@ -7,19 +7,15 @@ import PropTypes from 'prop-types';
|
|
|
7
7
|
import { withAsyncPaginate } from 'react-select-async-paginate';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
* Internal dependencies
|
|
11
|
+
*/
|
|
12
12
|
import { SearchSelect } from './SearchSelect';
|
|
13
13
|
|
|
14
14
|
// Asynchronous search select to load paginated results asynchronously
|
|
15
15
|
const CustomAsyncPaginate = withAsyncPaginate( SearchSelect );
|
|
16
16
|
|
|
17
17
|
const AsyncSearchSelect = ( { options, ...props } ) => (
|
|
18
|
-
<CustomAsyncPaginate
|
|
19
|
-
SelectComponent={ SearchSelect }
|
|
20
|
-
loadOptions={ options }
|
|
21
|
-
{ ...props }
|
|
22
|
-
/>
|
|
18
|
+
<CustomAsyncPaginate SelectComponent={ SearchSelect } loadOptions={ options } { ...props } />
|
|
23
19
|
);
|
|
24
20
|
|
|
25
21
|
AsyncSearchSelect.propTypes = {
|
|
@@ -7,35 +7,39 @@ import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
|
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import { MdDone } from 'react-icons/md';
|
|
9
9
|
|
|
10
|
-
const StyledCheckbox = props =>
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
10
|
+
const StyledCheckbox = props => (
|
|
11
|
+
<CheckboxPrimitive.Root
|
|
12
|
+
sx={ {
|
|
13
|
+
all: 'unset',
|
|
14
|
+
backgroundColor: 'grey.10',
|
|
15
|
+
width: 16,
|
|
16
|
+
height: 16,
|
|
17
|
+
borderRadius: 1,
|
|
18
|
+
display: 'flex',
|
|
19
|
+
alignItems: 'center',
|
|
20
|
+
justifyContent: 'center',
|
|
21
|
+
'&:hover': { backgroundColor: 'grey.20' },
|
|
22
|
+
'&:focus': { boxShadow: '0 0 0 2px black' },
|
|
23
|
+
'&[data-state=checked]': {
|
|
24
|
+
backgroundColor: 'primary',
|
|
25
|
+
color: 'brand.0',
|
|
26
|
+
},
|
|
27
|
+
svg: {
|
|
28
|
+
display: 'block',
|
|
29
|
+
},
|
|
30
|
+
} }
|
|
31
|
+
{ ...props }
|
|
32
|
+
/>
|
|
33
|
+
);
|
|
32
34
|
|
|
33
|
-
const StyledIndicator = props =>
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
const StyledIndicator = props => (
|
|
36
|
+
<CheckboxPrimitive.Indicator
|
|
37
|
+
sx={ {
|
|
38
|
+
color: 'brand.0',
|
|
39
|
+
} }
|
|
40
|
+
{ ...props }
|
|
41
|
+
/>
|
|
42
|
+
);
|
|
39
43
|
|
|
40
44
|
const Checkbox = ( { disabled, ...props } ) => (
|
|
41
45
|
<StyledCheckbox
|