Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/Breadcrumb/Breadcrumb.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const Breadcrumb = ({
}) => (
<div
className={cx(cssClasses.root, {
[cssClasses.noRefinement]: items.length > 0,
[cssClasses.noRefinementRoot]: items.length === 0,
})}
>
<ul className={cssClasses.list}>
Expand Down Expand Up @@ -84,7 +84,7 @@ Breadcrumb.propTypes = {
createURL: PropTypes.func.isRequired,
cssClasses: PropTypes.shape({
root: PropTypes.string.isRequired,
noRefinement: PropTypes.string.isRequired,
noRefinementRoot: PropTypes.string.isRequired,
list: PropTypes.string.isRequired,
item: PropTypes.string.isRequired,
selectedItem: PropTypes.string.isRequired,
Expand Down
11 changes: 7 additions & 4 deletions src/components/Breadcrumb/__tests__/Breadcrumb-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('Breadcrumb', () => {
items: [],
cssClasses: {
root: 'root',
noRefinement: 'noRefinement',
noRefinementRoot: 'noRefinementRoot',
list: 'list',
item: 'item',
selectedItem: 'selectedItem',
Expand All @@ -29,6 +29,7 @@ describe('Breadcrumb', () => {
};
const wrapper = mount(<Breadcrumb {...props} />);

expect(wrapper.find('.noRefinementRoot')).toHaveLength(1);
expect(wrapper).toMatchSnapshot();
});

Expand All @@ -46,7 +47,7 @@ describe('Breadcrumb', () => {
],
cssClasses: {
root: 'root',
noRefinement: 'noRefinement',
noRefinementRoot: 'noRefinementRoot',
list: 'list',
item: 'item',
selectedItem: 'selectedItem',
Expand All @@ -63,10 +64,11 @@ describe('Breadcrumb', () => {
};
const wrapper = mount(<Breadcrumb {...props} />);

expect(wrapper.find('.noRefinementRoot')).toHaveLength(0);
expect(wrapper).toMatchSnapshot();
});

it('should render <Breadcrumb /> with items', () => {
it('should render <Breadcrumb /> with multiple items', () => {
const props = {
createURL: data => {
JSON.stringify(data);
Expand All @@ -84,7 +86,7 @@ describe('Breadcrumb', () => {
],
cssClasses: {
root: 'root',
noRefinement: 'noRefinement',
noRefinementRoot: 'noRefinementRoot',
list: 'list',
item: 'item',
selectedItem: 'selectedItem',
Expand All @@ -101,6 +103,7 @@ describe('Breadcrumb', () => {
};
const wrapper = mount(<Breadcrumb {...props} />);

expect(wrapper.find('.noRefinementRoot')).toHaveLength(0);
expect(wrapper).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

exports[`Breadcrumb should render <Breadcrumb /> 1`] = `
<div
className="root"
className="root noRefinementRoot"
>
<ul
className="list"
Expand All @@ -26,7 +26,7 @@ exports[`Breadcrumb should render <Breadcrumb /> 1`] = `

exports[`Breadcrumb should render <Breadcrumb /> with a single item 1`] = `
<div
className="root noRefinement"
className="root"
>
<ul
className="list"
Expand Down Expand Up @@ -63,9 +63,9 @@ exports[`Breadcrumb should render <Breadcrumb /> with a single item 1`] = `
</div>
`;

exports[`Breadcrumb should render <Breadcrumb /> with items 1`] = `
exports[`Breadcrumb should render <Breadcrumb /> with multiple items 1`] = `
<div
className="root noRefinement"
className="root"
>
<ul
className="list"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ exports[`breadcrumb() render renders transformed items correctly 1`] = `
"item": "ais-Breadcrumb-item",
"link": "ais-Breadcrumb-link",
"list": "ais-Breadcrumb-list",
"noRefinement": "ais-Breadcrumb--noRefinement",
"noRefinementRoot": "ais-Breadcrumb--noRefinement",
"root": "ais-Breadcrumb",
"selectedItem": "ais-Breadcrumb-item--selected",
"separator": "ais-Breadcrumb-separator",
Expand Down
8 changes: 4 additions & 4 deletions src/widgets/breadcrumb/breadcrumb.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ breadcrumb({
container,
attributes,
[ rootPath = null ],
[ templates.{home, separator}]
[ transformItems ],
[ templates.{home, separator}],
[ cssClasses.{root, noRefinement, list, item, selectedItem, separator, link} ],
})`;

/**
* @typedef {Object} BreadcrumbCSSClasses
* @property {string|string[]} [root] CSS class to add to the root element of the widget.
* @property {string|string[]} [noRefinement] CSS class to add to the root element of the widget if there are no refinements.
* @property {string|string[]} [noRefinementRoot] CSS class to add to the root element of the widget if there are no refinements.
* @property {string|string[]} [list] CSS class to add to the list element.
* @property {string|string[]} [item] CSS class to add to the items of the list. The items contains the link and the separator.
* @property {string|string[]} [selectedItem] CSS class to add to the selected item in the list: the last one or the home if there are no refinements.
Expand Down Expand Up @@ -146,9 +146,9 @@ export default function breadcrumb({

const cssClasses = {
root: cx(suit(), userCssClasses.root),
noRefinement: cx(
noRefinementRoot: cx(
suit({ modifierName: 'noRefinement' }),
userCssClasses.noRefinement
userCssClasses.noRefinementRoot
),
list: cx(suit({ descendantName: 'list' }), userCssClasses.list),
item: cx(suit({ descendantName: 'item' }), userCssClasses.item),
Expand Down