@spothero/ui 16.0.0-beta.0 → 16.0.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/.eslintignore +0 -1
- package/babel.config.js +1 -0
- package/jest.config.json +3 -0
- package/package.json +7 -6
- package/v2/index.js +1 -1
- package/v2/index.js.map +1 -1
- package/styles/components/Accordion/Accordion.jsx +0 -1
- package/styles/components/Accordion/Accordion.stories.js +0 -103
- package/styles/components/Accordion/index.js +0 -7
- package/styles/components/Accordion/styles/button.js +0 -16
- package/styles/components/Accordion/styles/container.js +0 -9
- package/styles/components/Accordion/styles/index.js +0 -19
- package/styles/components/Accordion/styles/panel.js +0 -7
- package/styles/components/Alert/Alert.jsx +0 -121
- package/styles/components/Alert/Alert.stories.js +0 -50
- package/styles/components/Alert/index.js +0 -1
- package/styles/components/Alert/styles/index.js +0 -166
- package/styles/components/AutoSuggestSelect/AutoSuggestSelect.jsx +0 -194
- package/styles/components/AutoSuggestSelect/index.js +0 -1
- package/styles/components/Badge/Badge.jsx +0 -1
- package/styles/components/Badge/Badge.stories.js +0 -32
- package/styles/components/Badge/styles/index.js +0 -29
- package/styles/components/Button/Button.jsx +0 -31
- package/styles/components/Button/Button.spec.js +0 -29
- package/styles/components/Button/Button.styles.js +0 -156
- package/styles/components/Button/button-props.js +0 -66
- package/styles/components/Button/index.js +0 -2
- package/styles/components/Button/stories/button.js +0 -59
- package/styles/components/Button/stories/index.stories.js +0 -82
- package/styles/components/Button/stories/overview.js +0 -73
- package/styles/components/Card/Card.jsx +0 -16
- package/styles/components/Card/Card.stories.js +0 -33
- package/styles/components/Checkbox/Checkbox.jsx +0 -1
- package/styles/components/Checkbox/Checkbox.stories.js +0 -41
- package/styles/components/Checkbox/index.js +0 -1
- package/styles/components/Checkbox/styles/index.js +0 -31
- package/styles/components/Container/Container.jsx +0 -10
- package/styles/components/Container/Container.stories.js +0 -52
- package/styles/components/Container/Container.styles.js +0 -11
- package/styles/components/Divider/Divider.jsx +0 -31
- package/styles/components/Divider/Divider.stories.js +0 -41
- package/styles/components/Divider/Divider.styles.js +0 -15
- package/styles/components/FormControl/FormControl.jsx +0 -79
- package/styles/components/Grid/Grid.jsx +0 -25
- package/styles/components/Grid/Grid.stories.js +0 -128
- package/styles/components/Grid/Grid.styles.js +0 -12
- package/styles/components/Grid/GridItem.jsx +0 -10
- package/styles/components/Grid/GridItem.styles.js +0 -8
- package/styles/components/Grid/index.js +0 -2
- package/styles/components/Heading/Heading.jsx +0 -23
- package/styles/components/Heading/Heading.stories.js +0 -40
- package/styles/components/Heading/Heading.styles.js +0 -61
- package/styles/components/Icon/Icon.jsx +0 -1
- package/styles/components/Icon/Icon.stories.js +0 -38
- package/styles/components/Image/Image.jsx +0 -118
- package/styles/components/Image/Image.spec.js +0 -100
- package/styles/components/Image/Image.stories.js +0 -142
- package/styles/components/Input/Input.jsx +0 -51
- package/styles/components/Input/Input.stories.js +0 -60
- package/styles/components/Input/index.js +0 -1
- package/styles/components/Input/styles/index.js +0 -49
- package/styles/components/Link/Link.jsx +0 -1
- package/styles/components/Link/Link.stories.js +0 -82
- package/styles/components/Link/Link.styles.js +0 -38
- package/styles/components/List/List.jsx +0 -57
- package/styles/components/List/List.stories.js +0 -96
- package/styles/components/List/index.js +0 -2
- package/styles/components/List/styles/index.js +0 -12
- package/styles/components/List/styles/item.styles.js +0 -5
- package/styles/components/Loader/Loader.jsx +0 -75
- package/styles/components/Loader/Loader.stories.js +0 -145
- package/styles/components/Modal/Modal.jsx +0 -70
- package/styles/components/Modal/Modal.stories.js +0 -278
- package/styles/components/Modal/index.js +0 -1
- package/styles/components/Modal/styles/body.js +0 -24
- package/styles/components/Modal/styles/closeButton.js +0 -17
- package/styles/components/Modal/styles/dialog.js +0 -10
- package/styles/components/Modal/styles/dialogContainer.js +0 -10
- package/styles/components/Modal/styles/footer.js +0 -5
- package/styles/components/Modal/styles/header.js +0 -7
- package/styles/components/Modal/styles/index.js +0 -47
- package/styles/components/Modal/styles/overlay.js +0 -4
- package/styles/components/Popover/Popover.jsx +0 -28
- package/styles/components/Popover/Popover.stories.js +0 -113
- package/styles/components/Popover/PopoverArrow.jsx +0 -10
- package/styles/components/Popover/PopoverCloseButton.jsx +0 -10
- package/styles/components/Popover/PopoverContent.jsx +0 -41
- package/styles/components/Popover/index.js +0 -3
- package/styles/components/Popover/styles/index.js +0 -21
- package/styles/components/Popover/styles/popover-arrow.js +0 -5
- package/styles/components/Popover/styles/popover-body.js +0 -5
- package/styles/components/Popover/styles/popover-close-button.js +0 -17
- package/styles/components/Popover/styles/popover-content.js +0 -16
- package/styles/components/Popover/styles/popover-header.js +0 -6
- package/styles/components/Popover/styles/popper.js +0 -5
- package/styles/components/Radio/Radio.jsx +0 -50
- package/styles/components/Radio/Radio.stories.js +0 -155
- package/styles/components/Radio/RadioGroup.jsx +0 -69
- package/styles/components/Radio/index.js +0 -2
- package/styles/components/Radio/styles/index.js +0 -52
- package/styles/components/Select/Select.jsx +0 -62
- package/styles/components/Select/Select.stories.js +0 -60
- package/styles/components/Select/index.js +0 -1
- package/styles/components/Select/styles/index.js +0 -29
- package/styles/components/Skeleton/Skeleton.stories.jsx +0 -34
- package/styles/components/Skeleton/Skeleton.styles.js +0 -3
- package/styles/components/Skeleton/index.js +0 -1
- package/styles/components/Spinner/Spinner.jsx +0 -40
- package/styles/components/Spinner/Spinner.stories.js +0 -98
- package/styles/components/Spinner/Spinner.styles.js +0 -57
- package/styles/components/Switch/Switch.jsx +0 -52
- package/styles/components/Switch/Switch.stories.js +0 -88
- package/styles/components/Switch/index.js +0 -1
- package/styles/components/Switch/styles/index.js +0 -17
- package/styles/components/Table/Table.jsx +0 -1
- package/styles/components/Table/Table.stories.js +0 -90
- package/styles/components/Table/Table.styles.js +0 -66
- package/styles/components/Table/index.js +0 -2
- package/styles/components/Tabs/Tabs.jsx +0 -38
- package/styles/components/Tabs/Tabs.stories.js +0 -47
- package/styles/components/Tabs/combineSizeWithVariant.js +0 -31
- package/styles/components/Tabs/index.js +0 -2
- package/styles/components/Tabs/styles/index.js +0 -40
- package/styles/components/Text/Text.jsx +0 -35
- package/styles/components/Text/Text.stories.js +0 -47
- package/styles/components/Text/Text.styles.js +0 -33
- package/styles/components/Text/combineAsWithVariant.js +0 -106
- package/styles/components/Text/options.js +0 -92
- package/styles/components/ThemeProvider/ThemeProvider.jsx +0 -39
- package/styles/components/ThemeProvider/ThemeProvider.stories.js +0 -85
- package/styles/theme/base/breakpoints.js +0 -16
- package/styles/theme/base/colors.js +0 -136
- package/styles/theme/base/index.js +0 -5
- package/styles/theme/base/sizes.js +0 -48
- package/styles/theme/base/typography.js +0 -24
- package/styles/theme/base/zindices.js +0 -17
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import {variants} from './Heading.styles';
|
|
4
|
-
|
|
5
|
-
import Component from './Heading';
|
|
6
|
-
|
|
7
|
-
export default {
|
|
8
|
-
title: 'v2/Heading',
|
|
9
|
-
component: Component,
|
|
10
|
-
parameters: {
|
|
11
|
-
removeBaseHtmlClass: true,
|
|
12
|
-
},
|
|
13
|
-
argTypes: {
|
|
14
|
-
as: {
|
|
15
|
-
control: {
|
|
16
|
-
type: 'select',
|
|
17
|
-
options: Object.keys(variants),
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
variant: {
|
|
21
|
-
control: {
|
|
22
|
-
type: 'select',
|
|
23
|
-
options: Object.keys(variants),
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
children: {
|
|
27
|
-
control: {
|
|
28
|
-
type: 'text',
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const Template = props => <Component {...props} />;
|
|
35
|
-
|
|
36
|
-
export const Heading = Template.bind({});
|
|
37
|
-
|
|
38
|
-
Heading.args = {
|
|
39
|
-
children: 'Heading',
|
|
40
|
-
};
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import {fontSizes, fontWeights} from 'theme/base/typography';
|
|
2
|
-
|
|
3
|
-
const baseStyle = {
|
|
4
|
-
lineHeight: 1.5,
|
|
5
|
-
fontWeight: fontWeights.semibold,
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export const variants = {
|
|
9
|
-
h1: {
|
|
10
|
-
...baseStyle,
|
|
11
|
-
fontSize: {
|
|
12
|
-
base: fontSizes['2xl'],
|
|
13
|
-
desktop: fontSizes['3xl'],
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
h2: {
|
|
17
|
-
...baseStyle,
|
|
18
|
-
fontSize: {
|
|
19
|
-
base: fontSizes.xl,
|
|
20
|
-
desktop: fontSizes['2xl'],
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
h3: {
|
|
24
|
-
...baseStyle,
|
|
25
|
-
fontSize: {
|
|
26
|
-
base: fontSizes.lg,
|
|
27
|
-
desktop: fontSizes.xl,
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
h4: {
|
|
31
|
-
...baseStyle,
|
|
32
|
-
fontSize: {
|
|
33
|
-
base: fontSizes.base,
|
|
34
|
-
desktop: fontSizes.lg,
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
h5: {
|
|
38
|
-
...baseStyle,
|
|
39
|
-
fontSize: {
|
|
40
|
-
base: fontSizes.base,
|
|
41
|
-
desktop: fontSizes.base,
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
h6: {
|
|
45
|
-
...baseStyle,
|
|
46
|
-
fontSize: {
|
|
47
|
-
base: fontSizes.sm,
|
|
48
|
-
desktop: fontSizes.sm,
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const defaultProps = {
|
|
54
|
-
variant: variants.h2,
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
export default {
|
|
58
|
-
variants,
|
|
59
|
-
baseStyle,
|
|
60
|
-
defaultProps,
|
|
61
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {Icon as default} from '@chakra-ui/react';
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {S4BLogo, HeroCar, Shield} from '@spothero/icons';
|
|
3
|
-
import Component from './Icon';
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
title: 'v2/Icon',
|
|
7
|
-
component: Component,
|
|
8
|
-
parameters: {
|
|
9
|
-
removeBaseHtmlClass: true,
|
|
10
|
-
},
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const Template = props => (
|
|
14
|
-
<>
|
|
15
|
-
<Component
|
|
16
|
-
as={HeroCar}
|
|
17
|
-
color="primary.default"
|
|
18
|
-
height="24"
|
|
19
|
-
width="24"
|
|
20
|
-
/>
|
|
21
|
-
<Component
|
|
22
|
-
as={S4BLogo}
|
|
23
|
-
color="gray.dark"
|
|
24
|
-
height="24"
|
|
25
|
-
width="24"
|
|
26
|
-
paddingLeft="16"
|
|
27
|
-
/>
|
|
28
|
-
<Component
|
|
29
|
-
as={Shield}
|
|
30
|
-
color="green.default"
|
|
31
|
-
height="24"
|
|
32
|
-
width="24"
|
|
33
|
-
paddingLeft="16"
|
|
34
|
-
/>
|
|
35
|
-
</>
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
export const Icon = Template.bind({});
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import {Image as ChakraImage, Img as ChakraImg} from '@chakra-ui/react';
|
|
4
|
-
import template from 'lodash/template';
|
|
5
|
-
import {window as ssrWindow} from 'ssr-window';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Determines whether the display has a high density.
|
|
9
|
-
* @static
|
|
10
|
-
* @function isHighDensityDisplay
|
|
11
|
-
* @example
|
|
12
|
-
* EnvironmentUtils.isHighDensityDisplay();
|
|
13
|
-
* @returns {Boolean} - Whether the display is high density.
|
|
14
|
-
*/
|
|
15
|
-
export const isHighDensityDisplay = () => {
|
|
16
|
-
return (
|
|
17
|
-
(ssrWindow.matchMedia &&
|
|
18
|
-
(ssrWindow.matchMedia(
|
|
19
|
-
'only screen and (min-resolution: 124dpi), only screen and (min-resolution: 1.3dppx), only screen and (min-resolution: 48.8dpcm)'
|
|
20
|
-
).matches ||
|
|
21
|
-
ssrWindow.matchMedia(
|
|
22
|
-
'only screen and (-webkit-min-device-pixel-ratio: 1.3), only screen and (-o-min-device-pixel-ratio: 2.6/2), only screen and (min--moz-device-pixel-ratio: 1.3), only screen and (min-device-pixel-ratio: 1.3)'
|
|
23
|
-
).matches)) ||
|
|
24
|
-
(ssrWindow.devicePixelRatio && ssrWindow.devicePixelRatio > 1.3)
|
|
25
|
-
);
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const buildCloudinarySrc = ({
|
|
29
|
-
cloudinaryImageId,
|
|
30
|
-
cloudinaryTemplate,
|
|
31
|
-
cloudinaryCloudName,
|
|
32
|
-
htmlWidth,
|
|
33
|
-
htmlHeight,
|
|
34
|
-
quality,
|
|
35
|
-
}) => {
|
|
36
|
-
const defaultTemplate = `https://res.cloudinary.com/${cloudinaryCloudName}/image/upload/$w_{{WIDTH}},$h_{{HEIGHT}},$q_{{QUALITY}}/c_fill,f_auto,fl_progressive,dpr_${
|
|
37
|
-
isHighDensityDisplay() ? 2 : 1
|
|
38
|
-
},h_$h,q_$q,w_$w/${cloudinaryImageId}`;
|
|
39
|
-
const tmpl = cloudinaryTemplate ? cloudinaryTemplate : defaultTemplate;
|
|
40
|
-
|
|
41
|
-
return template(tmpl, {
|
|
42
|
-
interpolate: /{{([\s\S]+?)}}/g, // matches template vars in the format '{{ var }}' or '{{var}}'
|
|
43
|
-
})({
|
|
44
|
-
WIDTH: htmlWidth,
|
|
45
|
-
HEIGHT: htmlHeight,
|
|
46
|
-
QUALITY: quality,
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
const Image = ({
|
|
51
|
-
isSSR,
|
|
52
|
-
cloudinaryImageId,
|
|
53
|
-
cloudinaryTemplate,
|
|
54
|
-
cloudinaryCloudName,
|
|
55
|
-
htmlWidth,
|
|
56
|
-
htmlHeight,
|
|
57
|
-
quality,
|
|
58
|
-
lazyLoad,
|
|
59
|
-
...otherProps
|
|
60
|
-
}) => {
|
|
61
|
-
const hasValidCloudinarySrc =
|
|
62
|
-
(cloudinaryImageId || cloudinaryTemplate) &&
|
|
63
|
-
Boolean(htmlWidth) &&
|
|
64
|
-
Boolean(htmlHeight);
|
|
65
|
-
let cloudinarySrc;
|
|
66
|
-
|
|
67
|
-
if (hasValidCloudinarySrc) {
|
|
68
|
-
cloudinarySrc = buildCloudinarySrc({
|
|
69
|
-
cloudinaryImageId,
|
|
70
|
-
cloudinaryTemplate,
|
|
71
|
-
cloudinaryCloudName,
|
|
72
|
-
htmlWidth,
|
|
73
|
-
htmlHeight,
|
|
74
|
-
quality,
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const imageProps = {
|
|
79
|
-
...otherProps,
|
|
80
|
-
src: cloudinarySrc || otherProps.src,
|
|
81
|
-
htmlWidth,
|
|
82
|
-
htmlHeight,
|
|
83
|
-
...(lazyLoad && {loading: 'lazy'}),
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
if (isSSR) {
|
|
87
|
-
return <ChakraImg {...imageProps} />;
|
|
88
|
-
} else {
|
|
89
|
-
return <ChakraImage {...imageProps} />;
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
Image.propTypes = {
|
|
94
|
-
/** If true, use the image directly without client side checks. */
|
|
95
|
-
isSSR: PropTypes.bool,
|
|
96
|
-
/** The Cloudinary account that this image is stored under. */
|
|
97
|
-
cloudinaryCloudName: PropTypes.string,
|
|
98
|
-
/** The image ID that is stored in Cloudinary for this image. Will be used to replace the source path. */
|
|
99
|
-
cloudinaryImageId: PropTypes.string,
|
|
100
|
-
/** The template URL to use to create the source path from. Replaceable values are {{WIDTH}}, {{HEIGHT}}, and {{QUALITY}}. */
|
|
101
|
-
cloudinaryTemplate: PropTypes.string,
|
|
102
|
-
/** The width of the native HTML image, in pixels. Required if using a Cloudinary ID or Template. */
|
|
103
|
-
htmlWidth: PropTypes.number,
|
|
104
|
-
/** The height of the native HTML image, in pixels. Required if using a Cloudinary ID or Template. */
|
|
105
|
-
htmlHeight: PropTypes.number,
|
|
106
|
-
/** The quality setting if this image uses a Cloudinary ID or Template. */
|
|
107
|
-
quality: PropTypes.number,
|
|
108
|
-
/** Whether to use lazy loading for this image. */
|
|
109
|
-
lazyLoad: PropTypes.bool,
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
Image.defaultProps = {
|
|
113
|
-
isSSR: false,
|
|
114
|
-
quality: 50,
|
|
115
|
-
cloudinaryCloudName: 'spothero',
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
export default Image;
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {render as rtlRender, screen, waitFor} from '@testing-library/react';
|
|
3
|
-
import Image from './Image';
|
|
4
|
-
|
|
5
|
-
const defaultSrc = 'http://placehold.it/350x200';
|
|
6
|
-
|
|
7
|
-
const render = props => {
|
|
8
|
-
rtlRender(<Image {...props} />);
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
describe('Image', () => {
|
|
12
|
-
describe('basic behavior', () => {
|
|
13
|
-
it('displays an image', () => {
|
|
14
|
-
render({
|
|
15
|
-
src: defaultSrc,
|
|
16
|
-
alt: 'An image',
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
waitFor(() => {
|
|
20
|
-
expect(screen.getByRole('img')).toHaveAttribute(
|
|
21
|
-
'src',
|
|
22
|
-
defaultSrc
|
|
23
|
-
);
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it('displays an image (SSR)', () => {
|
|
28
|
-
render({
|
|
29
|
-
src: defaultSrc,
|
|
30
|
-
alt: 'An image',
|
|
31
|
-
isSSR: true,
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
expect(screen.getByRole('img')).toHaveAttribute('src', defaultSrc);
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
describe('Cloudinary properties', () => {
|
|
39
|
-
it('correctly sets image src when a Cloudinary image template is passed in', () => {
|
|
40
|
-
render({
|
|
41
|
-
cloudinaryTemplate:
|
|
42
|
-
'https://res.cloudinary.com/spothero/image/upload/$w_{{WIDTH}},$h_{{HEIGHT}},$q_{{QUALITY}}/c_fill,f_auto,h_$h,q_$q,w_$w/html-emails/google',
|
|
43
|
-
htmlWidth: 250,
|
|
44
|
-
htmlHeight: 500,
|
|
45
|
-
quality: 75,
|
|
46
|
-
alt: 'An image',
|
|
47
|
-
});
|
|
48
|
-
waitFor(() => {
|
|
49
|
-
expect(screen.getByRole('img')).toHaveAttribute(
|
|
50
|
-
'src',
|
|
51
|
-
'https://res.cloudinary.com/spothero/image/upload/$w_250,$h_500,$q_75/c_fill,f_auto,h_$h,q_$q,w_$w/html-emails/google'
|
|
52
|
-
);
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it('correctly sets image src when a Cloudinary image id is passed in', () => {
|
|
57
|
-
render({
|
|
58
|
-
cloudinaryImageId: 'html-emails/partner-hertz',
|
|
59
|
-
htmlWidth: 250,
|
|
60
|
-
htmlHeight: 500,
|
|
61
|
-
alt: 'An image',
|
|
62
|
-
isSSR: true,
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
expect(screen.getByRole('img')).toHaveAttribute(
|
|
66
|
-
'src',
|
|
67
|
-
'https://res.cloudinary.com/spothero/image/upload/$w_250,$h_500,$q_50/c_fill,f_auto,fl_progressive,dpr_1,h_$h,q_$q,w_$w/html-emails/partner-hertz'
|
|
68
|
-
);
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it('does not set in image src when invalid set of Cloudinary props is passed in', () => {
|
|
72
|
-
render({
|
|
73
|
-
cloudinaryImageId: 'html-emails/partner-hertz',
|
|
74
|
-
alt: 'An image',
|
|
75
|
-
isSSR: true,
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
waitFor(() => {
|
|
79
|
-
expect(screen.getByRole('img')).not.toHaveAttribute('src');
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
describe('Lazy loading', () => {
|
|
85
|
-
it('correctly sets image loading attribute to lazy when lazyLoad prop is true', () => {
|
|
86
|
-
render({
|
|
87
|
-
src: defaultSrc,
|
|
88
|
-
alt: 'An image',
|
|
89
|
-
lazyLoad: true,
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
waitFor(() => {
|
|
93
|
-
expect(screen.getByRole('img')).toHaveAttribute(
|
|
94
|
-
'loading',
|
|
95
|
-
'lazy'
|
|
96
|
-
);
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
});
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import Component from './Image';
|
|
3
|
-
|
|
4
|
-
export default {
|
|
5
|
-
title: 'v2/Image',
|
|
6
|
-
component: Component,
|
|
7
|
-
parameters: {
|
|
8
|
-
removeBaseHtmlClass: true,
|
|
9
|
-
importBy: 'Image',
|
|
10
|
-
},
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const Template = props => <Component {...props} />;
|
|
14
|
-
const LazyLoadTemplate = props => (
|
|
15
|
-
<>
|
|
16
|
-
<p>Scroll down to see lazy loaded image in action...</p>
|
|
17
|
-
<br />
|
|
18
|
-
<br />
|
|
19
|
-
<br />
|
|
20
|
-
<br />
|
|
21
|
-
<br />
|
|
22
|
-
<br />
|
|
23
|
-
<br />
|
|
24
|
-
<br />
|
|
25
|
-
<br />
|
|
26
|
-
<br />
|
|
27
|
-
<br />
|
|
28
|
-
<br />
|
|
29
|
-
<br />
|
|
30
|
-
<br />
|
|
31
|
-
<br />
|
|
32
|
-
<br />
|
|
33
|
-
<br />
|
|
34
|
-
<br />
|
|
35
|
-
<br />
|
|
36
|
-
<br />
|
|
37
|
-
<br />
|
|
38
|
-
<br />
|
|
39
|
-
<br />
|
|
40
|
-
<br />
|
|
41
|
-
<br />
|
|
42
|
-
<br />
|
|
43
|
-
<br />
|
|
44
|
-
<br />
|
|
45
|
-
<br />
|
|
46
|
-
<br />
|
|
47
|
-
<br />
|
|
48
|
-
<br />
|
|
49
|
-
<br />
|
|
50
|
-
<br />
|
|
51
|
-
<br />
|
|
52
|
-
<br />
|
|
53
|
-
<br />
|
|
54
|
-
<br />
|
|
55
|
-
<br />
|
|
56
|
-
<br />
|
|
57
|
-
<br />
|
|
58
|
-
<br />
|
|
59
|
-
<br />
|
|
60
|
-
<br />
|
|
61
|
-
<br />
|
|
62
|
-
<br />
|
|
63
|
-
<br />
|
|
64
|
-
<br />
|
|
65
|
-
<br />
|
|
66
|
-
<br />
|
|
67
|
-
<br />
|
|
68
|
-
<br />
|
|
69
|
-
<br />
|
|
70
|
-
<br />
|
|
71
|
-
<br />
|
|
72
|
-
<br />
|
|
73
|
-
<br />
|
|
74
|
-
<br />
|
|
75
|
-
<br />
|
|
76
|
-
<br />
|
|
77
|
-
<Component {...props} />
|
|
78
|
-
</>
|
|
79
|
-
);
|
|
80
|
-
|
|
81
|
-
export const DefaultImage = Template.bind({});
|
|
82
|
-
DefaultImage.args = {
|
|
83
|
-
src: 'http://placehold.it/350x200',
|
|
84
|
-
width: 350,
|
|
85
|
-
height: 200,
|
|
86
|
-
alt: 'Placeholder image',
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
export const StyledImage = Template.bind({});
|
|
90
|
-
StyledImage.args = {
|
|
91
|
-
src: 'http://placehold.it/350x200',
|
|
92
|
-
alt: 'Placeholder image',
|
|
93
|
-
padding: 4,
|
|
94
|
-
borderColor: 'green.default',
|
|
95
|
-
borderWidth: '1px',
|
|
96
|
-
borderStyle: 'solid',
|
|
97
|
-
height: {
|
|
98
|
-
base: 'auto',
|
|
99
|
-
tablet: 52,
|
|
100
|
-
},
|
|
101
|
-
width: {
|
|
102
|
-
base: 'auto',
|
|
103
|
-
tablet: 52,
|
|
104
|
-
},
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
export const SSRImg = Template.bind({});
|
|
108
|
-
SSRImg.args = {
|
|
109
|
-
src: 'http://placehold.it/350x200',
|
|
110
|
-
width: 350,
|
|
111
|
-
height: 200,
|
|
112
|
-
alt: 'SSR image',
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
export const CloudinaryImageId = Template.bind({});
|
|
116
|
-
CloudinaryImageId.args = {
|
|
117
|
-
cloudinaryImageId: 'html-emails/partner-hertz',
|
|
118
|
-
htmlWidth: 186,
|
|
119
|
-
htmlHeight: 76,
|
|
120
|
-
quality: 50,
|
|
121
|
-
alt: 'Cloudinary image ID',
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
export const CloudinaryImageTemplate = Template.bind({});
|
|
125
|
-
CloudinaryImageTemplate.args = {
|
|
126
|
-
cloudinaryTemplate:
|
|
127
|
-
'https://res.cloudinary.com/spothero/image/upload/$w_{{WIDTH}},$h_{{HEIGHT}},$q_{{QUALITY}}/c_fill,f_auto,h_$h,q_$q,w_$w/html-emails/google',
|
|
128
|
-
htmlWidth: 132,
|
|
129
|
-
htmlHeight: 111,
|
|
130
|
-
quality: 80,
|
|
131
|
-
alt: 'Cloudinary image template',
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
export const LazyLoadImage = LazyLoadTemplate.bind({});
|
|
135
|
-
LazyLoadImage.args = {
|
|
136
|
-
src:
|
|
137
|
-
'https://res.cloudinary.com/spothero/image/upload/$w_1024,$h_704,$q_50/c_fill,f_auto,h_$h,q_$q,w_$w,x_375,y_250/v1577978927/rzm2xqhtgqxfv3isxmyy.jpg',
|
|
138
|
-
width: 350,
|
|
139
|
-
height: 200,
|
|
140
|
-
alt: 'Placeholder image',
|
|
141
|
-
lazyLoad: true,
|
|
142
|
-
};
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import React, {forwardRef} from 'react';
|
|
2
|
-
import cn from 'classnames';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
|
-
import {Input as ChakraInput} from '@chakra-ui/react';
|
|
5
|
-
import FormControl from '../FormControl/FormControl';
|
|
6
|
-
|
|
7
|
-
const Input = forwardRef(
|
|
8
|
-
(
|
|
9
|
-
{
|
|
10
|
-
label,
|
|
11
|
-
helperText,
|
|
12
|
-
errorMessage,
|
|
13
|
-
isInvalid,
|
|
14
|
-
isDisabled,
|
|
15
|
-
isRequired,
|
|
16
|
-
isOptional,
|
|
17
|
-
...props
|
|
18
|
-
},
|
|
19
|
-
ref
|
|
20
|
-
) => {
|
|
21
|
-
const classes = cn({'FormElement-contains-error': isInvalid});
|
|
22
|
-
|
|
23
|
-
return (
|
|
24
|
-
<FormControl
|
|
25
|
-
isInvalid={isInvalid}
|
|
26
|
-
isDisabled={isDisabled}
|
|
27
|
-
isRequired={isRequired}
|
|
28
|
-
isOptional={isOptional}
|
|
29
|
-
errorMessage={errorMessage}
|
|
30
|
-
helperText={helperText}
|
|
31
|
-
label={label}
|
|
32
|
-
inputId={props.id}
|
|
33
|
-
>
|
|
34
|
-
<ChakraInput ref={ref} className={classes} {...props} />
|
|
35
|
-
</FormControl>
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
Input.propTypes = {
|
|
41
|
-
id: PropTypes.string.isRequired,
|
|
42
|
-
label: PropTypes.string,
|
|
43
|
-
helperText: PropTypes.string,
|
|
44
|
-
errorMessage: PropTypes.string,
|
|
45
|
-
isInvalid: PropTypes.bool,
|
|
46
|
-
isDisabled: PropTypes.bool,
|
|
47
|
-
isRequired: PropTypes.bool,
|
|
48
|
-
isOptional: PropTypes.bool,
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export default Input;
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
|
|
4
|
-
import Component from './Input';
|
|
5
|
-
import {useTheme} from '@chakra-ui/react';
|
|
6
|
-
|
|
7
|
-
export default {
|
|
8
|
-
title: 'v2/Input',
|
|
9
|
-
component: Component,
|
|
10
|
-
parameters: {
|
|
11
|
-
importBy: 'Input',
|
|
12
|
-
removeBaseHtmlClass: true,
|
|
13
|
-
chakraLink: 'https://chakra-ui.com/docs/components/input',
|
|
14
|
-
},
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const InputTemplate = props => (
|
|
18
|
-
<Component variant="outline" maxWidth="200px" {...props} />
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
InputTemplate.propTypes = {
|
|
22
|
-
placeholder: PropTypes.string,
|
|
23
|
-
label: PropTypes.string,
|
|
24
|
-
helperText: PropTypes.string,
|
|
25
|
-
errorMessage: PropTypes.string,
|
|
26
|
-
isInvalid: PropTypes.bool,
|
|
27
|
-
isDisabled: PropTypes.bool,
|
|
28
|
-
isReadOnly: PropTypes.bool,
|
|
29
|
-
isOptional: PropTypes.bool,
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export const Input = InputTemplate.bind({});
|
|
33
|
-
|
|
34
|
-
Input.argTypes = {
|
|
35
|
-
placeholder: {
|
|
36
|
-
control: {type: 'text'},
|
|
37
|
-
},
|
|
38
|
-
label: {
|
|
39
|
-
control: {type: 'text'},
|
|
40
|
-
},
|
|
41
|
-
helperText: {
|
|
42
|
-
control: {type: 'text'},
|
|
43
|
-
},
|
|
44
|
-
errorMessage: {
|
|
45
|
-
control: {type: 'text'},
|
|
46
|
-
},
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
Input.args = {
|
|
50
|
-
id: 'input_id',
|
|
51
|
-
placeholder: 'Placeholder text',
|
|
52
|
-
label: 'Label',
|
|
53
|
-
helperText: 'Helper text',
|
|
54
|
-
errorMessage: 'Error message',
|
|
55
|
-
isInvalid: false,
|
|
56
|
-
isDisabled: false,
|
|
57
|
-
isReadOnly: false,
|
|
58
|
-
isRequired: false,
|
|
59
|
-
isOptional: false,
|
|
60
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {default} from './Input';
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import merge from 'lodash/merge';
|
|
2
|
-
import chakraDefaultTheme from '@chakra-ui/theme';
|
|
3
|
-
|
|
4
|
-
const baseStyle = {
|
|
5
|
-
field: {
|
|
6
|
-
_placeholder: {
|
|
7
|
-
color: 'text.secondary.light',
|
|
8
|
-
fontWeight: 'normal',
|
|
9
|
-
_disabled: {color: 'text.secondary.light', opacity: 1},
|
|
10
|
-
},
|
|
11
|
-
},
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const variants = {
|
|
15
|
-
outline: {
|
|
16
|
-
field: {
|
|
17
|
-
border: '1px solid',
|
|
18
|
-
borderColor: 'gray.200',
|
|
19
|
-
fontSize: 'base',
|
|
20
|
-
paddingLeft: 3,
|
|
21
|
-
paddingRight: 3,
|
|
22
|
-
bg: 'inherit',
|
|
23
|
-
fontWeight: 'normal',
|
|
24
|
-
boxShadow: 'none !important',
|
|
25
|
-
_placeholder: {color: 'text.secondary.light', fontWeight: 'normal'},
|
|
26
|
-
_focus: {
|
|
27
|
-
borderColor: 'brandBlue',
|
|
28
|
-
},
|
|
29
|
-
_hover: {borderColor: 'gray.300'},
|
|
30
|
-
_readOnly: {boxShadow: 'none !important', userSelect: 'all'},
|
|
31
|
-
_disabled: {
|
|
32
|
-
backgroundColor: 'gray.50',
|
|
33
|
-
opacity: 1,
|
|
34
|
-
cursor: 'not-allowed',
|
|
35
|
-
},
|
|
36
|
-
_invalid: {
|
|
37
|
-
borderColor: 'error',
|
|
38
|
-
_focus: {
|
|
39
|
-
borderColor: 'error',
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export default merge(chakraDefaultTheme.components.Input, {
|
|
47
|
-
baseStyle,
|
|
48
|
-
variants,
|
|
49
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {Link as default} from '@chakra-ui/react';
|