hds-web 1.20.5 → 1.20.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hds-web",
3
- "version": "1.20.5",
3
+ "version": "1.20.6",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.es.js",
@@ -1,7 +1,13 @@
1
1
  export const INDEX_TYPES = Object.freeze({
2
+ All: "All",
3
+ //Website: "website",
2
4
  blog: "blog",
3
5
  docs: "docs",
4
6
  learn: "learn",
7
+ // tutorials: "Tutorials",
8
+ // case_studies: "Case studies",
9
+ // events: "Events",
10
+ // resources: "Resources"
5
11
  });
6
12
 
7
13
  export const SEARCH_INDICES = [
@@ -44,5 +50,5 @@ export const SEARCH_INDICES = [
44
50
  title: `Learn Reason React Apollo`,
45
51
  type: INDEX_TYPES.learn,
46
52
  },
47
- { name: `learn-database-mssql`, title: `Learn MicrosoftSQL`, type: INDEX_TYPES.learn },
53
+ { name: `learn-database-mssql`, title: `Learn MicrosoftSQL`, type: INDEX_TYPES.learn },
48
54
  ];
@@ -44,20 +44,20 @@ const DebouncedSearchBox = ({
44
44
  setValue(value);
45
45
  };
46
46
  return (
47
- <div className=" sticky -top-20 tb-m:-top-20 z-10 py-8 pt-16 tb-m:pt-16 tb-m:py-9 bg-neutral-50">
47
+ <div className=" sticky -top-20 tb-m:-top-20 z-10 py-8 pt-16 tb-m:pt-16 tb-m:py-9 bg-neutral-0">
48
48
  <div className="flex relative items-center w-full">
49
49
  <div className="absolute left-2">
50
50
  {isSearchStalled ? (
51
51
  <div className="loader-spin border-[3px] border-neutral-400 border-t-blue-500 w-5 h-5 rounded-full" />
52
52
  ) : (
53
- <Icon height={'w-5 h-5 stroke-[1.5px]'} variant="searchsm" strokeClass="stroke-neutral-800" />
53
+ <Icon height={'w-8 h-8 stroke-[1.5px]'} variant="searchsm" strokeClass="stroke-neutral-800" />
54
54
  )}
55
55
  </div>
56
56
  <form className={`${className} w-full`} onSubmit={e => e.preventDefault()}>
57
57
  <input
58
58
  id="search-input"
59
59
  ref={searchInputRef}
60
- className="w-full indent-5 rounded-xl border-neutral-400 h-12"
60
+ className="shodow-none w-full font-bold indent-8 text-2xl tb-m:text-4xl text-neutral-800 placeholder:text-neutral-800 rounded-xl border-0 h-12 focus:border-0 focus:shadow-[none] focus:border-neutral-0 tb:text-2xl"
61
61
  type="text"
62
62
  placeholder="Search for tutorials, articles or docs"
63
63
  aria-label="Search"
@@ -65,19 +65,21 @@ const DebouncedSearchBox = ({
65
65
  value={value}
66
66
  />
67
67
  </form>
68
- <div onClick={resetInput} className="absolute right-2 cursor-pointer bg-neutral-200 rounded-md">
68
+ <div onClick={resetInput} className="absolute right-2 cursor-pointer rounded-md">
69
69
  <Icon height={'w-6 h-6 stroke-[1.5px]'} variant="xclose" strokeClass="stroke-neutral-800" />
70
70
  </div>
71
71
  </div>
72
- <div className="hidden tb:flex flex-wrap items-center mt-4">
73
- <Typography textStyle="body2c-bold" className="uppercase text-neutral-500 mr-4">POPULAR</Typography>
72
+ <div className="tb:flex flex-wrap items-center mt-4">
73
+ {/* <Typography textStyle="body2c-bold" className="uppercase text-neutral-500 mr-4">POPULAR</Typography> */}
74
74
  {searchSuggestions.map(suggestion => (
75
75
  <button
76
76
  key={suggestion}
77
- className={`px-3 py-1 border rounded-md m-1 ${currentRefinement === suggestion ? "border-neutral-300 hover:bg-neutral-300 bg-neutral-300" : "bg-neutral-150 hover:bg-neutral-200 border-neutral-150"}`}
77
+ className={`px-2 py-[2px] text-blue-800 border rounded-[100px] m-1 ${currentRefinement === suggestion ? "border-blue-300 hover:bg-blue-300 bg-blue-300" : "bg-blue-200 hover:bg-blue-300 border-blue-200"}`}
78
78
  onClick={() => trySuggestion(suggestion)}
79
79
  >
80
+ <Typography textStyle="body2c-medium">
80
81
  {suggestion}
82
+ </Typography>
81
83
  </button>
82
84
  ))}
83
85
  </div>
@@ -3,8 +3,8 @@ import { PoweredBy } from "react-instantsearch-dom";
3
3
 
4
4
  const SearchFooter = () => (
5
5
  <Fragment>
6
- <hr className="my-5 border-t-neutral-200" />
7
- <div className="mt-12 flex flex-wrap justify-between">
6
+ <hr className="my-8 border-t-neutral-200" />
7
+ <div className="mt-10 flex flex-wrap justify-between">
8
8
  <div className="community-links-wrapper">
9
9
  <p>Unable to find what you're looking for?</p>
10
10
  <p>
@@ -19,7 +19,7 @@ export default function SearchOverlay({showSearch, onCloseSearch, ...props}) {
19
19
  if (!showSearch) return null;
20
20
 
21
21
  return (
22
- <div className="fixed left-0 top-0 w-full h-full z-[10000] bg-neutral-50">
22
+ <div className="fixed left-0 top-0 w-full h-full z-[10000] bg-neutral-0">
23
23
  <div className="absolute top-4 right-4 cursor-pointer z-[11]" onClick={onCloseSearch}>
24
24
  <Icon height={'w-8 h-8 stroke-[1.5px]'} variant="xclose" strokeClass="stroke-neutral-800" />
25
25
  </div>
@@ -3,21 +3,45 @@ import { connectStateResults, Highlight, Hits, Index, Snippet } from "react-inst
3
3
  import { INDEX_TYPES } from "./constants";
4
4
  import SearchFooter from "./searchfooter";
5
5
  import { Typography } from '../../foundation/Typography'
6
+ import { Icon } from '../../components/common-components/Icon';
6
7
 
7
8
  // import SearchFooter from "./SearchFooter";
8
9
 
9
10
  const baseDomain = 'hasura.io';
10
11
 
11
12
 
12
- const HitsHeader = ({ searchResults, indexTitle, showSeparator }) => {
13
+ const HitsHeader = ({ searchResults, indexTitle, showSeparator, allIndex }) => {
13
14
  const hitCount = searchResults && searchResults.nbHits;
15
+ console.log(allIndex)
16
+ const titleIcon = () => {
17
+ if(indexTitle === "Hasura Blog") {
18
+ return (
19
+ <Icon height={'block w-6 mr-3 h-6 stroke-[2px] transition ease-in-out'} variant="pentool02" strokeClass='stroke-blue-500' />
20
+ )
21
+ }
22
+ if(indexTitle === "Hasura GraphQL Engine Docs") {
23
+ return (
24
+ <Icon height={'block w-6 mr-3 h-6 stroke-[2px] transition ease-in-out'} variant="file02" strokeClass='stroke-blue-500' />
25
+ )
26
+ }
27
+ return (
28
+ <Icon height={'block w-6 mr-3 h-6 stroke-[2px] transition ease-in-out'} variant="graduationhat01" strokeClass='stroke-blue-500' />
29
+ )
30
+ }
31
+
14
32
  return hitCount > 0 ? (
15
33
  <Fragment>
16
- {showSeparator && <hr className="my-5 border-t-neutral-200" />}
34
+ {showSeparator && <hr className="my-8 border-t-neutral-200" />}
17
35
  {/* <div className="HitCount">
18
36
  {hitCount} result{hitCount !== 1 ? `s` : ``}
19
37
  </div> */}
20
- <Typography textStyle="body2c-medium" className="pb-4">{indexTitle}</Typography>
38
+ <Typography textStyle="sub1" className="pb-4 pl-2 flex items-center font-normal sticky tb-m:z-0 top-[170px] tb:top-[160px] tb-m:top-[120px] bg-neutral-0">
39
+ {
40
+ titleIcon()
41
+ }
42
+
43
+ {indexTitle}
44
+ </Typography>
21
45
  </Fragment>
22
46
  ) : null;
23
47
  };
@@ -27,35 +51,45 @@ const CustomHitsHeader = connectStateResults(HitsHeader);
27
51
  const PageHit = ({ hit, indexType }) => (
28
52
  <a href={hit.url} className="grid h-full">
29
53
  <div className="self-start">
30
- <Typography textStyle="body3c-medium" className="uppercase text-neutral-500">{indexType}</Typography>
54
+ {/* <Typography textStyle="body3c-medium" className="uppercase text-neutral-500">{indexType}</Typography> */}
31
55
  {indexType === INDEX_TYPES.docs ? (
32
- <Fragment>
33
- {!!hit.hierarchy && (
34
- <Typography textStyle="body1c-bold" className="font-semibold py-3">{`${
35
- Object.values(hit.hierarchy)
36
- .filter(h => !!h)
37
- .reverse()[0]
38
- }`}</Typography>
39
- )}
40
- <Typography textStyle="body2" className="text-neutral-600 break-words">
41
- <Snippet attribute="content" hit={hit} tagName="mark" />
42
- </Typography>
43
-
44
- </Fragment>
56
+ <div className="flex items-start">
57
+ <div className="w-6 h-6 mr-2 min-w-[24px] flex items-center justify-center">
58
+ <div className="w-3 h-3 rounded-full bg-blue-500"></div>
59
+ </div>
60
+ <div>
61
+ {!!hit.hierarchy && (
62
+ <Typography textStyle="body1c-bold" className="font-bold flex items-start pb-3">
63
+ {`${
64
+ Object.values(hit.hierarchy)
65
+ .filter(h => !!h)
66
+ .reverse()[0]
67
+ }`}</Typography>
68
+ )}
69
+ <Typography textStyle="body2" className="text-neutral-800 word-break">
70
+ <Snippet attribute="content" hit={hit} tagName="mark" />
71
+ </Typography>
72
+ </div>
73
+ </div>
45
74
  ) : (
46
- <Fragment>
47
- <Typography textStyle="body1c-bold" className="font-semibold py-3">
48
- <Highlight attribute="title" hit={hit} tagName="mark" />
49
- </Typography>
50
- <Typography textStyle="body2" className="text-neutral-600 break-words">
51
- <Snippet attribute="excerpt" hit={hit} tagName="mark" />
52
- </Typography>
53
- </Fragment>
75
+ <div className="flex items-start">
76
+ <div className="w-6 h-6 mr-2 min-w-[24px] flex items-center justify-center">
77
+ <div className="w-3 h-3 rounded-full bg-blue-500"></div>
78
+ </div>
79
+ <div>
80
+ <Typography textStyle="body1c-bold" className="font-bold text-neutral-800 pb-3">
81
+ <Highlight attribute="title" hit={hit} tagName="mark" />
82
+ </Typography>
83
+ <Typography textStyle="body2" className="text-neutral-800 word-break">
84
+ <Snippet attribute="excerpt" hit={hit} tagName="mark" />
85
+ </Typography>
86
+ </div>
87
+ </div>
54
88
  )}
55
89
  </div>
56
90
  {hit.url ? (
57
- <Typography textStyle="body3" className="self-end my-2 pt-3 text-neutral-600">
58
- <span className='hit-slug break-words'>{hit.url.replace(`https://${baseDomain}/`, "/")}</span>
91
+ <Typography textStyle="body3" className="self-end pl-8 pt-3 text-neutral-500">
92
+ <span className='hit-slug word-break'>{hit.url.replace(`https://${baseDomain}/`, "/")}</span>
59
93
  </Typography>
60
94
  ) : null}
61
95
  </a>
@@ -79,6 +113,7 @@ const HitsInIndex = ({ index, show }) => (
79
113
  <CustomHitsHeader
80
114
  indexTitle={index.title}
81
115
  showSeparator={index.type !== INDEX_TYPES.blog}
116
+ allIndex = {index.type}
82
117
  />
83
118
  <HitsByIndexType indexType={index.type} />
84
119
  </Fragment>
@@ -86,8 +121,9 @@ const HitsInIndex = ({ index, show }) => (
86
121
  </Index>
87
122
  );
88
123
 
89
- const SearchResult = ({ indices, className, id, wrapperRef, activeIndexTypes }) => (
90
- <div id={id} className={`${className} search-results z-[2] clear-both`} ref={wrapperRef}>
124
+ const SearchResult = ({ children, indices, className, id, wrapperRef, activeIndexTypes }) => (
125
+ <div id={id} className={`${className} search-results z-[-1] clear-both`} ref={wrapperRef}>
126
+ {children && children}
91
127
  {indices.map(index => (
92
128
  <HitsInIndex index={index} key={index.name} show={activeIndexTypes[index.type]} />
93
129
  ))}
@@ -1,5 +1,5 @@
1
1
  import algoliasearch from "algoliasearch/lite";
2
- import React, { useRef, useState } from "react";
2
+ import React, { useRef, useState, useEffect } from "react";
3
3
  import { InstantSearch, connectStateResults, Index } from "react-instantsearch-dom";
4
4
  import SearchBox from "./searchbox";
5
5
  import SearchResults from "./searchresults";
@@ -38,34 +38,81 @@ const AllResults = ({ allSearchResults, children, indices, searchState, searchin
38
38
  };
39
39
 
40
40
  const CustomAllResults = connectStateResults(AllResults);
41
+ let showAll = true;
41
42
 
42
43
  const IndexTypeFilter = ({ activeIndexTypes, setActiveIndexTypes }) => {
43
- const handleOnChange = indexType => ({ target }) => {
44
- setActiveIndexTypes(prevState => ({
45
- ...prevState,
46
- [indexType]: target.checked,
47
- }));
44
+ const [showDropdown, setShowDropdown] = useState(false);
45
+ const handleOnClick = (indexType) => {
46
+ if (indexType === INDEX_TYPES.All) {
47
+ showAll = true;
48
+ const allFiltersSelected = Object.keys(activeIndexTypes).reduce((acc, key) => {
49
+ acc[key] = true;
50
+ return acc;
51
+ }, {});
52
+ setActiveIndexTypes(allFiltersSelected);
53
+ } else {
54
+ showAll = false
55
+ const allFiltersSelected = Object.keys(activeIndexTypes).reduce((acc, key) => {
56
+ acc[key] = false;
57
+ return acc;
58
+ }, {});
59
+ setActiveIndexTypes(allFiltersSelected);
60
+ setActiveIndexTypes((prevState) => ({
61
+ ...prevState,
62
+ [indexType]: !prevState[indexType],
63
+ }));
64
+ }
65
+ setShowDropdown(false)
48
66
  };
49
67
 
50
68
  return (
51
- <div className="tb-m:min-w-[150px] static tb-m:sticky top-[96px] self-start">
52
- <Typography textStyle="h6" as="h6" className="text-neutral-700 uppercase">Filter</Typography>
53
- <ul className="flex tb-m:block">
54
- {Object.values(INDEX_TYPES).map(index => (
55
- <li key={index} className="flex items-center py-3 mr-4 tb-m:mr-0">
56
- <input
57
- type="checkbox"
58
- id={"algolia_index_type_" + index}
59
- name={"algolia_index_type_" + index}
60
- value={index}
61
- checked={activeIndexTypes[index]}
62
- onChange={handleOnChange(index)}
63
- className="mr-2 focus:outline-none"
64
- />
65
- <label htmlFor={"algolia_index_type_" + index}>{index}</label>
69
+ <div className="relative">
70
+ <div className="tb-m:min-w-[182px] static tb-m:sticky top-[116px] self-start">
71
+ <ul className="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">
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': ''} `}
78
+ >
79
+ <Typography
80
+ textStyle="body3c-medium"
81
+ className={`${(activeIndexTypes[index] && index === 'All') ? "text-neutral-0 " : ""} ${(activeIndexTypes[index] && !showAll) ? 'text-neutral-0' : ''} `
82
+ }
83
+ >
84
+ {index}
85
+ </Typography>
86
+ </button>
66
87
  </li>
67
88
  ))}
68
89
  </ul>
90
+
91
+ </div>
92
+ <div className="relative tb-m:hidden">
93
+ <button
94
+ onClick={() => setShowDropdown(!showDropdown)}
95
+ className="capitalize cursor-pointer py-1 px-3 w-full border border-neutral-300 text-left rounded-full text-neutral-500 bg-transparent"
96
+ >
97
+ {Object.values(INDEX_TYPES).find((index) => activeIndexTypes[index]) || "All"}
98
+
99
+ </button>
100
+ {showDropdown && (
101
+ <ul className="absolute top-full left-0 w-full bg-neutral-0 shadow-md z-[20] p-2 rounded-3xl mt-1">
102
+ {Object.values(INDEX_TYPES).map((index) => (
103
+ <li
104
+ key={index}
105
+ onClick={() => handleOnClick(index)}
106
+ className={`capitalize cursor-pointer py-2 px-4 ${activeIndexTypes[index] ? "text-neutral-1000 " : "text-neutral-500"
107
+ }`}
108
+ >
109
+ {index}
110
+ </li>
111
+ ))}
112
+ </ul>
113
+ )}
114
+ </div>
115
+
69
116
  </div>
70
117
  );
71
118
  };
@@ -100,12 +147,16 @@ export default function SearchWrapper({ indices, ...props }) {
100
147
  };
101
148
 
102
149
 
103
- const defaultIndexTypesState = Object.values(INDEX_TYPES).reduce((a, c) => {
104
- a[c] = true;
105
- return a;
150
+ const defaultIndexTypesState = Object.values(INDEX_TYPES).reduce((acc, index) => {
151
+ acc[index] = true;
152
+ return acc;
106
153
  }, {});
107
154
  const wrapperRef = useRef(null);
108
155
  const [activeIndexTypes, setActiveIndexTypes] = useState(defaultIndexTypesState);
156
+ useEffect(() => {
157
+ setActiveIndexTypes(defaultIndexTypesState);
158
+ }, []);
159
+
109
160
  return (
110
161
  <InstantSearch
111
162
  searchClient={searchClient}
@@ -114,18 +165,26 @@ export default function SearchWrapper({ indices, ...props }) {
114
165
  >
115
166
  <SearchBox />
116
167
  <CustomAllResults indices={indices}>
117
- <div className="tb-m:flex">
118
- <IndexTypeFilter
119
- activeIndexTypes={activeIndexTypes}
120
- setActiveIndexTypes={setActiveIndexTypes}
168
+ <div className="tb-m:flex gap-10">
169
+ <div className="hidden tb-m:flex">
170
+ <IndexTypeFilter
171
+ activeIndexTypes={activeIndexTypes}
172
+ setActiveIndexTypes={setActiveIndexTypes}
121
173
  />
174
+ </div>
122
175
  <SearchResults
123
176
  id="search-results"
124
177
  indices={indices}
125
178
  wrapperRef={wrapperRef}
126
179
  activeIndexTypes={activeIndexTypes}
127
- className="search-results"
128
- />
180
+ className="search-results">
181
+ <div className="tb-m:hidden sticky top-[124px] tb:top-[114px] z-10 bg-neutral-0 pb-3">
182
+ <IndexTypeFilter
183
+ activeIndexTypes={activeIndexTypes}
184
+ setActiveIndexTypes={setActiveIndexTypes}
185
+ />
186
+ </div>
187
+ </SearchResults>
129
188
  </div>
130
189
  </CustomAllResults>
131
190
  </InstantSearch>
package/src/index.css CHANGED
@@ -7,7 +7,9 @@
7
7
  .marketoFormWrapper {
8
8
  width: 100%;
9
9
  }
10
-
10
+ .shodow-none:focus {
11
+ box-shadow: none;
12
+ }
11
13
  .marketoFormWrapper .mktoFormRow {
12
14
  width: 100%;
13
15
  }
@@ -70,34 +72,58 @@
70
72
  width: calc(100% - 150px);
71
73
  }
72
74
 
75
+ .word-break {
76
+ word-break: break-word;
77
+ }
73
78
  .search-results .ais-Hits .ais-Hits-list,
74
79
  .search-results .Hits .ais-Hits-list {
75
80
  display: grid;
76
- grid-template-columns: repeat(3, 1fr);
81
+ grid-template-columns: repeat(2, 1fr);
77
82
  grid-gap: 40px;
78
83
  }
79
84
 
80
85
  .search-results .ais-Hits .ais-Hits-list .ais-Hits-item,
81
86
  .search-results .Hits .ais-Hits-list .ais-Hits-item {
82
87
  border-bottom: 1px solid transparent;
88
+ padding: 12px;
89
+ border-radius: 16px;
90
+ transition: all .3s ease-in-out;
83
91
  }
84
-
85
92
  .search-results .ais-Hits .ais-Hits-list .ais-Hits-item:hover,
86
93
  .search-results .Hits .ais-Hits-list .ais-Hits-item:hover {
87
- border-bottom: 1px solid #e5e7eb;
94
+ background-color: #F0F4FF;
88
95
  }
89
96
 
97
+ /* .search-results .ais-Hits .ais-Hits-list .ais-Hits-item:hover,
98
+ .search-results .Hits .ais-Hits-list .ais-Hits-item:hover {
99
+ border-bottom: 1px solid #e5e7eb;
100
+ } */
101
+
90
102
  .search-results .ais-Hits .ais-Hits-list .ais-Hits-item .hit-slug,
91
103
  .search-results .Hits .ais-Hits-list .ais-Hits-item .hit-slug {
92
104
  word-break: break-word;
93
105
  }
94
106
 
107
+ .search-results .ais-Hits .ais-Hits-list .ais-Hits-item .ais-Snippet-highlighted,
108
+ .search-results .Hits .ais-Hits-list .ais-Hits-item .ais-Snippet-highlighted {
109
+ color: #1E56E3;
110
+ background-color: transparent;
111
+ }
112
+
113
+ .search-results .ais-Hits .ais-Hits-list .ais-Hits-item .ais-Highlight-highlighted,
114
+ .search-results .Hits .ais-Hits-list .ais-Hits-item .ais-Highlight-highlighted {
115
+ color: #1E56E3;
116
+ background-color: transparent;
117
+ }
95
118
  @media (max-width: 799px) {
96
119
 
97
120
  .search-results .ais-Hits .ais-Hits-list,
98
121
  .search-results .Hits .ais-Hits-list {
99
122
  grid-template-columns: 1fr;
100
123
  }
124
+ .search-results {
125
+ width: 100%;
126
+ }
101
127
  }
102
128
 
103
129
  @media (min-width: 800px) and (max-width: 905px) {