gatsby-core-theme 30.0.66 → 30.0.67
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 +14 -0
- package/package.json +1 -1
- package/src/components/atoms/pretty-link/index.js +2 -2
- package/src/components/molecules/bonus/template-one/index.js +1 -1
- package/src/components/molecules/bonus/template-two/index.js +2 -2
- package/src/components/molecules/content/content.module.scss +10 -0
- package/src/components/molecules/module/module.module.scss +14 -0
- package/src/components/organisms/anchor/template-one/anchor.module.scss +4 -173
- package/src/components/organisms/anchor/template-one/anchor.stories.js +9 -28
- package/src/components/organisms/anchor/template-one/anchor.test.js +0 -1
- package/src/components/organisms/anchor/template-one/index.js +59 -105
- package/src/components/organisms/anchor/template-two/index.js +1 -22
- package/src/components/organisms/anchor/template-two/template-two.test.js +0 -1
- package/src/styles/utils/variables/_main.scss +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [30.0.67](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v30.0.66...v30.0.67) (2024-01-31)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* add validation ([9fb7327](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/9fb7327f8db264823ce66fadb205cbc7b71496f7))
|
|
7
|
+
* add validation ([23b06e6](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/23b06e6bef4ce0bb8baaebd926ed93da6cf296d9))
|
|
8
|
+
* anchor ([b83b456](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/b83b456efdc7418322642043e31c21f60ddaa57d))
|
|
9
|
+
* anchor module ([0e41993](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/0e41993d7c280aa3135d09f6038faf96cfec5267))
|
|
10
|
+
* fix tests ([6315ec5](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/6315ec564073a949c6583f400b44b02bdd8aa29a))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
* Merge branch 'tm-3976-anchor-module' into 'master' ([14e5e79](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/14e5e7979fb68d019d0453418c8212f58a459357))
|
|
14
|
+
|
|
1
15
|
## [30.0.66](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v30.0.65...v30.0.66) (2024-01-30)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
|
@@ -27,11 +27,11 @@ const PrettyLink = ({
|
|
|
27
27
|
return (
|
|
28
28
|
<a
|
|
29
29
|
href={prettyLink || '#'}
|
|
30
|
-
title={operator
|
|
30
|
+
title={operator?.name}
|
|
31
31
|
className={className}
|
|
32
32
|
target="_blank"
|
|
33
33
|
rel="noreferrer sponsored nofollow"
|
|
34
|
-
aria-label={`${operator
|
|
34
|
+
aria-label={`${operator?.name} Link`}
|
|
35
35
|
onClick={onCTAClick}
|
|
36
36
|
>
|
|
37
37
|
{children}
|
|
@@ -44,7 +44,7 @@ export default function Bonus({
|
|
|
44
44
|
<LazyImage alt={operator?.name} src={imagePrettyUrl(logo)} height={120} width={100} />
|
|
45
45
|
<div className={styles.details}>
|
|
46
46
|
{name && <span>{name}</span>}
|
|
47
|
-
{(operator
|
|
47
|
+
{(operator?.rating || bonus?.rating) && (
|
|
48
48
|
<Rating rating={operator.rating || bonus?.rating} showDecimal />
|
|
49
49
|
)}
|
|
50
50
|
</div>
|
|
@@ -70,8 +70,8 @@ export default function TemplateOne({
|
|
|
70
70
|
/>
|
|
71
71
|
<div className={styles.details}>
|
|
72
72
|
{name && <span>{name}</span>}
|
|
73
|
-
{(operator
|
|
74
|
-
<Rating rating={operator
|
|
73
|
+
{(operator?.rating || bonus?.rating) && (
|
|
74
|
+
<Rating rating={operator?.rating || bonus?.rating} showDecimal />
|
|
75
75
|
)}
|
|
76
76
|
</div>
|
|
77
77
|
</PrettyLink>
|
|
@@ -26,6 +26,16 @@
|
|
|
26
26
|
padding: var(--padding-conent) !important;
|
|
27
27
|
border: var(--border-content-module);
|
|
28
28
|
background: var(--background-content-module);
|
|
29
|
+
h1,
|
|
30
|
+
h2,
|
|
31
|
+
h3,
|
|
32
|
+
h4,
|
|
33
|
+
h5 {
|
|
34
|
+
scroll-margin-top: calc(var(--nav-height-mobile, 60) + var(--nav-anchor-height, 40));
|
|
35
|
+
@include min(laptop){
|
|
36
|
+
scroll-margin-top: calc(var(--nav-height-desktop, 80) + var(--nav-anchor-height, 40));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
29
39
|
|
|
30
40
|
@include min(tablet) {
|
|
31
41
|
margin: var(--margin-content-min-tablet) !important;
|
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
.module {
|
|
2
2
|
background-color: var(--module-background-color);
|
|
3
3
|
padding: 4.8rem 0;
|
|
4
|
+
scroll-margin-top: calc(var(--nav-height-mobile, 60) + var(--nav-anchor-height, 40));
|
|
5
|
+
@include min(laptop){
|
|
6
|
+
scroll-margin-top: calc(var(--nav-height-desktop, 80) + var(--nav-anchor-height, 40));
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.module,
|
|
11
|
+
.module h1,
|
|
12
|
+
.module h2,
|
|
13
|
+
.module h3 {
|
|
14
|
+
scroll-margin-top: calc(var(--nav-height-mobile) + var(--nav-anchor-height));
|
|
15
|
+
@include min(laptop) {
|
|
16
|
+
scroll-margin-top: calc(var(--nav-height-desktop) + var(--nav-anchor-height));
|
|
17
|
+
}
|
|
4
18
|
}
|
|
5
19
|
|
|
6
20
|
.anchor-module {
|
|
@@ -22,6 +22,8 @@
|
|
|
22
22
|
left: 0;
|
|
23
23
|
right: 0;
|
|
24
24
|
top: var(--nav-height);
|
|
25
|
+
@include flex-direction(row);
|
|
26
|
+
@include flex-align(center, center);
|
|
25
27
|
|
|
26
28
|
&.usingExclOperator {
|
|
27
29
|
top: calc(var(--nav-height) + var(--exc-operator-height));
|
|
@@ -37,11 +39,11 @@
|
|
|
37
39
|
|
|
38
40
|
.defaultConatiner {
|
|
39
41
|
position: relative;
|
|
42
|
+
@include flex-direction(row);
|
|
40
43
|
}
|
|
41
44
|
|
|
42
45
|
.anchor {
|
|
43
46
|
max-width: var(--main-container-max);
|
|
44
|
-
margin: 0 auto;
|
|
45
47
|
@include flex-direction(row);
|
|
46
48
|
|
|
47
49
|
&::-webkit-scrollbar {
|
|
@@ -98,13 +100,6 @@
|
|
|
98
100
|
}
|
|
99
101
|
}
|
|
100
102
|
|
|
101
|
-
.storyDivs {
|
|
102
|
-
width: 100%;
|
|
103
|
-
display: block;
|
|
104
|
-
margin: 3rem 0;
|
|
105
|
-
padding: 2rem;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
103
|
.anchorTitle {
|
|
109
104
|
font-size: var(--h2-size);
|
|
110
105
|
font-weight: var(--h2-font-weight);
|
|
@@ -119,6 +114,7 @@
|
|
|
119
114
|
@include flex-align(center, center);
|
|
120
115
|
display: none;
|
|
121
116
|
z-index: 1;
|
|
117
|
+
padding: 0rem 1rem;
|
|
122
118
|
|
|
123
119
|
@include custom-min(960) {
|
|
124
120
|
display: flex;
|
|
@@ -139,169 +135,4 @@
|
|
|
139
135
|
color: #515156;
|
|
140
136
|
background-color: #f4f4f4;
|
|
141
137
|
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
.staticShowButtons {
|
|
145
|
-
display: flex;
|
|
146
|
-
|
|
147
|
-
>button:first-child {
|
|
148
|
-
padding-right: 1.6rem;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
>button:last-of-type {
|
|
152
|
-
padding-left: 1.6rem;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
.stickyShowButtons {
|
|
157
|
-
>button:first-child {
|
|
158
|
-
position: absolute;
|
|
159
|
-
top: 0.6rem;
|
|
160
|
-
padding-right: 1.6rem;
|
|
161
|
-
height: 4rem;
|
|
162
|
-
|
|
163
|
-
@include custom-min(960) {
|
|
164
|
-
left: calc(50% - (var(--anchor-max-width, --main-container-max) / 2) - 2.6rem);
|
|
165
|
-
transform: translateX(50%);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
>button:last-of-type {
|
|
170
|
-
position: absolute;
|
|
171
|
-
top: 0.6rem;
|
|
172
|
-
height: 4rem;
|
|
173
|
-
padding-left: 1.6rem;
|
|
174
|
-
|
|
175
|
-
@include custom-min(960) {
|
|
176
|
-
right: calc(50% - (var(--anchor-max-width, --main-container-max) / 2) - 2.6rem);
|
|
177
|
-
transform: translateX(-50%);
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
>ul {
|
|
182
|
-
>li:first-child {
|
|
183
|
-
margin-left: 4.8rem;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
>li:last-child {
|
|
187
|
-
margin-right: 4.8rem;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
.containerAnchorFullWidth {
|
|
193
|
-
max-width: 100% !important;
|
|
194
|
-
padding: 0 !important;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
.titleFullWidth {
|
|
198
|
-
padding: 0 1.6rem;
|
|
199
|
-
max-width: var(--anchor-max-width, --main-container-max);
|
|
200
|
-
margin: 0 auto;
|
|
201
|
-
|
|
202
|
-
@include min(tablet) {
|
|
203
|
-
padding: 0 2.4rem;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
.staticFullScrollWidth {
|
|
208
|
-
min-width: 100vw;
|
|
209
|
-
display: inline-grid;
|
|
210
|
-
|
|
211
|
-
@include min(tablet) {
|
|
212
|
-
max-width: 100vw;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
&:not(.staticShowButtons) {
|
|
216
|
-
&::before {
|
|
217
|
-
display: none;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
>ul {
|
|
221
|
-
>li:first-child {
|
|
222
|
-
padding-left: calc((100vw - var(--anchor-max-width, --main-container-max)) / 2) !important;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
&::before,
|
|
228
|
-
&::after {
|
|
229
|
-
content: '';
|
|
230
|
-
display: none;
|
|
231
|
-
position: absolute;
|
|
232
|
-
top: 0;
|
|
233
|
-
background-color: var(--body-background-color, white);
|
|
234
|
-
height: 4.5rem;
|
|
235
|
-
z-index: 1;
|
|
236
|
-
|
|
237
|
-
@include custom-min(960) {
|
|
238
|
-
display: block;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
@include custom-min-max(960, 1100) {
|
|
242
|
-
width: 2.4rem;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
width: calc((100% - var(--anchor-max-width, --main-container-max)) / 2 + 6.8rem);
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
&::before {
|
|
249
|
-
left: 0;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
&::after {
|
|
253
|
-
right: 0;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
>button {
|
|
257
|
-
position: absolute;
|
|
258
|
-
z-index: 2;
|
|
259
|
-
height: 4.5rem;
|
|
260
|
-
padding-right: 1.6rem;
|
|
261
|
-
left: calc((100vw - var(--anchor-max-width, --main-container-max)) / 2 + 2.4rem);
|
|
262
|
-
|
|
263
|
-
&:last-of-type {
|
|
264
|
-
left: unset;
|
|
265
|
-
right: calc((100vw - var(--anchor-max-width, --main-container-max)) / 2 + 2.4rem);
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
@include custom-min-max(960, 1100) {
|
|
269
|
-
left: 2.4rem;
|
|
270
|
-
|
|
271
|
-
&:last-of-type {
|
|
272
|
-
right: 2.4rem;
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
>ul {
|
|
278
|
-
max-width: unset !important;
|
|
279
|
-
margin: 0 !important;
|
|
280
|
-
padding: 0 1.6rem;
|
|
281
|
-
|
|
282
|
-
&::-webkit-scrollbar {
|
|
283
|
-
display: block !important;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
>li:first-child {
|
|
287
|
-
padding-left: calc((100vw - var(--anchor-max-width, --main-container-max)) / 2 + 5.8rem) !important;
|
|
288
|
-
|
|
289
|
-
@include custom-min-max(960, 1100) {
|
|
290
|
-
padding-left: 7.2rem !important;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
>li:last-child {
|
|
296
|
-
padding-right: calc((100vw - var(--anchor-max-width, --main-container-max)) / 2 + 5.8rem) !important;
|
|
297
|
-
|
|
298
|
-
@include custom-min-max(960, 1100) {
|
|
299
|
-
padding-right: 7.2rem !important;
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
.displayNone {
|
|
306
|
-
visibility: hidden !important;
|
|
307
138
|
}
|
|
@@ -92,7 +92,13 @@ const sections = [
|
|
|
92
92
|
const Template = (args) => (
|
|
93
93
|
<>
|
|
94
94
|
<Navigation {...navigationData} />
|
|
95
|
-
<main
|
|
95
|
+
<main
|
|
96
|
+
style={{
|
|
97
|
+
marginTop: 'var(--nav-height, 8rem)',
|
|
98
|
+
'--anchor-max-width': `${args?.width}`,
|
|
99
|
+
alignItems: 'center',
|
|
100
|
+
}}
|
|
101
|
+
>
|
|
96
102
|
<Anchor {...args} />
|
|
97
103
|
{sections?.map((sec) => (
|
|
98
104
|
<div id={sec}>
|
|
@@ -132,7 +138,7 @@ Default.args = {
|
|
|
132
138
|
],
|
|
133
139
|
},
|
|
134
140
|
fullScrollWidth: false,
|
|
135
|
-
|
|
141
|
+
setShowButtons: false,
|
|
136
142
|
sliderGap: 10,
|
|
137
143
|
headerOffset: 20,
|
|
138
144
|
};
|
|
@@ -157,32 +163,7 @@ FullWidth.args = {
|
|
|
157
163
|
],
|
|
158
164
|
},
|
|
159
165
|
fullScrollWidth: true,
|
|
160
|
-
|
|
161
|
-
sliderGap: 10,
|
|
162
|
-
headerOffset: 80,
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
export const Buttons = Template.bind({});
|
|
166
|
-
Buttons.args = {
|
|
167
|
-
width: '100%',
|
|
168
|
-
module: {
|
|
169
|
-
items: [
|
|
170
|
-
{ label: 'section-one' },
|
|
171
|
-
{ label: 'section-two' },
|
|
172
|
-
{ label: 'section-three' },
|
|
173
|
-
{ label: 'section-four' },
|
|
174
|
-
{ label: 'section-five' },
|
|
175
|
-
{ label: 'section-six' },
|
|
176
|
-
{ label: 'section-seven' },
|
|
177
|
-
{ label: 'section-eight' },
|
|
178
|
-
{ label: 'section-nine' },
|
|
179
|
-
{ label: 'section-ten' },
|
|
180
|
-
{ label: 'section-eleven' },
|
|
181
|
-
{ label: 'section-twelf' },
|
|
182
|
-
],
|
|
183
|
-
},
|
|
184
|
-
fullScrollWidth: false,
|
|
185
|
-
isShowButtons: true,
|
|
166
|
+
setShowButtons: true,
|
|
186
167
|
sliderGap: 10,
|
|
187
168
|
headerOffset: 80,
|
|
188
169
|
};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
/* eslint-disable no-unused-expressions */
|
|
4
4
|
/* eslint-disable prefer-destructuring */
|
|
5
5
|
/* eslint-disable react-hooks/exhaustive-deps */
|
|
6
|
-
import React, { useRef, useContext, useState
|
|
6
|
+
import React, { useRef, useContext, useState } from 'react';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import { IoIosArrowBack } from '@react-icons/all-files/io/IoIosArrowBack';
|
|
9
9
|
import { IoIosArrowForward } from '@react-icons/all-files/io/IoIosArrowForward';
|
|
@@ -17,7 +17,7 @@ import styles from './anchor.module.scss';
|
|
|
17
17
|
|
|
18
18
|
function Anchor({
|
|
19
19
|
module: { items },
|
|
20
|
-
headerOffset =
|
|
20
|
+
headerOffset = 80,
|
|
21
21
|
isFixed = true,
|
|
22
22
|
stickyOffset = 0,
|
|
23
23
|
icon = null,
|
|
@@ -26,27 +26,30 @@ function Anchor({
|
|
|
26
26
|
offset = 10,
|
|
27
27
|
exclOperator = false,
|
|
28
28
|
isScrollable = true,
|
|
29
|
-
|
|
29
|
+
minCharactersForButtons = 86,
|
|
30
|
+
setShowButtons = true,
|
|
30
31
|
buttonScroll = 200,
|
|
31
32
|
leftButtonIcon = <IoIosArrowBack />,
|
|
32
33
|
rightButtonIcon = <IoIosArrowForward />,
|
|
33
|
-
fullScrollWidth = false,
|
|
34
34
|
}) {
|
|
35
35
|
const [scrollX, setScrollX] = useState(0);
|
|
36
36
|
const [scrollEnd, setScrollEnd] = useState(false);
|
|
37
|
-
const [showButtons, setShowButtons] = useState(false);
|
|
38
|
-
const [loading, setLoading] = useState(!!isShowButtons);
|
|
39
37
|
|
|
40
38
|
const itemsRef = useRef([]);
|
|
41
39
|
const anchorContainerRef = useRef(null);
|
|
42
40
|
const anchorListRef = useRef(null);
|
|
43
41
|
const progressBar = useRef(null);
|
|
44
42
|
const { translations } = useContext(Context) || {};
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
43
|
+
let numberOfCharacters = 0;
|
|
44
|
+
const anchorList = items.map((anchor) => {
|
|
45
|
+
numberOfCharacters += anchor?.label?.length;
|
|
46
|
+
return {
|
|
47
|
+
id: `${anchor.label && removeSymbols(anchorLink(anchor?.label?.toLowerCase().trim()))}`,
|
|
48
|
+
label: anchor.label,
|
|
49
|
+
slug: `${anchor.label && anchorLink(anchor?.label?.toLowerCase().trim())}`,
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
const showButtons = numberOfCharacters > minCharactersForButtons && setShowButtons;
|
|
50
53
|
|
|
51
54
|
const updateButtons = (shift) => {
|
|
52
55
|
setScrollEnd(
|
|
@@ -74,36 +77,10 @@ function Anchor({
|
|
|
74
77
|
setScrollX(scrollLeft);
|
|
75
78
|
};
|
|
76
79
|
|
|
77
|
-
useEffect(() => {
|
|
78
|
-
if (isShowButtons) {
|
|
79
|
-
setShowButtons(anchorListRef.current.scrollWidth > anchorListRef.current.offsetWidth);
|
|
80
|
-
setLoading(false);
|
|
81
|
-
}
|
|
82
|
-
}, []);
|
|
83
|
-
|
|
84
80
|
function compact(array) {
|
|
85
81
|
return array?.filter(Boolean);
|
|
86
82
|
}
|
|
87
83
|
|
|
88
|
-
const handleClick = (event) => {
|
|
89
|
-
event.preventDefault();
|
|
90
|
-
const scrollToElementId = event.currentTarget.getAttribute('href').replace('#', '');
|
|
91
|
-
|
|
92
|
-
const targetEl = document.getElementById(scrollToElementId);
|
|
93
|
-
|
|
94
|
-
if (targetEl) {
|
|
95
|
-
const offsetPosition = targetEl.offsetTop - headerOffset;
|
|
96
|
-
window.scrollTo({
|
|
97
|
-
top: isFixed ? offsetPosition - heightOfAnchor : offsetPosition,
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
function getWindowDimensions() {
|
|
103
|
-
const { innerWidth: width } = window;
|
|
104
|
-
return width;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
84
|
const setActiveAnchor = () => {
|
|
108
85
|
const { innerHeight, scrollY } = window;
|
|
109
86
|
|
|
@@ -144,12 +121,8 @@ function Anchor({
|
|
|
144
121
|
const elementOffsetLeft = activeElement.offsetLeft;
|
|
145
122
|
|
|
146
123
|
if (elementOffsetLeft > anchorContainerRef.current.offsetWidth - elementOffsetWidth) {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
elementOffsetWidth + elementOffsetLeft + 5 - anchorContainerRef.current.offsetWidth;
|
|
150
|
-
} else {
|
|
151
|
-
anchorListRef.current.scrollLeft = elementOffsetLeft - 5;
|
|
152
|
-
}
|
|
124
|
+
anchorListRef.current.scrollLeft =
|
|
125
|
+
elementOffsetWidth + elementOffsetLeft + 5 - anchorContainerRef.current.offsetWidth;
|
|
153
126
|
} else {
|
|
154
127
|
anchorListRef.current.scrollLeft = 0;
|
|
155
128
|
}
|
|
@@ -168,7 +141,6 @@ function Anchor({
|
|
|
168
141
|
draggable="false"
|
|
169
142
|
// eslint-disable-next-line no-return-assign
|
|
170
143
|
ref={(el) => (itemsRef.current[index] = el)}
|
|
171
|
-
onClick={handleClick}
|
|
172
144
|
href={`#${item?.id && item.id}`}
|
|
173
145
|
>
|
|
174
146
|
{translate(translations, item.slug, item.label)}
|
|
@@ -178,69 +150,51 @@ function Anchor({
|
|
|
178
150
|
));
|
|
179
151
|
|
|
180
152
|
return (
|
|
181
|
-
<div
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
153
|
+
<div className={styles.containerAnchor || ''} ref={anchorContainerRef}>
|
|
154
|
+
{showTitle && (
|
|
155
|
+
<div className={`${styles.anchorTitle || ''}`}>
|
|
156
|
+
<span>{translate(translations, 'anchor_title', 'Table of Contents')}</span>
|
|
157
|
+
</div>
|
|
158
|
+
)}
|
|
159
|
+
|
|
160
|
+
<div
|
|
161
|
+
className={`${sticky ? styles.stickyContainer || '' : styles.defaultConatiner || ''}
|
|
162
|
+
${exclOperator ? styles.usingExclOperator || '' : ''}`}
|
|
163
|
+
>
|
|
164
|
+
{showButtons && (
|
|
165
|
+
<button
|
|
166
|
+
className={`${styles.buttLeft} ${scrollX <= 0 ? styles.disabled : ''}`}
|
|
167
|
+
onClick={() => scroll(-buttonScroll)}
|
|
168
|
+
type="button"
|
|
191
169
|
>
|
|
192
|
-
|
|
193
|
-
</
|
|
194
|
-
)
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
? styles.stickyFullScrollWidth
|
|
203
|
-
: styles.staticFullScrollWidth
|
|
204
|
-
: ''
|
|
205
|
-
}
|
|
206
|
-
${exclOperator ? styles.usingExclOperator || '' : ''}`}
|
|
170
|
+
{leftButtonIcon}
|
|
171
|
+
</button>
|
|
172
|
+
)}
|
|
173
|
+
|
|
174
|
+
<ScollX
|
|
175
|
+
refTag={anchorListRef}
|
|
176
|
+
scroll={isScrollable}
|
|
177
|
+
stopScrolling={() => onStopScrolling()}
|
|
178
|
+
onScroll={onScroll}
|
|
179
|
+
leftPosition={scrollX}
|
|
207
180
|
>
|
|
208
|
-
{
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
refTag={anchorListRef}
|
|
219
|
-
scroll={isScrollable}
|
|
220
|
-
stopScrolling={() => onStopScrolling()}
|
|
221
|
-
onScroll={onScroll}
|
|
222
|
-
leftPosition={scrollX}
|
|
181
|
+
<ul ref={anchorListRef} className={`${styles.anchor || ''}`}>
|
|
182
|
+
{anchorItems}
|
|
183
|
+
</ul>
|
|
184
|
+
</ScollX>
|
|
185
|
+
|
|
186
|
+
{showButtons && (
|
|
187
|
+
<button
|
|
188
|
+
className={`${styles.buttRight} ${!scrollEnd ? '' : styles.disabled}`}
|
|
189
|
+
onClick={() => scroll(buttonScroll)}
|
|
190
|
+
type="button"
|
|
223
191
|
>
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
{anchorItems}
|
|
229
|
-
</ul>
|
|
230
|
-
</ScollX>
|
|
231
|
-
{showButtons && (
|
|
232
|
-
<button
|
|
233
|
-
className={`${styles.buttRight} ${!scrollEnd ? '' : styles.disabled}`}
|
|
234
|
-
onClick={() => scroll(buttonScroll)}
|
|
235
|
-
type="button"
|
|
236
|
-
>
|
|
237
|
-
{rightButtonIcon}
|
|
238
|
-
</button>
|
|
239
|
-
)}
|
|
192
|
+
{rightButtonIcon}
|
|
193
|
+
</button>
|
|
194
|
+
)}
|
|
195
|
+
</div>
|
|
240
196
|
|
|
241
|
-
|
|
242
|
-
</div>
|
|
243
|
-
</>
|
|
197
|
+
{sticky && <div ref={progressBar} className={styles.progressBar || ''} />}
|
|
244
198
|
</div>
|
|
245
199
|
);
|
|
246
200
|
}
|
|
@@ -263,11 +217,11 @@ Anchor.propTypes = {
|
|
|
263
217
|
offset: PropTypes.number,
|
|
264
218
|
isScrollable: PropTypes.bool,
|
|
265
219
|
stickyOffset: PropTypes.number,
|
|
266
|
-
isShowButtons: PropTypes.bool,
|
|
267
220
|
buttonScroll: PropTypes.number,
|
|
268
221
|
leftButtonIcon: PropTypes.shape({}),
|
|
269
222
|
rightButtonIcon: PropTypes.shape({}),
|
|
270
|
-
|
|
223
|
+
minCharactersForButtons: PropTypes.number,
|
|
224
|
+
setShowButtons: PropTypes.bool,
|
|
271
225
|
};
|
|
272
226
|
|
|
273
227
|
export default Anchor;
|
|
@@ -12,13 +12,7 @@ import { anchorLink, removeSymbols } from '~helpers/strings';
|
|
|
12
12
|
import { Context } from '~context/MainProvider';
|
|
13
13
|
import styles from './template-two.module.scss';
|
|
14
14
|
|
|
15
|
-
function Anchor({
|
|
16
|
-
module: { items },
|
|
17
|
-
headerOffset = 60,
|
|
18
|
-
icon = null,
|
|
19
|
-
showTitle = true,
|
|
20
|
-
exclOperator = false,
|
|
21
|
-
}) {
|
|
15
|
+
function Anchor({ module: { items }, icon = null, showTitle = true, exclOperator = false }) {
|
|
22
16
|
const itemsRef = useRef([]);
|
|
23
17
|
const anchorContainerRef = useRef(null);
|
|
24
18
|
const anchorListRef = useRef(null);
|
|
@@ -29,20 +23,6 @@ function Anchor({
|
|
|
29
23
|
slug: `${anchor.label && anchorLink(anchor?.label?.toLowerCase().trim())}`,
|
|
30
24
|
}));
|
|
31
25
|
|
|
32
|
-
const handleClick = (event) => {
|
|
33
|
-
event.preventDefault();
|
|
34
|
-
const scrollToElementId = event.currentTarget.getAttribute('href').replace('#', '');
|
|
35
|
-
|
|
36
|
-
const targetEl = document.getElementById(scrollToElementId);
|
|
37
|
-
|
|
38
|
-
if (targetEl) {
|
|
39
|
-
const offsetPosition = targetEl.offsetTop - headerOffset;
|
|
40
|
-
window.scrollTo({
|
|
41
|
-
top: offsetPosition,
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
|
|
46
26
|
return (
|
|
47
27
|
<div className={styles.containerAnchor || ''} ref={anchorContainerRef}>
|
|
48
28
|
{showTitle ? (
|
|
@@ -71,7 +51,6 @@ function Anchor({
|
|
|
71
51
|
draggable="false"
|
|
72
52
|
// eslint-disable-next-line no-return-assign
|
|
73
53
|
ref={(el) => (itemsRef.current[index] = el)}
|
|
74
|
-
onClick={handleClick}
|
|
75
54
|
href={`#${item?.id && item.id}`}
|
|
76
55
|
>
|
|
77
56
|
{translate(translations, item.slug, item.label)}
|