@blaze-cms/react-page-builder 0.141.0-core-styles.20 → 0.141.0-core-styles.22
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/CHANGELOG.md +19 -0
- package/lib/components/BlazeLink.js +6 -2
- package/lib/components/BlazeLink.js.map +1 -1
- package/lib/components/Card/Card.js.map +1 -1
- package/lib/components/Image/ImageRender.js +4 -2
- package/lib/components/Image/ImageRender.js.map +1 -1
- package/lib/components/List/components/Header/ListHeader.js +5 -2
- package/lib/components/List/components/Header/ListHeader.js.map +1 -1
- package/lib/components/List/components/Pagination/Classic.js +2 -2
- package/lib/components/List/components/Pagination/Classic.js.map +1 -1
- package/lib/components/List/components/Pagination/LoadMore.js +2 -1
- package/lib/components/List/components/Pagination/LoadMore.js.map +1 -1
- package/lib/components/List/helpers/build-pagination-items.js +2 -1
- package/lib/components/List/helpers/build-pagination-items.js.map +1 -1
- package/lib/components/Menu/Menu.js +4 -2
- package/lib/components/Menu/Menu.js.map +1 -1
- package/lib/components/SearchFilter/components/Select.js +1 -0
- package/lib/components/SearchFilter/components/Select.js.map +1 -1
- package/lib/components/SearchFilterSort/SearchFilterSort.js +1 -0
- package/lib/components/SearchFilterSort/SearchFilterSort.js.map +1 -1
- package/lib/components/SocialFollow/SFItem.js +4 -3
- package/lib/components/SocialFollow/SFItem.js.map +1 -1
- package/lib/variants/ThumbnailCarousel/ThumbnailCarousel.js +8 -10
- package/lib/variants/ThumbnailCarousel/ThumbnailCarousel.js.map +1 -1
- package/lib/variants/ThumbnailCarousel/ThumbnailImage/ThumbnailImage.js +1 -5
- package/lib/variants/ThumbnailCarousel/ThumbnailImage/ThumbnailImage.js.map +1 -1
- package/lib/variants/ThumbnailCarousel/ThumbnailImage/useThumbnailImage.js +10 -23
- package/lib/variants/ThumbnailCarousel/ThumbnailImage/useThumbnailImage.js.map +1 -1
- package/lib/variants/ThumbnailCarousel/useThumbnailCarousel.js +13 -9
- package/lib/variants/ThumbnailCarousel/useThumbnailCarousel.js.map +1 -1
- package/lib-es/components/BlazeLink.js +6 -2
- package/lib-es/components/BlazeLink.js.map +1 -1
- package/lib-es/components/Card/Card.js.map +1 -1
- package/lib-es/components/Image/ImageRender.js +4 -2
- package/lib-es/components/Image/ImageRender.js.map +1 -1
- package/lib-es/components/List/components/Header/ListHeader.js +5 -2
- package/lib-es/components/List/components/Header/ListHeader.js.map +1 -1
- package/lib-es/components/List/components/Pagination/Classic.js +2 -2
- package/lib-es/components/List/components/Pagination/Classic.js.map +1 -1
- package/lib-es/components/List/components/Pagination/LoadMore.js +2 -1
- package/lib-es/components/List/components/Pagination/LoadMore.js.map +1 -1
- package/lib-es/components/List/helpers/build-pagination-items.js +2 -1
- package/lib-es/components/List/helpers/build-pagination-items.js.map +1 -1
- package/lib-es/components/Menu/Menu.js +4 -2
- package/lib-es/components/Menu/Menu.js.map +1 -1
- package/lib-es/components/SearchFilter/components/Select.js +1 -0
- package/lib-es/components/SearchFilter/components/Select.js.map +1 -1
- package/lib-es/components/SearchFilterSort/SearchFilterSort.js +1 -0
- package/lib-es/components/SearchFilterSort/SearchFilterSort.js.map +1 -1
- package/lib-es/components/SocialFollow/SFItem.js +4 -3
- package/lib-es/components/SocialFollow/SFItem.js.map +1 -1
- package/lib-es/variants/ThumbnailCarousel/ThumbnailCarousel.js +8 -10
- package/lib-es/variants/ThumbnailCarousel/ThumbnailCarousel.js.map +1 -1
- package/lib-es/variants/ThumbnailCarousel/ThumbnailImage/ThumbnailImage.js +1 -5
- package/lib-es/variants/ThumbnailCarousel/ThumbnailImage/ThumbnailImage.js.map +1 -1
- package/lib-es/variants/ThumbnailCarousel/ThumbnailImage/useThumbnailImage.js +10 -23
- package/lib-es/variants/ThumbnailCarousel/ThumbnailImage/useThumbnailImage.js.map +1 -1
- package/lib-es/variants/ThumbnailCarousel/useThumbnailCarousel.js +13 -8
- package/lib-es/variants/ThumbnailCarousel/useThumbnailCarousel.js.map +1 -1
- package/package.json +7 -7
- package/src/components/BlazeLink.js +23 -4
- package/src/components/Card/Card.js +0 -1
- package/src/components/Image/ImageRender.js +4 -2
- package/src/components/List/components/Header/ListHeader.js +7 -4
- package/src/components/List/components/Pagination/Classic.js +2 -2
- package/src/components/List/components/Pagination/LoadMore.js +7 -2
- package/src/components/List/helpers/build-pagination-items.js +2 -1
- package/src/components/Menu/Menu.js +4 -3
- package/src/components/SearchFilter/components/Select.js +1 -0
- package/src/components/SearchFilterSort/SearchFilterSort.js +1 -0
- package/src/components/SocialFollow/SFItem.js +8 -2
- package/src/variants/ThumbnailCarousel/ThumbnailCarousel.js +6 -10
- package/src/variants/ThumbnailCarousel/ThumbnailImage/ThumbnailImage.js +4 -18
- package/src/variants/ThumbnailCarousel/ThumbnailImage/useThumbnailImage.js +11 -25
- package/src/variants/ThumbnailCarousel/useThumbnailCarousel.js +13 -8
- package/tests/unit/src/components/Breadcrumb/__snapshots__/Breadcrumb.test.js.snap +3 -0
- package/tests/unit/src/components/Button.test.js +2 -2
- package/tests/unit/src/components/Card/__snapshots__/Card.test.js.snap +13 -0
- package/tests/unit/src/components/Card/__snapshots__/CardContainer.test.js.snap +8 -0
- package/tests/unit/src/components/Image/GlobalLightbox/__snapshots__/GlobalLightbox.test.js.snap +1 -0
- package/tests/unit/src/components/Image/__snapshots__/Image.test.js.snap +3 -0
- package/tests/unit/src/components/Image/__snapshots__/ImageFactory.test.js.snap +4 -0
- package/tests/unit/src/components/List/components/Header/__snapshots__/ListHeader.test.js.snap +5 -0
- package/tests/unit/src/components/List/components/Pagination/__snapshots__/Classic.test.js.snap +8 -2
- package/tests/unit/src/components/List/components/Pagination/__snapshots__/ListPagination.test.js.snap +5 -1
- package/tests/unit/src/components/List/components/Pagination/__snapshots__/LoadMore.test.js.snap +1 -1
- package/tests/unit/src/components/List/helpers/__snapshots__/build-pagination-items.test.js.snap +21 -0
- package/tests/unit/src/components/MenuItem/__snapshots__/MenuItem.test.js.snap +1 -0
- package/tests/unit/src/components/SearchFilter/components/__snapshots__/Select.test.js.snap +5 -3
- package/tests/unit/src/components/SearchFilterSort/__snapshots__/SearchFilterSort.test.js.snap +2 -1
- package/tests/unit/src/components/SocialFollow/__snapshots__/SFItem.test.js.snap +2 -2
- package/tests/unit/src/components/SocialFollow/__snapshots__/SocialFollow.test.js.snap +2 -6
- package/tests/unit/src/components/TextBlock/__snapshots__/TextBlock.test.js.snap +4 -0
- package/tests/unit/src/components/__snapshots__/BlazeLink.test.js.snap +1 -1
- package/tests/unit/src/components/__snapshots__/Button.test.js.snap +1 -0
- package/tests/unit/src/helpers/__snapshots__/parse-textBlock.test.js.snap +1 -0
- package/tests/unit/src/helpers/parse-textBlock.test.js +3 -1
- package/tests/unit/src/variants/ThumbnailCarousel/__snapshots__/ThumbnailCarousel.test.js.snap +10 -15
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blaze-cms/react-page-builder",
|
|
3
|
-
"version": "0.141.0-core-styles.
|
|
3
|
+
"version": "0.141.0-core-styles.22",
|
|
4
4
|
"description": "Blaze react page builder",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib-es/index.js",
|
|
@@ -31,18 +31,18 @@
|
|
|
31
31
|
"@blaze-cms/core-errors": "0.140.2-core-styles.1",
|
|
32
32
|
"@blaze-cms/core-errors-ui": "0.140.2-core-styles.1",
|
|
33
33
|
"@blaze-cms/image-cdn-react": "0.3.0-alpha.6",
|
|
34
|
-
"@blaze-cms/nextjs-components": "0.141.0-core-styles.
|
|
35
|
-
"@blaze-cms/plugin-search-ui": "0.141.0-core-styles.
|
|
34
|
+
"@blaze-cms/nextjs-components": "0.141.0-core-styles.21",
|
|
35
|
+
"@blaze-cms/plugin-search-ui": "0.141.0-core-styles.21",
|
|
36
36
|
"@blaze-cms/setup-ui": "0.140.2-core-styles.1",
|
|
37
37
|
"@blaze-cms/utils": "0.140.2-core-styles.1",
|
|
38
|
-
"@blaze-cms/utils-handlebars": "0.141.0-core-styles.
|
|
38
|
+
"@blaze-cms/utils-handlebars": "0.141.0-core-styles.21",
|
|
39
39
|
"@blaze-react/breadcrumb": "0.8.0-alpha.60",
|
|
40
40
|
"@blaze-react/button": "0.5.19",
|
|
41
41
|
"@blaze-react/checkboxes": "0.5.31",
|
|
42
|
-
"@blaze-react/input": "0.
|
|
42
|
+
"@blaze-react/input": "0.8.0-alpha.78",
|
|
43
43
|
"@blaze-react/modal": "0.5.19",
|
|
44
44
|
"@blaze-react/range-filter": "0.7.2",
|
|
45
|
-
"@blaze-react/select": "0.8.0-alpha.
|
|
45
|
+
"@blaze-react/select": "0.8.0-alpha.78",
|
|
46
46
|
"@blaze-react/utils": "0.5.15",
|
|
47
47
|
"core-js": "^3.2.1",
|
|
48
48
|
"entities": "^2.0.0",
|
|
@@ -89,5 +89,5 @@
|
|
|
89
89
|
"lib/*",
|
|
90
90
|
"lib-es/*"
|
|
91
91
|
],
|
|
92
|
-
"gitHead": "
|
|
92
|
+
"gitHead": "5c47857c58e770d9533e569522053fa587f41a38"
|
|
93
93
|
}
|
|
@@ -3,14 +3,31 @@ import PropTypes from 'prop-types';
|
|
|
3
3
|
import { Link, MainContext } from '@blaze-cms/nextjs-components';
|
|
4
4
|
import buildLinkExtraProps from '../helpers/build-link-extra-props';
|
|
5
5
|
|
|
6
|
-
const BlazeLink = ({
|
|
6
|
+
const BlazeLink = ({
|
|
7
|
+
children,
|
|
8
|
+
className,
|
|
9
|
+
name,
|
|
10
|
+
ariaLabel,
|
|
11
|
+
href,
|
|
12
|
+
as,
|
|
13
|
+
shallow,
|
|
14
|
+
scroll,
|
|
15
|
+
gtmId,
|
|
16
|
+
onClick
|
|
17
|
+
}) => {
|
|
7
18
|
const { hasGTM } = useContext(MainContext);
|
|
8
19
|
const gtmProps = hasGTM && !!gtmId ? { gtmId } : {};
|
|
9
20
|
const linkExtraProps = buildLinkExtraProps({ className, name, as, ...gtmProps });
|
|
10
21
|
if (!href) return children;
|
|
11
22
|
|
|
12
23
|
return (
|
|
13
|
-
<Link
|
|
24
|
+
<Link
|
|
25
|
+
href={href}
|
|
26
|
+
ariaLabel={ariaLabel}
|
|
27
|
+
shallow={shallow}
|
|
28
|
+
scroll={scroll}
|
|
29
|
+
onClick={onClick}
|
|
30
|
+
{...linkExtraProps}>
|
|
14
31
|
{children}
|
|
15
32
|
</Link>
|
|
16
33
|
);
|
|
@@ -26,7 +43,8 @@ BlazeLink.propTypes = {
|
|
|
26
43
|
shallow: PropTypes.bool,
|
|
27
44
|
scroll: PropTypes.bool,
|
|
28
45
|
gtmId: PropTypes.string,
|
|
29
|
-
onClick: PropTypes.func
|
|
46
|
+
onClick: PropTypes.func,
|
|
47
|
+
ariaLabel: PropTypes.string
|
|
30
48
|
};
|
|
31
49
|
|
|
32
50
|
BlazeLink.defaultProps = {
|
|
@@ -39,7 +57,8 @@ BlazeLink.defaultProps = {
|
|
|
39
57
|
shallow: false,
|
|
40
58
|
scroll: null,
|
|
41
59
|
gtmId: '',
|
|
42
|
-
onClick: null
|
|
60
|
+
onClick: null,
|
|
61
|
+
ariaLabel: ''
|
|
43
62
|
};
|
|
44
63
|
|
|
45
64
|
export default BlazeLink;
|
|
@@ -72,7 +72,8 @@ ImageRender.propTypes = {
|
|
|
72
72
|
style: PropTypes.object,
|
|
73
73
|
isHero: PropTypes.bool,
|
|
74
74
|
priority: PropTypes.bool,
|
|
75
|
-
sizeKey: PropTypes.string
|
|
75
|
+
sizeKey: PropTypes.string,
|
|
76
|
+
shouldRenderImgTag: PropTypes.bool
|
|
76
77
|
};
|
|
77
78
|
|
|
78
79
|
ImageRender.defaultProps = {
|
|
@@ -84,7 +85,8 @@ ImageRender.defaultProps = {
|
|
|
84
85
|
isHero: false,
|
|
85
86
|
priority: false,
|
|
86
87
|
style: {},
|
|
87
|
-
sizeKey: ''
|
|
88
|
+
sizeKey: '',
|
|
89
|
+
shouldRenderImgTag: false
|
|
88
90
|
};
|
|
89
91
|
|
|
90
92
|
export default ImageRender;
|
|
@@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
|
|
|
3
3
|
import { useRouter } from 'next/router';
|
|
4
4
|
import { parseUrl } from 'query-string';
|
|
5
5
|
import { buildAzUrl } from '../../helpers';
|
|
6
|
+
import BlazeLink from '../../../BlazeLink';
|
|
6
7
|
|
|
7
8
|
const ListHeader = ({ name, listAggregations, azFilter }) => {
|
|
8
9
|
const router = useRouter();
|
|
@@ -12,7 +13,8 @@ const ListHeader = ({ name, listAggregations, azFilter }) => {
|
|
|
12
13
|
|
|
13
14
|
return (
|
|
14
15
|
<div className="az_list_filter flex">
|
|
15
|
-
<
|
|
16
|
+
<BlazeLink
|
|
17
|
+
ariaLabel="Show all"
|
|
16
18
|
className={`az_list_filter_option${!azFilter ? ' selected' : ''} flex-grow`}
|
|
17
19
|
href={allHref}
|
|
18
20
|
onClick={e => {
|
|
@@ -20,7 +22,7 @@ const ListHeader = ({ name, listAggregations, azFilter }) => {
|
|
|
20
22
|
return router.push('/Resolver', allHref, { shallow: true });
|
|
21
23
|
}}>
|
|
22
24
|
ALL
|
|
23
|
-
</
|
|
25
|
+
</BlazeLink>
|
|
24
26
|
{listAggregations.map(({ key, doc_count: count }) => {
|
|
25
27
|
if (!count)
|
|
26
28
|
return (
|
|
@@ -34,7 +36,8 @@ const ListHeader = ({ name, listAggregations, azFilter }) => {
|
|
|
34
36
|
const className = `az_list_filter_option${isSelected ? ' selected' : ''} flex-grow`;
|
|
35
37
|
|
|
36
38
|
return (
|
|
37
|
-
<
|
|
39
|
+
<BlazeLink
|
|
40
|
+
ariaLabel={`Filter by ${key}`}
|
|
38
41
|
key={key}
|
|
39
42
|
className={className}
|
|
40
43
|
href={href}
|
|
@@ -43,7 +46,7 @@ const ListHeader = ({ name, listAggregations, azFilter }) => {
|
|
|
43
46
|
return router.push('/Resolver', href, { shallow: true });
|
|
44
47
|
}}>
|
|
45
48
|
{key}
|
|
46
|
-
</
|
|
49
|
+
</BlazeLink>
|
|
47
50
|
);
|
|
48
51
|
})}
|
|
49
52
|
</div>
|
|
@@ -22,7 +22,7 @@ const Classic = ({ name, numberOfPages, currentPage, query, url, isLastPage, onC
|
|
|
22
22
|
onClick={onClick}
|
|
23
23
|
shallow
|
|
24
24
|
scroll>
|
|
25
|
-
{PREVIOUS_STRING}
|
|
25
|
+
{`${PREVIOUS_STRING} page`}
|
|
26
26
|
</BlazeLink>
|
|
27
27
|
)}
|
|
28
28
|
{pages}
|
|
@@ -33,7 +33,7 @@ const Classic = ({ name, numberOfPages, currentPage, query, url, isLastPage, onC
|
|
|
33
33
|
onClick={onClick}
|
|
34
34
|
shallow
|
|
35
35
|
scroll>
|
|
36
|
-
{NEXT_STRING}
|
|
36
|
+
{`${NEXT_STRING} page`}
|
|
37
37
|
</BlazeLink>
|
|
38
38
|
)}
|
|
39
39
|
</>
|
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { LOAD_MORE_STRING } from '../../../../constants';
|
|
4
4
|
import buildPaginationUrl from '../../helpers/build-pagination-url';
|
|
5
|
+
import BlazeLink from '../../../BlazeLink';
|
|
5
6
|
|
|
6
7
|
const LoadMore = ({ name, currentPage, query, url, triggerInfiniteScroll, isLastPage }) => {
|
|
7
8
|
if (isLastPage) return null;
|
|
@@ -15,9 +16,13 @@ const LoadMore = ({ name, currentPage, query, url, triggerInfiniteScroll, isLast
|
|
|
15
16
|
|
|
16
17
|
return (
|
|
17
18
|
<>
|
|
18
|
-
<
|
|
19
|
+
<BlazeLink
|
|
20
|
+
className="pagination_load-more"
|
|
21
|
+
role="button"
|
|
22
|
+
href={nextPageLink}
|
|
23
|
+
onClick={loadMoreItems}>
|
|
19
24
|
{LOAD_MORE_STRING}
|
|
20
|
-
</
|
|
25
|
+
</BlazeLink>
|
|
21
26
|
</>
|
|
22
27
|
);
|
|
23
28
|
};
|
|
@@ -6,6 +6,7 @@ import { useRouter } from 'next/router';
|
|
|
6
6
|
import { MdMenu, MdClose } from 'react-icons/md';
|
|
7
7
|
import { Link } from '@blaze-cms/nextjs-components';
|
|
8
8
|
import MenuContext from './MenuContext';
|
|
9
|
+
import BlazeLink from '../BlazeLink';
|
|
9
10
|
|
|
10
11
|
const Menu = ({
|
|
11
12
|
children,
|
|
@@ -76,7 +77,7 @@ const Menu = ({
|
|
|
76
77
|
)}
|
|
77
78
|
{logoOnMobile &&
|
|
78
79
|
!showMobileMenu && (
|
|
79
|
-
<Link href="/">
|
|
80
|
+
<Link href="/" name="mobile menu">
|
|
80
81
|
<img src={logoOnMobileUrl} alt={logoOnMobileAlt} className={logoOnMobileModifier} />
|
|
81
82
|
</Link>
|
|
82
83
|
)}
|
|
@@ -84,13 +85,13 @@ const Menu = ({
|
|
|
84
85
|
<div className="menu--desktop-wrapper">
|
|
85
86
|
<ul className={childModifiers}>
|
|
86
87
|
{logoOnDesktop && (
|
|
87
|
-
<
|
|
88
|
+
<BlazeLink href="/" className="">
|
|
88
89
|
<img
|
|
89
90
|
src={logoOnMobileUrl}
|
|
90
91
|
alt={logoOnMobileAlt}
|
|
91
92
|
className={logoOnDesktopModifier}
|
|
92
93
|
/>
|
|
93
|
-
</
|
|
94
|
+
</BlazeLink>
|
|
94
95
|
)}
|
|
95
96
|
{children}
|
|
96
97
|
</ul>
|
|
@@ -2,18 +2,24 @@
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import { SOCIAL_NETWORKS, BASE_CLASS_NAME_FOLLOW } from './sf.config';
|
|
5
|
+
import BlazeLink from '../BlazeLink';
|
|
5
6
|
|
|
6
7
|
const SFItem = ({ url, id }) => {
|
|
7
8
|
const { name, className, Icon, spanClassName } = SOCIAL_NETWORKS[id];
|
|
8
9
|
|
|
9
10
|
return (
|
|
10
11
|
<li className={BASE_CLASS_NAME_FOLLOW}>
|
|
11
|
-
<
|
|
12
|
+
<BlazeLink
|
|
13
|
+
href={url}
|
|
14
|
+
className={className}
|
|
15
|
+
rel="noopener nofollow"
|
|
16
|
+
target="_blank"
|
|
17
|
+
ariaLabel={name}>
|
|
12
18
|
<i>
|
|
13
19
|
<Icon />
|
|
14
20
|
</i>
|
|
15
21
|
<span className={`social__network ${spanClassName}`}>{name}</span>
|
|
16
|
-
</
|
|
22
|
+
</BlazeLink>
|
|
17
23
|
</li>
|
|
18
24
|
);
|
|
19
25
|
};
|
|
@@ -8,8 +8,8 @@ const ThumbnailCarousel = props => {
|
|
|
8
8
|
imageIds,
|
|
9
9
|
selectedImageId,
|
|
10
10
|
priorityLimit,
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
scrollToImage,
|
|
12
|
+
mainImageButtonClick
|
|
13
13
|
} = useThumbnailCarousel(props);
|
|
14
14
|
|
|
15
15
|
return (
|
|
@@ -22,12 +22,7 @@ const ThumbnailCarousel = props => {
|
|
|
22
22
|
onClick={() => mainImageButtonClick()}>
|
|
23
23
|
<div className="arrow arrow--left" />
|
|
24
24
|
</div>
|
|
25
|
-
<
|
|
26
|
-
className="thumbnail-carousel__main_image_container__main-image"
|
|
27
|
-
data-testid="thumbnail-main-image"
|
|
28
|
-
ref={thumbnailsListRef}>
|
|
29
|
-
<ThumbnailImage {...props} priority imageId={selectedImageId} />
|
|
30
|
-
</div>
|
|
25
|
+
<ThumbnailImage {...props} priority imageId={selectedImageId} />
|
|
31
26
|
<div
|
|
32
27
|
id="next-button"
|
|
33
28
|
className="thumbnail-carousel__main_image_container__button next"
|
|
@@ -36,15 +31,16 @@ const ThumbnailCarousel = props => {
|
|
|
36
31
|
<div className="arrow arrow--right" />
|
|
37
32
|
</div>
|
|
38
33
|
</div>
|
|
39
|
-
<div className="thumbnail-carousel__list">
|
|
34
|
+
<div className="thumbnail-carousel__list" ref={thumbnailsListRef}>
|
|
40
35
|
{imageIds.map((imageId, index) => (
|
|
41
36
|
<ThumbnailImage
|
|
42
37
|
{...props}
|
|
43
38
|
key={imageId}
|
|
39
|
+
imageIndex={index}
|
|
44
40
|
priority={index < priorityLimit}
|
|
45
41
|
imageId={imageId}
|
|
46
42
|
selectedImageId={selectedImageId}
|
|
47
|
-
|
|
43
|
+
scrollToImage={scrollToImage}
|
|
48
44
|
/>
|
|
49
45
|
))}
|
|
50
46
|
</div>
|
|
@@ -3,33 +3,19 @@ import LazyImage from '../../../components/LazyImage';
|
|
|
3
3
|
import useThumbnailImage from './useThumbnailImage';
|
|
4
4
|
|
|
5
5
|
const ThumbnailImage = props => {
|
|
6
|
-
const {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
className,
|
|
10
|
-
imageRef,
|
|
11
|
-
imageUrl,
|
|
12
|
-
altText,
|
|
13
|
-
priority,
|
|
14
|
-
handleClick,
|
|
15
|
-
handleEnableLightbox
|
|
16
|
-
} = useThumbnailImage(props);
|
|
6
|
+
const { loading, error, className, imageUrl, altText, priority, handleClick } = useThumbnailImage(
|
|
7
|
+
props
|
|
8
|
+
);
|
|
17
9
|
|
|
18
10
|
if (error) return error.message;
|
|
19
11
|
if (loading) return null;
|
|
20
12
|
|
|
21
13
|
return (
|
|
22
|
-
<div
|
|
23
|
-
ref={imageRef}
|
|
24
|
-
className={className}
|
|
25
|
-
onClick={handleClick}
|
|
26
|
-
role="button"
|
|
27
|
-
data-testid="thumbnail-image">
|
|
14
|
+
<div className={className} onClick={handleClick} role="button" data-testid="thumbnail-image">
|
|
28
15
|
<LazyImage
|
|
29
16
|
src={imageUrl}
|
|
30
17
|
alt={altText}
|
|
31
18
|
sizeKey="carousel"
|
|
32
|
-
onClick={handleEnableLightbox}
|
|
33
19
|
role="button"
|
|
34
20
|
priority={priority}
|
|
35
21
|
/>
|
|
@@ -1,38 +1,25 @@
|
|
|
1
|
-
import { useEffect, useRef } from 'react';
|
|
2
1
|
import PropTypes from 'prop-types';
|
|
3
2
|
import { useGetImages } from '../../../hooks';
|
|
4
3
|
import { getImageData } from '../../../utils';
|
|
5
4
|
|
|
6
5
|
const useThumbnailImage = ({
|
|
7
6
|
imageId,
|
|
7
|
+
imageIndex,
|
|
8
8
|
enableLightbox,
|
|
9
9
|
toggleModal,
|
|
10
10
|
handleSelectedImage,
|
|
11
11
|
priority,
|
|
12
12
|
selectedImageId,
|
|
13
|
-
|
|
13
|
+
scrollToImage
|
|
14
14
|
}) => {
|
|
15
|
-
const imageRef = useRef(null);
|
|
16
|
-
const isSelected = selectedImageId === imageId;
|
|
17
15
|
const { data = {}, loading, error } = useGetImages(imageId);
|
|
18
16
|
|
|
19
|
-
useEffect(
|
|
20
|
-
() => {
|
|
21
|
-
if (imageRef.current && isSelected) {
|
|
22
|
-
imageRef.current.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
[isSelected]
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
const handleEnableLightbox = () => {
|
|
29
|
-
if (!enableLightbox) return;
|
|
30
|
-
toggleModal();
|
|
31
|
-
handleSelectedImage(imageId);
|
|
32
|
-
};
|
|
33
|
-
|
|
34
17
|
const handleClick = () => {
|
|
35
|
-
|
|
18
|
+
if (scrollToImage) scrollToImage(imageIndex);
|
|
19
|
+
else if (enableLightbox) {
|
|
20
|
+
toggleModal();
|
|
21
|
+
handleSelectedImage(imageId);
|
|
22
|
+
}
|
|
36
23
|
};
|
|
37
24
|
|
|
38
25
|
const { url: imageUrl = '', data: imageData = {} } = data.getFile || {
|
|
@@ -49,12 +36,11 @@ const useThumbnailImage = ({
|
|
|
49
36
|
loading,
|
|
50
37
|
error,
|
|
51
38
|
className,
|
|
52
|
-
|
|
39
|
+
imageId,
|
|
53
40
|
imageUrl,
|
|
54
41
|
altText,
|
|
55
42
|
priority,
|
|
56
|
-
handleClick
|
|
57
|
-
handleEnableLightbox
|
|
43
|
+
handleClick
|
|
58
44
|
};
|
|
59
45
|
};
|
|
60
46
|
|
|
@@ -65,11 +51,11 @@ useThumbnailImage.propTypes = {
|
|
|
65
51
|
toggleModal: PropTypes.func.isRequired,
|
|
66
52
|
handleSelectedImage: PropTypes.func.isRequired,
|
|
67
53
|
priority: PropTypes.bool.isRequired,
|
|
68
|
-
|
|
54
|
+
scrollToImage: PropTypes.func
|
|
69
55
|
};
|
|
70
56
|
|
|
71
57
|
useThumbnailImage.defaultProps = {
|
|
72
|
-
|
|
58
|
+
scrollToImage: null
|
|
73
59
|
};
|
|
74
60
|
|
|
75
61
|
export default useThumbnailImage;
|
|
@@ -6,20 +6,25 @@ const useThumbnailCarousel = ({ imageIds, priorityLimit, ...props }) => {
|
|
|
6
6
|
const selectedImageId = imageIds[selectedImageIndex];
|
|
7
7
|
|
|
8
8
|
const mainImageButtonClick = next => {
|
|
9
|
+
let newIndex;
|
|
9
10
|
if (next) {
|
|
10
11
|
const isLast = imageIds.length - 1 === selectedImageIndex;
|
|
11
|
-
|
|
12
|
-
setSelectedImageIndex(newIndex);
|
|
12
|
+
newIndex = isLast ? 0 : selectedImageIndex + 1;
|
|
13
13
|
} else {
|
|
14
14
|
const isFirst = selectedImageIndex === 0;
|
|
15
|
-
|
|
16
|
-
setSelectedImageIndex(newIndex);
|
|
15
|
+
newIndex = isFirst ? imageIds.length - 1 : selectedImageIndex - 1;
|
|
17
16
|
}
|
|
17
|
+
scrollToImage(newIndex);
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
const scrollToImage = newIndex => {
|
|
21
|
+
if (thumbnailsListRef.current && selectedImageIndex !== newIndex) {
|
|
22
|
+
thumbnailsListRef.current.scrollTo({
|
|
23
|
+
left: 150 * newIndex,
|
|
24
|
+
behavior: 'smooth'
|
|
25
|
+
});
|
|
26
|
+
setSelectedImageIndex(newIndex);
|
|
27
|
+
}
|
|
23
28
|
};
|
|
24
29
|
|
|
25
30
|
return {
|
|
@@ -29,7 +34,7 @@ const useThumbnailCarousel = ({ imageIds, priorityLimit, ...props }) => {
|
|
|
29
34
|
selectedImageIndex,
|
|
30
35
|
thumbnailsListRef,
|
|
31
36
|
priorityLimit,
|
|
32
|
-
|
|
37
|
+
scrollToImage,
|
|
33
38
|
mainImageButtonClick
|
|
34
39
|
};
|
|
35
40
|
};
|
|
@@ -12,6 +12,7 @@ exports[`Breadcrumb component should match snapshot 1`] = `
|
|
|
12
12
|
class="breadcrumb__item"
|
|
13
13
|
>
|
|
14
14
|
<a
|
|
15
|
+
aria-label="Home"
|
|
15
16
|
href="/"
|
|
16
17
|
>
|
|
17
18
|
Home
|
|
@@ -39,6 +40,7 @@ exports[`Breadcrumb component should not render if loading, err or no data exist
|
|
|
39
40
|
class="breadcrumb__item"
|
|
40
41
|
>
|
|
41
42
|
<a
|
|
43
|
+
aria-label="Home"
|
|
42
44
|
href="/"
|
|
43
45
|
>
|
|
44
46
|
Home
|
|
@@ -66,6 +68,7 @@ exports[`Breadcrumb component should render 1`] = `
|
|
|
66
68
|
class="breadcrumb__item"
|
|
67
69
|
>
|
|
68
70
|
<a
|
|
71
|
+
aria-label="Home"
|
|
69
72
|
href="/"
|
|
70
73
|
>
|
|
71
74
|
Home
|
|
@@ -74,7 +74,7 @@ describe('Button component', () => {
|
|
|
74
74
|
const propsWithoutText = { ...componentProps, text: '' };
|
|
75
75
|
const { container } = await renderComponent(propsWithoutText);
|
|
76
76
|
expect(container.innerHTML).toBe(
|
|
77
|
-
'<a href="http://google.com" rel="noopener nofollow" target="_blank" class="icon-button"><i class="fas fas-trash"></i></a>'
|
|
77
|
+
'<a aria-label="Open http://google.com" href="http://google.com" rel="noopener nofollow" target="_blank" class="icon-button"><i class="fas fas-trash"></i></a>'
|
|
78
78
|
);
|
|
79
79
|
});
|
|
80
80
|
|
|
@@ -87,7 +87,7 @@ describe('Button component', () => {
|
|
|
87
87
|
const propsWithIcon = { ...componentProps, text: '', icon: 'test-icon' };
|
|
88
88
|
const { container } = await renderComponent(propsWithIcon);
|
|
89
89
|
expect(container.innerHTML).toBe(
|
|
90
|
-
'<a href="http://google.com" rel="noopener nofollow" target="_blank" class="icon-button"><i class="test-icon"></i></a>'
|
|
90
|
+
'<a aria-label="Open http://google.com" href="http://google.com" rel="noopener nofollow" target="_blank" class="icon-button"><i class="test-icon"></i></a>'
|
|
91
91
|
);
|
|
92
92
|
});
|
|
93
93
|
|
|
@@ -9,6 +9,7 @@ exports[`Card component should not render alternative headline if alternativePre
|
|
|
9
9
|
class="card__image card__image--portrait"
|
|
10
10
|
>
|
|
11
11
|
<a
|
|
12
|
+
aria-label="Open /mockurl"
|
|
12
13
|
class="card__image-link"
|
|
13
14
|
href="/mockurl"
|
|
14
15
|
>
|
|
@@ -25,6 +26,7 @@ exports[`Card component should not render alternative headline if alternativePre
|
|
|
25
26
|
class="card__content card__content--portrait"
|
|
26
27
|
>
|
|
27
28
|
<a
|
|
29
|
+
aria-label="category-name"
|
|
28
30
|
class="badge badge--label"
|
|
29
31
|
href="published-url"
|
|
30
32
|
>
|
|
@@ -34,6 +36,7 @@ exports[`Card component should not render alternative headline if alternativePre
|
|
|
34
36
|
class="card__title card__title--portrait "
|
|
35
37
|
>
|
|
36
38
|
<a
|
|
39
|
+
aria-label="mock name"
|
|
37
40
|
href="/mockurl"
|
|
38
41
|
>
|
|
39
42
|
mock name
|
|
@@ -84,6 +87,7 @@ exports[`Card component should not render alternative headline if displayCategor
|
|
|
84
87
|
class="card__image card__image--portrait"
|
|
85
88
|
>
|
|
86
89
|
<a
|
|
90
|
+
aria-label="Open /mockurl"
|
|
87
91
|
class="card__image-link"
|
|
88
92
|
href="/mockurl"
|
|
89
93
|
>
|
|
@@ -103,6 +107,7 @@ exports[`Card component should not render alternative headline if displayCategor
|
|
|
103
107
|
class="card__title card__title--portrait "
|
|
104
108
|
>
|
|
105
109
|
<a
|
|
110
|
+
aria-label="mock name"
|
|
106
111
|
href="/mockurl"
|
|
107
112
|
>
|
|
108
113
|
mock name
|
|
@@ -153,6 +158,7 @@ exports[`Card component should not render preHeader if alternativeHeadline is no
|
|
|
153
158
|
class="card__image card__image--portrait"
|
|
154
159
|
>
|
|
155
160
|
<a
|
|
161
|
+
aria-label="Open /mockurl"
|
|
156
162
|
class="card__image-link"
|
|
157
163
|
href="/mockurl"
|
|
158
164
|
>
|
|
@@ -169,6 +175,7 @@ exports[`Card component should not render preHeader if alternativeHeadline is no
|
|
|
169
175
|
class="card__content card__content--portrait"
|
|
170
176
|
>
|
|
171
177
|
<a
|
|
178
|
+
aria-label="category-name"
|
|
172
179
|
class="badge badge--label"
|
|
173
180
|
href="published-url"
|
|
174
181
|
>
|
|
@@ -178,6 +185,7 @@ exports[`Card component should not render preHeader if alternativeHeadline is no
|
|
|
178
185
|
class="card__title card__title--portrait "
|
|
179
186
|
>
|
|
180
187
|
<a
|
|
188
|
+
aria-label="mock name"
|
|
181
189
|
href="/mockurl"
|
|
182
190
|
>
|
|
183
191
|
mock name
|
|
@@ -228,6 +236,7 @@ exports[`Card component should render customPreheader and alternativeHeadline in
|
|
|
228
236
|
class="card__image card__image--portrait"
|
|
229
237
|
>
|
|
230
238
|
<a
|
|
239
|
+
aria-label="Open /mockurl"
|
|
231
240
|
class="card__image-link"
|
|
232
241
|
href="/mockurl"
|
|
233
242
|
>
|
|
@@ -252,6 +261,7 @@ exports[`Card component should render customPreheader and alternativeHeadline in
|
|
|
252
261
|
class="card__title card__title--portrait "
|
|
253
262
|
>
|
|
254
263
|
<a
|
|
264
|
+
aria-label="Alternative headline"
|
|
255
265
|
href="/mockurl"
|
|
256
266
|
>
|
|
257
267
|
Alternative headline
|
|
@@ -302,6 +312,7 @@ exports[`Card component should render without throwing an error and match snapsh
|
|
|
302
312
|
class="card__image card__image--portrait"
|
|
303
313
|
>
|
|
304
314
|
<a
|
|
315
|
+
aria-label="Open /mockurl"
|
|
305
316
|
class="card__image-link"
|
|
306
317
|
href="/mockurl"
|
|
307
318
|
>
|
|
@@ -318,6 +329,7 @@ exports[`Card component should render without throwing an error and match snapsh
|
|
|
318
329
|
class="card__content card__content--portrait"
|
|
319
330
|
>
|
|
320
331
|
<a
|
|
332
|
+
aria-label="category-name"
|
|
321
333
|
class="badge badge--label"
|
|
322
334
|
href="published-url"
|
|
323
335
|
>
|
|
@@ -327,6 +339,7 @@ exports[`Card component should render without throwing an error and match snapsh
|
|
|
327
339
|
class="card__title card__title--portrait "
|
|
328
340
|
>
|
|
329
341
|
<a
|
|
342
|
+
aria-label="mock name"
|
|
330
343
|
href="/mockurl"
|
|
331
344
|
>
|
|
332
345
|
mock name
|