Skip to content
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

Closed
wants to merge 17 commits into from

Conversation

brookslybrand
Copy link
Contributor

@@ -0,0 +1,959 @@
/*! @docsearch/css 3.5.2 | MIT License | © Algolia, Inc. and contributors | https://docsearch.algolia.com */
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's definitely stuff in here we can remove, I just copied all the styles from remix.run (which uses docsearch)

return null;
}

// TODO: Need to implement onClose, otherwise it's impossible to make this a controlled component
Copy link
Contributor Author

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 😕

Comment on lines +84 to +131
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>
</>
);
}
Copy link
Contributor Author

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

@brookslybrand brookslybrand deleted the brooks/orama-search branch July 17, 2024 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants