Skip to content
This repository has been archived by the owner on Jul 12, 2024. It is now read-only.

Add countLabel prop to SearchListItem #2569

Merged
merged 2 commits into from
Jul 4, 2019
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
3 changes: 3 additions & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# unreleased
- SearchListItem component: new `countLabel` prop that will overwrite the `item.count` value.

# 3.0.0
- <DateInput> and <DatePicker> got a `disabled` prop.
- TableCard component: new `onPageChange` prop.
Expand Down
7 changes: 6 additions & 1 deletion packages/components/src/search-list-control/item.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const getInteractionIcon = ( isSingle = false, isSelected = false ) => {
};

const SearchListItem = ( {
countLabel,
className,
depth = 0,
item,
Expand Down Expand Up @@ -87,7 +88,7 @@ const SearchListItem = ( {

{ !! showCount && (
<span className="woocommerce-search-list__item-count">
{ item.count }
{ countLabel || item.count }
</span>
) }
</MenuItem>
Expand All @@ -99,6 +100,10 @@ SearchListItem.propTypes = {
* Additional CSS classes.
*/
className: PropTypes.string,
/**
* Label to display if `showCount` is set to true. If undefined, it will use `item.count`.
*/
countLabel: PropTypes.node,
/**
* Depth, non-zero if the list is hierarchical.
*/
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/search-list-control/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@
line-height: 1.4;
color: $core-grey-dark-300;
background: $white;
white-space: nowrap;
}
}
}
Expand Down