feature: add property isActive for dropdown buttons
This commit is contained in:
@ -8,6 +8,7 @@ import { SortType } from './SortAndFilterBar';
|
|||||||
type OwnProps = {
|
type OwnProps = {
|
||||||
label: string;
|
label: string;
|
||||||
options: Array<SortType>;
|
options: Array<SortType>;
|
||||||
|
isActive: boolean;
|
||||||
onSortSelect?: (id: string) => void;
|
onSortSelect?: (id: string) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -20,6 +21,7 @@ const StyledDropdownButtonContainer = styled.div`
|
|||||||
|
|
||||||
type StyledDropdownButtonProps = {
|
type StyledDropdownButtonProps = {
|
||||||
isUnfolded: boolean;
|
isUnfolded: boolean;
|
||||||
|
isActive: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
const StyledDropdownButton = styled.div<StyledDropdownButtonProps>`
|
const StyledDropdownButton = styled.div<StyledDropdownButtonProps>`
|
||||||
@ -27,6 +29,7 @@ const StyledDropdownButton = styled.div<StyledDropdownButtonProps>`
|
|||||||
margin-left: ${(props) => props.theme.spacing(3)};
|
margin-left: ${(props) => props.theme.spacing(3)};
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
background: ${(props) => props.theme.primaryBackground};
|
background: ${(props) => props.theme.primaryBackground};
|
||||||
|
color: ${(props) => (props.isActive ? props.theme.blue : 'none')};
|
||||||
padding: ${(props) => props.theme.spacing(1)};
|
padding: ${(props) => props.theme.spacing(1)};
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
filter: ${(props) => (props.isUnfolded ? 'brightness(0.95)' : 'none')};
|
filter: ${(props) => (props.isUnfolded ? 'brightness(0.95)' : 'none')};
|
||||||
@ -85,7 +88,7 @@ const StyledIcon = styled.div`
|
|||||||
margin-right: ${(props) => props.theme.spacing(1)};
|
margin-right: ${(props) => props.theme.spacing(1)};
|
||||||
`;
|
`;
|
||||||
|
|
||||||
function DropdownButton({ label, options, onSortSelect }: OwnProps) {
|
function DropdownButton({ label, options, onSortSelect, isActive }: OwnProps) {
|
||||||
const [isUnfolded, setIsUnfolded] = useState(false);
|
const [isUnfolded, setIsUnfolded] = useState(false);
|
||||||
|
|
||||||
const onButtonClick = () => {
|
const onButtonClick = () => {
|
||||||
@ -101,7 +104,11 @@ function DropdownButton({ label, options, onSortSelect }: OwnProps) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<StyledDropdownButtonContainer>
|
<StyledDropdownButtonContainer>
|
||||||
<StyledDropdownButton isUnfolded={isUnfolded} onClick={onButtonClick}>
|
<StyledDropdownButton
|
||||||
|
isUnfolded={isUnfolded}
|
||||||
|
onClick={onButtonClick}
|
||||||
|
isActive={isActive}
|
||||||
|
>
|
||||||
{label}
|
{label}
|
||||||
</StyledDropdownButton>
|
</StyledDropdownButton>
|
||||||
{isUnfolded && options.length > 0 && (
|
{isUnfolded && options.length > 0 && (
|
||||||
|
|||||||
@ -86,13 +86,14 @@ function TableHeader({
|
|||||||
{viewName}
|
{viewName}
|
||||||
</StyledViewSection>
|
</StyledViewSection>
|
||||||
<StyledFilters>
|
<StyledFilters>
|
||||||
<DropdownButton label="Filter" options={[]} />
|
<DropdownButton label="Filter" options={[]} isActive={false} />
|
||||||
<DropdownButton
|
<DropdownButton
|
||||||
label="Sort"
|
label="Sort"
|
||||||
options={sortsAvailable}
|
options={sortsAvailable}
|
||||||
onSortSelect={onSortItemSelect}
|
onSortSelect={onSortItemSelect}
|
||||||
|
isActive={sorts.length > 0}
|
||||||
/>
|
/>
|
||||||
<DropdownButton label="Settings" options={[]} />
|
<DropdownButton label="Settings" options={[]} isActive={false} />
|
||||||
</StyledFilters>
|
</StyledFilters>
|
||||||
</StyledTableHeader>
|
</StyledTableHeader>
|
||||||
{sorts.length > 0 && (
|
{sorts.length > 0 && (
|
||||||
|
|||||||
Reference in New Issue
Block a user