-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft: alternative Orama search implementation #108
Conversation
use react
845d3b7
to
2ed33c4
Compare
2ed33c4
to
f8bd4c0
Compare
@@ -0,0 +1,959 @@ | |||
/*! @docsearch/css 3.5.2 | MIT License | © Algolia, Inc. and contributors | https://docsearch.algolia.com */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return null; | ||
} | ||
|
||
// TODO: Need to implement onClose, otherwise it's impossible to make this a controlled component |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't figure out a way to know when the onClose
triggers, so the custom button can only be clicked 1 time 😕
export function SearchButton() { | ||
let [, setShowSearchModal] = useSearchModal(); | ||
|
||
let hydrated = useHydrated(); | ||
|
||
if (!hydrated) { | ||
// The Algolia doc search container is hard-coded at 40px. It doesn't | ||
// render anything on the server, so we get a mis-match after hydration. | ||
// This placeholder prevents layout shift when the search appears. | ||
return <div className="h-10" />; | ||
} | ||
|
||
return ( | ||
<> | ||
<div className="animate-[fadeIn_100ms_ease-in_1]"> | ||
<button | ||
onClick={() => setShowSearchModal(true)} | ||
type="button" | ||
className="DocSearch DocSearch-Button" | ||
aria-label="Search" | ||
> | ||
<span className="DocSearch-Button-Container"> | ||
<svg | ||
width="20" | ||
height="20" | ||
className="DocSearch-Search-Icon" | ||
viewBox="0 0 20 20" | ||
> | ||
<path | ||
d="M14.386 14.386l4.0877 4.0877-4.0877-4.0877c-2.9418 2.9419-7.7115 2.9419-10.6533 0-2.9419-2.9418-2.9419-7.7115 0-10.6533 2.9418-2.9419 7.7115-2.9419 10.6533 0 2.9419 2.9418 2.9419 7.7115 0 10.6533z" | ||
stroke="currentColor" | ||
fill="none" | ||
fillRule="evenodd" | ||
strokeLinecap="round" | ||
strokeLinejoin="round" | ||
></path> | ||
</svg> | ||
<span className="DocSearch-Button-Placeholder">Search</span> | ||
</span> | ||
<span className="DocSearch-Button-Keys"> | ||
<kbd className="DocSearch-Button-Key">⌘</kbd> | ||
<kbd className="DocSearch-Button-Key">K</kbd> | ||
</span> | ||
</button> | ||
</div> | ||
</> | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really don't love implementing this custom button and the context provider. Definitely wish I could style the orma button to just look like what we have, even if it's by using css class selectors like the DocSearch example we have
#104