Skip to content

Commit

Permalink
LPS-174358 Replace ClayLabel with ClayButton for the FDS filter display
Browse files Browse the repository at this point in the history
  • Loading branch information
kresimir-coko committed Mar 10, 2023
1 parent 186f6af commit 80aae13
Showing 1 changed file with 46 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
* details.
*/

import ClayButton from '@clayui/button';
import ClayDropDown from '@clayui/drop-down';
import ClayIcon from '@clayui/icon';
import ClayLabel from '@clayui/label';
import classNames from 'classnames';
import PropTypes from 'prop-types';
import React, {useContext, useState} from 'react';
Expand All @@ -28,34 +28,15 @@ function FilterResume(props) {

const [open, setOpen] = useState(false);

const label = (
<ClayLabel
const button = (
<ClayButton
className={classNames(
'filter-resume component-label tbar-label mr-2',
'filter-resume component-label tbar-label',
props.disabled && 'disabled',
open && 'active'
)}
closeButtonProps={{
className: 'filter-resume-close',
disabled: props.disabled,
onClick: () => {
viewsDispatch({
type: VIEWS_ACTION_TYPES.UPDATE_FILTERS,
value: filters.map((filter) => ({
...filter,
...(filter.id === props.id
? {
active: false,
odataFilterString: undefined,
selectedData: undefined,
}
: {}),
})),
});
},
title: Liferay.Language.get('remove-filter'),
}}
role="button"
displayType="secondary"
size="sm"
>
<div className="filter-resume-content">
<ClayIcon
Expand All @@ -67,23 +48,51 @@ function FilterResume(props) {
{props.label}: {props.selectedItemsLabel}
</div>
</div>
</ClayLabel>
</ClayButton>
);

const dropDown = (
<ClayDropDown
active={open}
className="d-inline-flex"
onActiveChange={setOpen}
trigger={label}
>
<li className="dropdown-subheader">{props.label}</li>
const dropDownButtonGroup = (
<ClayButton.Group>
<ClayDropDown
active={open}
className="d-inline-flex"
onActiveChange={setOpen}
trigger={button}
>
<li className="dropdown-subheader">{props.label}</li>

<Filter {...props} />
</ClayDropDown>
<Filter {...props} />
</ClayDropDown>

<ClayButton
className="filter-resume-close"
disabled={props.disabled}
displayType="secondary"
monospaced
onClick={() =>
viewsDispatch({
type: VIEWS_ACTION_TYPES.UPDATE_FILTERS,
value: filters.map((filter) => ({
...filter,
...(filter.id === props.id
? {
active: false,
odataFilterString: undefined,
selectedData: undefined,
}
: {}),
})),
})
}
size="sm"
title={Liferay.Language.get('remove-filter')}
>
<ClayIcon symbol="times-small" />
</ClayButton>
</ClayButton.Group>
);

return props.disabled ? label : dropDown;
return props.disabled ? button : dropDownButtonGroup;
}

FilterResume.propTypes = {
Expand Down

0 comments on commit 80aae13

Please sign in to comment.