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

scxa-faceted-search-results-v5

v5.0.1

Published

Faceted experiments list for Single Cell Expression Atlas gene search results

Downloads

13

Readme

Faceted Search Results for Single Cell Expression Atlas

Build Status Coverage Status

A lightweight and extensible component to list and filter lists of search results. It receives a URL (as a combination of host and resource) to async-fetch the results, and a React component class to visualise each element (e.g. a card).

The facets are used to render a sidebar on the left as a set of filtering controls. Filter groups can be displayed either as searchable, multiselect dropdown lists or as checkboxes.

Two more optional props, namely noResultsMessageFormatter and resultsMessageFormatter, return a string which is displayed when there are no results, and as a header on top of the search results, respectively. In many occasions it is useful to display such messages using information returned by the server; that’s the reason why both functions take the JSON payload as an argument, allowing for some customisation in that regard. For example, if in the case of no results the server returns a field reason you could have something like this:

<ReactFacetedSearch
  ...
  noResultsMessageFormatter={(data) => `Your search yielded no results: ${data.reason}`}

Requirements

You should have at least Node 16 LTS with NPM 8 or later. You can check your current installed version executing this command.

npm --version
8.5.6

How to execute the unit tests with Cypress

We are using the Cypress framework for unit testing this package. You can execute the existing tests in the following way:

  1. Type npx cypress open in the terminal in the root folder of this package.
  2. In the appearing browser window you have to click on Component Testing, select a browser and click on Start Component Testing in <browser name>.
  3. In the appearing list just click on the test you would like to run and check the results on the screen.

Try out the component with a given example

Just run webpack-dev-server:

npx webpack serve --mode=development

How to run test with code coverage in the console

Run tests with:

npx cypress run --component

If you want to omit video recording:

npx cypress run --component --record false

Find coverage reports at: ./coverage/lcov-report/index.html

Add code coverage (in a nutshell)

This is an abridged version of https://docs.cypress.io/guides/tooling/code-coverage.

Add the following three packages:

npm install -D babel-plugin-transform-class-properties babel-plugin-istanbul @cypress/code-coverage

Add the two plugins to your .babelrc file:

{
  "presets": ["@babel/preset-react", "@babel/preset-env"],
  "plugins": [ "transform-class-properties", "istanbul" ]
}

Add @cypress/code-coverage in your cypress.config.js file so it looks like this:

const { defineConfig } = require(`cypress`)

module.exports = defineConfig({
  component: {
    setupNodeEvents(on, config) {
      require(`@cypress/code-coverage/task`)(on, config)
      // include any other plugin code...

      // It's IMPORTANT to return the config object
      // with any changed environment variables
      return config
    },
    devServer: {
      framework: `react`,
      bundler: `webpack`
    }
  }
})

Lastly, add the following import to cypress/support/component.js:

import '@cypress/code-coverage/support'

Combining with the EBI Visual Framework

React-Select allows you to style the div that encloses the input element, but not the input element itself. Therefore it’s convenient to add the snippet below to override the styling set by the EBI Visual Framework for input elements.

.input-clear input, .input-clear input:focus {
  height: unset;
  box-shadow: none;
  margin: 0;
}

At the time of writing this applies to the most recent version (v1.3). Wrapping these styles within the appropriate div selector is sufficient. See https://github.com/ebi-gene-expression-group/scxa-faceted-search-results/blob/master/html/filter-list.html for a working example.

A note about building with Webpack

The component uses async/await to fetch the JSON payload from the server. This requires to prefix the entry with @babel/polyfill. If you are already using an equivalent polyfill or Runtime transform you may skip this.