-
Notifications
You must be signed in to change notification settings - Fork 30
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
c42c636
commit 6cfe13d
Showing
44 changed files
with
1,633 additions
and
462 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { | ||
Dispatch, | ||
SetStateAction, | ||
ReactNode, | ||
} from 'react' | ||
|
||
import type { | ||
OpenPageState, | ||
} from '@b3/hooks' | ||
|
||
import { | ||
CardContainer, | ||
} from './styled' | ||
|
||
import { | ||
RegisteredCloseButton, | ||
} from './RegisteredCloseButton' | ||
|
||
interface B3CardProps { | ||
setOpenPage?: Dispatch<SetStateAction<OpenPageState>>, | ||
children: ReactNode; | ||
} | ||
|
||
export const B3Card = (props:B3CardProps) => { | ||
const { | ||
setOpenPage, | ||
children, | ||
} = props | ||
|
||
return ( | ||
<CardContainer> | ||
{ | ||
setOpenPage && <RegisteredCloseButton setOpenPage={setOpenPage} /> | ||
} | ||
{ children } | ||
</CardContainer> | ||
) | ||
} |
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,101 @@ | ||
import ListItemButton from '@mui/material/ListItemButton' | ||
import ListItemText from '@mui/material/ListItemText' | ||
import ExpandLess from '@mui/icons-material/ExpandLess' | ||
import ExpandMore from '@mui/icons-material/ExpandMore' | ||
import Menu from '@mui/material/Menu' | ||
import MenuItem from '@mui/material/MenuItem' | ||
|
||
import { | ||
Box, | ||
} from '@mui/material' | ||
|
||
import { | ||
useState, | ||
ReactElement, | ||
MouseEvent, | ||
} from 'react' | ||
|
||
type configProps = { | ||
name: string, | ||
key: string | number, | ||
} | ||
|
||
interface B3DropDownProps<T> { | ||
width?: string, | ||
list: Array<T>, | ||
config?: configProps, | ||
title: string, | ||
handleItemClick: (arg0: T) => void, | ||
} | ||
|
||
export const B3DropDown: <T>(props: B3DropDownProps<T>) => ReactElement = ({ | ||
width, | ||
list, | ||
config, | ||
title, | ||
handleItemClick, | ||
}) => { | ||
const [open, setOpen] = useState<null | HTMLElement>(null) | ||
|
||
const handleClick = (event: MouseEvent<HTMLElement>) => { | ||
setOpen(event.currentTarget) | ||
} | ||
|
||
const handleCloseMenuClick = () => { | ||
setOpen(null) | ||
} | ||
|
||
const keyName = config?.name || 'name' | ||
|
||
return ( | ||
<Box | ||
sx={{ | ||
width: width || '200px', | ||
}} | ||
> | ||
<ListItemButton | ||
onClick={handleClick} | ||
> | ||
<ListItemText primary={title} /> | ||
{open ? <ExpandLess /> : <ExpandMore />} | ||
</ListItemButton> | ||
<Menu | ||
anchorEl={open} | ||
open={Boolean(open)} | ||
anchorOrigin={{ | ||
vertical: 'bottom', | ||
horizontal: 'center', | ||
}} | ||
transformOrigin={{ | ||
vertical: 'top', | ||
horizontal: 'center', | ||
}} | ||
id="customized-menu" | ||
keepMounted | ||
onClose={handleCloseMenuClick} | ||
> | ||
|
||
{ | ||
list.length && list.map((item) => { | ||
const name = (item as any)[keyName] | ||
return ( | ||
<MenuItem | ||
sx={{ | ||
width: width || '200px', | ||
}} | ||
key={name} | ||
onClick={() => { | ||
handleCloseMenuClick() | ||
handleItemClick(item) | ||
}} | ||
> | ||
<ListItemText primary={name} /> | ||
</MenuItem> | ||
) | ||
}) | ||
} | ||
|
||
</Menu> | ||
</Box> | ||
) | ||
} |
Oops, something went wrong.