/* * Copyright (c) 2020 - present Cloudogu GmbH * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU Affero General Public License as published by the Free * Software Foundation, version 3. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more * details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see https://www.gnu.org/licenses/. */ import React, { FC, MutableRefObject, ReactNode, useRef } from "react"; import classNames from "classnames"; import styled from "styled-components"; import { Dialog, DialogTitle } from "@headlessui/react"; import { devices } from "../devices"; import useRegisterModal from "./useRegisterModal"; type ModalSize = "S" | "M" | "L"; const modalSizes: { [key in ModalSize]: number } = { S: 33, M: 50, L: 66 }; type Props = { title: string; closeFunction: () => void; body?: any; footer?: any; active: boolean; className?: string; headColor?: string; headTextColor?: string; size?: ModalSize; initialFocusRef?: MutableRefObject; overflowVisible?: boolean; children?: ReactNode; }; const SizedModal = styled.div<{ size?: ModalSize; overflow: string }>` width: ${(props) => (props.size ? `${modalSizes[props.size]}%` : "640px")}; overflow: ${(props) => props.overflow}; @media screen and (max-width: ${devices.mobile.width}px) { width: ${(props) => (props.size ? `${modalSizes[props.size]}%` : "320px")}; } `; export const Modal: FC = ({ title, closeFunction, body, children, footer, active, className, headColor = "secondary-less", headTextColor = "secondary-most", size, initialFocusRef, overflowVisible, }) => { useRegisterModal(active); const closeButtonRef = useRef(null); let showFooter = null; if (footer) { showFooter =
{footer}
; } const overflowAttribute = overflowVisible ? "visible" : "auto"; const borderBottomRadiusAttribute = overflowVisible && !footer ? "inherit" : "unset"; return (

{title}

); }; export default Modal;