hds-web 1.15.8 → 1.15.9
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/.env +2 -0
- package/dist/index.css +1 -1
- package/dist/index.es.css +1 -1
- package/dist/index.es.js +5 -13
- package/dist/index.js +5 -13
- package/package.json +5 -1
- package/src/HDS/components/Cards/index.js +0 -1
- package/src/HDS/components/Headers/v3Header.js +2 -0
- package/src/HDS/components/Snippet/CodeSnippet.js +58 -58
- package/src/HDS/components/Snippet/index.js +1 -1
- package/src/HDS/components/index.js +0 -1
- package/src/HDS/helpers/AlgoliaSearch/constants.js +48 -0
- package/src/HDS/helpers/AlgoliaSearch/index.js +1 -0
- package/src/HDS/helpers/AlgoliaSearch/search.js +38 -0
- package/src/HDS/helpers/AlgoliaSearch/search.scss +38 -0
- package/src/HDS/helpers/AlgoliaSearch/searchbox.js +88 -0
- package/src/HDS/helpers/AlgoliaSearch/searchfooter.js +30 -0
- package/src/HDS/helpers/AlgoliaSearch/searchoverlay.js +36 -0
- package/src/HDS/helpers/AlgoliaSearch/searchresults.js +98 -0
- package/src/HDS/helpers/AlgoliaSearch/searchwrapper.js +126 -0
- package/src/HDS/helpers/index.js +1 -0
- package/src/styles/tailwind.css +89 -0
@@ -0,0 +1,126 @@
|
|
1
|
+
import algoliasearch from "algoliasearch/lite";
|
2
|
+
import React, { useRef, useState } from "react";
|
3
|
+
import { InstantSearch, connectStateResults, Index } from "react-instantsearch-dom";
|
4
|
+
import SearchBox from "./searchbox";
|
5
|
+
import SearchResults from "./searchresults";
|
6
|
+
import { INDEX_TYPES } from "./constants";
|
7
|
+
import SearchFooter from "./searchfooter";
|
8
|
+
import { Typography } from '../../foundation/Typography'
|
9
|
+
|
10
|
+
|
11
|
+
const algoliaClient = algoliasearch(
|
12
|
+
process.env.ALGOLIA_APP_ID,
|
13
|
+
process.env.ALGOLIA_SEARCH_KEY
|
14
|
+
);
|
15
|
+
|
16
|
+
const searchClient = {
|
17
|
+
...algoliaClient,
|
18
|
+
search(requests) {
|
19
|
+
if (requests.every(({ params }) => !params.query)) {
|
20
|
+
return Promise.resolve({
|
21
|
+
results: requests.map(() => ({
|
22
|
+
hits: [],
|
23
|
+
nbHits: 0,
|
24
|
+
nbPages: 0,
|
25
|
+
processingTimeMS: 0,
|
26
|
+
})),
|
27
|
+
});
|
28
|
+
}
|
29
|
+
|
30
|
+
return algoliaClient.search(requests);
|
31
|
+
},
|
32
|
+
};
|
33
|
+
|
34
|
+
const AllResults = ({ allSearchResults, children, indices, searchState, searching }) => {
|
35
|
+
if (!searchState?.query) return null;
|
36
|
+
|
37
|
+
const hasResults =
|
38
|
+
allSearchResults && Object.values(allSearchResults).some(results => results.nbHits > 0);
|
39
|
+
return !hasResults ? (
|
40
|
+
<div>
|
41
|
+
<div>
|
42
|
+
{searching ? (
|
43
|
+
<span>
|
44
|
+
Searching for "<em>{searchState?.query}</em>"
|
45
|
+
</span>
|
46
|
+
) : (
|
47
|
+
<span>
|
48
|
+
No results for "<em>{searchState?.query}</em>"
|
49
|
+
</span>
|
50
|
+
)}
|
51
|
+
</div>
|
52
|
+
{indices.map(index => (
|
53
|
+
<Index indexName={index.name} key={index.name} />
|
54
|
+
))}
|
55
|
+
<SearchFooter />
|
56
|
+
</div>
|
57
|
+
) : (
|
58
|
+
children
|
59
|
+
);
|
60
|
+
};
|
61
|
+
|
62
|
+
const CustomAllResults = connectStateResults(AllResults);
|
63
|
+
|
64
|
+
const IndexTypeFilter = ({ activeIndexTypes, setActiveIndexTypes }) => {
|
65
|
+
const handleOnChange = indexType => ({ target }) => {
|
66
|
+
setActiveIndexTypes(prevState => ({
|
67
|
+
...prevState,
|
68
|
+
[indexType]: target.checked,
|
69
|
+
}));
|
70
|
+
};
|
71
|
+
|
72
|
+
return (
|
73
|
+
<div className="tb-m:min-w-[150px] static tb-m:sticky top-[96px] self-start">
|
74
|
+
<Typography textStyle="h6" as="h6" className="text-neutral-700 uppercase">Filter</Typography>
|
75
|
+
<ul className="flex tb-m:block">
|
76
|
+
{Object.values(INDEX_TYPES).map(index => (
|
77
|
+
<li key={index} className="flex items-center py-3 mr-4 tb-m:mr-0">
|
78
|
+
<input
|
79
|
+
type="checkbox"
|
80
|
+
id={"algolia_index_type_" + index}
|
81
|
+
name={"algolia_index_type_" + index}
|
82
|
+
value={index}
|
83
|
+
checked={activeIndexTypes[index]}
|
84
|
+
onChange={handleOnChange(index)}
|
85
|
+
className="mr-2 focus:outline-none"
|
86
|
+
/>
|
87
|
+
<label htmlFor={"algolia_index_type_" + index}>{index}</label>
|
88
|
+
</li>
|
89
|
+
))}
|
90
|
+
</ul>
|
91
|
+
</div>
|
92
|
+
);
|
93
|
+
};
|
94
|
+
|
95
|
+
export default function SearchWrapper({ indices }) {
|
96
|
+
const defaultIndexTypesState = Object.values(INDEX_TYPES).reduce((a, c) => {
|
97
|
+
a[c] = true;
|
98
|
+
return a;
|
99
|
+
}, {});
|
100
|
+
const wrapperRef = useRef(null);
|
101
|
+
const [activeIndexTypes, setActiveIndexTypes] = useState(defaultIndexTypesState);
|
102
|
+
return (
|
103
|
+
<InstantSearch
|
104
|
+
searchClient={searchClient}
|
105
|
+
indexName={indices[0].name}
|
106
|
+
onSearchStateChange={() => setActiveIndexTypes(defaultIndexTypesState)}
|
107
|
+
>
|
108
|
+
<SearchBox />
|
109
|
+
<CustomAllResults indices={indices}>
|
110
|
+
<div className="tb-m:flex">
|
111
|
+
<IndexTypeFilter
|
112
|
+
activeIndexTypes={activeIndexTypes}
|
113
|
+
setActiveIndexTypes={setActiveIndexTypes}
|
114
|
+
/>
|
115
|
+
<SearchResults
|
116
|
+
id="search-results"
|
117
|
+
indices={indices}
|
118
|
+
wrapperRef={wrapperRef}
|
119
|
+
activeIndexTypes={activeIndexTypes}
|
120
|
+
className="search-results"
|
121
|
+
/>
|
122
|
+
</div>
|
123
|
+
</CustomAllResults>
|
124
|
+
</InstantSearch>
|
125
|
+
);
|
126
|
+
}
|
package/src/HDS/helpers/index.js
CHANGED
package/src/styles/tailwind.css
CHANGED
@@ -827,6 +827,10 @@ select{
|
|
827
827
|
visibility: hidden;
|
828
828
|
}
|
829
829
|
|
830
|
+
.static{
|
831
|
+
position: static;
|
832
|
+
}
|
833
|
+
|
830
834
|
.fixed{
|
831
835
|
position: fixed;
|
832
836
|
}
|
@@ -886,6 +890,10 @@ select{
|
|
886
890
|
right: -44px;
|
887
891
|
}
|
888
892
|
|
893
|
+
.-top-20{
|
894
|
+
top: -5rem;
|
895
|
+
}
|
896
|
+
|
889
897
|
.bottom-0{
|
890
898
|
bottom: 0px;
|
891
899
|
}
|
@@ -970,6 +978,10 @@ select{
|
|
970
978
|
right: 0.5rem;
|
971
979
|
}
|
972
980
|
|
981
|
+
.right-4{
|
982
|
+
right: 1rem;
|
983
|
+
}
|
984
|
+
|
973
985
|
.right-8{
|
974
986
|
right: 2rem;
|
975
987
|
}
|
@@ -994,6 +1006,10 @@ select{
|
|
994
1006
|
top: 0.5rem;
|
995
1007
|
}
|
996
1008
|
|
1009
|
+
.top-4{
|
1010
|
+
top: 1rem;
|
1011
|
+
}
|
1012
|
+
|
997
1013
|
.top-5{
|
998
1014
|
top: 1.25rem;
|
999
1015
|
}
|
@@ -1022,6 +1038,10 @@ select{
|
|
1022
1038
|
top: 72px;
|
1023
1039
|
}
|
1024
1040
|
|
1041
|
+
.top-\[96px\]{
|
1042
|
+
top: 96px;
|
1043
|
+
}
|
1044
|
+
|
1025
1045
|
.isolate{
|
1026
1046
|
isolation: isolate;
|
1027
1047
|
}
|
@@ -1050,6 +1070,10 @@ select{
|
|
1050
1070
|
z-index: 50;
|
1051
1071
|
}
|
1052
1072
|
|
1073
|
+
.z-\[10000\]{
|
1074
|
+
z-index: 10000;
|
1075
|
+
}
|
1076
|
+
|
1053
1077
|
.z-\[100\]{
|
1054
1078
|
z-index: 100;
|
1055
1079
|
}
|
@@ -1058,6 +1082,10 @@ select{
|
|
1058
1082
|
z-index: 10;
|
1059
1083
|
}
|
1060
1084
|
|
1085
|
+
.z-\[11\]{
|
1086
|
+
z-index: 11;
|
1087
|
+
}
|
1088
|
+
|
1061
1089
|
.z-\[1\]{
|
1062
1090
|
z-index: 1;
|
1063
1091
|
}
|
@@ -1082,6 +1110,10 @@ select{
|
|
1082
1110
|
grid-column: span 4 / span 4;
|
1083
1111
|
}
|
1084
1112
|
|
1113
|
+
.clear-both{
|
1114
|
+
clear: both;
|
1115
|
+
}
|
1116
|
+
|
1085
1117
|
.-m-1{
|
1086
1118
|
margin: -0.25rem;
|
1087
1119
|
}
|
@@ -1102,6 +1134,10 @@ select{
|
|
1102
1134
|
margin: -0.75rem;
|
1103
1135
|
}
|
1104
1136
|
|
1137
|
+
.m-1{
|
1138
|
+
margin: 0.25rem;
|
1139
|
+
}
|
1140
|
+
|
1105
1141
|
.m-2{
|
1106
1142
|
margin: 0.5rem;
|
1107
1143
|
}
|
@@ -2654,6 +2690,10 @@ select{
|
|
2654
2690
|
border-width: 1.5px;
|
2655
2691
|
}
|
2656
2692
|
|
2693
|
+
.border-\[3px\]{
|
2694
|
+
border-width: 3px;
|
2695
|
+
}
|
2696
|
+
|
2657
2697
|
.border-x{
|
2658
2698
|
border-left-width: 1px;
|
2659
2699
|
border-right-width: 1px;
|
@@ -3201,11 +3241,21 @@ select{
|
|
3201
3241
|
border-bottom-color: rgb(157 164 174 / var(--tw-border-opacity));
|
3202
3242
|
}
|
3203
3243
|
|
3244
|
+
.border-t-blue-500{
|
3245
|
+
--tw-border-opacity: 1;
|
3246
|
+
border-top-color: rgb(57 112 253 / var(--tw-border-opacity));
|
3247
|
+
}
|
3248
|
+
|
3204
3249
|
.border-t-neutral-150{
|
3205
3250
|
--tw-border-opacity: 1;
|
3206
3251
|
border-top-color: rgb(236 237 240 / var(--tw-border-opacity));
|
3207
3252
|
}
|
3208
3253
|
|
3254
|
+
.border-t-neutral-200{
|
3255
|
+
--tw-border-opacity: 1;
|
3256
|
+
border-top-color: rgb(229 231 235 / var(--tw-border-opacity));
|
3257
|
+
}
|
3258
|
+
|
3209
3259
|
.bg-amber-100{
|
3210
3260
|
--tw-bg-opacity: 1;
|
3211
3261
|
background-color: rgb(255 243 212 / var(--tw-bg-opacity));
|
@@ -6457,6 +6507,10 @@ select{
|
|
6457
6507
|
text-align: right;
|
6458
6508
|
}
|
6459
6509
|
|
6510
|
+
.indent-5{
|
6511
|
+
text-indent: 1.25rem;
|
6512
|
+
}
|
6513
|
+
|
6460
6514
|
.font-petrona{
|
6461
6515
|
font-family: Petrona, serif;
|
6462
6516
|
}
|
@@ -9462,6 +9516,11 @@ select{
|
|
9462
9516
|
color: rgb(30 86 227 / var(--tw-text-opacity));
|
9463
9517
|
}
|
9464
9518
|
|
9519
|
+
.hover\:text-blue-700:hover{
|
9520
|
+
--tw-text-opacity: 1;
|
9521
|
+
color: rgb(13 65 198 / var(--tw-text-opacity));
|
9522
|
+
}
|
9523
|
+
|
9465
9524
|
.hover\:text-neutral-0:hover{
|
9466
9525
|
--tw-text-opacity: 1;
|
9467
9526
|
color: rgb(255 255 255 / var(--tw-text-opacity));
|
@@ -10846,6 +10905,23 @@ select{
|
|
10846
10905
|
}
|
10847
10906
|
|
10848
10907
|
@media (min-width: 800px){
|
10908
|
+
.tb-m\:sticky{
|
10909
|
+
position: -webkit-sticky;
|
10910
|
+
position: sticky;
|
10911
|
+
}
|
10912
|
+
|
10913
|
+
.tb-m\:-top-20{
|
10914
|
+
top: -5rem;
|
10915
|
+
}
|
10916
|
+
|
10917
|
+
.tb-m\:mr-0{
|
10918
|
+
margin-right: 0px;
|
10919
|
+
}
|
10920
|
+
|
10921
|
+
.tb-m\:block{
|
10922
|
+
display: block;
|
10923
|
+
}
|
10924
|
+
|
10849
10925
|
.tb-m\:flex{
|
10850
10926
|
display: flex;
|
10851
10927
|
}
|
@@ -10854,6 +10930,10 @@ select{
|
|
10854
10930
|
width: 50%;
|
10855
10931
|
}
|
10856
10932
|
|
10933
|
+
.tb-m\:min-w-\[150px\]{
|
10934
|
+
min-width: 150px;
|
10935
|
+
}
|
10936
|
+
|
10857
10937
|
.tb-m\:snap-start{
|
10858
10938
|
scroll-snap-align: start;
|
10859
10939
|
}
|
@@ -10870,6 +10950,11 @@ select{
|
|
10870
10950
|
border-top-width: 0px;
|
10871
10951
|
}
|
10872
10952
|
|
10953
|
+
.tb-m\:py-9{
|
10954
|
+
padding-top: 2.25rem;
|
10955
|
+
padding-bottom: 2.25rem;
|
10956
|
+
}
|
10957
|
+
|
10873
10958
|
.tb-m\:pb-0{
|
10874
10959
|
padding-bottom: 0px;
|
10875
10960
|
}
|
@@ -10877,6 +10962,10 @@ select{
|
|
10877
10962
|
.tb-m\:pt-0{
|
10878
10963
|
padding-top: 0px;
|
10879
10964
|
}
|
10965
|
+
|
10966
|
+
.tb-m\:pt-16{
|
10967
|
+
padding-top: 4rem;
|
10968
|
+
}
|
10880
10969
|
}
|
10881
10970
|
|
10882
10971
|
@media (min-width: 905px){
|