Skip to content

Commit

Permalink
Implement Search View More and View less props (#149)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmcphillips authored Jun 8, 2021
1 parent 0a9a329 commit 7bb85c8
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/components/SearchFacets/SearchFacet/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ const SearchFacet = ({
},
selectedFacets,
inputType,
onMore,
onLess
}) => {

let myLabel = '';
Expand Down Expand Up @@ -139,6 +141,8 @@ const SearchFacet = ({
container="div"
items={choices}
limit={10}
onMore={onMore}
onLess={onLess}
/>
</ToggleBlock>
</div>
Expand Down Expand Up @@ -169,6 +173,8 @@ SearchFacet.propTypes = {
icon: PropTypes.func,
}),
inputType: PropTypes.string,
onMore: PropTypes.func,
onLess: PropTypes.func
};

export default SearchFacet;
6 changes: 6 additions & 0 deletions src/components/SearchFacets/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ const SearchFacets = ({
className,
toggleClasses,
InputComponent,
onMore,
onLess
}) => {
const facetList = Object.entries(facetsConfig);
const facetComponents = facetList.map(
Expand All @@ -33,6 +35,8 @@ const SearchFacets = ({
reset={facetInfo[1].reset}
selectedFacets={selectedFacets}
inputType={facetInfo[1].inputType}
onMore={onMore}
onLess={onLess}
/>
);
},
Expand Down Expand Up @@ -60,6 +64,8 @@ SearchFacets.propTypes = {
className: PropTypes.string,
toggleClasses: PropTypes.string,
InputComponent: PropTypes.func,
onMore: PropTypes.func,
onLess: PropTypes.func
};

export default SearchFacets;
16 changes: 14 additions & 2 deletions src/components/ShowMoreContainer/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,21 @@ export default function ShowMoreContainer({
btnClosedText,
containerClasses,
wrapperClasses,
onMore,
onLess
}) {
const [showMore, toggleShowMore] = useState(false);

let showMoreButton = (
<button
type="button"
className="showmore-button"
onClick={() => toggleShowMore(!showMore)}
onClick={() => {
if (onLess){
onLess()
}
toggleShowMore(!showMore)
}}
>
{btnOpenText || 'Show less'}
</button>
Expand All @@ -35,7 +42,12 @@ export default function ShowMoreContainer({
<button
type="button"
className="showmore-button"
onClick={() => toggleShowMore(!showMore)}
onClick={() => {
if (onMore){
onMore()
}
toggleShowMore(!showMore)
}}
>
{btnText}
</button>
Expand Down

0 comments on commit 7bb85c8

Please sign in to comment.