Update dialog logic to support defining buttons/icon from anywhere

This commit is contained in:
DaneEveritt 2022-07-02 17:24:12 -04:00
parent 48af9bced1
commit 7c4028f8f1
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
9 changed files with 182 additions and 121 deletions

View file

@ -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);
};