gatsby-core-theme 1.6.21 → 1.6.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 +15 -0
- package/package.json +2 -2
- package/src/components/molecules/footer/footer.test.js +22 -22
- package/src/components/molecules/footer/index.js +3 -1
- package/src/components/molecules/header/index.js +7 -2
- package/src/components/molecules/search/index.js +5 -3
- package/src/components/molecules/slider/index.js +6 -2
- package/src/components/molecules/slider/slider.test.js +30 -23
- package/src/components/pages/search/index.js +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
## [1.6.22](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v1.6.21...v1.6.22) (2021-12-10)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* tests ([c8f7780](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/c8f7780b257ef1994244217d9d20c2c934a43859))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Code Refactoring
|
|
10
|
+
|
|
11
|
+
* using loadable for components set to visible against a condition ([16e23e0](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/16e23e06b835f7b41a303f1ff317d3dc19dd1d9c))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
* Merge branch 'performance-improvements' into 'master' ([a853c75](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/a853c75bcdafe099f4b8b4e13485477503c0fc85))
|
|
15
|
+
|
|
1
16
|
## [1.6.21](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v1.6.20...v1.6.21) (2021-12-07)
|
|
2
17
|
|
|
3
18
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gatsby-core-theme",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.22",
|
|
4
4
|
"description": "Gatsby Theme NPM Package",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"GATSBY_RECAPTCHA_SITEKEY": "6LfoyvMUAAAAAO4nl_MQnqHb4XdHxEiu5cXgIqeB",
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
"babel-preset-gatsby": "^1.3.0",
|
|
86
86
|
"eslint-import-resolver-alias": "^1.1.2",
|
|
87
87
|
"eslint-plugin-react": "^7.22.0",
|
|
88
|
-
"gatsby-plugin-webpack-bundle-analyser-v2": "^1.1.
|
|
88
|
+
"gatsby-plugin-webpack-bundle-analyser-v2": "^1.1.26",
|
|
89
89
|
"identity-obj-proxy": "^3.0.0",
|
|
90
90
|
"jest": "^26.6.3",
|
|
91
91
|
"react-test-renderer": "^17.0.1",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { render, cleanup } from '@testing-library/react';
|
|
2
|
+
import { render, cleanup, waitFor } from '@testing-library/react';
|
|
3
3
|
import '@testing-library/jest-dom/extend-expect';
|
|
4
4
|
|
|
5
5
|
import getFooterSection from '~tests/factories/sections/footer.factory';
|
|
@@ -8,7 +8,7 @@ import Footer from '.';
|
|
|
8
8
|
const footerSection = getFooterSection();
|
|
9
9
|
|
|
10
10
|
describe('Footer Component', () => {
|
|
11
|
-
test('render footer menu items', () => {
|
|
11
|
+
test('render footer menu items', async () => {
|
|
12
12
|
const { getByText } = render(
|
|
13
13
|
<Footer
|
|
14
14
|
footerMenu="footer_links"
|
|
@@ -16,27 +16,26 @@ describe('Footer Component', () => {
|
|
|
16
16
|
section={footerSection.sections.footer}
|
|
17
17
|
/>
|
|
18
18
|
);
|
|
19
|
-
expect(getByText('test1sub1')).toBeTruthy();
|
|
20
|
-
expect(getByText('test1sub1').closest('a').getAttribute('href')).toEqual('/test1sub1link');
|
|
21
|
-
expect(getByText('test1sub2')).toBeTruthy();
|
|
22
|
-
expect(getByText('test1sub2').closest('a').getAttribute('href')).toEqual('/test1sub2link');
|
|
23
|
-
expect(getByText('test1sub2').closest('ul').children.length).toBe(3);
|
|
24
19
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
20
|
+
await waitFor(() => {
|
|
21
|
+
expect(getByText('test1sub1')).toBeTruthy();
|
|
22
|
+
expect(getByText('test1sub1').closest('a').getAttribute('href')).toEqual('/test1sub1link');
|
|
23
|
+
expect(getByText('test1sub2')).toBeTruthy();
|
|
24
|
+
expect(getByText('test1sub2').closest('a').getAttribute('href')).toEqual('/test1sub2link');
|
|
25
|
+
expect(getByText('test1sub2').closest('ul').children.length).toBe(3);
|
|
26
|
+
|
|
27
|
+
expect(getByText('test2sub1')).toBeTruthy();
|
|
28
|
+
expect(getByText('test2sub1').closest('a').getAttribute('href')).toEqual('/test2sub1link');
|
|
29
|
+
expect(getByText('test2sub2')).toBeTruthy();
|
|
30
|
+
expect(getByText('test2sub2').closest('a').getAttribute('href')).toEqual('/test2sub2link');
|
|
31
|
+
expect(getByText('test2sub2').closest('ul').children.length).toBe(3);
|
|
32
|
+
});
|
|
30
33
|
});
|
|
31
34
|
|
|
32
35
|
test('render footer extra component', () => {
|
|
33
|
-
const FooterTop = () =>
|
|
34
|
-
return <>Test Extra component</>;
|
|
35
|
-
};
|
|
36
|
+
const FooterTop = () => <>Test Extra component</>;
|
|
36
37
|
|
|
37
|
-
const FooterBottom= () =>
|
|
38
|
-
return <>Test Extra component2</>;
|
|
39
|
-
};
|
|
38
|
+
const FooterBottom = () => <>Test Extra component2</>;
|
|
40
39
|
|
|
41
40
|
const { getByText } = render(
|
|
42
41
|
<Footer
|
|
@@ -51,7 +50,7 @@ describe('Footer Component', () => {
|
|
|
51
50
|
expect(getByText('Test Extra component2')).toBeTruthy();
|
|
52
51
|
});
|
|
53
52
|
|
|
54
|
-
test('render logo list', () => {
|
|
53
|
+
test('render logo list', async () => {
|
|
55
54
|
const { getByTitle } = render(
|
|
56
55
|
<Footer
|
|
57
56
|
footerMenu="footer_links"
|
|
@@ -59,9 +58,10 @@ describe('Footer Component', () => {
|
|
|
59
58
|
section={footerSection.sections.footer}
|
|
60
59
|
/>
|
|
61
60
|
);
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
await waitFor(() => {
|
|
62
|
+
expect(getByTitle('logo1')).toBeTruthy();
|
|
63
|
+
expect(getByTitle('logo2')).toBeTruthy();
|
|
64
|
+
});
|
|
65
65
|
});
|
|
66
66
|
});
|
|
67
67
|
afterEach(() => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import
|
|
3
|
+
import loadable from '@loadable/component';
|
|
4
4
|
import { getExtraField, copyrightText } from '~helpers/getters';
|
|
5
5
|
import styles from './footer.module.scss';
|
|
6
6
|
|
|
@@ -19,6 +19,8 @@ const Footer = ({
|
|
|
19
19
|
const BottomSection = footerBottomCustom;
|
|
20
20
|
const showLinks = template !== 'ppc';
|
|
21
21
|
|
|
22
|
+
const LinkList = footerMenu && showLinks ? loadable(() => import('~molecules/link-list')) : null;
|
|
23
|
+
|
|
22
24
|
return (
|
|
23
25
|
<footer className={styles.footer}>
|
|
24
26
|
<div className={styles.topPart}>
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
|
|
4
|
+
import loadable from '@loadable/component';
|
|
4
5
|
import styles from './header.module.scss';
|
|
5
6
|
import Breadcrumbs from '~atoms/breadcrumbs';
|
|
6
|
-
import Author from '~atoms/author';
|
|
7
7
|
import { imagePrettyUrl, getSectionExtraField } from '~helpers/getters';
|
|
8
8
|
|
|
9
9
|
// eslint-disable-next-line import/no-named-as-default
|
|
@@ -41,6 +41,11 @@ function Header({ section, content = null, backgroundImage = true }) {
|
|
|
41
41
|
return <div dangerouslySetInnerHTML={innerBannerHTML()} />;
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
+
const Author =
|
|
45
|
+
section.page.path !== '/' && section.page.path !== 'contact-us' && section.page.author
|
|
46
|
+
? loadable(() => import('~atoms/author'))
|
|
47
|
+
: null;
|
|
48
|
+
|
|
44
49
|
return (
|
|
45
50
|
<header className={styles.header}>
|
|
46
51
|
{backgroundImage && backgroundImg}
|
|
@@ -51,7 +56,7 @@ function Header({ section, content = null, backgroundImage = true }) {
|
|
|
51
56
|
>
|
|
52
57
|
<div className={styles.topSection}>
|
|
53
58
|
{section.page.path && <Breadcrumbs page={section.page} />}
|
|
54
|
-
{
|
|
59
|
+
{Author && (
|
|
55
60
|
<div className={styles.authorContainer}>
|
|
56
61
|
<Author
|
|
57
62
|
authorProfile={section.page.author?.profile_page_path}
|
|
@@ -2,7 +2,7 @@ import React, { useState, useEffect, useRef, useCallback, useContext } from 'rea
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { navigate } from 'gatsby';
|
|
4
4
|
import { FaSearch } from 'react-icons/fa';
|
|
5
|
-
|
|
5
|
+
import loadable from '@loadable/component';
|
|
6
6
|
import LazyImage from '~hooks/lazy-image';
|
|
7
7
|
import ConditionalWrapper from '~atoms/conditional-wrapper';
|
|
8
8
|
import styles from './search.module.scss';
|
|
@@ -12,9 +12,7 @@ import keygen from '~helpers/keygen';
|
|
|
12
12
|
import { filterByKey, sortDateOn, sortIntOn, sortStringOn } from '~helpers/search';
|
|
13
13
|
import loadSource from '~helpers/search-source';
|
|
14
14
|
import { leftTrim } from '~helpers/strings';
|
|
15
|
-
import Archive from '~organisms/archive';
|
|
16
15
|
import ModuleTitle from '~atoms/module-title';
|
|
17
|
-
import CustomSelect from '~atoms/custom-select';
|
|
18
16
|
import { NavigationContext } from '~organisms/navigation/navigationContext';
|
|
19
17
|
|
|
20
18
|
/* eslint-disable no-underscore-dangle */
|
|
@@ -213,6 +211,8 @@ const Search = ({
|
|
|
213
211
|
}
|
|
214
212
|
}, [pageSearchOptionsCopy]);
|
|
215
213
|
if (pageSearchOptionsCopy !== null && pageSearchOptionsCopy.sort !== undefined) {
|
|
214
|
+
const CustomSelect = loadable(() => import('~atoms/custom-select'));
|
|
215
|
+
|
|
216
216
|
pageSearchOptionsCopy.tabsOptions.HeaderComp = (
|
|
217
217
|
<div className={styles.selectwrapper}>
|
|
218
218
|
<CustomSelect
|
|
@@ -343,6 +343,8 @@ const Search = ({
|
|
|
343
343
|
|
|
344
344
|
if (items.length === 0) return null;
|
|
345
345
|
|
|
346
|
+
const Archive = loadable(() => import('~organisms/archive'));
|
|
347
|
+
|
|
346
348
|
return (
|
|
347
349
|
<div label={titleObj.title} tabId={type + index} key={keygen()}>
|
|
348
350
|
{pageSearchOptionsCopy.useArchive === undefined ||
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
/* eslint-disable react-hooks/exhaustive-deps */
|
|
3
3
|
import React, { useState, useRef, useEffect } from 'react';
|
|
4
4
|
import PropTypes, { element } from 'prop-types';
|
|
5
|
+
import loadable from '@loadable/component';
|
|
5
6
|
|
|
6
7
|
import {
|
|
7
8
|
updateSlider,
|
|
@@ -14,7 +15,6 @@ import {
|
|
|
14
15
|
|
|
15
16
|
import styles from './slider.module.scss';
|
|
16
17
|
import Arrow from '~atoms/carousel/arrow';
|
|
17
|
-
import Pagination from '~atoms/carousel/pagination-item';
|
|
18
18
|
|
|
19
19
|
function Slider({
|
|
20
20
|
gtmClass = '',
|
|
@@ -179,6 +179,10 @@ function Slider({
|
|
|
179
179
|
};
|
|
180
180
|
});
|
|
181
181
|
|
|
182
|
+
const Pagination = usePagination
|
|
183
|
+
? loadable(() => import('~atoms/carousel/pagination-item'))
|
|
184
|
+
: null;
|
|
185
|
+
|
|
182
186
|
return (
|
|
183
187
|
state.length > 0 && (
|
|
184
188
|
<div className={`${className} ${styles.slider}`} ref={sliderContainerRef}>
|
|
@@ -221,7 +225,7 @@ function Slider({
|
|
|
221
225
|
</div>
|
|
222
226
|
))}
|
|
223
227
|
</div>
|
|
224
|
-
{
|
|
228
|
+
{Pagination && (
|
|
225
229
|
<Pagination
|
|
226
230
|
type="dots"
|
|
227
231
|
paginationHandler={paginationHandler}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { render, cleanup, fireEvent, act } from '@testing-library/react';
|
|
2
|
+
import { render, cleanup, fireEvent, act, waitFor } from '@testing-library/react';
|
|
3
3
|
import '@testing-library/jest-dom/extend-expect';
|
|
4
4
|
import keygen from '~helpers/keygen';
|
|
5
5
|
import Slider from '.';
|
|
@@ -12,9 +12,9 @@ describe('Slider Component', () => {
|
|
|
12
12
|
act(() => {
|
|
13
13
|
const { container } = render(
|
|
14
14
|
<Slider useArrows={false} usePagination={false} settings={{ numberOfSlides: 0 }}>
|
|
15
|
-
{list.map((element) =>
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
{list.map((element) => (
|
|
16
|
+
<div key={keygen()}>{element}</div>
|
|
17
|
+
))}
|
|
18
18
|
</Slider>
|
|
19
19
|
);
|
|
20
20
|
|
|
@@ -30,9 +30,9 @@ describe('Slider Component', () => {
|
|
|
30
30
|
const list = ['Summer', 'Autumn', 'Winter', 'Spring'];
|
|
31
31
|
const { container } = render(
|
|
32
32
|
<Slider useArrows={false} usePagination={false} settings={{ numberOfSlides: 0 }}>
|
|
33
|
-
{list.map((element) =>
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
{list.map((element) => (
|
|
34
|
+
<div key={keygen()}>{element}</div>
|
|
35
|
+
))}
|
|
36
36
|
</Slider>
|
|
37
37
|
);
|
|
38
38
|
|
|
@@ -51,20 +51,24 @@ describe('Slider Component', () => {
|
|
|
51
51
|
const list = ['Summer', 'Autumn', 'Winter', 'Spring'];
|
|
52
52
|
const { container } = render(
|
|
53
53
|
<Slider>
|
|
54
|
-
{list.map((element) =>
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
{list.map((element) => (
|
|
55
|
+
<div key={keygen()}>{element}</div>
|
|
56
|
+
))}
|
|
57
57
|
</Slider>
|
|
58
58
|
);
|
|
59
59
|
|
|
60
60
|
const prev = container.querySelector('button.left');
|
|
61
61
|
const next = container.querySelector('button.right');
|
|
62
|
-
|
|
62
|
+
|
|
63
|
+
await waitFor(() => {
|
|
64
|
+
const dots = container.querySelector('div.pagination');
|
|
65
|
+
expect(dots).toBeTruthy();
|
|
66
|
+
});
|
|
67
|
+
|
|
63
68
|
const content = container.querySelector('div.sliderContent');
|
|
64
69
|
|
|
65
70
|
expect(prev).toBeTruthy();
|
|
66
71
|
expect(next).toBeTruthy();
|
|
67
|
-
expect(dots).toBeTruthy();
|
|
68
72
|
expect(content).toBeTruthy();
|
|
69
73
|
expect(content.querySelector('.active>div').innerHTML).toBe('Summer');
|
|
70
74
|
});
|
|
@@ -74,15 +78,15 @@ describe('Slider Component', () => {
|
|
|
74
78
|
|
|
75
79
|
const { container } = render(
|
|
76
80
|
<Slider>
|
|
77
|
-
{list.map((element) =>
|
|
78
|
-
|
|
79
|
-
|
|
81
|
+
{list.map((element) => (
|
|
82
|
+
<div key={keygen()}>{element}</div>
|
|
83
|
+
))}
|
|
80
84
|
</Slider>
|
|
81
85
|
);
|
|
82
86
|
|
|
83
87
|
const prev = container.querySelector('button.left');
|
|
84
88
|
const next = container.querySelector('button.right');
|
|
85
|
-
|
|
89
|
+
|
|
86
90
|
const content = container.querySelector('div.sliderContent');
|
|
87
91
|
|
|
88
92
|
fireEvent.click(next);
|
|
@@ -91,10 +95,13 @@ describe('Slider Component', () => {
|
|
|
91
95
|
fireEvent.click(prev);
|
|
92
96
|
expect(content.querySelector('.active>div').innerHTML).toBe('Summer');
|
|
93
97
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
+
await waitFor(() => {
|
|
99
|
+
const dots = container.querySelector('div.pagination');
|
|
100
|
+
const dot = dots.querySelectorAll('button');
|
|
101
|
+
expect(dot.length).toEqual(4);
|
|
102
|
+
fireEvent.click(dot[1]);
|
|
103
|
+
expect(content.querySelector('.active>div').innerHTML).toBe('Autumn');
|
|
104
|
+
});
|
|
98
105
|
});
|
|
99
106
|
|
|
100
107
|
test('Swipe Slides', async () => {
|
|
@@ -102,9 +109,9 @@ describe('Slider Component', () => {
|
|
|
102
109
|
act(() => {
|
|
103
110
|
const { container } = render(
|
|
104
111
|
<Slider>
|
|
105
|
-
{list.map((element) =>
|
|
106
|
-
|
|
107
|
-
|
|
112
|
+
{list.map((element) => (
|
|
113
|
+
<div key={keygen()}>{element}</div>
|
|
114
|
+
))}
|
|
108
115
|
</Slider>
|
|
109
116
|
);
|
|
110
117
|
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/* eslint-disable arrow-body-style */
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
|
-
|
|
5
|
-
import Search from '~molecules/search';
|
|
4
|
+
import loadable from '@loadable/component';
|
|
6
5
|
import Card from '~atoms/cards/default-card';
|
|
7
6
|
import { translate } from '~helpers/getters';
|
|
8
7
|
|
|
9
8
|
const SearchContent = ({ page }) => {
|
|
9
|
+
const Search = loadable(() => import('~molecules/search'));
|
|
10
|
+
|
|
10
11
|
return (
|
|
11
12
|
<Search
|
|
12
13
|
pageSearchOptions={{
|