-
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.
- Loading branch information
1 parent
0b5284a
commit 4287f6c
Showing
8 changed files
with
339 additions
and
5 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,66 @@ | ||
import React from 'react'; | ||
|
||
import { Button } from '../ui/button'; | ||
|
||
import { | ||
Drawer as UIDrawer, | ||
DrawerContent, | ||
DrawerFooter, | ||
DrawerClose, | ||
DrawerTrigger, | ||
} from '../ui/drawer'; | ||
import { Separator } from '../ui/separator'; | ||
|
||
import Header, { IHeader } from './Header'; | ||
|
||
interface IFilterDrawe { | ||
children?: React.ReactNode; | ||
onCancel?: () => void; | ||
onFilter?: () => void; | ||
headerProps: IHeader; | ||
} | ||
|
||
const Drawer = ({ | ||
children, | ||
onCancel, | ||
onFilter, | ||
headerProps, | ||
}: IFilterDrawe): JSX.Element => { | ||
return ( | ||
<UIDrawer> | ||
<DrawerTrigger asChild> | ||
<Button variant="outline">Open Drawer</Button> | ||
</DrawerTrigger> | ||
<DrawerContent className="flex items-center bg-lightGray"> | ||
<div className="w-[1000px] rounded-lg bg-white"> | ||
<Header {...headerProps} /> | ||
|
||
{React.Children.map(children, child => ( | ||
<> | ||
<Separator /> | ||
<div className="px-6 py-10">{child}</div> | ||
</> | ||
))} | ||
</div> | ||
|
||
<DrawerFooter className="flex flex-row justify-end w-full h-20 bg-white mt-6 gap-x-6"> | ||
<DrawerClose asChild> | ||
<Button variant="ghost" onClick={onCancel}> | ||
Cancel | ||
</Button> | ||
</DrawerClose> | ||
<DrawerClose | ||
asChild | ||
className="w-[200px] rounded-full bg-lightBlue text-white" | ||
> | ||
<Button variant="outline" onClick={onFilter}> | ||
Filter | ||
</Button> | ||
</DrawerClose> | ||
</DrawerFooter> | ||
</DrawerContent> | ||
</UIDrawer> | ||
); | ||
}; | ||
|
||
export default Drawer; |
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,27 @@ | ||
export interface IHeader { | ||
title: string; | ||
tree: string; | ||
matainer: string; | ||
commit: string; | ||
estimate: string; | ||
} | ||
|
||
const Header = ({ | ||
title, | ||
tree, | ||
matainer, | ||
commit, | ||
estimate, | ||
}: IHeader): JSX.Element => { | ||
return ( | ||
<div className="h-[100px]"> | ||
{title} | ||
{tree} | ||
{matainer} | ||
{commit} | ||
{estimate} | ||
</div> | ||
); | ||
}; | ||
|
||
export default Header; |
2 changes: 1 addition & 1 deletion
2
...onents/Filter/CheckboxSection.stories.tsx → ...ilter/stories/CheckboxSection.stories.tsx
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
67 changes: 67 additions & 0 deletions
67
dashboard/src/components/Filter/stories/FilterDrawer.stories.tsx
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,67 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
import { IntlProvider } from 'react-intl'; | ||
import { flatten } from 'flat'; | ||
|
||
import { LOCALES } from '../../../locales/constants'; | ||
|
||
import { messages } from '../../../locales/messages'; | ||
|
||
import FilterDrawer from '../Drawer'; | ||
|
||
import CheckboxSection from '../CheckboxSection'; | ||
import TimeRangeSection from '../TimeRangeSection'; | ||
|
||
const meta: Meta<typeof FilterDrawer> = { | ||
title: 'FilterDrawer', | ||
component: FilterDrawer, | ||
parameters: { | ||
layout: 'centered', | ||
}, | ||
tags: ['autodocs'], | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default: Story = { | ||
decorators: [ | ||
(): JSX.Element => ( | ||
<IntlProvider | ||
messages={flatten(messages[LOCALES.EN_US])} | ||
locale={LOCALES.EN_US} | ||
> | ||
<FilterDrawer headerProps={headerProps}> | ||
<CheckboxSection {...checkboxSectionProps} /> | ||
<CheckboxSection {...checkboxSectionProps} /> | ||
<TimeRangeSection {...timeRangeSectionProps} /> | ||
</FilterDrawer> | ||
</IntlProvider> | ||
), | ||
], | ||
}; | ||
|
||
const headerProps = { | ||
title: 'Tree', | ||
tree: 'stable-rc', | ||
matainer: 'Shannon Nelson', | ||
commit: '5.15.150-rc1 - 3ab4d9c9e190217ee7e974c70b96795cd2f74611', | ||
estimate: '2 hours', | ||
}; | ||
|
||
const checkboxSectionProps = { | ||
items: ['linux-5.15.y', 'Status:failed', 'Status: Warnings'], | ||
title: 'Branch', | ||
subtitle: 'Please select one or more Branches', | ||
onClickItem: (idx: number, isChecked: boolean): void => | ||
console.log(idx, isChecked), | ||
}; | ||
|
||
const onChangeM = (e: React.FormEvent<HTMLInputElement>): void => | ||
console.log(e.target); | ||
const timeRangeSectionProps = { | ||
min: 0, | ||
max: 100, | ||
onMinChange: onChangeM, | ||
onMaxChange: onChangeM, | ||
}; |
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
Oops, something went wrong.