gatsby-core-theme 30.0.49 → 30.0.50

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,13 @@
1
+ ## [30.0.50](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v30.0.49...v30.0.50) (2024-01-11)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * disable autocomplete ([1a3b7b3](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/1a3b7b3a8c06a039af1bfa67666d013aeb086035))
7
+
8
+
9
+ * Merge branch 'tm-3972-disable-autocomplete' into 'master' ([41831ba](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/41831ba7d12de622f5468bbea99c96c3909db1e2))
10
+
1
11
  ## [30.0.49](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v30.0.48...v30.0.49) (2024-01-10)
2
12
 
3
13
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gatsby-core-theme",
3
- "version": "30.0.49",
3
+ "version": "30.0.50",
4
4
  "description": "Gatsby Theme NPM Package",
5
5
  "author": "",
6
6
  "license": "ISC",
@@ -1,7 +1,8 @@
1
- import React, { useContext } from 'react';
1
+ import React, { useContext, useRef, useState, useEffect } from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import loadable from '@loadable/component';
3
+ import { navigate } from 'gatsby';
4
4
  import { FaSearch } from '@react-icons/all-files/fa/FaSearch';
5
+ import { leftTrim } from '~helpers/strings';
5
6
 
6
7
  import { toggleScroll } from '~helpers/scroll';
7
8
 
@@ -9,23 +10,10 @@ import { NavigationContext } from '../navigation/navigationContext';
9
10
 
10
11
  import styles from './search.module.scss';
11
12
 
12
- const SearchForm = ({
13
- className,
14
- searchIcon,
15
- iconWidth = 24,
16
- iconHeight = 24,
17
- pageContext,
18
- searchURLPageName,
19
- }) => {
13
+ const SearchForm = ({ className, searchIcon, iconWidth = 24, iconHeight = 24 }) => {
20
14
  const { showSearch, setShowSearch, setShowMenu, showMenu } = useContext(NavigationContext);
21
- const Search = showSearch ? loadable(() => import('~molecules/search')) : <></>;
22
- const Operator = showSearch ? (
23
- loadable(() => import('~atoms/search/autocomplete/operator'))
24
- ) : (
25
- <></>
26
- );
27
- const Game = showSearch ? loadable(() => import('~atoms/search/autocomplete/game')) : <></>;
28
- const Article = showSearch ? loadable(() => import('~atoms/search/autocomplete/article')) : <></>;
15
+ const [searchBoxQuery, setSearchBoxQuery] = useState();
16
+ const searchInputRef = useRef();
29
17
 
30
18
  const handleOnSearchIconClick = () => {
31
19
  setShowSearch(!showSearch);
@@ -45,6 +33,20 @@ const SearchForm = ({
45
33
  }
46
34
  };
47
35
 
36
+ const formSubmitBoxHandler = (e) => {
37
+ e.preventDefault();
38
+ if (searchBoxQuery === '') {
39
+ e.target.querySelector('input').focus();
40
+ } else {
41
+ navigate(`/s?s=${searchBoxQuery}`);
42
+ }
43
+ };
44
+
45
+ useEffect(() => {
46
+ // eslint-disable-next-line no-unused-expressions
47
+ showSearch && searchInputRef.current.focus();
48
+ }, [showSearch]);
49
+
48
50
  return (
49
51
  <div className={className || ''}>
50
52
  <button
@@ -71,30 +73,22 @@ const SearchForm = ({
71
73
  aria-label="Close search"
72
74
  className={`${styles.searchForm || ''} ${styles.show || ''}`}
73
75
  >
74
- <Search
75
- pageContext={pageContext}
76
- searchURLPageName={searchURLPageName}
77
- searchIcon={searchIcon}
78
- formSearchOptions={{
79
- autoComplete: true,
80
- sort: true,
81
- limit: 3,
82
- }}
83
- >
84
- {(item) => (
85
- <>
86
- <div type="operator">
87
- <Operator item={item} />
88
- </div>
89
- <div type="game">
90
- <Game item={item} />
91
- </div>
92
- <div type="article">
93
- <Article item={item} />
94
- </div>
95
- </>
96
- )}
97
- </Search>
76
+ <form onSubmit={formSubmitBoxHandler} className={styles.form || ''}>
77
+ <input
78
+ type="text"
79
+ aria-label="Søk spill eller casino her"
80
+ placeholder="Søk spill eller casino her"
81
+ className={styles.formInput || ''}
82
+ maxLength="60"
83
+ ref={searchInputRef}
84
+ onChange={(e) => setSearchBoxQuery(leftTrim(e.target.value))}
85
+ />
86
+ <div className={styles.searchButton || ''}>
87
+ <button aria-label="Search" type="submit" className="search-gtm btn-cta">
88
+ {searchIcon === null ? <FaSearch /> : <img alt="search" src={searchIcon} />}
89
+ </button>
90
+ </div>
91
+ </form>
98
92
  </div>
99
93
  )}
100
94
  </div>
@@ -107,7 +101,6 @@ SearchForm.propTypes = {
107
101
  iconWidth: PropTypes.number,
108
102
  iconHeight: PropTypes.number,
109
103
  pageContext: PropTypes.shape({}),
110
- searchURLPageName: PropTypes.string,
111
104
  };
112
105
 
113
106
  export default SearchForm;
@@ -18,3 +18,45 @@
18
18
  width: 100%;
19
19
  }
20
20
  }
21
+
22
+
23
+ .form {
24
+ width: 100%;
25
+ max-width: var(--main-container-max);
26
+ padding: 0 1.6rem;
27
+ display: flex;
28
+ flex-direction: column;
29
+ position: absolute;
30
+ top: var(--search-top-space, 2.4rem);
31
+ left: 50%;
32
+ transform: translateX(-50%);
33
+ >input{
34
+ align-items: center;
35
+ border-radius: var(--border-radius);
36
+ color: #0e1118;
37
+ display: flex;
38
+ font-size: 1.8rem;
39
+ font-size: 1.6rem;
40
+ font-weight: 500;
41
+ line-height: 2.7rem;
42
+ padding: 2.2rem 1.6rem;
43
+ width: 100%;
44
+ }
45
+
46
+ .searchButton > button >img{
47
+ filter: brightness(0);
48
+ height: 2.4rem;
49
+ width: 2.4rem;
50
+ }
51
+
52
+ .searchButton {
53
+ position: absolute;
54
+ right: 3rem;
55
+ top: 2.3rem;
56
+
57
+ svg {
58
+ color: var(--nav-icon-color);
59
+ font-size: 3rem;
60
+ }
61
+ }
62
+ }