From 58d833ad1d91a8ec9238c4b67a8a2e5d98447ab1 Mon Sep 17 00:00:00 2001 From: lublagg Date: Thu, 25 Jan 2024 20:46:13 -0500 Subject: [PATCH] Revert to old DataReturnWarning component. --- src/components/App.tsx | 2 + src/components/data-return-warning.scss | 61 ++++++++++++++++++++++++ src/components/data-return-warning.tsx | 32 +++++++++++++ src/components/date-range/date-range.tsx | 30 ++---------- 4 files changed, 98 insertions(+), 27 deletions(-) create mode 100644 src/components/data-return-warning.scss create mode 100644 src/components/data-return-warning.tsx diff --git a/src/components/App.tsx b/src/components/App.tsx index 8480b91..e8f8f7e 100755 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -14,6 +14,7 @@ import { useCODAPApi } from "../hooks/use-codap-api"; import { dataTypeStore } from "../utils/noaaDataTypes"; import { composeURL, formatData } from "../utils/noaaApiHelper"; import { IDataType } from "../types"; +import { DataReturnWarning } from "./data-return-warning"; import "./App.scss"; @@ -163,6 +164,7 @@ export const App = () => { {showModal === "info" && } + {showModal === "data-return-warning" && } ); }; diff --git a/src/components/data-return-warning.scss b/src/components/data-return-warning.scss new file mode 100644 index 0000000..4326d1b --- /dev/null +++ b/src/components/data-return-warning.scss @@ -0,0 +1,61 @@ +$teal-dark: #177991; + +.data-return-warning-background { + position: fixed; + top: 0; + left: 0; + right: 0; + bottom: 0; + background-color: rgba(0, 0, 0, 0.51); +} + +.data-return-warning { + position: fixed; + top: 5px; + left: 15px; + width: 340px; + border-radius: 6px; + padding: 0; + background-color: #fff; + z-index: 10; + + div:nth-child(1) { + width: 100%; + height: 25px; + border-radius: 6px 6px 0 0; + background-color: #ffbf00; + display: flex; + align-items: center; + justify-content: center; + color: #000; + font-weight: bold; + + svg { + position: absolute; + right: 6px; + cursor: pointer; + } + } + div:nth-child(2) { + padding: 10px; + text-align: left; + } + div:nth-child(3) { + display: flex; + align-items: center; + justify-content: right; + padding: 0 10px 10px 0; + + button { + width: 82px; + height: 31px; + border-radius: 3px; + border: solid 1px #000; + background-color: #fff; + display: flex; + align-items: center; + justify-content: center; + cursor: pointer; + } + } +} \ No newline at end of file diff --git a/src/components/data-return-warning.tsx b/src/components/data-return-warning.tsx new file mode 100644 index 0000000..84027f4 --- /dev/null +++ b/src/components/data-return-warning.tsx @@ -0,0 +1,32 @@ +import React from "react"; +import { useStateContext } from "../hooks/use-state"; +import ExitIcon from "../assets/images/icon-exit.svg"; + +import "./data-return-warning.scss"; + +export const DataReturnWarning = () => { + const {setState} = useStateContext(); + + const handleCloseModal = () => { + setState(draft => { + draft.showModal = undefined; + }); + }; + + return ( + <> +
+
+
+ Data Return Warning +
+
+ Your current date range is likely to return too many results, which may affect application performance. +
+
+ +
+
+ + ); +}; diff --git a/src/components/date-range/date-range.tsx b/src/components/date-range/date-range.tsx index bd575a2..0f6346e 100644 --- a/src/components/date-range/date-range.tsx +++ b/src/components/date-range/date-range.tsx @@ -4,7 +4,6 @@ import { useStateContext } from "../../hooks/use-state"; import { DateSelector } from "./date-selector"; import { Calendars } from "./calendars"; import WarningIcon from "../../assets/icon-warning.svg"; -import ExitIcon from "../../assets/images/icon-exit.svg"; import { defaultDates } from "../../constants"; import "./date-range.scss"; @@ -15,7 +14,6 @@ export const DateRange = () => { const [selectedCalendar, setSelectedCalendar] = useState(); // "start" | "end" const [showCalendars, setShowCalendars] = useState(false); const [showWarningIcon, setShowWarningIcon] = useState(false); - const [showWarningModal, setShowWarningModal] = useState(false); const frequencies = ["hourly", "daily", "monthly"] as IFrequency[]; useEffect(() => { @@ -77,13 +75,9 @@ export const DateRange = () => { setShowCalendars(false); setSelectedCalendar(undefined); if (showWarningIcon) { - setShowWarningModal(true); - } - }; - - const handleOuterModalClick = (e: React.MouseEvent) => { - if (e.target === e.currentTarget) { - setShowWarningModal(false); + setState(draft => { + draft.showModal = "data-return-warning"; + }); } }; @@ -128,24 +122,6 @@ export const DateRange = () => { /> }
- { - showWarningModal && -
-
-
-
Data Return Warning
-
setShowWarningModal(false)}>
-
-
- Your current date range is likely to return too many results, which - may affect application performance. -
-
- -
-
-
- } ); };