Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(breadcrumb): Add the breadcrumb widget #2451

Merged
merged 45 commits into from
Oct 9, 2017
Merged

Conversation

marielaures
Copy link
Member

Summary

Add a breadcrumb widget to improve navigability.
This has already been implemented on React InstantSearch and this pull request aims to provide the same functionality.

Result
image

@bobylito bobylito changed the base branch from develop to feat/2.3 October 4, 2017 15:13
@algobot
Copy link
Contributor

algobot commented Oct 5, 2017

Deploy preview ready!

Built with commit 88ded98

https://deploy-preview-2451--algolia-instantsearch.netlify.com

Copy link
Contributor

@bobylito bobylito left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job 💯 . Just a few remarks

facetSet.separator !== separator
) {
console.warn(
'Using Breadcrumb & HierarchicalMenu on the same facet with different options'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could be more specific on the next steps. What about adding that one of the configuration will be overriden and that they should check their options?

return {
getConfiguration: currentConfiguration => {
if (currentConfiguration.hierarchicalFacets) {
const facetSet = find(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be named isFacetSet instead of facetSet because it's a boolean (and I was confused by the usage of a set here)

}, []);
}

function processArray(array) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

processArray doesn't say much about the process that is applied to the array. In this case you're shifting the values, what about shiftItemsValues?

function processArray(array) {
return array.map((x, idx) => ({
name: x.name,
value: idx + 1 == array.length ? null : array[idx + 1].value,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should only use == when we want JS to make type coercion automatically. Since we're comparing numbers, it should not be an issue to use ===.

*/

/**
* The breadcrumb widget is a secondary navigation scheme that allows the user to see where the current page is in relation to the website's hierarchy.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be a bit confusing to talk about website hierarchy because search is only a part of the website. I would go for something like 'facet hierarchy', WDYT?

</a>
: <a
className={cssClasses.label}
href={createURL(items[idx].value)}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

items[idx] === item so the code can be simplfied here.

breadcrumb[0]
)
);
} else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An function which does not explicitly return a value, actually returns undefined. So we don't need the last else block

(Array.isArray(state.hierarchicalFacets) &&
state.hierarchicalFacets.length === 0)
) {
throw new Error(usage);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This message is sent too late. It should be done as soon as we have all the necessary information. Most likely before returning the widget object.

@bobylito
Copy link
Contributor

bobylito commented Oct 6, 2017

This widget could be a nice addition to the e-commerce demo.

screen shot 2017-10-06 at 12 26 32

@bobylito
Copy link
Contributor

bobylito commented Oct 9, 2017

I think we're good to go here :) Thanks @marielaures and congrats on your first widget on IS.js, welcome to the contributors 🚀

Let's do the update of demo in another PR ;)

@bobylito bobylito merged commit 8e14e0b into feat/2.3 Oct 9, 2017
samouss pushed a commit that referenced this pull request Oct 9, 2017
* feat(breadcrumb): kick-off connectBreadcrumb
* chore(dev): add breadcrumb into storybook
* feat(connectBreadcrumb): remove view logic
* feat(widgets): export breadcrumb widget
* feat(widget): breadcrumb
* feat(component): kick-off breadcrumb component
* feat(Breadcrumb): WIP
* feat(Breadcrumb): modified separator
* feat(Breadcrumb): display breadcrumb (without any links)
* feat(Breadcrumb): WIP
* feat(Breadcrumb): add css classes
* feat(Breadcrumb): working on styling
* feat(Breadcrumb): modified onClick prop
* feat(Breadcrumb): Add headerFooter + autoHideContainer
* feat(Breadcrumb): documentation
* feat(Breadcrumb): remove cssClass root
* enable use as a standalone widget
* add template to widget
* add custom label story
* first series of tests
* add logic for the onclick on "Home"
* add templates for home and separator
* warn the user if there's already a Breadcrumb used with the same facet
* add cssClasses
* add lifecycle test
* modify template so it re renders when rootProps are modified
* modify css classes applied to the home label
* change the separator in the theme
* more tests for connectBreadcrumb
* add documentation
* add createUrl + some refactoring
* add default selected item story
* WIP
* WIP - fixing response data for hierarchical values
* add createUrl + rootPath
* add default selected item story
* WIP
* chore(test): test on second value
* feat(Breadcrumb): update API of the connector
* fix(dep): use same casing for isEqual
* chore(doc): fix misc. errors
* chore(breadcrumb): add more docs and validation
* various code improvements
Review fixes.

Fix #2299
@marielaures marielaures deleted the feat/2.2-breadcrumb branch October 11, 2017 15:10
iam4x added a commit that referenced this pull request Oct 16, 2017
<a name=2.3.0-beta.1></a>
# [2.3.0-beta.1](v2.2.0...v2.3.0-beta.1) (2017-10-16)

### Bug Fixes

* **connectRangeSlider:** only clear the refinement on the current attribute ([#2459](#2459)) ([7cebf58](7cebf58))
* **menuSelect:** select in userCssClasses ([#2455](#2455)) ([0eb3dc8](0eb3dc8))

### Features

* **breadcrumb:** Add the breadcrumb widget ([#2451](#2451)) ([076e063](076e063)), closes [#2299](#2299)
* **rangeInput:** add rangeInput widget ([#2440](#2440)) ([4be1ee8](4be1ee8))
samouss pushed a commit that referenced this pull request Oct 18, 2017
* feat(breadcrumb): kick-off connectBreadcrumb
* chore(dev): add breadcrumb into storybook
* feat(connectBreadcrumb): remove view logic
* feat(widgets): export breadcrumb widget
* feat(widget): breadcrumb
* feat(component): kick-off breadcrumb component
* feat(Breadcrumb): WIP
* feat(Breadcrumb): modified separator
* feat(Breadcrumb): display breadcrumb (without any links)
* feat(Breadcrumb): WIP
* feat(Breadcrumb): add css classes
* feat(Breadcrumb): working on styling
* feat(Breadcrumb): modified onClick prop
* feat(Breadcrumb): Add headerFooter + autoHideContainer
* feat(Breadcrumb): documentation
* feat(Breadcrumb): remove cssClass root
* enable use as a standalone widget
* add template to widget
* add custom label story
* first series of tests
* add logic for the onclick on "Home"
* add templates for home and separator
* warn the user if there's already a Breadcrumb used with the same facet
* add cssClasses
* add lifecycle test
* modify template so it re renders when rootProps are modified
* modify css classes applied to the home label
* change the separator in the theme
* more tests for connectBreadcrumb
* add documentation
* add createUrl + some refactoring
* add default selected item story
* WIP
* WIP - fixing response data for hierarchical values
* add createUrl + rootPath
* add default selected item story
* WIP
* chore(test): test on second value
* feat(Breadcrumb): update API of the connector
* fix(dep): use same casing for isEqual
* chore(doc): fix misc. errors
* chore(breadcrumb): add more docs and validation
* various code improvements
Review fixes.

Fix #2299
iam4x added a commit that referenced this pull request Oct 24, 2017
<a name=2.3.0-beta.2></a>
# [2.3.0-beta.2](v2.2.1...v2.3.0-beta.2) (2017-10-24)

### Bug Fixes

* **connectHierarchicalMenu:** do not return if facet not set ([#2521](#2521)) ([26e99fb](26e99fb))
* **MenuSelect:** switch from react to preact-compat ([#2513](#2513)) ([06aa626](06aa626))
* **range-slider:** add option  ([#2502](#2502)) ([e78399d](e78399d)), closes [#2501](#2501)

### Features

* **breadcrumb:** Add the breadcrumb widget ([#2451](#2451)) ([11d78f0](11d78f0)), closes [#2299](#2299)
* **connectRange:** round the range based on precision ([#2498](#2498)) ([d4df45d](d4df45d))
* **rangeInput:** add rangeInput widget ([#2440](#2440)) ([7916d16](7916d16))
bobylito pushed a commit that referenced this pull request Nov 13, 2017
<a name=2.3.0-beta.4></a>
# [2.3.0-beta.4](v2.2.4...v2.3.0-beta.4) (2017-11-13)

### Features

* **core:** InstantSearch hot remove/add widgets ([#2384](#2384)) ([cfc1710](cfc1710))

<a name=2.3.0-beta.3></a>
# [2.3.0-beta.3](v2.3.0-beta.2...v2.3.0-beta.3) (2017-10-25)

### Bug Fixes

* **connectors:** export  as well ([0b78d75](0b78d75))

### Features

* **refinementList:** add escapeFacetHits parameter ([#2507](#2507)) ([9b1b7ee](9b1b7ee))

<a name=2.3.0-beta.2></a>
# [2.3.0-beta.2](v2.2.1...v2.3.0-beta.2) (2017-10-24)

### Bug Fixes

* **connectHierarchicalMenu:** do not return if facet not set ([#2521](#2521)) ([26e99fb](26e99fb))

### Features

* **breadcrumb:** Add the breadcrumb widget ([#2451](#2451)) ([11d78f0](11d78f0)), closes [#2299](#2299)
* **connectRange:** round the range based on precision ([#2498](#2498)) ([d4df45d](d4df45d))
* **rangeInput:** add rangeInput widget ([#2440](#2440)) ([7916d16](7916d16))
bobylito pushed a commit that referenced this pull request Nov 16, 2017
<a name=2.3.0-beta.5></a>
# [2.3.0-beta.5](v2.2.4...v2.3.0-beta.5) (2017-11-16)

### Features

* **core:** InstantSearch hot remove/add widgets ([#2384](#2384)) ([cfc1710](cfc1710))

<a name=2.3.0-beta.3></a>
# [2.3.0-beta.3](v2.3.0-beta.2...v2.3.0-beta.3) (2017-10-25)

### Bug Fixes

* **connectors:** export  as well ([0b78d75](0b78d75))

### Features

* **refinementList:** add escapeFacetHits parameter ([#2507](#2507)) ([9b1b7ee](9b1b7ee))

<a name=2.3.0-beta.2></a>
# [2.3.0-beta.2](v2.2.1...v2.3.0-beta.2) (2017-10-24)

### Bug Fixes

* **connectHierarchicalMenu:** do not return if facet not set ([#2521](#2521)) ([26e99fb](26e99fb))

### Features

* **breadcrumb:** Add the breadcrumb widget ([#2451](#2451)) ([11d78f0](11d78f0)), closes [#2299](#2299)
* **connectRange:** round the range based on precision ([#2498](#2498)) ([d4df45d](d4df45d))
* **rangeInput:** add rangeInput widget ([#2440](#2440)) ([7916d16](7916d16))
bobylito pushed a commit that referenced this pull request Nov 20, 2017
<a name=2.3.0-beta.7></a>
# [2.3.0-beta.7](v2.2.5...v2.3.0-beta.7) (2017-11-20)

<a name=2.3.0-beta.6></a>
# [2.3.0-beta.6](v2.3.0-beta.5...v2.3.0-beta.6) (2017-11-16)

### Bug Fixes

* **connectors:** prefer wrappers over bind ([#2575](#2575)) ([f8e0e00](f8e0e00))

<a name=2.3.0-beta.5></a>
# [2.3.0-beta.5](v2.2.4...v2.3.0-beta.5) (2017-11-16)

### Features

* **core:** InstantSearch hot remove/add widgets ([#2384](#2384)) ([cfc1710](cfc1710))

<a name=2.3.0-beta.3></a>
# [2.3.0-beta.3](v2.3.0-beta.2...v2.3.0-beta.3) (2017-10-25)

### Bug Fixes

* **connectors:** export  as well ([0b78d75](0b78d75))

### Features

* **refinementList:** add escapeFacetHits parameter ([#2507](#2507)) ([9b1b7ee](9b1b7ee))

<a name=2.3.0-beta.2></a>
# [2.3.0-beta.2](v2.2.1...v2.3.0-beta.2) (2017-10-24)

### Bug Fixes

* **connectHierarchicalMenu:** do not return if facet not set ([#2521](#2521)) ([26e99fb](26e99fb))

### Features

* **breadcrumb:** Add the breadcrumb widget ([#2451](#2451)) ([11d78f0](11d78f0)), closes [#2299](#2299)
* **connectRange:** round the range based on precision ([#2498](#2498)) ([d4df45d](d4df45d))
* **rangeInput:** add rangeInput widget ([#2440](#2440)) ([7916d16](7916d16))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants