hds-web 1.36.5 → 1.36.7
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/index.es.js +5 -5
- package/dist/index.js +3 -3
- package/package.json +1 -1
- package/src/HDS/helpers/AlgoliaSearch/constants.js +19 -101
- package/src/HDS/helpers/AlgoliaSearch/search.js +1 -2
- package/src/HDS/helpers/AlgoliaSearch/searchfooter.js +2 -8
- package/src/HDS/helpers/AlgoliaSearch/searchoverlay.js +8 -13
- package/src/HDS/helpers/AlgoliaSearch/searchresults.js +76 -66
- package/src/HDS/helpers/AlgoliaSearch/searchwrapper.js +64 -95
- package/src/HDS/helpers/AlgoliaSearch/SearchHit.js +0 -117
package/package.json
CHANGED
@@ -4,7 +4,6 @@ export const INDEX_TYPES = Object.freeze({
|
|
4
4
|
blog: "blog",
|
5
5
|
docs: "docs",
|
6
6
|
learn: "learn",
|
7
|
-
events: "events",
|
8
7
|
// tutorials: "Tutorials",
|
9
8
|
// case_studies: "Case studies",
|
10
9
|
// events: "Events",
|
@@ -12,112 +11,35 @@ export const INDEX_TYPES = Object.freeze({
|
|
12
11
|
});
|
13
12
|
|
14
13
|
export const SEARCH_INDICES = [
|
15
|
-
{
|
16
|
-
name: `marketing_events`,
|
17
|
-
title: `Hasura Events`,
|
18
|
-
type: INDEX_TYPES.events,
|
19
|
-
},
|
20
14
|
{ name: `blog-production`, title: `Hasura Blog`, type: INDEX_TYPES.blog },
|
21
|
-
{
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
},
|
26
|
-
{
|
27
|
-
name: `learn-intro-graphql`,
|
28
|
-
title: `Learn Intro GraphQL`,
|
29
|
-
type: INDEX_TYPES.learn,
|
30
|
-
},
|
31
|
-
{
|
32
|
-
name: `learn-intro-graphql-zh`,
|
33
|
-
title: `Learn Intro GraphQL`,
|
34
|
-
type: INDEX_TYPES.learn,
|
35
|
-
},
|
36
|
-
{
|
37
|
-
name: `learn-elm-graphql`,
|
38
|
-
title: `Learn ELM GraphQl`,
|
39
|
-
type: INDEX_TYPES.learn,
|
40
|
-
},
|
41
|
-
{
|
42
|
-
name: `learn-flutter-graphql`,
|
43
|
-
title: `Learn Flutter GraphQL`,
|
44
|
-
type: INDEX_TYPES.learn,
|
45
|
-
},
|
46
|
-
{
|
47
|
-
name: `learn-database-mysql`,
|
48
|
-
title: `Learn Database MySQL`,
|
49
|
-
type: INDEX_TYPES.learn,
|
50
|
-
},
|
15
|
+
{ name: `graphql-docs-prod`, title: `Hasura GraphQL Engine Docs`, type: INDEX_TYPES.docs },
|
16
|
+
{ name: `learn-intro-graphql`, title: `Learn Intro GraphQL`, type: INDEX_TYPES.learn },
|
17
|
+
{ name: `learn-intro-graphql-zh`, title: `Learn Intro GraphQL`, type: INDEX_TYPES.learn },
|
18
|
+
{ name: `learn-elm-graphql`, title: `Learn ELM GraphQl`, type: INDEX_TYPES.learn },
|
19
|
+
{ name: `learn-flutter-graphql`, title: `Learn Flutter GraphQL`, type: INDEX_TYPES.learn },
|
20
|
+
{ name: `learn-database-mysql`, title: `Learn Database MySQL`, type: INDEX_TYPES.learn },
|
51
21
|
{
|
52
22
|
name: `learn-database-postgresql`,
|
53
23
|
title: `Learn Database PostgreSQL`,
|
54
24
|
type: INDEX_TYPES.learn,
|
55
25
|
},
|
56
|
-
{
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
},
|
61
|
-
{
|
62
|
-
|
63
|
-
title: `Learn Hasura Backend`,
|
64
|
-
type: INDEX_TYPES.learn,
|
65
|
-
},
|
66
|
-
{
|
67
|
-
name: `learn-hasura-backend-zh`,
|
68
|
-
title: `Learn Hasura Backend`,
|
69
|
-
type: INDEX_TYPES.learn,
|
70
|
-
},
|
71
|
-
{
|
72
|
-
name: `learn-hasura-backend-advanced`,
|
73
|
-
title: `Learn Hasura Backend Advanced`,
|
74
|
-
type: INDEX_TYPES.learn,
|
75
|
-
},
|
76
|
-
{
|
77
|
-
name: `learn-hasura-auth-slack`,
|
78
|
-
title: `Learn Hasura Auth Slack`,
|
79
|
-
type: INDEX_TYPES.learn,
|
80
|
-
},
|
81
|
-
{
|
82
|
-
name: `learn-react-apollo-hooks`,
|
83
|
-
title: `Learn React Apollo Hooks`,
|
84
|
-
type: INDEX_TYPES.learn,
|
85
|
-
},
|
86
|
-
{
|
87
|
-
name: `learn-react-apollo`,
|
88
|
-
title: `Learn React Apollo`,
|
89
|
-
type: INDEX_TYPES.learn,
|
90
|
-
},
|
26
|
+
{ name: `learn-hasura-backend`, title: `Learn Hasura Backend`, type: INDEX_TYPES.learn },
|
27
|
+
{ name: `learn-hasura-backend-ja`, title: `Learn Hasura Backend`, type: INDEX_TYPES.learn },
|
28
|
+
{ name: `learn-hasura-backend-zh`, title: `Learn Hasura Backend`, type: INDEX_TYPES.learn },
|
29
|
+
{ name: `learn-hasura-backend-advanced`, title: `Learn Hasura Backend Advanced`, type: INDEX_TYPES.learn },
|
30
|
+
{ name: `learn-hasura-auth-slack`, title: `Learn Hasura Auth Slack`, type: INDEX_TYPES.learn },
|
31
|
+
{ name: `learn-react-apollo-hooks`, title: `Learn React Apollo Hooks`, type: INDEX_TYPES.learn },
|
32
|
+
{ name: `learn-react-apollo`, title: `Learn React Apollo`, type: INDEX_TYPES.learn },
|
91
33
|
{
|
92
34
|
name: `learn-typescript-react-apollo`,
|
93
35
|
title: `Learn TypeScript React Apollo`,
|
94
36
|
type: INDEX_TYPES.learn,
|
95
37
|
},
|
96
|
-
{
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
},
|
101
|
-
{
|
102
|
-
name: `learn-vue-apollo`,
|
103
|
-
title: `Learn Vue Apollo`,
|
104
|
-
type: INDEX_TYPES.learn,
|
105
|
-
},
|
106
|
-
{
|
107
|
-
name: `learn-ios-apollo`,
|
108
|
-
title: `Learn IOS Apollo`,
|
109
|
-
type: INDEX_TYPES.learn,
|
110
|
-
},
|
111
|
-
{
|
112
|
-
name: `learn-svelte-apollo`,
|
113
|
-
title: `Learn Svelte Apollo`,
|
114
|
-
type: INDEX_TYPES.learn,
|
115
|
-
},
|
116
|
-
{
|
117
|
-
name: `learn-android-apollo`,
|
118
|
-
title: `Learn Android Apollo`,
|
119
|
-
type: INDEX_TYPES.learn,
|
120
|
-
},
|
38
|
+
{ name: `learn-angular-apollo`, title: `Learn Angular Apollo`, type: INDEX_TYPES.learn },
|
39
|
+
{ name: `learn-vue-apollo`, title: `Learn Vue Apollo`, type: INDEX_TYPES.learn },
|
40
|
+
{ name: `learn-ios-apollo`, title: `Learn IOS Apollo`, type: INDEX_TYPES.learn },
|
41
|
+
{ name: `learn-svelte-apollo`, title: `Learn Svelte Apollo`, type: INDEX_TYPES.learn },
|
42
|
+
{ name: `learn-android-apollo`, title: `Learn Android Apollo`, type: INDEX_TYPES.learn },
|
121
43
|
{
|
122
44
|
name: `learn-react-native-apollo`,
|
123
45
|
title: `Learn React Native Apollo`,
|
@@ -128,9 +50,5 @@ export const SEARCH_INDICES = [
|
|
128
50
|
title: `Learn Reason React Apollo`,
|
129
51
|
type: INDEX_TYPES.learn,
|
130
52
|
},
|
131
|
-
{
|
132
|
-
name: `learn-database-mssql`,
|
133
|
-
title: `Learn MicrosoftSQL`,
|
134
|
-
type: INDEX_TYPES.learn,
|
135
|
-
},
|
53
|
+
{ name: `learn-database-mssql`, title: `Learn MicrosoftSQL`, type: INDEX_TYPES.learn },
|
136
54
|
];
|
@@ -3,8 +3,7 @@ import { useEffect, useState } from "react";
|
|
3
3
|
import SearchOverlay from "./searchoverlay";
|
4
4
|
import { Icon } from "../../components/common-components";
|
5
5
|
export default function Search(props) {
|
6
|
-
|
7
|
-
const [showSearch, setShowSearch] = useState(true);
|
6
|
+
const [showSearch, setShowSearch] = useState(false);
|
8
7
|
|
9
8
|
const handleSearchWithKeyboard = (e) => {
|
10
9
|
if (e.key === "/" || e.key === "Escape") {
|
@@ -9,17 +9,11 @@ const SearchFooter = () => (
|
|
9
9
|
<p>Unable to find what you're looking for?</p>
|
10
10
|
<p>
|
11
11
|
Reach out to our{" "}
|
12
|
-
<a
|
13
|
-
className="text-blue-500 hover:text-blue-700"
|
14
|
-
href="https://discord.com/invite/hasura"
|
15
|
-
target="_blank"
|
16
|
-
rel="noopener noreferrer"
|
17
|
-
>
|
12
|
+
<a className="text-blue-500 hover:text-blue-700" href="https://discord.com/invite/hasura" target="_blank" rel="noopener noreferrer">
|
18
13
|
Discord Community
|
19
14
|
</a>{" "}
|
20
15
|
or start a{" "}
|
21
|
-
<a
|
22
|
-
className="text-blue-500 hover:text-blue-700"
|
16
|
+
<a className="text-blue-500 hover:text-blue-700"
|
23
17
|
href="https://github.com/hasura/graphql-engine/discussions"
|
24
18
|
target="_blank"
|
25
19
|
rel="noopener noreferrer"
|
@@ -1,9 +1,11 @@
|
|
1
|
-
import React
|
2
|
-
import {
|
1
|
+
import React from "react";
|
2
|
+
import { useEffect, useState } from "react";
|
3
|
+
import { Icon } from '../../components/common-components/Icon'
|
3
4
|
import SearchWrapper from "./searchwrapper";
|
4
5
|
import { SEARCH_INDICES } from "./constants";
|
5
6
|
|
6
|
-
export default function SearchOverlay({
|
7
|
+
export default function SearchOverlay({showSearch, onCloseSearch, ...props}) {
|
8
|
+
|
7
9
|
useEffect(() => {
|
8
10
|
if (showSearch) {
|
9
11
|
document.body.style.overflow = "hidden";
|
@@ -18,15 +20,8 @@ export default function SearchOverlay({ showSearch, onCloseSearch, ...props }) {
|
|
18
20
|
|
19
21
|
return (
|
20
22
|
<div className="fixed left-0 top-0 w-full h-full z-[10000] bg-neutral-100">
|
21
|
-
<div
|
22
|
-
|
23
|
-
onClick={onCloseSearch}
|
24
|
-
>
|
25
|
-
<Icon
|
26
|
-
height={"w-8 h-8 stroke-[1.5px]"}
|
27
|
-
variant="xclose"
|
28
|
-
strokeClass="stroke-neutral-800"
|
29
|
-
/>
|
23
|
+
<div className="absolute top-4 right-4 cursor-pointer z-[11]" onClick={onCloseSearch}>
|
24
|
+
<Icon height={'w-8 h-8 stroke-[1.5px]'} variant="xclose" strokeClass="stroke-neutral-800" />
|
30
25
|
</div>
|
31
26
|
<div className="py-20 overflow-y-auto h-full w-full bg-neutral-100">
|
32
27
|
<div className="px-4">
|
@@ -39,4 +34,4 @@ export default function SearchOverlay({ showSearch, onCloseSearch, ...props }) {
|
|
39
34
|
</div>
|
40
35
|
</div>
|
41
36
|
);
|
42
|
-
}
|
37
|
+
}
|
@@ -1,64 +1,44 @@
|
|
1
1
|
import React, { Fragment } from "react";
|
2
|
-
import { connectStateResults, Hits, Index } from "react-instantsearch-dom";
|
2
|
+
import { connectStateResults, Highlight, Hits, Index, Snippet } from "react-instantsearch-dom";
|
3
3
|
import { INDEX_TYPES } from "./constants";
|
4
4
|
import SearchFooter from "./searchfooter";
|
5
|
-
import { Typography } from
|
6
|
-
import { Icon } from
|
7
|
-
|
5
|
+
import { Typography } from '../../foundation/Typography'
|
6
|
+
import { Icon } from '../../components/common-components/Icon';
|
7
|
+
|
8
|
+
// import SearchFooter from "./SearchFooter";
|
9
|
+
|
10
|
+
const baseDomain = 'hasura.io';
|
11
|
+
|
8
12
|
|
9
13
|
const HitsHeader = ({ searchResults, indexTitle, showSeparator, allIndex }) => {
|
10
14
|
const hitCount = searchResults && searchResults.nbHits;
|
11
15
|
const titleIcon = () => {
|
12
|
-
if
|
16
|
+
if(indexTitle === "Hasura Blog") {
|
13
17
|
return (
|
14
|
-
<Icon
|
15
|
-
|
16
|
-
variant="pentool02"
|
17
|
-
strokeClass="stroke-blue-500"
|
18
|
-
/>
|
19
|
-
);
|
18
|
+
<Icon height={'block w-6 mr-3 h-6 stroke-[2px] transition ease-in-out'} variant="pentool02" strokeClass='stroke-blue-500' />
|
19
|
+
)
|
20
20
|
}
|
21
|
-
if
|
21
|
+
if(indexTitle === "Hasura GraphQL Engine Docs") {
|
22
22
|
return (
|
23
|
-
<Icon
|
24
|
-
|
25
|
-
variant="file02"
|
26
|
-
strokeClass="stroke-blue-500"
|
27
|
-
/>
|
28
|
-
);
|
29
|
-
}
|
30
|
-
|
31
|
-
if (indexTitle === "Hasura Events") {
|
32
|
-
return (
|
33
|
-
<Icon
|
34
|
-
height={"block w-6 mr-3 h-6 stroke-[2px] transition ease-in-out"}
|
35
|
-
variant="calendarplus02"
|
36
|
-
strokeClass="stroke-blue-500"
|
37
|
-
/>
|
38
|
-
);
|
23
|
+
<Icon height={'block w-6 mr-3 h-6 stroke-[2px] transition ease-in-out'} variant="file02" strokeClass='stroke-blue-500' />
|
24
|
+
)
|
39
25
|
}
|
40
|
-
|
41
26
|
return (
|
42
|
-
<Icon
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
/>
|
47
|
-
);
|
48
|
-
};
|
49
|
-
|
27
|
+
<Icon height={'block w-6 mr-3 h-6 stroke-[2px] transition ease-in-out'} variant="graduationhat01" strokeClass='stroke-blue-500' />
|
28
|
+
)
|
29
|
+
}
|
30
|
+
|
50
31
|
return hitCount > 0 ? (
|
51
32
|
<Fragment>
|
52
33
|
{showSeparator && <hr className="my-8 border-t-neutral-200" />}
|
53
34
|
{/* <div className="HitCount">
|
54
35
|
{hitCount} result{hitCount !== 1 ? `s` : ``}
|
55
36
|
</div> */}
|
56
|
-
<Typography
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
37
|
+
<Typography textStyle="sub1" className="pb-4 pl-2 flex items-center text-neutral-800 font-normal sticky tb-m:z-0 top-[170px] tb:top-[160px] tb-m:top-[120px] bg-neutral-100">
|
38
|
+
{
|
39
|
+
titleIcon()
|
40
|
+
}
|
41
|
+
|
62
42
|
{indexTitle}
|
63
43
|
</Typography>
|
64
44
|
</Fragment>
|
@@ -67,15 +47,60 @@ const HitsHeader = ({ searchResults, indexTitle, showSeparator, allIndex }) => {
|
|
67
47
|
|
68
48
|
const CustomHitsHeader = connectStateResults(HitsHeader);
|
69
49
|
|
50
|
+
const PageHit = ({ hit, indexType }) => (
|
51
|
+
<a href={hit.url} className="grid h-full">
|
52
|
+
<div className="self-start">
|
53
|
+
{/* <Typography textStyle="body3c-medium" className="uppercase text-neutral-500">{indexType}</Typography> */}
|
54
|
+
{indexType === INDEX_TYPES.docs ? (
|
55
|
+
<div className="flex items-start">
|
56
|
+
<div className="w-6 h-6 mr-2 min-w-[24px] flex items-center justify-center">
|
57
|
+
<div className="w-3 h-3 rounded-full bg-blue-500"></div>
|
58
|
+
</div>
|
59
|
+
<div>
|
60
|
+
{!!hit.hierarchy && (
|
61
|
+
<Typography textStyle="body1c-bold" className="font-bold flex items-start pb-3">
|
62
|
+
{`${
|
63
|
+
Object.values(hit.hierarchy)
|
64
|
+
.filter(h => !!h)
|
65
|
+
.reverse()[0]
|
66
|
+
}`}</Typography>
|
67
|
+
)}
|
68
|
+
<Typography textStyle="body2" className="text-neutral-800 word-break">
|
69
|
+
<Snippet attribute="content" hit={hit} tagName="mark" />
|
70
|
+
</Typography>
|
71
|
+
</div>
|
72
|
+
</div>
|
73
|
+
) : (
|
74
|
+
<div className="flex items-start">
|
75
|
+
<div className="w-6 h-6 mr-2 min-w-[24px] flex items-center justify-center">
|
76
|
+
<div className="w-3 h-3 rounded-full bg-blue-500"></div>
|
77
|
+
</div>
|
78
|
+
<div>
|
79
|
+
<Typography textStyle="body1c-bold" className="font-bold text-neutral-800 pb-3">
|
80
|
+
<Highlight attribute="title" hit={hit} tagName="mark" />
|
81
|
+
</Typography>
|
82
|
+
<Typography textStyle="body2" className="text-neutral-800 word-break">
|
83
|
+
<Snippet attribute="excerpt" hit={hit} tagName="mark" />
|
84
|
+
</Typography>
|
85
|
+
</div>
|
86
|
+
</div>
|
87
|
+
)}
|
88
|
+
</div>
|
89
|
+
{hit.url ? (
|
90
|
+
<Typography textStyle="body3" className="self-end pl-8 pt-3 text-neutral-500">
|
91
|
+
<span className='hit-slug word-break'>{hit.url.replace(`https://${baseDomain}/`, "/")}</span>
|
92
|
+
</Typography>
|
93
|
+
) : null}
|
94
|
+
</a>
|
95
|
+
);
|
96
|
+
|
70
97
|
const HitsByIndexType = ({ indexType }) => {
|
71
98
|
if (INDEX_TYPES[indexType] === undefined) return null;
|
72
99
|
|
73
100
|
return (
|
74
101
|
<Hits
|
75
102
|
className="Hits"
|
76
|
-
hitComponent={
|
77
|
-
<SearchHit {...hitProps} indexType={indexType} />
|
78
|
-
)}
|
103
|
+
hitComponent={hitProps => <PageHit {...hitProps} indexType={indexType} />}
|
79
104
|
/>
|
80
105
|
);
|
81
106
|
};
|
@@ -87,7 +112,7 @@ const HitsInIndex = ({ index, show }) => (
|
|
87
112
|
<CustomHitsHeader
|
88
113
|
indexTitle={index.title}
|
89
114
|
showSeparator={index.type !== INDEX_TYPES.blog}
|
90
|
-
allIndex={index.type}
|
115
|
+
allIndex = {index.type}
|
91
116
|
/>
|
92
117
|
<HitsByIndexType indexType={index.type} />
|
93
118
|
</Fragment>
|
@@ -95,26 +120,11 @@ const HitsInIndex = ({ index, show }) => (
|
|
95
120
|
</Index>
|
96
121
|
);
|
97
122
|
|
98
|
-
const SearchResult = ({
|
99
|
-
|
100
|
-
indices,
|
101
|
-
className,
|
102
|
-
id,
|
103
|
-
wrapperRef,
|
104
|
-
activeIndexTypes,
|
105
|
-
}) => (
|
106
|
-
<div
|
107
|
-
id={id}
|
108
|
-
className={`${className} search-results clear-both`}
|
109
|
-
ref={wrapperRef}
|
110
|
-
>
|
123
|
+
const SearchResult = ({ children, indices, className, id, wrapperRef, activeIndexTypes }) => (
|
124
|
+
<div id={id} className={`${className} search-results clear-both`} ref={wrapperRef}>
|
111
125
|
{children && children}
|
112
|
-
{indices.map(
|
113
|
-
<HitsInIndex
|
114
|
-
index={index}
|
115
|
-
key={index.name}
|
116
|
-
show={activeIndexTypes[index.type]}
|
117
|
-
/>
|
126
|
+
{indices.map(index => (
|
127
|
+
<HitsInIndex index={index} key={index.name} show={activeIndexTypes[index.type]} />
|
118
128
|
))}
|
119
129
|
<SearchFooter />
|
120
130
|
</div>
|
@@ -1,28 +1,19 @@
|
|
1
1
|
import algoliasearch from "algoliasearch/lite";
|
2
2
|
import React, { useRef, useState, useEffect } from "react";
|
3
|
-
import {
|
4
|
-
InstantSearch,
|
5
|
-
connectStateResults,
|
6
|
-
Index,
|
7
|
-
} from "react-instantsearch-dom";
|
3
|
+
import { InstantSearch, connectStateResults, Index } from "react-instantsearch-dom";
|
8
4
|
import SearchBox from "./searchbox";
|
9
5
|
import SearchResults from "./searchresults";
|
10
6
|
import { INDEX_TYPES } from "./constants";
|
11
7
|
import SearchFooter from "./searchfooter";
|
12
|
-
import { Typography } from
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
indices,
|
18
|
-
searchState,
|
19
|
-
searching,
|
20
|
-
}) => {
|
8
|
+
import { Typography } from '../../foundation/Typography'
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
const AllResults = ({ allSearchResults, children, indices, searchState, searching }) => {
|
21
13
|
if (!searchState?.query) return null;
|
22
14
|
|
23
15
|
const hasResults =
|
24
|
-
allSearchResults &&
|
25
|
-
Object.values(allSearchResults).some((results) => results.nbHits > 0);
|
16
|
+
allSearchResults && Object.values(allSearchResults).some(results => results.nbHits > 0);
|
26
17
|
return !hasResults ? (
|
27
18
|
<div>
|
28
19
|
<div>
|
@@ -36,7 +27,7 @@ const AllResults = ({
|
|
36
27
|
</span>
|
37
28
|
)}
|
38
29
|
</div>
|
39
|
-
{indices.map(
|
30
|
+
{indices.map(index => (
|
40
31
|
<Index indexName={index.name} key={index.name} />
|
41
32
|
))}
|
42
33
|
<SearchFooter />
|
@@ -54,74 +45,57 @@ const IndexTypeFilter = ({ activeIndexTypes, setActiveIndexTypes }) => {
|
|
54
45
|
const handleOnClick = (indexType) => {
|
55
46
|
if (indexType === INDEX_TYPES.All) {
|
56
47
|
showAll = true;
|
57
|
-
const allFiltersSelected = Object.keys(activeIndexTypes).reduce(
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
},
|
62
|
-
{}
|
63
|
-
);
|
48
|
+
const allFiltersSelected = Object.keys(activeIndexTypes).reduce((acc, key) => {
|
49
|
+
acc[key] = true;
|
50
|
+
return acc;
|
51
|
+
}, {});
|
64
52
|
setActiveIndexTypes(allFiltersSelected);
|
65
53
|
} else {
|
66
|
-
showAll = false
|
67
|
-
const allFiltersSelected = Object.keys(activeIndexTypes).reduce(
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
},
|
72
|
-
{}
|
73
|
-
);
|
54
|
+
showAll = false
|
55
|
+
const allFiltersSelected = Object.keys(activeIndexTypes).reduce((acc, key) => {
|
56
|
+
acc[key] = false;
|
57
|
+
return acc;
|
58
|
+
}, {});
|
74
59
|
setActiveIndexTypes(allFiltersSelected);
|
75
60
|
setActiveIndexTypes((prevState) => ({
|
76
61
|
...prevState,
|
77
62
|
[indexType]: !prevState[indexType],
|
78
63
|
}));
|
79
64
|
}
|
80
|
-
setShowDropdown(false)
|
65
|
+
setShowDropdown(false)
|
81
66
|
};
|
82
67
|
|
83
68
|
return (
|
84
69
|
<div className="relative">
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
70
|
+
<div className="tb-m:min-w-[182px] static tb-m:sticky top-[116px] self-start">
|
71
|
+
<ul className="hds-hidden tb-m:block bg-neutral-0 shadow-md p-4 rounded-2xl">
|
72
|
+
{Object.values(INDEX_TYPES).map((index) => (
|
73
|
+
<li key={index} className="flex items-center mb-2 last:mb-0 tb-m:mr-0 py-0">
|
74
|
+
<button
|
75
|
+
onClick={() => handleOnClick(index)}
|
76
|
+
className={`capitalize cursor-pointer py-1 px-3 w-full text-left rounded-full text-neutral-500 ${(activeIndexTypes[index] && index === 'All') ? "bg-blue-500 " : ""
|
77
|
+
} ${(activeIndexTypes[index] && !showAll) ? 'bg-blue-500': ''} `}
|
91
78
|
>
|
92
|
-
<
|
93
|
-
|
94
|
-
className={
|
95
|
-
|
96
|
-
? "bg-blue-500 "
|
97
|
-
: ""
|
98
|
-
} ${activeIndexTypes[index] && !showAll ? "bg-blue-500" : ""} `}
|
79
|
+
<Typography
|
80
|
+
textStyle="body3c-medium"
|
81
|
+
className={`${(activeIndexTypes[index] && index === 'All') ? "text-neutral-0 " : ""} ${(activeIndexTypes[index] && !showAll) ? 'text-neutral-0' : ''} `
|
82
|
+
}
|
99
83
|
>
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
} `}
|
109
|
-
>
|
110
|
-
{index}
|
111
|
-
</Typography>
|
112
|
-
</button>
|
113
|
-
</li>
|
114
|
-
))}
|
115
|
-
</ul>
|
116
|
-
</div>
|
84
|
+
{index}
|
85
|
+
</Typography>
|
86
|
+
</button>
|
87
|
+
</li>
|
88
|
+
))}
|
89
|
+
</ul>
|
90
|
+
|
91
|
+
</div>
|
117
92
|
<div className="relative hds-hidden-tbm">
|
118
93
|
<button
|
119
94
|
onClick={() => setShowDropdown(!showDropdown)}
|
120
95
|
className="capitalize cursor-pointer py-1 px-3 w-full border border-neutral-800 text-left rounded-full text-neutral-800 bg-transparent"
|
121
96
|
>
|
122
|
-
{Object.values(INDEX_TYPES).find(
|
123
|
-
|
124
|
-
) || "All"}
|
97
|
+
{Object.values(INDEX_TYPES).find((index) => activeIndexTypes[index]) || "All"}
|
98
|
+
|
125
99
|
</button>
|
126
100
|
{showDropdown && (
|
127
101
|
<ul className="absolute top-full left-0 w-full bg-neutral-0 shadow-md z-[20] p-2 rounded-3xl mt-1">
|
@@ -129,11 +103,8 @@ const IndexTypeFilter = ({ activeIndexTypes, setActiveIndexTypes }) => {
|
|
129
103
|
<li
|
130
104
|
key={index}
|
131
105
|
onClick={() => handleOnClick(index)}
|
132
|
-
className={`capitalize cursor-pointer py-2 px-4 ${
|
133
|
-
|
134
|
-
? "text-neutral-1000 "
|
135
|
-
: "text-neutral-500"
|
136
|
-
}`}
|
106
|
+
className={`capitalize cursor-pointer py-2 px-4 ${activeIndexTypes[index] ? "text-neutral-1000 " : "text-neutral-500"
|
107
|
+
}`}
|
137
108
|
>
|
138
109
|
{index}
|
139
110
|
</li>
|
@@ -141,18 +112,21 @@ const IndexTypeFilter = ({ activeIndexTypes, setActiveIndexTypes }) => {
|
|
141
112
|
</ul>
|
142
113
|
)}
|
143
114
|
</div>
|
115
|
+
|
144
116
|
</div>
|
145
117
|
);
|
146
118
|
};
|
147
119
|
|
148
120
|
export default function SearchWrapper({ indices, ...props }) {
|
149
|
-
let ALGOLIA_APP_ID, ALGOLIA_SEARCH_KEY;
|
150
|
-
if (props.ALGOLIA_APP_ID && props.ALGOLIA_SEARCH_KEY)
|
121
|
+
let ALGOLIA_APP_ID, ALGOLIA_SEARCH_KEY ;
|
122
|
+
if (props.ALGOLIA_APP_ID && props.ALGOLIA_SEARCH_KEY){
|
151
123
|
ALGOLIA_APP_ID = props.ALGOLIA_APP_ID;
|
152
124
|
ALGOLIA_SEARCH_KEY = props.ALGOLIA_SEARCH_KEY;
|
153
125
|
}
|
154
|
-
|
155
|
-
|
126
|
+
const algoliaClient = algoliasearch(
|
127
|
+
ALGOLIA_APP_ID,
|
128
|
+
ALGOLIA_SEARCH_KEY
|
129
|
+
);
|
156
130
|
|
157
131
|
const searchClient = {
|
158
132
|
...algoliaClient,
|
@@ -172,17 +146,13 @@ export default function SearchWrapper({ indices, ...props }) {
|
|
172
146
|
},
|
173
147
|
};
|
174
148
|
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
{}
|
181
|
-
);
|
149
|
+
|
150
|
+
const defaultIndexTypesState = Object.values(INDEX_TYPES).reduce((acc, index) => {
|
151
|
+
acc[index] = true;
|
152
|
+
return acc;
|
153
|
+
}, {});
|
182
154
|
const wrapperRef = useRef(null);
|
183
|
-
const [activeIndexTypes, setActiveIndexTypes] = useState(
|
184
|
-
defaultIndexTypesState
|
185
|
-
);
|
155
|
+
const [activeIndexTypes, setActiveIndexTypes] = useState(defaultIndexTypesState);
|
186
156
|
useEffect(() => {
|
187
157
|
setActiveIndexTypes(defaultIndexTypesState);
|
188
158
|
}, []);
|
@@ -198,8 +168,8 @@ export default function SearchWrapper({ indices, ...props }) {
|
|
198
168
|
<div className="tb-m:flex gap-10">
|
199
169
|
<div className="hds-hidden tb-m:flex">
|
200
170
|
<IndexTypeFilter
|
201
|
-
|
202
|
-
|
171
|
+
activeIndexTypes={activeIndexTypes}
|
172
|
+
setActiveIndexTypes={setActiveIndexTypes}
|
203
173
|
/>
|
204
174
|
</div>
|
205
175
|
<SearchResults
|
@@ -207,14 +177,13 @@ export default function SearchWrapper({ indices, ...props }) {
|
|
207
177
|
indices={indices}
|
208
178
|
wrapperRef={wrapperRef}
|
209
179
|
activeIndexTypes={activeIndexTypes}
|
210
|
-
className="search-results"
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
</div>
|
180
|
+
className="search-results">
|
181
|
+
<div className="hds-hidden-tbm sticky top-[124px] tb:top-[114px] z-10 bg-neutral-100 pb-3">
|
182
|
+
<IndexTypeFilter
|
183
|
+
activeIndexTypes={activeIndexTypes}
|
184
|
+
setActiveIndexTypes={setActiveIndexTypes}
|
185
|
+
/>
|
186
|
+
</div>
|
218
187
|
</SearchResults>
|
219
188
|
</div>
|
220
189
|
</CustomAllResults>
|