From 0462ea9d4ebb47980dfa63d6da9eb4070634821c Mon Sep 17 00:00:00 2001 From: Jeran Date: Wed, 11 Jun 2025 12:00:26 +0200 Subject: [PATCH 1/7] min-maxed-performance on scroller --- src/components/ui/VariableScroller.tsx | 26 +++++++++++++--------- src/components/ui/css/VariableScroller.css | 7 +++--- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/components/ui/VariableScroller.tsx b/src/components/ui/VariableScroller.tsx index 361ae01b..a68a4ba9 100644 --- a/src/components/ui/VariableScroller.tsx +++ b/src/components/ui/VariableScroller.tsx @@ -10,7 +10,6 @@ const formatArray = (value: string | number[]): string => { const MetaDataInfo = ({meta} : {meta : any}) =>{ const [show, setShow] = useState(false) - const setVariable = useGlobalStore(useShallow(state=> state.setVariable)) return(
@@ -46,7 +45,6 @@ const MetaDataInfo = ({meta} : {meta : any}) =>{ const VariableScroller = ({zMeta} : {zMeta : object[]}) => { const variables = useGlobalStore(useShallow(state=>state.variables)) const [selectedIndex, setSelectedIndex] = useState(Math.floor(variables.length / 2)); - const [variable, setVariable] = useState("Default") const [meta, setMeta] = useState(null) //This is the individual metadata for the element const [scrollHeight, setScrollHeight] = useState(82); const previousTouch = useRef(null) @@ -78,18 +76,25 @@ const VariableScroller = ({zMeta} : {zMeta : object[]}) => { } useEffect(()=>{ //Update variable onScroll - if (variables){ - setVariable(variables[selectedIndex]) + if (variables && zMeta){ + const tempVar = variables[selectedIndex] + const relevant = zMeta.find((e : any) => e.name === tempVar) + setMeta(relevant) } },[selectedIndex, variables]) - useEffect(()=>{ //Grab relevant metadata - if(zMeta){ - const relevant = zMeta.find((e : any) => e.name === variable) - setMeta(relevant) + function handleResize(){ + const width = window.innerWidth + if (width <= 480){ + setScrollHeight(42) } - },[variable]) - + else if (width <= 570){ + setScrollHeight(54) + } + else { + setScrollHeight(82) + } + } useEffect(()=>{ //Sets scrollsize. Doesn't work with resize though const width = window.innerWidth if (width <= 480){ @@ -101,6 +106,7 @@ const VariableScroller = ({zMeta} : {zMeta : object[]}) => { else { setScrollHeight(82) } + return window.addEventListener('resize', handleResize) },[]) return ( diff --git a/src/components/ui/css/VariableScroller.css b/src/components/ui/css/VariableScroller.css index f0bd7a9c..48fcc244 100644 --- a/src/components/ui/css/VariableScroller.css +++ b/src/components/ui/css/VariableScroller.css @@ -31,10 +31,9 @@ .meta-container{ text-align: left; position: absolute; - min-width: 400px; - max-width: 500px; - left: 70%; - top: 50%; + width: 85%; + left: 7.5%; + top: 10%; z-index: 3; font-size: 18px; border-radius: 10px; From 6e42dea68e07b5800e1ce4430886e4eabdaf584d Mon Sep 17 00:00:00 2001 From: Lazaro Alonso Date: Wed, 11 Jun 2025 12:59:48 +0200 Subject: [PATCH 2/7] popover --- package.json | 1 + src/components/ui/popover.tsx | 48 +++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 src/components/ui/popover.tsx diff --git a/package.json b/package.json index 01231f24..bc07db19 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "dependencies": { "@lazarusa/react-tweakpane": "^0.9.0", "@radix-ui/react-dropdown-menu": "^2.1.15", + "@radix-ui/react-popover": "^1.1.14", "@radix-ui/react-select": "^2.2.5", "@radix-ui/react-slot": "^1.2.3", "@react-spring/three": "^10.0.0", diff --git a/src/components/ui/popover.tsx b/src/components/ui/popover.tsx new file mode 100644 index 00000000..01e468b6 --- /dev/null +++ b/src/components/ui/popover.tsx @@ -0,0 +1,48 @@ +"use client" + +import * as React from "react" +import * as PopoverPrimitive from "@radix-ui/react-popover" + +import { cn } from "@/lib/utils" + +function Popover({ + ...props +}: React.ComponentProps) { + return +} + +function PopoverTrigger({ + ...props +}: React.ComponentProps) { + return +} + +function PopoverContent({ + className, + align = "center", + sideOffset = 4, + ...props +}: React.ComponentProps) { + return ( + + + + ) +} + +function PopoverAnchor({ + ...props +}: React.ComponentProps) { + return +} + +export { Popover, PopoverTrigger, PopoverContent, PopoverAnchor } From 550e72712f538600e82c29338e27e9f81975d504 Mon Sep 17 00:00:00 2001 From: Jeran Date: Wed, 11 Jun 2025 13:13:07 +0200 Subject: [PATCH 3/7] tweaks --- src/components/ui/Navbar.tsx | 93 ++++++++++++++++++++++-------------- src/utils/GlobalStates.ts | 15 +++++- 2 files changed, 72 insertions(+), 36 deletions(-) diff --git a/src/components/ui/Navbar.tsx b/src/components/ui/Navbar.tsx index 05bae9a0..45e8e1f2 100644 --- a/src/components/ui/Navbar.tsx +++ b/src/components/ui/Navbar.tsx @@ -1,9 +1,15 @@ +"use client"; + import Image from "next/image"; import { AboutButton } from "@/components/ui"; import ThemeSwitch from "@/components/ui/ThemeSwitch"; import logo from "@/app/logo.png" import './css/Navbar.css' - +import { useShallow } from "zustand/shallow"; +import { useGlobalStore, usePlotStore } from "@/utils/GlobalStates"; +import { colormaps } from '@/components/textures'; +import { useEffect, useState } from "react"; +import { GetColorMapTexture } from "@/components/textures"; import { Button } from "@/components/ui/button" import { DropdownMenu, @@ -31,6 +37,20 @@ import { } from "@/components/ui/select" const Navbar = () => { + const {setInitStore, setVariable, setColormap} = useGlobalStore( + useShallow(state=>({ + setInitStore : state.setInitStore, + setVariable : state.setVariable, + setColormap : state.setColormap + + }))) + const variables = useGlobalStore(useShallow(state=>state.variables)) + const setPlotType = usePlotStore(state=> state.setPlotType) + const [cmap, setCmap] = useState("viridis") + + // useEffect(()=>{ + // setColormap(GetColorMapTexture(colormap, settings.cmap, 1, "#000000", 0, settings.flipCmap)); + // },[settings.cmap, colormap, settings.flipCmap, setColormap]) return (