diff --git a/frontend/app/element/modal.less b/frontend/app/element/modal.less new file mode 100644 index 000000000..246dcf382 --- /dev/null +++ b/frontend/app/element/modal.less @@ -0,0 +1,55 @@ +.modal-container { + position: absolute; + top: 0; + left: 0; + width: 100vw; + height: 100vh; + z-index: 100; + background-color: rgba(21, 23, 21, 0.7); + + .modal { + display: flex; + flex-direction: column; + border-radius: 10px; + padding: 0; + width: 450px; + max-height: 80vh; + margin-top: 25vh; + margin-left: auto; + margin-right: auto; + background: var(--modal-bg-color); + border: 1px solid var(--app-border-color); + + .modal-header { + display: flex; + flex-direction: column; + padding: 20px 20px 10px; + border-bottom: 1px solid var(--modal-header-bottom-border-color); + + .modal-title { + margin: 0 0 5px; + color: var(--app-text-primary-color); + font-size: var(--title-font-size); + } + + p { + margin: 0; + font-size: 0.8rem; + color: var(--app-text-secondary-color); + } + } + + .modal-content { + padding: 20px; + overflow: auto; + } + + .modal-footer { + display: flex; + flex-direction: row; + justify-content: flex-end; + padding: 15px 20px; + gap: 20px; + } + } +} diff --git a/frontend/app/element/modal.tsx b/frontend/app/element/modal.tsx new file mode 100644 index 000000000..d0a7a2268 --- /dev/null +++ b/frontend/app/element/modal.tsx @@ -0,0 +1,80 @@ +import React from "react"; +import { Button } from "@/element/button"; + +import "./modal.less"; + +interface ModalProps { + id?: string; + children: React.ReactNode; + onClickOut: () => void; +} + +function Modal({ children, onClickOut, id = "modal", ...otherProps }: ModalProps) { + const handleOutsideClick = (e: React.SyntheticEvent) => { + if (typeof onClickOut === "function" && (e.target as Element).className === "modal-container") { + onClickOut(); + } + }; + + return ( +
+ + {children} + +
+ ); +} + +interface ModalContentProps { + children: React.ReactNode; +} + +function ModalContent({ children }: ModalContentProps) { + return
{children}
; +} + +interface ModalHeaderProps { + title: React.ReactNode; + description?: string; +} + +function ModalHeader({ title, description }: ModalHeaderProps) { + return ( +
+ {typeof title === "string" ?

{title}

: title} + {description &&

{description}

} +
+ ); +} + +interface ModalFooterProps { + children: React.ReactNode; +} + +function ModalFooter({ children }: ModalFooterProps) { + return ; +} + +interface WaveModalProps { + title: string; + description?: string; + id?: string; + onSubmit: () => void; + onCancel: () => void; + buttonLabel?: string; + children: React.ReactNode; +} + +function WaveModal({ title, description, onSubmit, onCancel, buttonLabel = "Ok", children }: WaveModalProps) { + return ( + + + {children} + + + + + ); +} + +export { WaveModal }; diff --git a/frontend/app/view/plotview.less b/frontend/app/view/plotview.less index a1e0e161a..96801a3c8 100644 --- a/frontend/app/view/plotview.less +++ b/frontend/app/view/plotview.less @@ -11,7 +11,6 @@ margin: 0; padding: 0; resize: none; - max-height: 40%; height: auto; background-color: var(--panel-bg-color); color: var(--main-text-color); diff --git a/frontend/app/view/plotview.tsx b/frontend/app/view/plotview.tsx index 32f758df4..06ad2ff5f 100644 --- a/frontend/app/view/plotview.tsx +++ b/frontend/app/view/plotview.tsx @@ -1,6 +1,8 @@ import * as React from "react"; import * as Plot from "@observablehq/plot"; import * as d3 from "d3"; +import { Button } from "@/element/button"; +import { WaveModal } from "@/element/modal"; import "./plotview.less"; @@ -29,6 +31,9 @@ function evalAsync(Plot: any, d3: any, funcText: string): Promise { function PlotView() { const containerRef = React.useRef(); const [plotDef, setPlotDef] = React.useState(); + const [tempDef, setTempDef] = React.useState(); + const [savedDef, setSavedDef] = React.useState(); + const [modalUp, setModalUp] = React.useState(false); /* const [data, setData] = React.useState(); @@ -94,13 +99,23 @@ function PlotView() { return (
+
-