-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from Vizzuality/SS-46-basemap-with-settings-ce…
…ntred-on-south-sudan Add map settings
- Loading branch information
Showing
24 changed files
with
545 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import MapSettingsControls from "./map-settings"; | ||
import ZoomControls from "./zoom"; | ||
|
||
const Controls = () => { | ||
return ( | ||
<div className="absolute bottom-10 right-5 z-10 flex flex-col gap-2 xl:bottom-6 xl:right-10"> | ||
<ZoomControls /> | ||
<MapSettingsControls /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Controls; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import MapSettingsPanel from "@/components/panels/map-settings"; | ||
import { Button } from "@/components/ui/button"; | ||
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"; | ||
import GlobeIcon from "@/svgs/globe.svg"; | ||
|
||
const MapSettingsControls = () => { | ||
return ( | ||
<Popover> | ||
<PopoverTrigger asChild> | ||
<Button type="button" variant="yellow" size="icon"> | ||
<span className="sr-only">Map settings</span> | ||
<GlobeIcon aria-hidden /> | ||
</Button> | ||
</PopoverTrigger> | ||
<PopoverContent side="left" align="end" className="w-[250px]"> | ||
<MapSettingsPanel /> | ||
</PopoverContent> | ||
</Popover> | ||
); | ||
}; | ||
|
||
export default MapSettingsControls; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export enum BasemapStyle { | ||
Light = "light", | ||
Dark = "dark", | ||
Satellite = "satellite", | ||
} | ||
|
||
export enum LabelsStyle { | ||
Dark = "dark", | ||
Light = "light", | ||
NoLabels = "", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import Image from "next/image"; | ||
|
||
import { BASEMAPS, LABELS } from "@/components/map/constants"; | ||
import { BasemapStyle, LabelsStyle } from "@/components/map/types"; | ||
import { Label } from "@/components/ui/label"; | ||
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"; | ||
import useMapBasemap from "@/hooks/use-map-basemap"; | ||
import useMapLabels from "@/hooks/use-map-labels"; | ||
import GlobeFilledIcon from "@/svgs/globe-filled.svg"; | ||
|
||
const MapSettingsPanel = () => { | ||
const [basemap, setBasemap] = useMapBasemap(); | ||
const [labels, setLabels] = useMapLabels(); | ||
|
||
return ( | ||
<div className="pb-4 pt-1.5"> | ||
<fieldset className="border-b border-b-casper-blue-400 px-4 pb-3"> | ||
<legend className="flex items-center gap-1.5 text-sm leading-[26px]"> | ||
<GlobeFilledIcon className="shrink-0" /> | ||
Map style | ||
</legend> | ||
<RadioGroup | ||
value={basemap} | ||
onValueChange={(value) => setBasemap(value as BasemapStyle)} | ||
className="mt-2 flex flex-col gap-2" | ||
> | ||
{Object.entries(BASEMAPS).map(([key, { name, image }]) => ( | ||
<div key={key} className="flex items-center gap-1 py-1"> | ||
<RadioGroupItem | ||
variant="icon" | ||
size="icon" | ||
value={key} | ||
id={`basemap-${key}`} | ||
className="shrink-0" | ||
> | ||
<Image src={image} width={20} height={20} alt="" className="rounded-full" /> | ||
</RadioGroupItem> | ||
<Label | ||
htmlFor={`basemap-${key}`} | ||
className="text-sm peer-hover:font-medium peer-hover:underline peer-focus-visible:font-medium peer-focus-visible:underline" | ||
> | ||
{name} | ||
</Label> | ||
</div> | ||
))} | ||
</RadioGroup> | ||
</fieldset> | ||
<fieldset className="mt-2 px-4"> | ||
<legend className="text-xs leading-6">Labels</legend> | ||
<RadioGroup | ||
value={labels} | ||
onValueChange={(value) => setLabels(value as LabelsStyle)} | ||
className="mt-1 flex items-center gap-6" | ||
> | ||
{Object.entries(LABELS).map(([key, { name }]) => ( | ||
<div key={key} className="flex items-center gap-2"> | ||
<RadioGroupItem value={key} id={`labels-${key}`} className="shrink-0" /> | ||
<Label htmlFor={`labels-${key}`} className="text-xs"> | ||
{name} | ||
</Label> | ||
</div> | ||
))} | ||
</RadioGroup> | ||
</fieldset> | ||
</div> | ||
); | ||
}; | ||
|
||
export default MapSettingsPanel; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
"use client"; | ||
|
||
import * as LabelPrimitive from "@radix-ui/react-label"; | ||
import { cva, type VariantProps } from "class-variance-authority"; | ||
import * as React from "react"; | ||
|
||
import { cn } from "@/lib/utils"; | ||
|
||
const labelVariants = cva("peer-disabled:cursor-not-allowed peer-disabled:opacity-70"); | ||
|
||
const Label = React.forwardRef< | ||
React.ElementRef<typeof LabelPrimitive.Root>, | ||
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> & VariantProps<typeof labelVariants> | ||
>(({ className, ...props }, ref) => ( | ||
<LabelPrimitive.Root ref={ref} className={cn(labelVariants(), className)} {...props} /> | ||
)); | ||
Label.displayName = LabelPrimitive.Root.displayName; | ||
|
||
export { Label }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
"use client"; | ||
|
||
import * as PopoverPrimitive from "@radix-ui/react-popover"; | ||
import * as React from "react"; | ||
|
||
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 = 26, ...props }, ref) => ( | ||
<PopoverPrimitive.Portal> | ||
<PopoverPrimitive.Content | ||
ref={ref} | ||
align={align} | ||
sideOffset={sideOffset} | ||
className={cn( | ||
"z-10 bg-white outline-none duration-500 ease-out 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 }; |
Oops, something went wrong.