mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 00:34:19 +00:00
- Ease popups in with a 2px drift from their anchor and fade them out faster - Fade dialogs and their backdrops in and out - Bring notices, map pills and the lost connection card in with a short rise - Glide the memory, progress, bake and pregen meters to each new reading - Turn all of it off under reduced motion - Drop the animation classes that had no styles behind them
62 lines
2.7 KiB
TypeScript
62 lines
2.7 KiB
TypeScript
import * as React from "react"
|
|
import { cn } from "@/lib/utils"
|
|
import { DropdownMenu as DropdownMenuPrimitive } from "radix-ui"
|
|
import { Glyph } from "@/studio/Glyph"
|
|
|
|
const MENU_SURFACE =
|
|
"z-50 min-w-[8rem] overflow-x-hidden overflow-y-auto popup p-1 popup-motion"
|
|
const MENU_ROW =
|
|
"relative flex cursor-default items-center gap-2 rounded-md px-2 py-1 text-[13px] outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50"
|
|
|
|
function DropdownMenu(props: React.ComponentProps<typeof DropdownMenuPrimitive.Root>) {
|
|
return <DropdownMenuPrimitive.Root data-slot="dropdown-menu" {...props} />
|
|
}
|
|
|
|
function DropdownMenuTrigger(props: React.ComponentProps<typeof DropdownMenuPrimitive.Trigger>) {
|
|
return <DropdownMenuPrimitive.Trigger data-slot="dropdown-menu-trigger" {...props} />
|
|
}
|
|
|
|
function DropdownMenuContent({ className, sideOffset = 2, ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Content>) {
|
|
return (
|
|
<DropdownMenuPrimitive.Portal>
|
|
<DropdownMenuPrimitive.Content
|
|
data-slot="dropdown-menu-content"
|
|
sideOffset={sideOffset}
|
|
className={cn(MENU_SURFACE, "max-h-(--radix-dropdown-menu-content-available-height)", className)}
|
|
{...props}
|
|
/>
|
|
</DropdownMenuPrimitive.Portal>
|
|
)
|
|
}
|
|
|
|
function DropdownMenuItem({ className, ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Item>) {
|
|
return <DropdownMenuPrimitive.Item data-slot="dropdown-menu-item" className={cn(MENU_ROW, className)} {...props} />
|
|
}
|
|
|
|
function DropdownMenuSub(props: React.ComponentProps<typeof DropdownMenuPrimitive.Sub>) {
|
|
return <DropdownMenuPrimitive.Sub data-slot="dropdown-menu-sub" {...props} />
|
|
}
|
|
|
|
function DropdownMenuSubTrigger({ className, children, ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.SubTrigger>) {
|
|
return (
|
|
<DropdownMenuPrimitive.SubTrigger
|
|
data-slot="dropdown-menu-sub-trigger"
|
|
className={cn(MENU_ROW, "data-[state=open]:bg-accent data-[state=open]:text-accent-foreground", className)}
|
|
{...props}
|
|
>
|
|
{children}
|
|
<Glyph glyph="chevronRight" className="ml-auto size-3.5" />
|
|
</DropdownMenuPrimitive.SubTrigger>
|
|
)
|
|
}
|
|
|
|
function DropdownMenuSubContent({ className, ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.SubContent>) {
|
|
return (
|
|
<DropdownMenuPrimitive.Portal>
|
|
<DropdownMenuPrimitive.SubContent data-slot="dropdown-menu-sub-content" className={cn(MENU_SURFACE, className)} {...props} />
|
|
</DropdownMenuPrimitive.Portal>
|
|
)
|
|
}
|
|
|
|
export { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem, DropdownMenuSub, DropdownMenuSubTrigger, DropdownMenuSubContent }
|