-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(filterspopover): add filters popover
- Loading branch information
Jin Lee
committed
Sep 10, 2022
1 parent
0fb7565
commit 541e226
Showing
9 changed files
with
165 additions
and
24 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
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,19 @@ | ||
import { BADGE } from '@geometricpanda/storybook-addon-badges'; | ||
import { StoryObj, Meta } from '@storybook/react'; | ||
import React from 'react'; | ||
|
||
import { FiltersPopover } from './FiltersPopover'; | ||
|
||
export default { | ||
title: 'PleaseUpdateThisToADifferentFolder/FiltersPopover', | ||
component: FiltersPopover, | ||
parameters: { | ||
badges: [BADGE.BETA], | ||
}, | ||
} as Meta<Args>; | ||
|
||
type Args = React.ComponentProps<typeof FiltersPopover>; | ||
|
||
export const Default: StoryObj<Args> = { | ||
args: {}, | ||
}; |
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,6 @@ | ||
import { generateSnapshots } from '@chanzuckerberg/story-utils'; | ||
import * as stories from './FiltersPopover.stories'; | ||
|
||
describe('<FiltersPopover />', () => { | ||
generateSnapshots(stories); | ||
}); |
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,76 @@ | ||
import clsx from 'clsx'; | ||
import React from 'react'; | ||
import Button from '../Button'; | ||
import ButtonGroup from '../ButtonGroup'; | ||
import Popover from '../Popover'; | ||
|
||
export type FiltersPopoverProps = { | ||
/** | ||
* Form controls, form fields, or other relevant information that will be displayed in the filters popover. | ||
*/ | ||
children: React.ReactNode; | ||
/** | ||
* CSS class names that can be appended to the component. | ||
*/ | ||
className?: string; | ||
/** | ||
* Callback called when the clear button is called. | ||
*/ | ||
onClear?: () => void; | ||
/** | ||
* Callback called when filters drawer is closed. | ||
*/ | ||
onClose?: () => void; | ||
/** | ||
* Callback called when the apply button is called. | ||
*/ | ||
onApply?: () => void; | ||
}; | ||
|
||
/** | ||
* BETA: This component is still a work in progress and is subject to change. | ||
* | ||
* ```ts | ||
* import {FiltersPopover} from "@chanzuckerberg/eds"; | ||
* ``` | ||
* | ||
* TODO: update this comment with a description of the component. | ||
*/ | ||
export const FiltersPopover = ({ | ||
children, | ||
className, | ||
onApply, | ||
onClear, | ||
...other | ||
}: FiltersPopoverProps) => { | ||
const componentClassName = clsx(styles['filters-popover'], className); | ||
|
||
return ( | ||
<Popover.Content className={componentClassName} {...other}> | ||
<div>{children}</div> | ||
{(onClear || onApply) && ( | ||
<div className={styles['filters-popover__footer']}> | ||
<ButtonGroup className={styles['filters-popover__button-group']}> | ||
{onClear && ( | ||
<Button | ||
className={styles['footer__button']} | ||
onClick={() => onClear()} | ||
> | ||
Clear All | ||
</Button> | ||
)} | ||
{onApply && ( | ||
<Button | ||
className={styles['footer__button']} | ||
onClick={() => onApply()} | ||
variant="primary" | ||
> | ||
Apply | ||
</Button> | ||
)} | ||
</ButtonGroup> | ||
</div> | ||
)} | ||
</Popover.Content> | ||
); | ||
}; |
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 @@ | ||
export { FiltersPopover as default } from './FiltersPopover'; |
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