gatsby-core-theme 1.6.19 → 2.0.0
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 +92 -0
- package/gatsby-node.esm.js +23 -14
- package/package.json +2 -2
- package/src/components/app.js +4 -0
- package/src/components/atoms/iframe/index.js +15 -9
- package/src/components/atoms/menu/items/item/index.js +9 -1
- package/src/components/atoms/selling-points/index.js +1 -2
- package/src/components/atoms/selling-points/selling-points.module.scss +12 -5
- package/src/components/atoms/selling-points/selling-points.test.js +1 -1
- package/src/components/molecules/content/index.js +5 -1
- 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/link-list/index.js +9 -12
- package/src/components/molecules/menu/index.js +6 -1
- package/src/components/molecules/operator-banner/operator-banner.test.js +0 -1
- 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/molecules/star-rating/index.js +8 -24
- package/src/components/molecules/star-rating/star-rating.module.scss +13 -1
- package/src/components/molecules/star-rating/star-rating.test.js +4 -2
- package/src/components/molecules/tnc/index.js +2 -3
- package/src/components/molecules/tnc/tnc.test.js +0 -1
- package/src/components/molecules/toplist/default-row/index.js +22 -20
- package/src/components/organisms/navigation/index.js +9 -1
- package/src/components/pages/search/index.js +3 -2
- package/src/helpers/device-detect.js +5 -6
- package/src/helpers/events.js +91 -0
- package/src/helpers/generators.js +11 -3
- package/src/helpers/generators.test.js +34 -12
- package/src/helpers/processor/sports.js +0 -2
- package/src/helpers/rating.js +2 -0
- package/src/helpers/schedule.js +0 -36
- package/src/hooks/lazy-image/index.js +30 -44
- package/src/hooks/tabs/index.js +4 -2
- package/src/hooks/tabs/tabs.test.js +32 -15
- package/src/styles/utils/_mixins.scss +42 -0
- package/src/styles/utils/variables/_main.scss +8 -0
|
@@ -1,39 +1,29 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
2
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
3
|
-
// import LazyLoad from 'react-lazyload';
|
|
4
3
|
import PropTypes from 'prop-types';
|
|
4
|
+
import loadable from '@loadable/component';
|
|
5
|
+
import { isNativeImageLazyLoadingSupported } from '~helpers/device-detect';
|
|
5
6
|
|
|
6
|
-
// When to use this component:
|
|
7
|
-
// 1. If you have 1 image to lazyload
|
|
8
|
-
// 2. If you have images for different breakpoints and want the browser to decide when to serve the images based on the device, bandwidth, etc.
|
|
9
7
|
export default function LazyImage({
|
|
10
8
|
height,
|
|
11
9
|
width,
|
|
12
|
-
// offset = 200,
|
|
13
10
|
style = {},
|
|
14
11
|
className,
|
|
15
12
|
src = '#',
|
|
16
|
-
// srcSet = '',
|
|
17
13
|
alt = '',
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
// once = false,
|
|
14
|
+
defaultImg,
|
|
15
|
+
loading = 'lazy',
|
|
21
16
|
}) {
|
|
22
|
-
|
|
17
|
+
const [errorImage, setErrorImage] = useState(false);
|
|
23
18
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
if ((defaultImg && !src) || errorImage === true) {
|
|
20
|
+
return defaultImg;
|
|
21
|
+
}
|
|
27
22
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
width={`${width}px`}
|
|
33
|
-
offset={offset}
|
|
34
|
-
debounce={0}
|
|
35
|
-
once={once}
|
|
36
|
-
>
|
|
23
|
+
if (!isNativeImageLazyLoadingSupported()) {
|
|
24
|
+
const LazyLoad = loadable(() => import(`react-lazyload`));
|
|
25
|
+
return (
|
|
26
|
+
<LazyLoad height={`${height}px`} width={`${width}px`} debounce={0}>
|
|
37
27
|
<img
|
|
38
28
|
src={src}
|
|
39
29
|
className={className}
|
|
@@ -41,36 +31,32 @@ export default function LazyImage({
|
|
|
41
31
|
width={width}
|
|
42
32
|
alt={alt}
|
|
43
33
|
style={style}
|
|
44
|
-
srcSet={srcSet}
|
|
45
|
-
sizes={sizes}
|
|
46
|
-
onError={() => setErrorImage(true)}
|
|
47
34
|
/>
|
|
48
|
-
</LazyLoad>
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
{
|
|
60
|
-
|
|
35
|
+
</LazyLoad>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<img
|
|
41
|
+
src={src}
|
|
42
|
+
loading={loading}
|
|
43
|
+
className={className}
|
|
44
|
+
height={height}
|
|
45
|
+
width={width}
|
|
46
|
+
alt={alt}
|
|
47
|
+
style={style}
|
|
48
|
+
onError={() => setErrorImage(true)}
|
|
49
|
+
/>
|
|
61
50
|
);
|
|
62
51
|
}
|
|
63
52
|
|
|
64
53
|
LazyImage.propTypes = {
|
|
65
54
|
width: PropTypes.number,
|
|
66
55
|
height: PropTypes.number,
|
|
67
|
-
// offset: PropTypes.number,
|
|
68
56
|
style: PropTypes.shape({}),
|
|
69
57
|
className: PropTypes.string,
|
|
70
58
|
src: PropTypes.string,
|
|
71
59
|
alt: PropTypes.string,
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
// defaultImg: PropTypes.element,
|
|
75
|
-
// once: PropTypes.bool,
|
|
60
|
+
defaultImg: PropTypes.element,
|
|
61
|
+
loading: PropTypes.string,
|
|
76
62
|
};
|
package/src/hooks/tabs/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { forceCheck } from 'react-lazyload';
|
|
4
|
-
import
|
|
4
|
+
import loadable from '@loadable/component';
|
|
5
5
|
import styles from './tabs.module.scss';
|
|
6
6
|
|
|
7
7
|
const Tabs = ({
|
|
@@ -19,6 +19,8 @@ const Tabs = ({
|
|
|
19
19
|
showAll ? showAllTabId : `${children[0].props.label}_0`
|
|
20
20
|
);
|
|
21
21
|
|
|
22
|
+
const TabList = showTabs ? loadable(() => import('./tab/tab-list')) : null;
|
|
23
|
+
|
|
22
24
|
const tabHeaderClass = `${styles.tabsHeader} ${!HeaderComp && styles.tabsOnly} ${
|
|
23
25
|
styles[headerClass]
|
|
24
26
|
} ${tabsAlign === 'right' && styles.invertOrder}`;
|
|
@@ -31,7 +33,7 @@ const Tabs = ({
|
|
|
31
33
|
return (
|
|
32
34
|
<>
|
|
33
35
|
<div className={tabHeaderClass}>
|
|
34
|
-
{
|
|
36
|
+
{TabList && (
|
|
35
37
|
<TabList
|
|
36
38
|
onClick={onClickTabItem}
|
|
37
39
|
items={children}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { render, cleanup, fireEvent } from '@testing-library/react';
|
|
2
|
+
import { render, cleanup, fireEvent, waitFor } from '@testing-library/react';
|
|
3
3
|
import '@testing-library/jest-dom/extend-expect';
|
|
4
4
|
|
|
5
5
|
import Tabs from '.';
|
|
6
6
|
|
|
7
7
|
describe('Tabs Component', () => {
|
|
8
|
-
test('render tabs', () => {
|
|
8
|
+
test('render tabs', async () => {
|
|
9
9
|
const { container, getByText } = render(
|
|
10
10
|
<Tabs tabsAlign="right" HeaderComp={<div className="header">my header</div>}>
|
|
11
11
|
<div label="one" key={1}>
|
|
@@ -19,15 +19,18 @@ describe('Tabs Component', () => {
|
|
|
19
19
|
</div>
|
|
20
20
|
</Tabs>
|
|
21
21
|
);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
|
|
23
|
+
await waitFor(() => {
|
|
24
|
+
expect(container.querySelectorAll('.tabListItem')).toHaveLength(2);
|
|
25
|
+
// tabsAlign="right"
|
|
26
|
+
expect(container.querySelectorAll('div.tabsHeader.invertOrder')).toHaveLength(1);
|
|
27
|
+
// // HeaderComp
|
|
28
|
+
expect(getByText('my header')).toBeTruthy();
|
|
29
|
+
expect(getByText('1111111111111')).toBeTruthy();
|
|
30
|
+
});
|
|
28
31
|
});
|
|
29
32
|
|
|
30
|
-
test('show all', () => {
|
|
33
|
+
test('show all', async () => {
|
|
31
34
|
const { container, getByText } = render(
|
|
32
35
|
<Tabs
|
|
33
36
|
tabsAlign="left"
|
|
@@ -45,12 +48,14 @@ describe('Tabs Component', () => {
|
|
|
45
48
|
</div>
|
|
46
49
|
</Tabs>
|
|
47
50
|
);
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
+
await waitFor(() => {
|
|
52
|
+
expect(container.querySelectorAll('.tabListItem')).toHaveLength(3);
|
|
53
|
+
expect(container.querySelectorAll('div.tabsHeader')).toHaveLength(1);
|
|
54
|
+
expect(getByText('1111111111111222222233333333')).toBeInTheDocument();
|
|
55
|
+
});
|
|
51
56
|
});
|
|
52
57
|
|
|
53
|
-
test('switch tabs', () => {
|
|
58
|
+
test('switch tabs', async () => {
|
|
54
59
|
const { getByText } = render(
|
|
55
60
|
<Tabs tabsAlign="right" HeaderComp={<div className="header">my header</div>}>
|
|
56
61
|
<div label="one" key={1}>
|
|
@@ -64,11 +69,23 @@ describe('Tabs Component', () => {
|
|
|
64
69
|
</div>
|
|
65
70
|
</Tabs>
|
|
66
71
|
);
|
|
72
|
+
|
|
73
|
+
await waitFor(() => {
|
|
74
|
+
expect(getByText('two')).toBeTruthy();
|
|
75
|
+
});
|
|
76
|
+
|
|
67
77
|
fireEvent.click(getByText('two'));
|
|
68
78
|
expect(getByText('2222222')).toBeTruthy();
|
|
69
|
-
|
|
79
|
+
|
|
80
|
+
await waitFor(() => {
|
|
81
|
+
fireEvent.click(getByText('three'));
|
|
82
|
+
});
|
|
83
|
+
|
|
70
84
|
expect(getByText('33333333')).toBeTruthy();
|
|
71
|
-
|
|
85
|
+
|
|
86
|
+
await waitFor(() => {
|
|
87
|
+
fireEvent.click(getByText('one'));
|
|
88
|
+
});
|
|
72
89
|
expect(getByText('1111111111111')).toBeTruthy();
|
|
73
90
|
});
|
|
74
91
|
});
|
|
@@ -84,3 +84,45 @@
|
|
|
84
84
|
background: linear-gradient(to bottom, $color2 0, $color1 100%);
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
|
+
|
|
88
|
+
@mixin star($border-color: #fba62f, $fill-color: #fba62f) {
|
|
89
|
+
line-height: 2rem;
|
|
90
|
+
width: 16px;
|
|
91
|
+
font-weight: normal;
|
|
92
|
+
display: inline-block;
|
|
93
|
+
color: $fill-color;
|
|
94
|
+
font-size: 15px;
|
|
95
|
+
position: relative;
|
|
96
|
+
text-shadow: -1px 0 $border-color, 0 1px $border-color, 1px 0 $border-color, 0 -1px $border-color;
|
|
97
|
+
|
|
98
|
+
&:last-child {
|
|
99
|
+
margin-right: 0;
|
|
100
|
+
}
|
|
101
|
+
&:before {
|
|
102
|
+
content: '\2605';
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
@mixin half-star($border-color: #fba62f, $half-empty-color: #fba62f , $half-full-color: white) {
|
|
108
|
+
line-height: 2rem;
|
|
109
|
+
width: 16px;
|
|
110
|
+
font-weight: normal;
|
|
111
|
+
display: inline-block;
|
|
112
|
+
color: $half-full-color;
|
|
113
|
+
font-size: 15px;
|
|
114
|
+
position: relative;
|
|
115
|
+
&:before {
|
|
116
|
+
content: '\2605';
|
|
117
|
+
}
|
|
118
|
+
text-shadow: -1px 0 $border-color, 0 1px $border-color, 1px 0 $border-color, 0 -1px $border-color;
|
|
119
|
+
&:after {
|
|
120
|
+
content: '\2605';
|
|
121
|
+
color: $half-empty-color;
|
|
122
|
+
position: absolute;
|
|
123
|
+
width: 7px;
|
|
124
|
+
overflow: hidden;
|
|
125
|
+
bottom: 0;
|
|
126
|
+
left: 0;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
@@ -9,6 +9,13 @@
|
|
|
9
9
|
--secondary-text-color: var(--color-4);
|
|
10
10
|
--heading-base-color: var(--color-12);
|
|
11
11
|
--text-link-color: var(--color-13);
|
|
12
|
+
--full-star-fill-color: #fba62f;
|
|
13
|
+
--full-star-border-color: #fba62f;
|
|
14
|
+
--halfFull-star-fill-color: #fba62f;
|
|
15
|
+
--halfEmpty-star-fill-color: white;
|
|
16
|
+
--half-star-border-color: #fba62f;
|
|
17
|
+
--empty-star-fill-color: white;
|
|
18
|
+
--empty-star-border-color: grey;
|
|
12
19
|
|
|
13
20
|
// Font
|
|
14
21
|
--main-font: Nunito;
|
|
@@ -51,6 +58,7 @@
|
|
|
51
58
|
--modal-background-color: white;
|
|
52
59
|
|
|
53
60
|
--star-rating-color: orange;
|
|
61
|
+
--selling-point-icon-color: #00889e;
|
|
54
62
|
|
|
55
63
|
--scroll-to-top-background-color: var(--color-1);
|
|
56
64
|
|