-
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.
- Loading branch information
1 parent
8095eb0
commit 74ef090
Showing
27 changed files
with
1,153 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,6 @@ | |
}, | ||
"aliases": { | ||
"components": "@/components", | ||
"utils": "@/lib/utils" | ||
"utils": "@/lib/classnames" | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,42 @@ | ||
"use client"; | ||
|
||
import { PropsWithChildren, useState } from "react"; | ||
import { PropsWithChildren, useCallback, useState } from "react"; | ||
|
||
import { MapProvider } from "react-map-gl"; | ||
|
||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; | ||
import { RecoilRoot } from "recoil"; | ||
|
||
import { RecoilURLSyncNext } from "@/lib/recoil"; | ||
import type { Deserialize, Serialize } from "@/lib/recoil"; | ||
// import RecoilDevTools from "@/lib/recoil/devtools"; | ||
|
||
import { TooltipProvider } from "@/components/ui/tooltip"; | ||
|
||
export default function LayoutProviders({ children }: PropsWithChildren) { | ||
const [queryClient] = useState(() => new QueryClient()); | ||
const serialize: Serialize = useCallback((x) => { | ||
return x === undefined ? "" : JSON.stringify(x); | ||
}, []); | ||
|
||
//Demo of custom deserialization | ||
const deserialize: Deserialize = useCallback((x: string) => { | ||
return JSON.parse(x); | ||
}, []); | ||
|
||
return ( | ||
<QueryClientProvider client={queryClient}> | ||
<MapProvider> | ||
<TooltipProvider>{children}</TooltipProvider> | ||
</MapProvider> | ||
<RecoilRoot> | ||
<RecoilURLSyncNext | ||
location={{ part: "queryParams" }} | ||
serialize={serialize} | ||
deserialize={deserialize} | ||
> | ||
<MapProvider> | ||
<TooltipProvider>{children}</TooltipProvider> | ||
</MapProvider> | ||
</RecoilURLSyncNext> | ||
</RecoilRoot> | ||
</QueryClientProvider> | ||
); | ||
} |
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,62 @@ | ||
"use client"; | ||
|
||
import { FC, HTMLAttributes, PropsWithChildren } from "react"; | ||
|
||
import { PopoverArrow } from "@radix-ui/react-popover"; | ||
import { TooltipPortal } from "@radix-ui/react-tooltip"; | ||
import { LuSettings } from "react-icons/lu"; | ||
|
||
import { cn } from "@/lib/classnames"; | ||
|
||
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"; | ||
import { Tooltip, TooltipArrow, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip"; | ||
|
||
import { CONTROL_BUTTON_STYLES } from "../constants"; | ||
|
||
interface SettingsControlProps { | ||
className?: HTMLAttributes<HTMLDivElement>["className"]; | ||
} | ||
|
||
export const SettingsControl: FC<PropsWithChildren<SettingsControlProps>> = ({ | ||
className, | ||
children, | ||
}: PropsWithChildren<SettingsControlProps>) => { | ||
return ( | ||
<div className={cn("flex flex-col space-y-0.5", className)}> | ||
<Popover> | ||
<Tooltip> | ||
<PopoverTrigger asChild> | ||
<TooltipTrigger asChild> | ||
<button | ||
className={cn({ | ||
[CONTROL_BUTTON_STYLES.default]: true, | ||
[CONTROL_BUTTON_STYLES.hover]: true, | ||
[CONTROL_BUTTON_STYLES.active]: true, | ||
})} | ||
aria-label="Map settings" | ||
type="button" | ||
> | ||
<LuSettings className="h-full w-full" /> | ||
</button> | ||
</TooltipTrigger> | ||
</PopoverTrigger> | ||
|
||
<TooltipPortal> | ||
<TooltipContent side="left" align="center"> | ||
<div className="text-xxs">Map settings</div> | ||
|
||
<TooltipArrow className="fill-white" width={10} height={5} /> | ||
</TooltipContent> | ||
</TooltipPortal> | ||
|
||
<PopoverContent side="left" align="start"> | ||
{children} | ||
<PopoverArrow className="fill-white" width={10} height={5} /> | ||
</PopoverContent> | ||
</Tooltip> | ||
</Popover> | ||
</div> | ||
); | ||
}; | ||
|
||
export default SettingsControl; |
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,29 @@ | ||
"use client"; | ||
|
||
import * as React from "react"; | ||
|
||
import * as CheckboxPrimitive from "@radix-ui/react-checkbox"; | ||
import { LuCheck } from "react-icons/lu"; | ||
|
||
import { cn } from "@/lib/classnames"; | ||
|
||
const Checkbox = React.forwardRef< | ||
React.ElementRef<typeof CheckboxPrimitive.Root>, | ||
React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root> | ||
>(({ className, ...props }, ref) => ( | ||
<CheckboxPrimitive.Root | ||
ref={ref} | ||
className={cn( | ||
"peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground", | ||
className, | ||
)} | ||
{...props} | ||
> | ||
<CheckboxPrimitive.Indicator className={cn("flex items-center justify-center text-current")}> | ||
<LuCheck className="h-4 w-4" /> | ||
</CheckboxPrimitive.Indicator> | ||
</CheckboxPrimitive.Root> | ||
)); | ||
Checkbox.displayName = CheckboxPrimitive.Root.displayName; | ||
|
||
export { Checkbox }; |
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 @@ | ||
"use client"; | ||
|
||
import * as React from "react"; | ||
|
||
import * as LabelPrimitive from "@radix-ui/react-label"; | ||
import { cva, type VariantProps } from "class-variance-authority"; | ||
|
||
import { cn } from "@/lib/classnames"; | ||
|
||
const labelVariants = cva( | ||
"text-sm font-medium leading-none 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,32 @@ | ||
"use client"; | ||
|
||
import * as React from "react"; | ||
|
||
import * as PopoverPrimitive from "@radix-ui/react-popover"; | ||
|
||
import { cn } from "@/lib/classnames"; | ||
|
||
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 }; |
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,39 @@ | ||
"use client"; | ||
|
||
import * as React from "react"; | ||
|
||
import * as RadioGroupPrimitive from "@radix-ui/react-radio-group"; | ||
import { LuCircle } from "react-icons/lu"; | ||
|
||
import { cn } from "@/lib/classnames"; | ||
|
||
const RadioGroup = React.forwardRef< | ||
React.ElementRef<typeof RadioGroupPrimitive.Root>, | ||
React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Root> | ||
>(({ className, ...props }, ref) => { | ||
return <RadioGroupPrimitive.Root className={cn("grid gap-2", className)} {...props} ref={ref} />; | ||
}); | ||
RadioGroup.displayName = RadioGroupPrimitive.Root.displayName; | ||
|
||
const RadioGroupItem = React.forwardRef< | ||
React.ElementRef<typeof RadioGroupPrimitive.Item>, | ||
React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Item> | ||
>(({ className, ...props }, ref) => { | ||
return ( | ||
<RadioGroupPrimitive.Item | ||
ref={ref} | ||
className={cn( | ||
"aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50", | ||
className, | ||
)} | ||
{...props} | ||
> | ||
<RadioGroupPrimitive.Indicator className="flex items-center justify-center"> | ||
<LuCircle className="h-2.5 w-2.5 fill-current text-current" /> | ||
</RadioGroupPrimitive.Indicator> | ||
</RadioGroupPrimitive.Item> | ||
); | ||
}); | ||
RadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName; | ||
|
||
export { RadioGroup, RadioGroupItem }; |
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
Oops, something went wrong.