@npm_leadtech/legal-lib-components 7.22.3 → 7.22.5
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/dist/images/componentsSvg/CloseIcon.d.ts +6 -0
- package/dist/images/componentsSvg/CloseIcon.js +2 -0
- package/dist/images/componentsSvg/CloseIcon.tsx +14 -0
- package/dist/images/svg/search_24px.svg +3 -0
- package/dist/src/components/atoms/DropdownInput/DropdownInput.js +3 -2
- package/dist/src/components/atoms/DropdownInput/DropdownInput.styled.js +2 -1
- package/dist/src/components/atoms/DropdownInput/DropdownInput.styled.ts +2 -1
- package/dist/src/components/atoms/DropdownInput/DropdownInput.tsx +4 -2
- package/dist/src/components/atoms/DropdownInput/DropdownInputProps.types.d.ts +1 -0
- package/dist/src/components/atoms/DropdownInput/DropdownInputProps.types.ts +1 -0
- package/dist/src/components/molecules/SearchBar/SearchBar.js +33 -16
- package/dist/src/components/molecules/SearchBar/SearchBar.styled.js +8 -14
- package/dist/src/components/molecules/SearchBar/SearchBar.styled.ts +8 -14
- package/dist/src/components/molecules/SearchBar/SearchBar.tsx +64 -18
- package/package.json +1 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
export const CloseIcon = ({ className }) => (_jsx("svg", { className: className, width: 20, height: 20, viewBox: '0 0 20 20', fill: 'none', xmlns: 'http://www.w3.org/2000/svg', children: _jsx("path", { d: 'M15.2462 5.92913C15.5706 5.60466 15.5706 5.07859 15.2462 4.75413C14.9217 4.42966 14.3956 4.42966 14.0712 4.75413L10.0003 8.82496L5.92949 4.75413C5.60503 4.42966 5.07896 4.42966 4.75449 4.75413C4.43002 5.07859 4.43003 5.60466 4.75449 5.92913L8.82533 9.99996L4.75449 14.0708C4.43003 14.3953 4.43002 14.9213 4.75449 15.2458C5.07896 15.5703 5.60502 15.5703 5.92949 15.2458L10.0003 11.175L14.0712 15.2458C14.3956 15.5703 14.9217 15.5703 15.2462 15.2458C15.5706 14.9213 15.5706 14.3953 15.2462 14.0708L11.1753 9.99996L15.2462 5.92913Z', fill: '#B5BABD' }) }));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React, { FC } from 'react'
|
|
2
|
+
|
|
3
|
+
interface Close24Props {
|
|
4
|
+
className?: string
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export const CloseIcon: FC<Close24Props> = ({ className }: Close24Props): React.ReactElement => (
|
|
8
|
+
<svg className={className} width={20} height={20} viewBox='0 0 20 20' fill='none' xmlns='http://www.w3.org/2000/svg'>
|
|
9
|
+
<path
|
|
10
|
+
d='M15.2462 5.92913C15.5706 5.60466 15.5706 5.07859 15.2462 4.75413C14.9217 4.42966 14.3956 4.42966 14.0712 4.75413L10.0003 8.82496L5.92949 4.75413C5.60503 4.42966 5.07896 4.42966 4.75449 4.75413C4.43002 5.07859 4.43003 5.60466 4.75449 5.92913L8.82533 9.99996L4.75449 14.0708C4.43003 14.3953 4.43002 14.9213 4.75449 15.2458C5.07896 15.5703 5.60502 15.5703 5.92949 15.2458L10.0003 11.175L14.0712 15.2458C14.3956 15.5703 14.9217 15.5703 15.2462 15.2458C15.5706 14.9213 15.5706 14.3953 15.2462 14.0708L11.1753 9.99996L15.2462 5.92913Z'
|
|
11
|
+
fill='#B5BABD'
|
|
12
|
+
/>
|
|
13
|
+
</svg>
|
|
14
|
+
)
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M7.83105 13.9947C6.10828 13.9947 4.65024 13.3981 3.45694 12.2048C2.26364 11.0115 1.66699 9.55346 1.66699 7.83069C1.66699 6.10791 2.26364 4.64987 3.45694 3.45657C4.65024 2.26328 6.10828 1.66663 7.83105 1.66663C9.55383 1.66663 11.0119 2.26328 12.2052 3.45657C13.3985 4.64987 13.9951 6.10791 13.9951 7.83069C13.9951 8.52612 13.8845 9.18204 13.6632 9.79844C13.4419 10.4148 13.1416 10.9601 12.7623 11.4343L18.0729 16.7449C18.2467 16.9187 18.3337 17.14 18.3337 17.4087C18.3337 17.6774 18.2467 17.8986 18.0729 18.0725C17.899 18.2464 17.6777 18.3333 17.4091 18.3333C17.1404 18.3333 16.9191 18.2464 16.7452 18.0725L11.4347 12.7619C10.9605 13.1413 10.4152 13.4416 9.79881 13.6628C9.1824 13.8841 8.52648 13.9947 7.83105 13.9947ZM7.83105 12.0981C9.01645 12.0981 10.024 11.6832 10.8538 10.8534C11.6836 10.0237 12.0985 9.01608 12.0985 7.83069C12.0985 6.64529 11.6836 5.6377 10.8538 4.80793C10.024 3.97815 9.01645 3.56326 7.83105 3.56326C6.64566 3.56326 5.63807 3.97815 4.80829 4.80793C3.97851 5.6377 3.56363 6.64529 3.56363 7.83069C3.56363 9.01608 3.97851 10.0237 4.80829 10.8534C5.63807 11.6832 6.64566 12.0981 7.83105 12.0981Z" fill="#078080"/>
|
|
3
|
+
</svg>
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
|
3
3
|
import React, { forwardRef, useState } from 'react';
|
|
4
4
|
import { DropdownInputStyled } from './DropdownInput.styled';
|
|
5
|
-
export const DropdownInput = forwardRef(({ onChange, results, className = '', name, icon, placeholder }, ref) => {
|
|
5
|
+
export const DropdownInput = forwardRef(({ onChange, results, className = '', name, icon, placeholder, onClose }, ref) => {
|
|
6
6
|
const [searchTerm, setSearchTerm] = useState('');
|
|
7
7
|
const updateInput = (e) => {
|
|
8
8
|
setSearchTerm(e.target.value);
|
|
@@ -15,7 +15,8 @@ export const DropdownInput = forwardRef(({ onChange, results, className = '', na
|
|
|
15
15
|
updateInput(e);
|
|
16
16
|
} }), _jsxs("div", { className: `dropdown_input__container__icon ${searchTerm ? 'active' : ''}`, children: [icon &&
|
|
17
17
|
React.cloneElement(icon, {
|
|
18
|
-
className: 'dropdown_input__container__icon__main'
|
|
18
|
+
className: 'dropdown_input__container__icon__main',
|
|
19
|
+
onClick: onClose
|
|
19
20
|
}), searchTerm && (_jsx("div", { className: 'icon-cross main-color dropdown_input__container__icon__clear', onClick: () => {
|
|
20
21
|
resetInput();
|
|
21
22
|
}, onKeyDown: () => {
|
|
@@ -2,6 +2,7 @@ import { device } from '../../../globalStyles/breakpoints';
|
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
export const DropdownInputStyled = styled.div `
|
|
4
4
|
position: relative;
|
|
5
|
+
padding: 1.5rem;
|
|
5
6
|
|
|
6
7
|
@media ${device['landscape-tablets']} {
|
|
7
8
|
padding: 1rem 2rem;
|
|
@@ -132,7 +133,7 @@ export const DropdownInputStyled = styled.div `
|
|
|
132
133
|
left: 0;
|
|
133
134
|
top: 100%;
|
|
134
135
|
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
|
135
|
-
margin-top:
|
|
136
|
+
margin-top: -5px;
|
|
136
137
|
border: none;
|
|
137
138
|
border-radius: 0 0 8px 8px;
|
|
138
139
|
}
|
|
@@ -3,6 +3,7 @@ import styled from 'styled-components'
|
|
|
3
3
|
|
|
4
4
|
export const DropdownInputStyled = styled.div`
|
|
5
5
|
position: relative;
|
|
6
|
+
padding: 1.5rem;
|
|
6
7
|
|
|
7
8
|
@media ${device['landscape-tablets']} {
|
|
8
9
|
padding: 1rem 2rem;
|
|
@@ -133,7 +134,7 @@ export const DropdownInputStyled = styled.div`
|
|
|
133
134
|
left: 0;
|
|
134
135
|
top: 100%;
|
|
135
136
|
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
|
136
|
-
margin-top:
|
|
137
|
+
margin-top: -5px;
|
|
137
138
|
border: none;
|
|
138
139
|
border-radius: 0 0 8px 8px;
|
|
139
140
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
|
2
2
|
import React, { forwardRef, useState } from 'react'
|
|
3
|
+
|
|
3
4
|
import { DropdownInputProps } from './DropdownInputProps.types'
|
|
4
5
|
import { DropdownInputStyled } from './DropdownInput.styled'
|
|
5
6
|
|
|
6
7
|
export const DropdownInput = forwardRef<HTMLInputElement, DropdownInputProps>(
|
|
7
|
-
({ onChange, results, className = '', name, icon, placeholder }, ref) => {
|
|
8
|
+
({ onChange, results, className = '', name, icon, placeholder, onClose }, ref) => {
|
|
8
9
|
const [searchTerm, setSearchTerm] = useState('')
|
|
9
10
|
|
|
10
11
|
const updateInput = (e): void => {
|
|
@@ -33,7 +34,8 @@ export const DropdownInput = forwardRef<HTMLInputElement, DropdownInputProps>(
|
|
|
33
34
|
<div className={`dropdown_input__container__icon ${searchTerm ? 'active' : ''}`}>
|
|
34
35
|
{icon &&
|
|
35
36
|
React.cloneElement(icon, {
|
|
36
|
-
className: 'dropdown_input__container__icon__main'
|
|
37
|
+
className: 'dropdown_input__container__icon__main',
|
|
38
|
+
onClick: onClose
|
|
37
39
|
})}
|
|
38
40
|
{searchTerm && (
|
|
39
41
|
<div
|
|
@@ -1,43 +1,52 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/* eslint-disable jsx-a11y/click-events-have-key-events */
|
|
3
|
+
/* eslint-disable jsx-a11y/anchor-is-valid */
|
|
4
|
+
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
|
5
|
+
import { useEffect, useRef, useState } from 'react';
|
|
6
|
+
import { CloseIcon } from '../../../../images/componentsSvg/CloseIcon';
|
|
3
7
|
import { DropdownInput } from '../../atoms/DropdownInput/DropdownInput';
|
|
4
8
|
import { SearchIcon } from '../../../../images/componentsSvg/SearchIcon';
|
|
9
|
+
import search from '../../../../images/svg/search_24px.svg';
|
|
5
10
|
import { useWindowSize } from '../../../hooks/useWindowSize';
|
|
6
11
|
import { SearchBarStyled } from './SearchBar.styled';
|
|
7
12
|
import { useSearchFunction } from '../../../hooks/useSearchFunction';
|
|
8
|
-
const DesktopSearchBar = ({ products, searchBarTexts, routes, handleResultClick }) => {
|
|
13
|
+
const DesktopSearchBar = ({ products, searchBarTexts, routes, handleResultClick, isOpen, onClose }) => {
|
|
9
14
|
const { results, searchFunction } = useSearchFunction({
|
|
10
15
|
products,
|
|
11
16
|
searchBarTexts,
|
|
12
17
|
routes,
|
|
13
|
-
handleResultClick
|
|
18
|
+
handleResultClick,
|
|
19
|
+
onClose
|
|
14
20
|
});
|
|
15
21
|
const searchInputRef = useRef(null);
|
|
16
22
|
const searchBarContainerRef = useRef(null);
|
|
17
|
-
const isResultsVisible = Array.isArray(results) && results.length > 0;
|
|
18
23
|
useEffect(() => {
|
|
19
24
|
const handleKeyDown = (event) => {
|
|
20
25
|
if (event.key === 'Escape') {
|
|
21
|
-
|
|
26
|
+
onClose();
|
|
22
27
|
}
|
|
23
28
|
};
|
|
24
29
|
const handleClickOutside = (event) => {
|
|
25
30
|
if (searchBarContainerRef.current && !searchBarContainerRef.current.contains(event.target)) {
|
|
26
|
-
|
|
31
|
+
onClose();
|
|
27
32
|
}
|
|
28
33
|
};
|
|
29
|
-
if (
|
|
34
|
+
if (isOpen) {
|
|
30
35
|
document.addEventListener('keydown', handleKeyDown);
|
|
31
36
|
document.addEventListener('mousedown', handleClickOutside);
|
|
37
|
+
if (searchInputRef.current) {
|
|
38
|
+
searchInputRef.current.focus();
|
|
39
|
+
}
|
|
32
40
|
}
|
|
33
41
|
return () => {
|
|
34
42
|
document.removeEventListener('keydown', handleKeyDown);
|
|
35
43
|
document.removeEventListener('mousedown', handleClickOutside);
|
|
36
44
|
};
|
|
37
|
-
}, [
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
45
|
+
}, [isOpen, onClose]);
|
|
46
|
+
if (!isOpen) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
return (_jsx(SearchBarStyled, { ref: searchBarContainerRef, className: 'modal_searchbar', children: _jsx("div", { className: 'modal_searchbar__content', children: _jsx(DropdownInput, { ref: searchInputRef, name: 'desktop-search', className: 'search', placeholder: searchBarTexts.placeholder, icon: _jsx(CloseIcon, {}), onChange: searchFunction, results: results, onClose: onClose }) }) }));
|
|
41
50
|
};
|
|
42
51
|
const MobileSearchBar = ({ products, searchBarTexts, routes, handleResultClick }) => {
|
|
43
52
|
const { results, searchFunction } = useSearchFunction({
|
|
@@ -69,15 +78,23 @@ const MobileSearchBar = ({ products, searchBarTexts, routes, handleResultClick }
|
|
|
69
78
|
document.removeEventListener('mousedown', handleClickOutside);
|
|
70
79
|
};
|
|
71
80
|
}, [isResultsVisible, searchFunction]);
|
|
72
|
-
return (_jsx(SearchBarStyled, { ref: searchBarContainerRef, children: _jsx(DropdownInput, { ref: searchInputRef, name: 'search', className: 'search', placeholder: searchBarTexts.placeholder, icon: _jsx(SearchIcon, {}), onChange:
|
|
73
|
-
searchFunction(text);
|
|
74
|
-
}, results: results }) }));
|
|
81
|
+
return (_jsx(SearchBarStyled, { ref: searchBarContainerRef, children: _jsx(DropdownInput, { ref: searchInputRef, name: 'mobile-and-tablet-search', className: 'search', placeholder: searchBarTexts.placeholder, icon: _jsx(SearchIcon, {}), onChange: searchFunction, results: results }) }));
|
|
75
82
|
};
|
|
76
83
|
export const SearchBar = (props) => {
|
|
77
84
|
const windowSize = useWindowSize();
|
|
78
85
|
const isDesktop = !!windowSize.width && windowSize.width >= 960;
|
|
86
|
+
const [isModalOpen, setIsModalOpen] = useState(false);
|
|
87
|
+
const closeModal = () => setIsModalOpen(false);
|
|
79
88
|
if (isDesktop) {
|
|
80
|
-
return _jsx(
|
|
89
|
+
return (_jsxs("div", { style: { position: 'relative', display: 'flex' }, children: [_jsx("a", { onClick: () => setIsModalOpen(true), style: {
|
|
90
|
+
cursor: 'pointer',
|
|
91
|
+
display: 'inline-block',
|
|
92
|
+
width: '20px',
|
|
93
|
+
height: '20px'
|
|
94
|
+
}, children: _jsx("img", { src: search, alt: 'search-icon-primary', style: {
|
|
95
|
+
width: '100%',
|
|
96
|
+
height: '100%'
|
|
97
|
+
} }) }), _jsx(DesktopSearchBar, { ...props, isOpen: isModalOpen, onClose: closeModal })] }));
|
|
81
98
|
}
|
|
82
99
|
return _jsx(MobileSearchBar, { ...props });
|
|
83
100
|
};
|
|
@@ -10,29 +10,23 @@ export const SearchBarStyled = styled.div `
|
|
|
10
10
|
|
|
11
11
|
@media ${device['landscape-tablets']} {
|
|
12
12
|
&.modal_searchbar {
|
|
13
|
-
position:
|
|
14
|
-
top:
|
|
13
|
+
position: absolute;
|
|
14
|
+
top: 45px;
|
|
15
15
|
left: 0;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
display: flex;
|
|
21
|
-
justify-content: center;
|
|
22
|
-
align-items: flex-start;
|
|
23
|
-
padding-top: 100px;
|
|
16
|
+
z-index: 10000;
|
|
17
|
+
width: 400px;
|
|
18
|
+
max-width: 90vw;
|
|
19
|
+
background: none;
|
|
24
20
|
|
|
25
21
|
.modal_searchbar__content {
|
|
26
22
|
background-color: var(--neutral-white);
|
|
27
23
|
padding: 1.5rem;
|
|
28
24
|
border-radius: 8px;
|
|
29
|
-
width:
|
|
30
|
-
max-width: 768px;
|
|
25
|
+
width: 100%;
|
|
31
26
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
32
27
|
|
|
33
|
-
@media ${device['
|
|
28
|
+
@media ${device['laptop']} {
|
|
34
29
|
padding: 0;
|
|
35
|
-
border-radius: 8px 8px 0 0;
|
|
36
30
|
}
|
|
37
31
|
}
|
|
38
32
|
|
|
@@ -11,29 +11,23 @@ export const SearchBarStyled = styled.div`
|
|
|
11
11
|
|
|
12
12
|
@media ${device['landscape-tablets']} {
|
|
13
13
|
&.modal_searchbar {
|
|
14
|
-
position:
|
|
15
|
-
top:
|
|
14
|
+
position: absolute;
|
|
15
|
+
top: 45px;
|
|
16
16
|
left: 0;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
display: flex;
|
|
22
|
-
justify-content: center;
|
|
23
|
-
align-items: flex-start;
|
|
24
|
-
padding-top: 100px;
|
|
17
|
+
z-index: 10000;
|
|
18
|
+
width: 400px;
|
|
19
|
+
max-width: 90vw;
|
|
20
|
+
background: none;
|
|
25
21
|
|
|
26
22
|
.modal_searchbar__content {
|
|
27
23
|
background-color: var(--neutral-white);
|
|
28
24
|
padding: 1.5rem;
|
|
29
25
|
border-radius: 8px;
|
|
30
|
-
width:
|
|
31
|
-
max-width: 768px;
|
|
26
|
+
width: 100%;
|
|
32
27
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
33
28
|
|
|
34
|
-
@media ${device['
|
|
29
|
+
@media ${device['laptop']} {
|
|
35
30
|
padding: 0;
|
|
36
|
-
border-radius: 8px 8px 0 0;
|
|
37
31
|
}
|
|
38
32
|
}
|
|
39
33
|
|
|
@@ -1,59 +1,82 @@
|
|
|
1
|
-
|
|
1
|
+
/* eslint-disable jsx-a11y/click-events-have-key-events */
|
|
2
|
+
/* eslint-disable jsx-a11y/anchor-is-valid */
|
|
3
|
+
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
|
4
|
+
import React, { useEffect, useRef, useState } from 'react'
|
|
5
|
+
import { CloseIcon } from '../../../../images/componentsSvg/CloseIcon'
|
|
2
6
|
import { DropdownInput } from '../../atoms/DropdownInput/DropdownInput'
|
|
3
7
|
import { SearchIcon } from '../../../../images/componentsSvg/SearchIcon'
|
|
8
|
+
import search from '../../../../images/svg/search_24px.svg'
|
|
4
9
|
import { useWindowSize } from '../../../hooks/useWindowSize'
|
|
5
10
|
|
|
6
11
|
import { type SearchBarProps } from './SearchBarProps.types'
|
|
7
12
|
import { SearchBarStyled } from './SearchBar.styled'
|
|
8
13
|
import { useSearchFunction } from '../../../hooks/useSearchFunction'
|
|
9
14
|
|
|
10
|
-
|
|
15
|
+
interface DesktopSearchBarProps extends SearchBarProps {
|
|
16
|
+
isOpen: boolean
|
|
17
|
+
onClose: () => void
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const DesktopSearchBar: React.FC<DesktopSearchBarProps> = ({
|
|
21
|
+
products,
|
|
22
|
+
searchBarTexts,
|
|
23
|
+
routes,
|
|
24
|
+
handleResultClick,
|
|
25
|
+
isOpen,
|
|
26
|
+
onClose
|
|
27
|
+
}) => {
|
|
11
28
|
const { results, searchFunction } = useSearchFunction({
|
|
12
29
|
products,
|
|
13
30
|
searchBarTexts,
|
|
14
31
|
routes,
|
|
15
|
-
handleResultClick
|
|
32
|
+
handleResultClick,
|
|
33
|
+
onClose
|
|
16
34
|
})
|
|
17
35
|
const searchInputRef = useRef<HTMLInputElement>(null)
|
|
18
36
|
const searchBarContainerRef = useRef<HTMLDivElement>(null)
|
|
19
|
-
const isResultsVisible = Array.isArray(results) && results.length > 0
|
|
20
37
|
|
|
21
38
|
useEffect(() => {
|
|
22
39
|
const handleKeyDown = (event: KeyboardEvent) => {
|
|
23
40
|
if (event.key === 'Escape') {
|
|
24
|
-
|
|
41
|
+
onClose()
|
|
25
42
|
}
|
|
26
43
|
}
|
|
27
44
|
const handleClickOutside = (event: MouseEvent) => {
|
|
28
45
|
if (searchBarContainerRef.current && !searchBarContainerRef.current.contains(event.target as Node)) {
|
|
29
|
-
|
|
46
|
+
onClose()
|
|
30
47
|
}
|
|
31
48
|
}
|
|
32
49
|
|
|
33
|
-
if (
|
|
50
|
+
if (isOpen) {
|
|
34
51
|
document.addEventListener('keydown', handleKeyDown)
|
|
35
52
|
document.addEventListener('mousedown', handleClickOutside)
|
|
53
|
+
if (searchInputRef.current) {
|
|
54
|
+
searchInputRef.current.focus()
|
|
55
|
+
}
|
|
36
56
|
}
|
|
37
57
|
|
|
38
58
|
return () => {
|
|
39
59
|
document.removeEventListener('keydown', handleKeyDown)
|
|
40
60
|
document.removeEventListener('mousedown', handleClickOutside)
|
|
41
61
|
}
|
|
42
|
-
}, [
|
|
62
|
+
}, [isOpen, onClose])
|
|
63
|
+
|
|
64
|
+
if (!isOpen) {
|
|
65
|
+
return null
|
|
66
|
+
}
|
|
43
67
|
|
|
44
68
|
return (
|
|
45
69
|
<SearchBarStyled ref={searchBarContainerRef} className='modal_searchbar'>
|
|
46
70
|
<div className='modal_searchbar__content'>
|
|
47
71
|
<DropdownInput
|
|
48
72
|
ref={searchInputRef}
|
|
49
|
-
name='search'
|
|
73
|
+
name='desktop-search'
|
|
50
74
|
className='search'
|
|
51
75
|
placeholder={searchBarTexts.placeholder}
|
|
52
|
-
icon={<
|
|
53
|
-
onChange={
|
|
54
|
-
searchFunction(text)
|
|
55
|
-
}}
|
|
76
|
+
icon={<CloseIcon />}
|
|
77
|
+
onChange={searchFunction}
|
|
56
78
|
results={results}
|
|
79
|
+
onClose={onClose}
|
|
57
80
|
/>
|
|
58
81
|
</div>
|
|
59
82
|
</SearchBarStyled>
|
|
@@ -98,13 +121,11 @@ const MobileSearchBar: React.FC<SearchBarProps> = ({ products, searchBarTexts, r
|
|
|
98
121
|
<SearchBarStyled ref={searchBarContainerRef}>
|
|
99
122
|
<DropdownInput
|
|
100
123
|
ref={searchInputRef}
|
|
101
|
-
name='search'
|
|
124
|
+
name='mobile-and-tablet-search'
|
|
102
125
|
className='search'
|
|
103
126
|
placeholder={searchBarTexts.placeholder}
|
|
104
127
|
icon={<SearchIcon />}
|
|
105
|
-
onChange={
|
|
106
|
-
searchFunction(text)
|
|
107
|
-
}}
|
|
128
|
+
onChange={searchFunction}
|
|
108
129
|
results={results}
|
|
109
130
|
/>
|
|
110
131
|
</SearchBarStyled>
|
|
@@ -114,9 +135,34 @@ const MobileSearchBar: React.FC<SearchBarProps> = ({ products, searchBarTexts, r
|
|
|
114
135
|
export const SearchBar: React.FC<SearchBarProps> = (props) => {
|
|
115
136
|
const windowSize = useWindowSize()
|
|
116
137
|
const isDesktop = !!windowSize.width && windowSize.width >= 960
|
|
138
|
+
const [isModalOpen, setIsModalOpen] = useState(false)
|
|
139
|
+
|
|
140
|
+
const closeModal = () => setIsModalOpen(false)
|
|
117
141
|
|
|
118
142
|
if (isDesktop) {
|
|
119
|
-
return
|
|
143
|
+
return (
|
|
144
|
+
<div style={{ position: 'relative', display: 'flex' }}>
|
|
145
|
+
<a
|
|
146
|
+
onClick={() => setIsModalOpen(true)}
|
|
147
|
+
style={{
|
|
148
|
+
cursor: 'pointer',
|
|
149
|
+
display: 'inline-block',
|
|
150
|
+
width: '20px',
|
|
151
|
+
height: '20px'
|
|
152
|
+
}}
|
|
153
|
+
>
|
|
154
|
+
<img
|
|
155
|
+
src={search}
|
|
156
|
+
alt='search-icon-primary'
|
|
157
|
+
style={{
|
|
158
|
+
width: '100%',
|
|
159
|
+
height: '100%'
|
|
160
|
+
}}
|
|
161
|
+
/>
|
|
162
|
+
</a>
|
|
163
|
+
<DesktopSearchBar {...props} isOpen={isModalOpen} onClose={closeModal} />
|
|
164
|
+
</div>
|
|
165
|
+
)
|
|
120
166
|
}
|
|
121
167
|
|
|
122
168
|
return <MobileSearchBar {...props} />
|