Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions src/components/Header/Search/Search.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@
top: 65px;
left: 0;
right: 0;
height: 100vh;
height: calc(100vh - 65px);
padding-top: 60px;
border-radius: 0;
}

#searchModal.large {
top: 0;
height: fit-content;
max-height: 80vh;
background: #fff;
position: absolute;
border-radius: 24px;
Expand All @@ -24,7 +23,7 @@

.resultsWrapper {
padding: 20px 20px 1rem;
overflow: overlay;
height: calc(100% - 50px);
}

.searchInput {
Expand Down Expand Up @@ -129,11 +128,6 @@
box-sizing: content-box;
}

.hitWrapper {
max-height: 40vh;
overflow: overlay;
}

.hitWrapper ol {
list-style: none;
}
Expand All @@ -147,6 +141,9 @@
.queryResults {
display: grid;
grid-template-columns: 1fr;
grid-auto-rows: max-content;
height: 100%;
overflow-y: auto;
}

.queryResults h6 {
Expand Down Expand Up @@ -224,8 +221,8 @@
}

.hitWrapper {
max-height: calc(80vh - 100px);
overflow: auto;
max-height: calc(80vh - 150px);
overflow-y: auto;
}

.hitList li {
Expand Down Expand Up @@ -259,4 +256,9 @@
.resultsWrapper * {
padding-left: 0 !important;
}

.queryResults.large {
max-height: calc(80vh - 48px);
height: max-content;
}
}
10 changes: 6 additions & 4 deletions src/components/Header/Search/SearchModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@ const recommendedArticles = [
},
]

function EmptyQueryBoundary({ children, fallback }) {
function EmptyQueryBoundary({ children, size, fallback }) {
const { indexUiState } = useInstantSearch()

const recentArticles = JSON.parse(localStorage.getItem("recentArticles") || "[]")

console.log(indexUiState, "indexUiState")
if (!indexUiState.query) {
return (
<div className={styles.queryResults}>
<div className={clsx(styles.queryResults, styles[size])}>
<div>
<h6 style={{ paddingLeft: "var(--space-2x)", marginBottom: "1rem" }}>Recommended articles</h6>
<div className={styles.hitWrapper}>
Expand Down Expand Up @@ -108,6 +109,7 @@ function NoResultsBoundary({ children }) {
function CustomHits({ title, hitClassName, ...props }: UseHitsProps & { title: string; hitClassName?: string }) {
const { hits, results } = useHits(props)

console.log(hits, "hits")
if (hits.length === 0) return null
return (
<div>
Expand Down Expand Up @@ -150,9 +152,9 @@ export function SearchModal({ size = "mini", isOpen, onClose }: { size: Size; is
<InstantSearch indexName={getIndexName()} searchClient={searchClient}>
<SearchInput size={size} onClose={onClose} />
<div className={styles.resultsWrapper}>
<EmptyQueryBoundary fallback={null}>
<EmptyQueryBoundary fallback={null} size={size}>
<NoResultsBoundary>
<div className={styles.queryResults}>
<div className={clsx(styles.queryResults, styles[size])}>
<CustomHits
title="Title Matches"
escapeHTML={false}
Expand Down