From f98d0c56d07f43a56ff9ebe72d4a703313cf9ac1 Mon Sep 17 00:00:00 2001 From: Lazaro Alonso Date: Wed, 15 Oct 2025 01:42:20 +0200 Subject: [PATCH 1/2] more sides --- src/components/ui/MainPanel/AdjustPlot.tsx | 22 ++- src/components/ui/MainPanel/Dataset.tsx | 219 +++++++++++---------- src/components/ui/MainPanel/PlayButton.tsx | 17 +- src/components/ui/MainPanel/PlotType.tsx | 15 +- 4 files changed, 147 insertions(+), 126 deletions(-) diff --git a/src/components/ui/MainPanel/AdjustPlot.tsx b/src/components/ui/MainPanel/AdjustPlot.tsx index 3f26964c..71684123 100644 --- a/src/components/ui/MainPanel/AdjustPlot.tsx +++ b/src/components/ui/MainPanel/AdjustPlot.tsx @@ -468,6 +468,7 @@ const GlobalOptions = () =>{ const AdjustPlot = () => { const [isMobile, setIsMobile] = useState(false); + const [popoverSide, setPopoverSide] = useState<"left" | "top">("left"); const {plotOn} = useGlobalStore( useShallow(state=>({ @@ -480,15 +481,13 @@ const AdjustPlot = () => { useEffect(() => { - const checkWindowSize = () => { - setIsMobile(window.innerWidth <= 768); - }; - - checkWindowSize(); // Initial check - window.addEventListener("resize", checkWindowSize); - - return () => window.removeEventListener("resize", checkWindowSize); - }, []); + const handleResize = () => { + setPopoverSide(window.innerWidth < 768 ? "top" : "left"); + }; + handleResize(); + window.addEventListener("resize", handleResize); + return () => window.removeEventListener("resize", handleResize); + }, []); const enableCond = (plotOn) return ( @@ -511,7 +510,10 @@ const AdjustPlot = () => { - + Plot Settings diff --git a/src/components/ui/MainPanel/Dataset.tsx b/src/components/ui/MainPanel/Dataset.tsx index 8f6794bf..f17efd89 100644 --- a/src/components/ui/MainPanel/Dataset.tsx +++ b/src/components/ui/MainPanel/Dataset.tsx @@ -1,19 +1,23 @@ "use client"; -import React, { SetStateAction, useEffect, useState } from 'react'; +import React, { SetStateAction, useEffect, useState, ReactNode } from 'react'; import { useGlobalStore } from '@/utils/GlobalStates'; import { useShallow } from 'zustand/shallow'; import { Input } from '../input'; import { Button } from '../button'; -// import { CgDatabase } from "react-icons/cg"; import { TbDatabasePlus } from "react-icons/tb"; import LocalZarr from './LocalZarr'; -import { Popover, PopoverTrigger, PopoverContent, PopoverAnchor } from "@/components/ui/popover"; +import { Popover, PopoverTrigger, PopoverContent } from "@/components/ui/popover"; import { Tooltip, TooltipContent, TooltipTrigger, } from "@/components/ui/tooltip" +import { + Dialog, + DialogContent, + DialogTitle, +} from "@/components/ui/dialog"; const ZARR_STORES = { ESDC: 'https://s3.bgc-jena.mpg.de:9000/esdl-esdc-v3.0.2/esdc-16d-2.5deg-46x72x1440-3.0.2.zarr', @@ -46,6 +50,27 @@ const DescriptionContent = ({setOpenVariables}:{setOpenVariables : React.Dispatc ) } +const DatasetOption = ({ + children, + active, + onClick, +}: { + children: ReactNode; + active: boolean; + onClick: () => void; +}) => { + return ( + + ); +}; + + const Dataset = ({setOpenVariables} : {setOpenVariables: React.Dispatch>}) => { const [showStoreInput, setShowStoreInput] = useState(false); const [showLocalInput, setShowLocalInput] = useState(false); @@ -53,7 +78,7 @@ const Dataset = ({setOpenVariables} : {setOpenVariables: React.Dispatch('ESDC') const [openDescription, setOpenDescription] = useState(false) - const { setInitStore, setVariable } = useGlobalStore( + const { setInitStore } = useGlobalStore( useShallow((state) => ({ setInitStore: state.setInitStore, setVariable: state.setVariable, @@ -70,7 +95,7 @@ const Dataset = ({setOpenVariables} : {setOpenVariables: React.Dispatch +
@@ -87,126 +112,108 @@ const Dataset = ({setOpenVariables} : {setOpenVariables: React.Dispatch
- {popoverSide === "left" ? ( - - Select dataset - - ) : ( - - Select dataset - - )} + + Select dataset +
- -

Curated

- - { + const target = e.target as HTMLElement; + // If the click is inside the MetaData popover, do not close + if (target.closest('[data-meta-popover]')) { + e.preventDefault(); + } + }} + > +
+

Curated

+ { setShowStoreInput(false); setShowLocalInput(false); - setActiveOption('ESDC') + setActiveOption('ESDC'); setInitStore(ZARR_STORES.ESDC); + setOpenDescription(true); }} > - - - - - - - - - - - - - - - -
-

Personal

-
- - {showStoreInput && ( -
) => { - e.preventDefault(); - const input = e.currentTarget.elements[0] as HTMLInputElement; - setInitStore(input.value); + Seasfire + + +
+

Personal

+
+ { + setShowStoreInput((prev) => !prev); + setActiveOption('remote'); }} > - - - - )} -
- - -
- - {showLocalInput && ( -
- -
- )} -
-
- - - -
+ + + + )} +
+
+ { + setShowLocalInput((prev) => !prev); + setShowStoreInput(false); + setActiveOption('local'); + }} + > + Local + + {showLocalInput && ( +
+ +
+ )} +
+
+ + {} + + + + ); }; diff --git a/src/components/ui/MainPanel/PlayButton.tsx b/src/components/ui/MainPanel/PlayButton.tsx index 22ba50cd..0ef704a6 100644 --- a/src/components/ui/MainPanel/PlayButton.tsx +++ b/src/components/ui/MainPanel/PlayButton.tsx @@ -193,10 +193,20 @@ const PlayButton = () => { const [showOptions, setShowOptions] = useState(false) const cond = useMemo(()=>!isFlat && plotOn, [isFlat,plotOn]) const enableCond = (!isFlat && plotOn) + const [popoverSide, setPopoverSide] = useState<"left" | "top">("left"); useEffect(()=>{ setShowOptions(false) },[reFetch]) + + useEffect(() => { + const handleResize = () => { + setPopoverSide(window.innerWidth < 768 ? "top" : "left"); + }; + handleResize(); + window.addEventListener("resize", handleResize); + return () => window.removeEventListener("resize", handleResize); + }, []); return ( <> @@ -216,9 +226,14 @@ const PlayButton = () => {
- + Animation controls + diff --git a/src/components/ui/MainPanel/PlotType.tsx b/src/components/ui/MainPanel/PlotType.tsx index 2d228c93..a8534b6c 100644 --- a/src/components/ui/MainPanel/PlotType.tsx +++ b/src/components/ui/MainPanel/PlotType.tsx @@ -79,15 +79,12 @@ const PlotType = () => {
- {popoverSide === "left" ? ( - - Change plot type - - ) : ( - - Change plot type - - )} + + Change plot type +
From 48da8fa7c1c325004f8d07f1ed6dda973b93ea10 Mon Sep 17 00:00:00 2001 From: Lazaro Alonso Date: Wed, 15 Oct 2025 02:25:50 +0200 Subject: [PATCH 2/2] user click here --- src/components/ui/MainPanel/Dataset.tsx | 51 ++++++++++++++++++------- 1 file changed, 37 insertions(+), 14 deletions(-) diff --git a/src/components/ui/MainPanel/Dataset.tsx b/src/components/ui/MainPanel/Dataset.tsx index f17efd89..b1aa7b70 100644 --- a/src/components/ui/MainPanel/Dataset.tsx +++ b/src/components/ui/MainPanel/Dataset.tsx @@ -6,6 +6,7 @@ import { useShallow } from 'zustand/shallow'; import { Input } from '../input'; import { Button } from '../button'; import { TbDatabasePlus } from "react-icons/tb"; +import { TbVariable } from "react-icons/tb"; import LocalZarr from './LocalZarr'; import { Popover, PopoverTrigger, PopoverContent } from "@/components/ui/popover"; import { @@ -17,6 +18,7 @@ import { Dialog, DialogContent, DialogTitle, + DialogPortal } from "@/components/ui/dialog"; const ZARR_STORES = { @@ -24,7 +26,13 @@ const ZARR_STORES = { SEASFIRE: 'https://s3.bgc-jena.mpg.de:9000/misc/seasfire_rechunked.zarr', }; -const DescriptionContent = ({setOpenVariables}:{setOpenVariables : React.Dispatch>}) => { +const DescriptionContent = ({ + setOpenVariables, + onCloseDialog, +}: { + setOpenVariables: React.Dispatch>; + onCloseDialog: () => void; +}) => { const {titleDescription} = useGlobalStore(useShallow(state => ({ titleDescription: state.titleDescription }))) @@ -32,19 +40,27 @@ const DescriptionContent = ({setOpenVariables}:{setOpenVariables : React.Dispatc return (
- Title -

- {title ? title : "No Title"} +

+ {title ? title : "Store"}

- Description -

{description ? description : "No Description"}

+

+ {description ? description : "No Description"} +

+ onClick={() => { + setOpenVariables(true); + onCloseDialog(); + }} + > + Open Variables + +
) @@ -95,6 +111,7 @@ const Dataset = ({setOpenVariables} : {setOpenVariables: React.Dispatch
@@ -208,13 +225,19 @@ const Dataset = ({setOpenVariables} : {setOpenVariables: React.Dispatch
- - {} - - - -
+ + + {} + + setOpenDescription(false)} + /> + + + + ); };