diff --git a/src/Dialog/Content/Panel.tsx b/src/Dialog/Content/Panel.tsx index 8b35b590..2a194b09 100644 --- a/src/Dialog/Content/Panel.tsx +++ b/src/Dialog/Content/Panel.tsx @@ -28,6 +28,7 @@ const Panel = React.forwardRef((props, ref) => { footer, closable, closeIcon, + fullscreenIcon, onClose, children, bodyStyle, @@ -40,6 +41,7 @@ const Panel = React.forwardRef((props, ref) => { forceRender, width, height, + fullscreenable } = props; // ================================= Refs ================================= @@ -61,14 +63,20 @@ const Panel = React.forwardRef((props, ref) => { })); // ================================ Style ================================= - const contentStyle: React.CSSProperties = {}; + const [contentStyle, setContentStyle] = React.useState({ + ...(width !== undefined ? { width } : {}), + ...(height !== undefined ? { height } : {}) + }); - if (width !== undefined) { - contentStyle.width = width; - } - if (height !== undefined) { - contentStyle.height = height; - } + const toggleFullscreen = () => { + if (width) { + if (width === contentStyle.width) { + setContentStyle({ width: '100%' }); + } else { + setContentStyle({ width }); + } + } + }; // ================================ Render ================================ let footerNode: React.ReactNode; if (footer) { @@ -86,6 +94,16 @@ const Panel = React.forwardRef((props, ref) => { ); } + let fullscreen: React.ReactNode; + if (fullscreenable) { + const isFullscreen = '100%' === contentStyle.width; + fullscreen = ( + + ); + } + let closer: React.ReactNode; if (closable) { closer = ( @@ -97,6 +115,7 @@ const Panel = React.forwardRef((props, ref) => { const content = (
+ {fullscreen} {closer} {headerNode}
diff --git a/src/IDialogPropTypes.tsx b/src/IDialogPropTypes.tsx index 042b2d63..07db1e9a 100644 --- a/src/IDialogPropTypes.tsx +++ b/src/IDialogPropTypes.tsx @@ -37,9 +37,11 @@ export type IDialogPropTypes = { wrapProps?: any; getContainer?: GetContainer | false; closeIcon?: ReactNode; + fullscreenIcon?: (isFullscreen: boolean) => ReactNode; modalRender?: (node: ReactNode) => ReactNode; forceRender?: boolean; // https://github.com/ant-design/ant-design/issues/19771 // https://github.com/react-component/dialog/issues/95 focusTriggerAfterClose?: boolean; + fullscreenable?: boolean };