-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Create common FilterGroup component (#560)
* Refactored out filter group into a reusable component. * Address PR feedback.
- Loading branch information
Showing
7 changed files
with
136 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
.filter-group { | ||
width: 200px; | ||
|
||
.header { | ||
font-size: 16px; | ||
margin-bottom: 8px; | ||
line-height: 24px; | ||
} | ||
|
||
.button-group { | ||
.filter-button { | ||
height: 38px; | ||
min-width: 200px; | ||
color: $text-secondary; | ||
background-color: $cool-gray-20; | ||
} | ||
|
||
.selected { | ||
color: #ffffff; | ||
background: #d9d9d93d; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import React from "react"; | ||
import { Button, ButtonGroup } from "react-bootstrap"; | ||
import classNames from "classnames"; | ||
|
||
type Filter = { | ||
label: string; | ||
value: any; | ||
}; | ||
|
||
interface Props { | ||
header: string; | ||
filters: Filter[]; | ||
selectedFilter: string; | ||
onFilterSelect: (value: string) => void; | ||
className?: string; | ||
} | ||
|
||
const FilterGroup = ({ | ||
header, | ||
filters, | ||
selectedFilter, | ||
onFilterSelect, | ||
className, | ||
}: Props) => { | ||
return ( | ||
<div className={classNames("filter-group", className)}> | ||
<div className="header">{header}</div> | ||
<ButtonGroup className="button-group" vertical> | ||
{filters.map((filter) => { | ||
return ( | ||
<Button | ||
key={filter.value} | ||
className={classNames("filter-button", { | ||
selected: selectedFilter === filter.value, | ||
})} | ||
onClick={() => onFilterSelect(filter.value)} | ||
> | ||
{filter.label} | ||
</Button> | ||
); | ||
})} | ||
</ButtonGroup> | ||
</div> | ||
); | ||
}; | ||
|
||
export default FilterGroup; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters