parent
414987ef3e
commit
e8fe92321e
5 changed files with 77 additions and 44 deletions
@ -0,0 +1,33 @@ |
||||
import { styled } from '@mui/material'; |
||||
import { FC, ReactElement, useMemo } from 'react'; |
||||
import { v4 as uuidv4 } from 'uuid'; |
||||
|
||||
import ContainedButton from './ContainedButton'; |
||||
import FlexBox from './FlexBox'; |
||||
|
||||
const FlexEndBox = styled(FlexBox)({ |
||||
justifyContent: 'flex-end', |
||||
width: '100%', |
||||
}); |
||||
|
||||
const ActionGroup: FC<ActionGroupProps> = (props) => { |
||||
const { actions = [] } = props; |
||||
|
||||
const elements = useMemo( |
||||
() => |
||||
actions.map<ReactElement>((actionProps) => ( |
||||
<ContainedButton key={uuidv4()} {...actionProps}> |
||||
{actionProps.children} |
||||
</ContainedButton> |
||||
)), |
||||
[actions], |
||||
); |
||||
|
||||
return ( |
||||
<FlexEndBox row spacing=".5em"> |
||||
{elements} |
||||
</FlexEndBox> |
||||
); |
||||
}; |
||||
|
||||
export default ActionGroup; |
@ -1,6 +1,11 @@ |
||||
import Dialog from './Dialog'; |
||||
import DialogActionArea from './DialogActionArea'; |
||||
import DialogActionGroup from './DialogActionGroup'; |
||||
import DialogHeader from './DialogHeader'; |
||||
import DialogScrollBox from './DialogScrollBox'; |
||||
|
||||
export { Dialog, DialogActionArea, DialogHeader, DialogScrollBox }; |
||||
export { |
||||
Dialog, |
||||
DialogActionGroup as DialogActionArea, |
||||
DialogHeader, |
||||
DialogScrollBox, |
||||
}; |
||||
|
@ -0,0 +1,5 @@ |
||||
type ActionGroupOptionalProps = { |
||||
actions?: ContainedButtonProps[]; |
||||
}; |
||||
|
||||
type ActionGroupProps = ActionGroupOptionalProps; |
Loading…
Reference in new issue