gatsby-core-theme 44.0.22 → 44.0.24

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 CHANGED
@@ -1,3 +1,23 @@
1
+ ## [44.0.24](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/compare/v44.0.23...v44.0.24) (2025-04-23)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * added a class ([c489c96](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/c489c965d506f3dab762a506a86f82aec0f72c04))
7
+ * added a condition ([2d2811a](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/2d2811aad40c038bcb8f51de7740d8483242dcf9))
8
+ * search autocomplete ([148c853](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/148c8535ca29639387b091db2db7a82c83f1e3ce))
9
+ * search autocomplete ([d7b68c0](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/d7b68c0b6385e0be4e3f74479deb8321e35a3e3b))
10
+
11
+
12
+ * Merge branch 'tm-5397-autocomplete-functions' into 'master' ([8eec763](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/8eec763c9e1e8bc2a3a039cd169e71ce1fd7b83e))
13
+
14
+ ## [44.0.23](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/compare/v44.0.22...v44.0.23) (2025-04-23)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * autocomplete ([3ab3ece](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/3ab3ece020d94e6df3ad15ab8bef9e8442f7f311))
20
+
1
21
  ## [44.0.22](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/compare/v44.0.21...v44.0.22) (2025-04-21)
2
22
 
3
23
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gatsby-core-theme",
3
- "version": "44.0.22",
3
+ "version": "44.0.24",
4
4
  "description": "Gatsby Theme NPM Package",
5
5
  "author": "",
6
6
  "license": "ISC",
@@ -3,7 +3,7 @@
3
3
 
4
4
  gap: .8rem;
5
5
  width: 100%;
