This repository has been archived by the owner on Jun 11, 2021. It is now read-only.
feat(docsearch): introduce DocSearch.js v3 #56
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This introduces the package
@docsearch/js
to use DocSearch v3 in vanilla JavaScript projects.Technical details
The vanilla package is a simple call to the
DocSearch
component from@docsearch/react
, with an alias to Preact.This means we share a single codebase, and that any feature or fix applied to
@docsearch/react
will get propagated to@docsearch/js
.Importing styles
The way to import style has changed internally, but it's transparent to the
@docsearch/react
package.We now publish a package called
@docsearch/css
that gathers all the styles: complete style, or partials (variables, search button and modal). These styles are re-exported from@docsearch/react
.Next steps
Search button acting as an input
The way we treat the search button as an input (see #54) doesn't work with Preact. This behaves differently because Preact better respects the native DOM focus management than React, which disallows to assign the focus to an element that gets added to the DOM after the page load. I plan to add support for this in another PR.
Algolia user agents
If we want to better track Algolia user agents, we need to find a way to alter the user agents sent to differentiate between
@docsearch/react
and@docsearch/js
.E2E testing
We might want to E2E-test with Cypress this new vanilla package to make sure that it acts as the React one.