Skip to content

Commit

Permalink
added toogle legend
Browse files Browse the repository at this point in the history
  • Loading branch information
davidsingal committed Mar 6, 2024
1 parent c1c5681 commit c72deff
Show file tree
Hide file tree
Showing 6 changed files with 489 additions and 1 deletion.
2 changes: 2 additions & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@
"@loaders.gl/core": "3.3.1",
"@luma.gl/constants": "8.5.18",
"@radix-ui/react-collapsible": "1.0.3",
"@radix-ui/react-dropdown-menu": "^2.0.6",
"@radix-ui/react-label": "2.0.2",
"@radix-ui/react-popover": "^1.0.7",
"@radix-ui/react-radio-group": "1.1.3",
"@reduxjs/toolkit": "1.8.2",
"@tailwindcss/forms": "0.4.0",
Expand Down
29 changes: 29 additions & 0 deletions client/src/components/ui/popover.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import * as React from "react"
import * as PopoverPrimitive from "@radix-ui/react-popover"

import { cn } from "@/lib/utils"

const Popover = PopoverPrimitive.Root

const PopoverTrigger = PopoverPrimitive.Trigger

const PopoverContent = React.forwardRef<
React.ElementRef<typeof PopoverPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content>
>(({ className, align = "center", sideOffset = 4, ...props }, ref) => (
<PopoverPrimitive.Portal>
<PopoverPrimitive.Content
ref={ref}
align={align}
sideOffset={sideOffset}
className={cn(
"z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
className
)}
{...props}
/>
</PopoverPrimitive.Portal>
))
PopoverContent.displayName = PopoverPrimitive.Content.displayName

export { Popover, PopoverTrigger, PopoverContent }
2 changes: 2 additions & 0 deletions client/src/containers/analysis-eudr/map/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Map from 'react-map-gl/maplibre';
import { type MapViewState } from '@deck.gl/core/typed';

import ZoomControl from './zoom';
import LegendControl from './legend';

import BasemapControl from '@/components/map/controls/basemap';
import { INITIAL_VIEW_STATE, MAP_STYLES } from '@/components/map';
Expand Down Expand Up @@ -58,6 +59,7 @@ const EUDRMap = () => {
<div className="absolute bottom-10 right-6 z-10 w-10 space-y-2">
<BasemapControl value={mapStyle} onChange={handleMapStyleChange} />
<ZoomControl viewState={viewState} onZoomIn={handleZoomIn} onZoomOut={handleZoomOut} />
<LegendControl />
</div>
</>
);
Expand Down
31 changes: 31 additions & 0 deletions client/src/containers/analysis-eudr/map/legend/component.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { useState } from 'react';
import classNames from 'classnames';

import SandwichIcon from 'components/icons/sandwich';
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';

const EURDLegend = () => {
const [isOpen, setIsOpen] = useState(false);

return (
<div>
<Popover open={isOpen} onOpenChange={setIsOpen}>
<PopoverTrigger asChild>
<button
type="button"
className={classNames(
'relative flex h-10 w-10 items-center justify-center rounded-lg bg-white p-1.5 text-black transition-colors hover:text-navy-400',
)}
>
<SandwichIcon />
</button>
</PopoverTrigger>
<PopoverContent align="end" side="left">
Place content for the popover here.
</PopoverContent>
</Popover>
</div>
);
};

export default EURDLegend;
1 change: 1 addition & 0 deletions client/src/containers/analysis-eudr/map/legend/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './component';
Loading

0 comments on commit c72deff

Please sign in to comment.