0.2.6 ā€¢ Published 5 years ago

instantsearch-group-size-refinement-list-react v0.2.6

Weekly downloads
45
License
-
Repository
github
Last release
5 years ago

GroupSizeRefinementList Widget

šŸŽ„ See it Live on CodeSandbox

Demo

Demo of GroupSizeRefinementList Widget

Description

This is the GroupSizeRefinementList Labs widget for React InstantSearch. You can use this widget to refine products sizes with Algolia.

This widget displays groups of facets depending on passed regex.

This helps the user find the sizes he is looking for, grouping them by format.

Table of Contents

Get the code

This widget comes with JavaScript but also pre-defined CSS.

JavaScript

You can copy and paste the JavaScript code from the repository itself, grab it in the src/lib folder and use the <GroupSizeRefinementList /> component.

CSS

You can copy and paste the necessary CSS code from the repository itself, grab it in src/lib/GroupSizeRefinementList.css.

Usage

Install it with yarn add instantsearch-group-size-refinement-list-react then, use it as simply as:

import { InstantSearch, Panel } from 'react-instantsearch-dom';
import GroupSizeRefinementList from 'instantsearch-group-size-refinement-list-react';

<InstantSearch
    appId="..."
    apiKey="..."
    indexName="..."
>
    <Panel header="...">
        <GroupSizeRefinementList
            attribute="..."
            patterns="<array of regex>"
        />
    </Panel>
</InstantSearch>

Requirements

You should encapsulate the <GroupSizeRefinementList/> component inside a <Panel/> and in an <InstantSearch/> one.

To work properly, you'll need to specify the record attribute:

Props

NameTypeUse
attribute (required)stringThe name of the attribute
patterns (required)Array(string)The regex patterns for each blocks
nbGroupsNumberThe number of group sizes to display by default when showMore is set to true
sortGroupByNbResultsBooleanDisplay first results with the most result. If false, it will use the regex order. Default: True
sortSizesByNbResultsBooleanDisplay first the sizes with the most hits. If false, see formatting bellow^footnote Default: True

^footnote: To sort the sizes manualy, you need to pass a number corresponding to the position of the size in the size group. This number has to follow the size label, you should use a ';' as separator. Example: XXL;3 - S;1 - M;2 will display S, M and XXL in this order

Implementation details

This widget is implemented using the connectRefinementList() connector. To learn more about connectors, you can read the associated guide.

Contributing

To contribute to the project, clone this repository then run:

yarn
yarn start
0.2.6

5 years ago

0.2.5

5 years ago

0.2.4

5 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.2.1-a

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.7-a

5 years ago

0.1.7

5 years ago

0.1.6-a

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago