hds-web 1.36.6 → 1.36.8
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.css +2 -2
- package/dist/index.es.css +2 -2
- package/dist/index.es.js +5 -5
- package/dist/index.js +3 -3
- package/package.json +1 -1
- package/src/HDS/components/Cards/Announcement/announcementMd.js +74 -37
- package/src/HDS/helpers/AlgoliaSearch/constants.js +19 -101
- package/src/HDS/helpers/AlgoliaSearch/search.js +0 -1
- 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 +77 -67
- package/src/HDS/helpers/AlgoliaSearch/searchwrapper.js +67 -101
- package/src/styles/tailwind.css +8 -0
- package/src/HDS/helpers/AlgoliaSearch/SearchHit.js +0 -117
@@ -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,21 +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
|
-
let ALGOLIA_APP_ID = `WCBB1VVLRC`;
|
149
|
-
let ALGOLIA_SEARCH_KEY = `baf43aa3921858bc144d0fe5ce85b526`;
|
150
|
-
|
151
120
|
export default function SearchWrapper({ indices, ...props }) {
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
121
|
+
let ALGOLIA_APP_ID, ALGOLIA_SEARCH_KEY ;
|
122
|
+
if (props.ALGOLIA_APP_ID && props.ALGOLIA_SEARCH_KEY){
|
123
|
+
ALGOLIA_APP_ID = props.ALGOLIA_APP_ID;
|
124
|
+
ALGOLIA_SEARCH_KEY = props.ALGOLIA_SEARCH_KEY;
|
125
|
+
}
|
126
|
+
const algoliaClient = algoliasearch(
|
127
|
+
ALGOLIA_APP_ID,
|
128
|
+
ALGOLIA_SEARCH_KEY
|
129
|
+
);
|
159
130
|
|
160
131
|
const searchClient = {
|
161
132
|
...algoliaClient,
|
@@ -175,17 +146,13 @@ export default function SearchWrapper({ indices, ...props }) {
|
|
175
146
|
},
|
176
147
|
};
|
177
148
|
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
{}
|
184
|
-
);
|
149
|
+
|
150
|
+
const defaultIndexTypesState = Object.values(INDEX_TYPES).reduce((acc, index) => {
|
151
|
+
acc[index] = true;
|
152
|
+
return acc;
|
153
|
+
}, {});
|
185
154
|
const wrapperRef = useRef(null);
|
186
|
-
const [activeIndexTypes, setActiveIndexTypes] = useState(
|
187
|
-
defaultIndexTypesState
|
188
|
-
);
|
155
|
+
const [activeIndexTypes, setActiveIndexTypes] = useState(defaultIndexTypesState);
|
189
156
|
useEffect(() => {
|
190
157
|
setActiveIndexTypes(defaultIndexTypesState);
|
191
158
|
}, []);
|
@@ -201,8 +168,8 @@ export default function SearchWrapper({ indices, ...props }) {
|
|
201
168
|
<div className="tb-m:flex gap-10">
|
202
169
|
<div className="hds-hidden tb-m:flex">
|
203
170
|
<IndexTypeFilter
|
204
|
-
|
205
|
-
|
171
|
+
activeIndexTypes={activeIndexTypes}
|
172
|
+
setActiveIndexTypes={setActiveIndexTypes}
|
206
173
|
/>
|
207
174
|
</div>
|
208
175
|
<SearchResults
|
@@ -210,14 +177,13 @@ export default function SearchWrapper({ indices, ...props }) {
|
|
210
177
|
indices={indices}
|
211
178
|
wrapperRef={wrapperRef}
|
212
179
|
activeIndexTypes={activeIndexTypes}
|
213
|
-
className="search-results"
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
</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>
|
221
187
|
</SearchResults>
|
222
188
|
</div>
|
223
189
|
</CustomAllResults>
|
package/src/styles/tailwind.css
CHANGED
@@ -10964,6 +10964,14 @@ select{
|
|
10964
10964
|
top: 160px;
|
10965
10965
|
}
|
10966
10966
|
|
10967
|
+
.tb\:left-4{
|
10968
|
+
left: 1rem;
|
10969
|
+
}
|
10970
|
+
|
10971
|
+
.tb\:left-3{
|
10972
|
+
left: 0.75rem;
|
10973
|
+
}
|
10974
|
+
|
10967
10975
|
.tb\:mb-0{
|
10968
10976
|
margin-bottom: 0px;
|
10969
10977
|
}
|
@@ -1,117 +0,0 @@
|
|
1
|
-
import React from "react";
|
2
|
-
import { Highlight, Snippet } from "react-instantsearch-dom";
|
3
|
-
import { INDEX_TYPES } from "./constants";
|
4
|
-
import { Typography } from "../../foundation/Typography";
|
5
|
-
|
6
|
-
const baseDomain = "hasura.io";
|
7
|
-
|
8
|
-
export const SearchHit = ({ hit, indexType }) => {
|
9
|
-
if (indexType === "events") {
|
10
|
-
return (
|
11
|
-
<a href={hit.metaTags?.canonical_url} className="grid h-full">
|
12
|
-
<div className="self-start">
|
13
|
-
<div className="flex items-start">
|
14
|
-
<div className="w-6 h-6 mr-2 min-w-[24px] flex items-center justify-center">
|
15
|
-
<div className="w-3 h-3 rounded-full bg-blue-500"></div>
|
16
|
-
</div>
|
17
|
-
<div>
|
18
|
-
<Typography
|
19
|
-
textStyle="body1c-bold"
|
20
|
-
className="font-bold text-neutral-800 pb-3"
|
21
|
-
>
|
22
|
-
<Highlight
|
23
|
-
attribute="metaTags.meta_title"
|
24
|
-
hit={hit}
|
25
|
-
tagName="mark"
|
26
|
-
/>
|
27
|
-
</Typography>
|
28
|
-
<Typography
|
29
|
-
textStyle="body2"
|
30
|
-
className="text-neutral-800 word-break"
|
31
|
-
>
|
32
|
-
<Snippet
|
33
|
-
attribute="metaTags.meta_description"
|
34
|
-
hit={hit}
|
35
|
-
tagName="mark"
|
36
|
-
/>
|
37
|
-
</Typography>
|
38
|
-
</div>
|
39
|
-
</div>
|
40
|
-
</div>
|
41
|
-
<Typography
|
42
|
-
textStyle="body3"
|
43
|
-
className="self-end pl-8 pt-3 text-neutral-500"
|
44
|
-
>
|
45
|
-
<span className="hit-slug word-break">
|
46
|
-
{hit.metaTags?.canonical_url.replace(`https://${baseDomain}/`, "/")}
|
47
|
-
</span>
|
48
|
-
</Typography>
|
49
|
-
</a>
|
50
|
-
);
|
51
|
-
}
|
52
|
-
|
53
|
-
return (
|
54
|
-
<a href={hit.url} className="grid h-full">
|
55
|
-
<div className="self-start">
|
56
|
-
{/* <Typography textStyle="body3c-medium" className="uppercase text-neutral-500">{indexType}</Typography> */}
|
57
|
-
{indexType === INDEX_TYPES.docs ? (
|
58
|
-
<div className="flex items-start">
|
59
|
-
<div className="w-6 h-6 mr-2 min-w-[24px] flex items-center justify-center">
|
60
|
-
<div className="w-3 h-3 rounded-full bg-blue-500"></div>
|
61
|
-
</div>
|
62
|
-
<div>
|
63
|
-
{!!hit.hierarchy && (
|
64
|
-
<Typography
|
65
|
-
textStyle="body1c-bold"
|
66
|
-
className="font-bold flex items-start pb-3"
|
67
|
-
>
|
68
|
-
{`${
|
69
|
-
Object.values(hit.hierarchy)
|
70
|
-
.filter((h) => !!h)
|
71
|
-
.reverse()[0]
|
72
|
-
}`}
|
73
|
-
</Typography>
|
74
|
-
)}
|
75
|
-
<Typography
|
76
|
-
textStyle="body2"
|
77
|
-
className="text-neutral-800 word-break"
|
78
|
-
>
|
79
|
-
<Snippet attribute="content" hit={hit} tagName="mark" />
|
80
|
-
</Typography>
|
81
|
-
</div>
|
82
|
-
</div>
|
83
|
-
) : (
|
84
|
-
<div className="flex items-start">
|
85
|
-
<div className="w-6 h-6 mr-2 min-w-[24px] flex items-center justify-center">
|
86
|
-
<div className="w-3 h-3 rounded-full bg-blue-500"></div>
|
87
|
-
</div>
|
88
|
-
<div>
|
89
|
-
<Typography
|
90
|
-
textStyle="body1c-bold"
|
91
|
-
className="font-bold text-neutral-800 pb-3"
|
92
|
-
>
|
93
|
-
<Highlight attribute="title" hit={hit} tagName="mark" />
|
94
|
-
</Typography>
|
95
|
-
<Typography
|
96
|
-
textStyle="body2"
|
97
|
-
className="text-neutral-800 word-break"
|
98
|
-
>
|
99
|
-
<Snippet attribute="excerpt" hit={hit} tagName="mark" />
|
100
|
-
</Typography>
|
101
|
-
</div>
|
102
|
-
</div>
|
103
|
-
)}
|
104
|
-
</div>
|
105
|
-
{hit.url ? (
|
106
|
-
<Typography
|
107
|
-
textStyle="body3"
|
108
|
-
className="self-end pl-8 pt-3 text-neutral-500"
|
109
|
-
>
|
110
|
-
<span className="hit-slug word-break">
|
111
|
-
{hit.url.replace(`https://${baseDomain}/`, "/")}
|
112
|
-
</span>
|
113
|
-
</Typography>
|
114
|
-
) : null}
|
115
|
-
</a>
|
116
|
-
);
|
117
|
-
};
|