Update dialog logic to support defining buttons/icon from anywhere
This commit is contained in:
parent
48af9bced1
commit
7c4028f8f1
9 changed files with 182 additions and 121 deletions
|
@ -0,0 +1,17 @@
|
|||
import React, { useContext } from 'react';
|
||||
import { createPortal } from 'react-dom';
|
||||
import DialogContext from '@/components/elements/dialog/context';
|
||||
|
||||
export default ({ children }: { children: React.ReactNode }) => {
|
||||
const { buttons } = useContext(DialogContext);
|
||||
|
||||
if (!buttons.current) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const element = (
|
||||
<div className={'px-6 py-3 bg-gray-700 flex items-center justify-end space-x-3 rounded-b'}>{children}</div>
|
||||
);
|
||||
|
||||
return createPortal(element, buttons.current);
|
||||
};
|
Reference in a new issue