6
- background-color: var(--color-7);
6
+ background-color: var(--autocomplete-bg, #FFF);
7
7
  border-radius: .8rem;
8
8
  padding: 1.2rem;
9
9
 
@@ -4,14 +4,14 @@ import Button from 'gatsby-core-theme/src/components/atoms/button/button';
4
4
  import { FaArrowRight } from '@react-icons/all-files/fa/FaArrowRight';
5
5
  import styles from './article.module.scss';
6
6
 
7
- const Article = ({ item = {} }) => (
7
+ const Article = ({ item = {}, btnText = '', icon = <FaArrowRight title="Right-pointing Arrow Icon" /> }) => (
8
8
  <li className={styles.row || ''}>
9
9
  <h3 className={styles.operatorTitle}>{item.title}</h3>
10
10
  <Button
11
- btnText=''
11
+ btnText={btnText}
12
12
  to={item?.path}
13
13
  gtmClass="autocomplete-article-item-gtm btn-cta"
14
- icon={<FaArrowRight title="Right-pointing Arrow Icon" />}
14
+ icon={icon}
15
15
  />
16
16
  </li>
17
17
  );
@@ -20,6 +20,8 @@ Article.propTypes = {
20
20
  item: PropTypes.shape({
21
21
  title: PropTypes.string,
22
22
  }).isRequired,
23
+ btnText: PropTypes.string,
24
+ icon: PropTypes.node,
23
25
  };
24
26
 
25
27
  export default Article;
@@ -3,7 +3,7 @@
3
3
 
4
4
  gap: .8rem;
5
5
  width: 100%;
6
- background-color: var(--color-7);
6
+ background-color: var(--autocomplete-bg, #FFF);
7
7
  border-radius: .8rem;
8
8
  padding: 1.2rem;
9
9
 
@@ -4,14 +4,14 @@ import Button from 'gatsby-core-theme/src/components/atoms/button/button';
4
4
  import { FaArrowRight } from '@react-icons/all-files/fa/FaArrowRight';
5
5
  import styles from './default.module.scss';
6
6
 
7
- const Default = ({ item = {} }) => (
7
+ const Default = ({ item = {}, btnText='', icon=<FaArrowRight title="Right-pointing Arrow Icon" /> }) => (
8
8
  <li className={styles.row || ''}>
9
9
  <h3 className={styles.operatorTitle}>{item.title}</h3>
10
10
  <Button
11
- btnText=''
11
+ btnText={btnText}
12
12
  to={item?.path}
13
13
  gtmClass="autocomplete-article-item-gtm btn-cta"
14
- icon={<FaArrowRight title="Right-pointing Arrow Icon" />}
14
+ icon={icon}
15
15
  />
16
16
  </li>
17
17
  );
@@ -20,6 +20,8 @@ Default.propTypes = {
20
20
  item: PropTypes.shape({
21
21
  title: PropTypes.string,
22
22
  }).isRequired,
23
+ btnText: PropTypes.string,
24
+ icon: PropTypes.node,
23
25
  };
24
26
 
25
27
  export default Default;
@@ -3,7 +3,7 @@
3
3
 
4
4
  gap: .8rem;
5
5
  width: 100%;
6
- background-color: var(--color-7);
6
+ background-color: var(--autocomplete-bg, #FFF);
7
7
  border-radius: .8rem;
8
8
  padding: 1.2rem;
9
9
 
@@ -6,7 +6,7 @@ import LazyImage from '~hooks/lazy-image';
6
6
  import { imagePrettyUrl } from '~helpers/getters';
7
7
  import styles from './game.module.scss';
8
8
 
9
- const Game = ({ item = {}, width = 56, height = 56 }) => {
9
+ const Game = ({ item = {}, width = 56, height = 56, btnText = '', icon = <FaArrowRight title="Right-pointing Arrow Icon" /> }) => {
10
10
  const { logo } = item;
11
11
 
12
12
  return (
@@ -20,9 +20,10 @@ const Game = ({ item = {}, width = 56, height = 56 }) => {
20
20
  />
21
21
  <h3 className={styles.gameTitle}>{item.title}</h3>
22
22
  <Button
23
+ btnText={btnText}
23
24
  to={item?.path}
24
25
  gtmClass="autocomplete-game-item-gtm btn-cta"
25
- icon={<FaArrowRight title="Right-pointing Arrow Icon" />}
26
+ icon={icon}
26
27
  />
27
28
  </li>
28
29
  );
@@ -37,6 +38,8 @@ Game.propTypes = {
37
38
  }).isRequired,
38
39
  width: PropTypes.number,
39
40
  height: PropTypes.number,
41
+ btnText: PropTypes.string,
42
+ icon: PropTypes.node,
40
43
  };
41
44
 
42
45
  export default Game;
@@ -6,7 +6,7 @@ import LazyImage from '~hooks/lazy-image';
6
6
  import { imagePrettyUrl } from '~helpers/getters';
7
7
  import styles from './operator.module.scss';
8
8
 
9
- const Operator = ({ item = {}, width = 56, height = 56 }) => {
9
+ const Operator = ({ item = {}, width = 56, height = 56, btnText = '', icon = <FaArrowRight title="Right-pointing Arrow Icon" /> }) => {
10
10
  const { logo } = item;
11
11
  return (
12
12
  <li className={styles.row || ''}>
@@ -20,8 +20,9 @@ const Operator = ({ item = {}, width = 56, height = 56 }) => {
20
20
  <h3 className={styles.operatorTitle}>{item.title}</h3>
21
21
  <Button
22
22
  to={item?.path}
23
+ btnText={btnText}
23
24
  gtmClass="autocomplete-operator-item-gtm btn-cta"
24
- icon={<FaArrowRight title="Right-pointing Arrow Icon" />}
25
+ icon={icon}
25
26
  />
26
27
  </li>
27
28
  );
@@ -36,6 +37,8 @@ Operator.propTypes = {
36
37
  }).isRequired,
37
38
  width: PropTypes.number,
38
39
  height: PropTypes.number,
40
+ btnText: PropTypes.string,
41
+ icon: PropTypes.node,
39
42
  };
40
43
 
41
44
  export default Operator;
@@ -3,7 +3,7 @@
3
3
 
4
4
  gap: .8rem;
5
5
  width: 100%;
6
- background-color: var(--color-7);
6
+ background-color: var(--autocomplete-bg, #FFF);
7
7
  border-radius: .8rem;
8
8
  padding: 1.2rem;
9
9
 
@@ -4,6 +4,7 @@
4
4
  import React, { useRef, useState, useEffect, Suspense } from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import { BiSearchAlt } from '@react-icons/all-files/bi/BiSearchAlt';
7
+ import { IoIosArrowForward } from "@react-icons/all-files/io/IoIosArrowForward";
7
8
  import loadSource from '../../../helpers/search-source';
8
9
  import useTranslate from '~hooks/useTranslate/useTranslate';
9
10
  import { toggleScroll } from '~helpers/scroll';
@@ -17,6 +18,7 @@ import styles from './search.module.scss';
17
18
 
18
19
  const SearchForm = ({
19
20
  pageContext,
21
+ loadAutoComplete = 5,
20
22
  className,
21
23
  searchIcon,
22
24
  iconWidth = 24,
@@ -24,10 +26,21 @@ const SearchForm = ({
24
26
  marketPrefix = '/',
25
27
  startSearchAt = 3,
26
28
  isDisabled,
29
+ autoCompleteIcon = <IoIosArrowForward title="Search Icon" />,
27
30
  }) => {
28
31
  const { market, template } = pageContext.page;
29
32
  const [localSearch, setLocalSearch] = useState(false);
30
33
 
34
+ const loadedCounts = {
35
+ page: loadAutoComplete,
36
+ operator: loadAutoComplete,
37
+ game: loadAutoComplete,
38
+ article: loadAutoComplete,
39
+ author: loadAutoComplete,
40
+ payment_method: loadAutoComplete,
41
+ software_provider: loadAutoComplete,
42
+ };
43
+
31
44
  const [autoCompleteLoading, setAutoCompleteLoading] = useState(false);
32
45
  const autoCompleteData = useRef(null);
33
46
  const [filteredData, setFilteredData] = useState(null);
@@ -38,6 +51,7 @@ const SearchForm = ({
38
51
  const searchInputRef = useRef();
39
52
  const searchFormRef = useRef();
40
53
 
54
+
41
55
  const handleOnSearchIconClick = () => {
42
56
  setLocalSearch(!localSearch);
43
57
  toggleScroll('search');
@@ -72,7 +86,7 @@ const SearchForm = ({
72
86
  try {
73
87
  autoCompleteData.current = autoCompleteData.current || await loadSource(market)
74
88
 
75
- setFilteredData(autoCompleteData.current.filter(item =>
89
+ setFilteredData(autoCompleteData.current.filter(item =>
76
90
  item.title.toLowerCase().includes(query.toLowerCase())
77
91
  ));
78
92
 
@@ -104,15 +118,21 @@ const SearchForm = ({
104
118
  if (localSearch) searchInputRef.current.focus();
105
119
  }, [localSearch]);
106
120
 
121
+ // Group data by pageType
122
+ const groupedData = filteredData?.reduce((acc, item) => {
123
+ acc[item.pageType] = acc[item.pageType] || [];
124
+ acc[item.pageType].push(item);
125
+ return acc;
126
+ }, {});
127
+
107
128
  return (
108
129
  <div className={className || ''} ref={searchFormRef}>
109
130
  <button
110
131
  type="button"
111
132
  aria-label="Search"
112
133
  onClick={handleOnSearchIconClick}
113
- className={`${styles.searchButton || ''} ${
114
- localSearch && (styles.active || '')
115
- } search-gtm btn-cta`}
134
+ className={`${styles.searchButton || ''} ${localSearch && (styles.active || '')
135
+ } search-gtm btn-cta`}
116
136
  disabled={isDisabled}
117
137
  >
118
138
  {searchIcon === null ? (
@@ -154,12 +174,48 @@ const SearchForm = ({
154
174
  </div>
155
175
  ) : (
156
176
  <div className={styles.autoCompleteInner}>
157
- {filteredData.length ? <ul>
158
- {filteredData.map((value) => {
159
- const PageTypeCard = getComponent(value.pageType);
160
- return <Suspense fallback={<Loading single />} key={keygen()}><PageTypeCard item={value} /></Suspense>
161
- })}
162
- </ul> : <NoResults text={useTranslate('autocomplete_no_results', 'No Results Found')} />}
177
+ {filteredData.length ? (
178
+ <ul>
179
+ {Object.entries(groupedData).map(([type, items]) => items.length > 1 && (
180
+ <>
181
+ <div className={styles.autoCompleteTitle} key={type}>
182
+ {useTranslate(type, type)}
183
+ </div>
184
+
185
+ <div key={type} className={styles.autoCompleteList}>
186
+ {items.slice(0, loadedCounts[type]).map((value) => {
187
+ const PageTypeCard = getComponent(value.pageType);
188
+ return (
189
+ <Suspense fallback={<Loading single />} key={keygen()}>
190
+ <PageTypeCard item={value} icon={autoCompleteIcon} />
191
+ </Suspense>
192
+ );
193
+ })}
194
+
195
+ {loadedCounts[type] < items.length && (
196
+ <button
197
+ type='button'
198
+ className={styles.loadMoreBtn}
199
+ onClick={() => {
200
+ const inputValue = searchInputRef.current?.value.trim();
201
+ if (inputValue) {
202
+ const url = `/s${process.env.TRAILING_SLASH ? '/' : ''}?s=${encodeURIComponent(inputValue)}`;
203
+ window.location.href = url;
204
+ }
205
+ }}
206
+ >
207
+ {useTranslate('autocomplete_see_all', 'View more')} {type}
208
+ </button>
209
+ )}
210
+
211
+
212
+ </div>
213
+ </>
214
+ ))}
215
+ </ul>
216
+ ) : (
217
+ <NoResults text={useTranslate('autocomplete_no_results', 'No Results Found')} />
218
+ )}
163
219
  </div>
164
220
  )}
165
221
  </div>
@@ -173,6 +229,7 @@ const SearchForm = ({
173
229
 
174
230
  SearchForm.propTypes = {
175
231
  className: PropTypes.string.isRequired,
232
+ loadAutoComplete: PropTypes.number,
176
233
  searchIcon: PropTypes.string,
177
234
  iconWidth: PropTypes.number,
178
235
  iconHeight: PropTypes.number,
@@ -184,7 +241,8 @@ SearchForm.propTypes = {
184
241
  }),
185
242
  marketPrefix: PropTypes.string,
186
243
  isDisabled: PropTypes.bool,
187
- startSearchAt: PropTypes.number
244
+ startSearchAt: PropTypes.number,
245
+ autoCompleteIcon: PropTypes.node,
188
246
  };
189
247
 
190
248
  export default SearchForm;
@@ -64,16 +64,41 @@
64
64
  }
65
65
  }
66
66
 
67
- .autoCompleteContainer{
67
+ .autoCompleteContainer {
68
68
  background-color: #fff;
69
- margin-top: .8rem;
70
- border-radius: .8rem;
69
+ margin-top: 0.8rem;
70
+ border-radius: 0.8rem;
71
71
  }
72
72
 
73
- .autoCompleteInner > ul{
73
+ .autoCompleteInner > ul {
74
74
  @include flex-direction(column);
75
75
 
76
- gap: .8rem;
77
- padding: 1.2rem;
76
+ gap: 0.8rem;
77
+ padding: 1.6rem;
78
+ }
79
+
80
+ .autoCompleteList {
81
+ display: flex;
82
+ flex-direction: column;
83
+ gap: 0.8rem;
84
+ }
85
+
86
+ .autoCompleteTitle {
87
+ font-size: 2.4rem;
88
+ font-weight: 500;
89
+ text-transform: capitalize;
90
+ color: var(--autoCompleteTitle-color);
91
+ }
78
92
 
79
- }
93
+ .loadMoreBtn {
94
+ display: block;
95
+ font-size: 1.8rem !important;
96
+ background-color: var(--loadMoreBtn-bg, #6e33e5);
97
+ color: #fff;
98
+ border-radius: 2.4rem;
99
+ padding: 1.2rem 2.4rem;
100
+ border: hidden;
101
+ width: fit-content !important;
102
+ cursor: "pointer";
103
+ margin: 1rem auto;
104
+ }