From a599768638f0d7c6b6bda90fda967414c960f479 Mon Sep 17 00:00:00 2001 From: Vyacheslav Matyukhin Date: Wed, 27 Jul 2022 01:26:54 +0400 Subject: [PATCH] increase modal width --- .../components/src/components/ui/Modal.tsx | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/packages/components/src/components/ui/Modal.tsx b/packages/components/src/components/ui/Modal.tsx index f688e17c..e18631cb 100644 --- a/packages/components/src/components/ui/Modal.tsx +++ b/packages/components/src/components/ui/Modal.tsx @@ -2,10 +2,8 @@ import { motion } from "framer-motion"; import React, { useContext } from "react"; import * as ReactDOM from "react-dom"; import { XIcon } from "@heroicons/react/solid"; -import { SquiggleContainer } from "../SquiggleContainer"; import clsx from "clsx"; import { useWindowScroll, useWindowSize } from "react-use"; -import { rectToClientRect } from "@floating-ui/core"; type ModalContextShape = { close: () => void; @@ -79,15 +77,16 @@ const ModalWindow: React.FC<{ } | undefined; - const { clientWidth: screenWidth, clientHeight: screenHeight } = - document.documentElement; - if (container) { - const rect = container?.getBoundingClientRect(); + // If available space in `visibleRect` is smaller than these, fallback to positioning in the middle of the screen. + const minWidth = 384; + const minHeight = 300; + const offset = 8; + const naturalWidth = 576; // maximum possible width; modal tries to take this much space, but can be smaller - // If available space in `visibleRect` is smaller than these, fallback to positioning in the middle of the screen. - const minWidth = 384; // matches the w-96 below - const minHeight = 300; - const offset = 8; + if (container) { + const { clientWidth: screenWidth, clientHeight: screenHeight } = + document.documentElement; + const rect = container?.getBoundingClientRect(); const visibleRect = { left: Math.max(rect.left, 0), @@ -116,15 +115,17 @@ const ModalWindow: React.FC<{ return (
{children}