diff --git a/src/app/map/[id]/components/inspector/InspectorPanel.tsx b/src/app/map/[id]/components/inspector/InspectorPanel.tsx index b49cfb70f..05bc4a9ef 100644 --- a/src/app/map/[id]/components/inspector/InspectorPanel.tsx +++ b/src/app/map/[id]/components/inspector/InspectorPanel.tsx @@ -1,5 +1,11 @@ import { useQuery } from "@tanstack/react-query"; -import { ArrowLeftIcon, MapPinIcon, TableIcon, XIcon } from "lucide-react"; +import { + ArrowLeftIcon, + MapPinIcon, + SettingsIcon, + TableIcon, + XIcon, +} from "lucide-react"; import { useInspector } from "@/app/map/[id]/hooks/useInspector"; import { useTable } from "@/app/map/[id]/hooks/useTable"; @@ -9,10 +15,15 @@ import { Button } from "@/shadcn/ui/button"; import { cn } from "@/shadcn/utils"; import { LayerType } from "@/types"; import { useMapRef } from "../../hooks/useMapCore"; -import LayerTypeIcon from "../LayerTypeIcon"; import BoundaryMarkersList from "./BoundaryMarkersList"; import PropertiesList from "./PropertiesList"; import TurfMarkersList from "./TurfMarkersList"; +import { + UnderlineTabs, + UnderlineTabsContent, + UnderlineTabsList, + UnderlineTabsTrigger, +} from "./UnderlineTabs"; export default function InspectorPanel() { const { @@ -22,6 +33,7 @@ export default function InspectorPanel() { selectedTurf, focusedRecord, setFocusedRecord, + selectedRecords, } = useInspector(); const mapRef = useMapRef(); const { setSelectedDataSourceId, selectedDataSourceId } = useTable(); @@ -49,6 +61,8 @@ export default function InspectorPanel() { (selectedTurf && type !== LayerType.Turf) || (selectedBoundary && type !== LayerType.Boundary); + const markerCount = selectedRecords?.length || 0; + const onCloseDetailsView = () => { setFocusedRecord(null); }; @@ -65,15 +79,14 @@ export default function InspectorPanel() {
-
+

- - {inspectorContent?.name as string}

+ {recordLoading ? ( + Loading... + ) : ( + )} - {dataSource && ( - + + {(isDetailsView || dataSource) && ( +
+ {isDetailsView && focusedRecord?.geocodePoint && ( + + )} + {dataSource && ( + + )} +
)}
- )} -
+ + + +
+ {type === LayerType.Turf && } + {type === LayerType.Boundary && } +
+
+ + +
+

No notes yet

+
+
+ + +
+

Configuration options

+
+
+
); diff --git a/src/app/map/[id]/components/inspector/UnderlineTabs.tsx b/src/app/map/[id]/components/inspector/UnderlineTabs.tsx new file mode 100644 index 000000000..f46892390 --- /dev/null +++ b/src/app/map/[id]/components/inspector/UnderlineTabs.tsx @@ -0,0 +1,133 @@ +"use client"; + +import * as TabsPrimitive from "@radix-ui/react-tabs"; +import * as React from "react"; + +import { cn } from "@/shadcn/utils"; + +function UnderlineTabs({ + className, + ...props +}: React.ComponentProps) { + return ( + + ); +} + +function UnderlineTabsList({ + className, + ...props +}: React.ComponentProps) { + const [underlineStyle, setUnderlineStyle] = React.useState({ + left: 0, + width: 0, + }); + const listRef = React.useRef(null); + + const updateUnderline = React.useCallback(() => { + if (!listRef.current) return; + + const activeButton = listRef.current.querySelector( + '[data-state="active"]', + ) as HTMLButtonElement; + if (!activeButton) return; + + const listRect = listRef.current.getBoundingClientRect(); + const buttonRect = activeButton.getBoundingClientRect(); + + setUnderlineStyle({ + left: buttonRect.left - listRect.left, + width: buttonRect.width, + }); + }, []); + + React.useEffect(() => { + updateUnderline(); + + // Use MutationObserver to watch for data-state changes + const mutationObserver = new MutationObserver(updateUnderline); + if (listRef.current) { + mutationObserver.observe(listRef.current, { + attributes: true, + attributeFilter: ["data-state"], + subtree: true, + }); + } + + // Also use ResizeObserver for size changes + const resizeObserver = new ResizeObserver(updateUnderline); + if (listRef.current) { + resizeObserver.observe(listRef.current); + } + + window.addEventListener("resize", updateUnderline); + + return () => { + mutationObserver.disconnect(); + resizeObserver.disconnect(); + window.removeEventListener("resize", updateUnderline); + }; + }, [updateUnderline]); + + return ( + + {props.children} +
+ + ); +} + +function UnderlineTabsTrigger({ + className, + ...props +}: React.ComponentProps) { + return ( + + ); +} + +function UnderlineTabsContent({ + className, + ...props +}: React.ComponentProps) { + return ( + + ); +} + +export { + UnderlineTabs, + UnderlineTabsList, + UnderlineTabsTrigger, + UnderlineTabsContent, +};