Git Product home page Git Product logo

react-search's Issues

Support customization of how a search result is rendered

Search results can be configured with arbitrary metadata, and the consumer should be able to use this metadata to drive how a search result is rendered. One solution could be to provide a search result deserializer prop and a render prop.

Update images in README to use relative links to images stored in repo, and specify widths

By using relative links we can ensure they stay up-to-date if the images change. By specifying widths, we can ensure the images don't look too large.

Currently, links look like this:

<img style="max-width: 100%;" alt="Welcome to React-Search" src="https://raw.githubusercontent.com/vectara/react-search/main/images/projectLogo.png"/>

![React-Search input](https://raw.githubusercontent.com/vectara/react-search/main/images/searchInput.jpg)

But they can be this instead:

<img style="max-width: 100%;" alt="Welcome to React-Search" src="images/projectLogo.png"/>
<img src="images/searchInput.jpg" alt="React-Search input" width="800" />

Add support for OAuth

We should consider the user journey from using this component in prototypes (API keys) to using it in production (OAuth).

Add x-source to query header

For insights purposes, we can add a header param to queries coming from search. This helps us measure the usage of this component to query our API/

Mouse scroll not working

To repro:

  • Issue a search and get back search results
  • Reduce browser window height until scroll bar appears in search results
  • Attempt to use mouse scroll to scroll the results
  • Scroll doesn't occur

I'm using a Mac with a Magic Mouse.

Add “close” button to the search modal

This will be useful for any device that lacks an “Escape” button, e.g. a touchscreen. This also will fix a critical bug on smaller touchscreens, because on those devices the modal occupies the entire screen and there’s no way to dismiss it.

Add option for configuring deep-link query parameter name

Currently, setting isDeeplinkable will persist the search query to the search query parameter. This could collide with a query parameter already in use by the consumer. We can resolve this by providing an option for persisting the search query to a different query parameter.

Theming

We can support basic themes that change the color scheme, e.g. green, orange, red, dark.

Reduce bundle size of icons

Per @mrderyk, react-icons accounts for close to 75% of our bundle size. We can find a way to selectively include specific icons or find a different library.

Handle errors

The component needs to handle errors and surface them to the user. Looks like right now the code doesn't anticipate them:

const sendSearchQuery = async (query: string) => {
if (query.length === 0) {
return;
}
if (isDeeplinkable) {
// Persist search.
const queryParams = new URLSearchParams(window.location.search);
queryParams.set("search", query);
history.replaceState(null, "", "?" + queryParams.toString());
}
addPreviousSearch(query);
const searchId = ++searchCount.current;
const results = await fetchSearchResults(query);
if (searchId === searchCount.current) {
setSearchResults(results);
setSelectedResultIndex(null);
selectedResultRef.current = null;
}
};

Swap out react-icons for another icon library

react-icons currently takes up over 83% of our bundle size. Let's look for an alternative, since we only need one icon, and deep-importing from react-icons doesn't look to be working.

Add support for summarized answer

We can use tabs to provide access to both the current search results, as well as a summary of the results. We can use localStorage to remember the user's preference so that they don't have to keep selecting the tab they want.

image

Refine useSearch interface

This hook currently returns { fetchSearchResults, isLoading }. I noticed two things:

  • We're using two different verbs to describe the same action: "fetch" and "load"
  • The action is verbose but the state is terse

I think we can reconcile these differences and create more symmetry between the action and the state. I suggest erring on the side of verbosity to avoid potential conflicts with the consumer's variables, e.g. a local isLoading variable. I'd suggest { fetchSearchResults, isFetchingSearchResults }.

Accept reranker param

To enable support for Vectara's multiple reranker options, we need to allow ReactSearch to accept a rerankerId option.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.