npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@watermarkchurch/react-instantsearch-components

v6.1.1

Published

Components for reuse across apps that use Algolia react-instantsearch

Downloads

57

Readme

@watermarkchurch/react-instantsearch-components

For Watermark internal use only

Exports a number of React components that are commonly used across our apps to execute searches with Algolia.

Versioning note:

All versions less than v1.0 are compatible with react-instantsearch v5

Versions >= v6.0 share a major version with the version of react-instantsearch with which it is compatible.

AlgoliaSearch

import {AlgoliaSearch} from '@watermarkchurch/react-instantsearch-components'

<AlgoliaSearch
  apiKey="[string]"
  appId="[string]"
  indexName="[string]"
  widgetName="[string]"
  storeStateInQuery={true}
  onSearchStateChange={(searchState) => {...}}>
  • apiKey: the Algolia API key with search access to the specified index
  • appId: The Algolia app ID
  • indexName: The name of the index to search
  • widgetName: A class to be applied to the wrapper div
  • storeStateInQuery:
    set to true to have the search state serialized to the query string. This enables direct linking to search queries.
  • onSearchStateChange: A function to listen to changes in the Search State.

Server-Side Rendering of Algolia results

The AlgoliaSearch wrapper allows injecting the results of a server-side search, in order to set the initial context for server-side rendering. To do this, you need to execute a search on the server and set the initialState and initialResults fields.

Here's how to do the query in Ruby:

query = 'work'
facetFilters = ["tags:Young Adults", "ministry:The Porch"]
limit = 5

state = {
  query: query,
  facetFilters: facetFilters,
  hitsPerPage: limit
}

results = Algolia::Index.new(index).search(query, {
  facetFilters: facetFilters,
  hitsPerPage: limit
})

Then prerender your react component:

<%= react_component('MyWrapperComponent',
      {
        # ... other props,
        initialState: state,
        initialResults: results
      },
      prerender: true) %>

SearchBox

import {SearchBox} from '@watermarkchurch/react-instantsearch-components'

<SearchBox
  className="[string]"
  autoFocus={true}
  focusShortcuts={['s', '/']}
  searchAsYouType={true}
  showLoadingIndicator={false}
  loadingIndicator={<svg>...</svg>}
  reset={<i className="material-icons">...</i>}
  submit={<i className="material-icons">...</i>}

  autosuggestIndex={'[string]'}
  >

Renders a search box with Autocomplete

  • autosuggestIndex: set this to use a different index for Autocomplete results instead of the current search index
  • autoFocus: set to true to grab focus as soon as the component renders
  • searchAsyouType: set to false to wait until the user hits enter before executing a search (does not affect autosuggest)
  • showLoadingIndicator: set to false to disable the loading spinner SVG

MediaGallery

import {MediaGallery} from '@watermarkchurch/react-instantsearch-components'

<MediaGallery
  mediaSourceDefaults={{}}
  mediaSource={{}}
  excludeIDs={'[string]'}
  header={<>...</>}
  viewAllLink={'[url]'}
  apiKey={'[algolia api key]'}
  appId={'[algolia app id]'}
  columns={3}

  HitComponent={MyHitComponent}
  LoadingComponent={MyLoadingComponent}
>

Renders a Gallery widget that sources data from the Media system or Algolia.

See JSDoc annotations on IMediaGalleryProps for details.

Changelog:

v6.0.2

  • Fix Cannot read property 'ALGOLIA_SEARCH_API_KEY' of undefined in WMR

v6.0.1

v6.0.0