A very performant and light (2mb in memory) link shortener and tracker. Written in Rust and React and uses Postgres/SQLite.
at master 7.4 kB view raw
1import * as React from "react" 2import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu" 3import { Check, ChevronRight, Circle } from "lucide-react" 4 5import { cn } from "@/lib/utils" 6 7const DropdownMenu = DropdownMenuPrimitive.Root 8 9const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger 10 11const DropdownMenuGroup = DropdownMenuPrimitive.Group 12 13const DropdownMenuPortal = DropdownMenuPrimitive.Portal 14 15const DropdownMenuSub = DropdownMenuPrimitive.Sub 16 17const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup 18 19const DropdownMenuSubTrigger = React.forwardRef< 20 React.ElementRef<typeof DropdownMenuPrimitive.SubTrigger>, 21 React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubTrigger> & { 22 inset?: boolean 23 } 24>(({ className, inset, children, ...props }, ref) => ( 25 <DropdownMenuPrimitive.SubTrigger 26 ref={ref} 27 className={cn( 28 "flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0", 29 inset && "pl-8", 30 className 31 )} 32 {...props} 33 > 34 {children} 35 <ChevronRight className="ml-auto" /> 36 </DropdownMenuPrimitive.SubTrigger> 37)) 38DropdownMenuSubTrigger.displayName = 39 DropdownMenuPrimitive.SubTrigger.displayName 40 41const DropdownMenuSubContent = React.forwardRef< 42 React.ElementRef<typeof DropdownMenuPrimitive.SubContent>, 43 React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubContent> 44>(({ className, ...props }, ref) => ( 45 <DropdownMenuPrimitive.SubContent 46 ref={ref} 47 className={cn( 48 "z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg 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", 49 className 50 )} 51 {...props} 52 /> 53)) 54DropdownMenuSubContent.displayName = 55 DropdownMenuPrimitive.SubContent.displayName 56 57const DropdownMenuContent = React.forwardRef< 58 React.ElementRef<typeof DropdownMenuPrimitive.Content>, 59 React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content> 60>(({ className, sideOffset = 4, ...props }, ref) => ( 61 <DropdownMenuPrimitive.Portal> 62 <DropdownMenuPrimitive.Content 63 ref={ref} 64 sideOffset={sideOffset} 65 className={cn( 66 "z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md", 67 "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", 68 className 69 )} 70 {...props} 71 /> 72 </DropdownMenuPrimitive.Portal> 73)) 74DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName 75 76const DropdownMenuItem = React.forwardRef< 77 React.ElementRef<typeof DropdownMenuPrimitive.Item>, 78 React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & { 79 inset?: boolean 80 } 81>(({ className, inset, ...props }, ref) => ( 82 <DropdownMenuPrimitive.Item 83 ref={ref} 84 className={cn( 85 "relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>svg]:size-4 [&>svg]:shrink-0", 86 inset && "pl-8", 87 className 88 )} 89 {...props} 90 /> 91)) 92DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName 93 94const DropdownMenuCheckboxItem = React.forwardRef< 95 React.ElementRef<typeof DropdownMenuPrimitive.CheckboxItem>, 96 React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.CheckboxItem> 97>(({ className, children, checked, ...props }, ref) => ( 98 <DropdownMenuPrimitive.CheckboxItem 99 ref={ref} 100 className={cn( 101 "relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50", 102 className 103 )} 104 checked={checked} 105 {...props} 106 > 107 <span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center"> 108 <DropdownMenuPrimitive.ItemIndicator> 109 <Check className="h-4 w-4" /> 110 </DropdownMenuPrimitive.ItemIndicator> 111 </span> 112 {children} 113 </DropdownMenuPrimitive.CheckboxItem> 114)) 115DropdownMenuCheckboxItem.displayName = 116 DropdownMenuPrimitive.CheckboxItem.displayName 117 118const DropdownMenuRadioItem = React.forwardRef< 119 React.ElementRef<typeof DropdownMenuPrimitive.RadioItem>, 120 React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.RadioItem> 121>(({ className, children, ...props }, ref) => ( 122 <DropdownMenuPrimitive.RadioItem 123 ref={ref} 124 className={cn( 125 "relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50", 126 className 127 )} 128 {...props} 129 > 130 <span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center"> 131 <DropdownMenuPrimitive.ItemIndicator> 132 <Circle className="h-2 w-2 fill-current" /> 133 </DropdownMenuPrimitive.ItemIndicator> 134 </span> 135 {children} 136 </DropdownMenuPrimitive.RadioItem> 137)) 138DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName 139 140const DropdownMenuLabel = React.forwardRef< 141 React.ElementRef<typeof DropdownMenuPrimitive.Label>, 142 React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label> & { 143 inset?: boolean 144 } 145>(({ className, inset, ...props }, ref) => ( 146 <DropdownMenuPrimitive.Label 147 ref={ref} 148 className={cn( 149 "px-2 py-1.5 text-sm font-semibold", 150 inset && "pl-8", 151 className 152 )} 153 {...props} 154 /> 155)) 156DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName 157 158const DropdownMenuSeparator = React.forwardRef< 159 React.ElementRef<typeof DropdownMenuPrimitive.Separator>, 160 React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator> 161>(({ className, ...props }, ref) => ( 162 <DropdownMenuPrimitive.Separator 163 ref={ref} 164 className={cn("-mx-1 my-1 h-px bg-muted", className)} 165 {...props} 166 /> 167)) 168DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName 169 170const DropdownMenuShortcut = ({ 171 className, 172 ...props 173}: React.HTMLAttributes<HTMLSpanElement>) => { 174 return ( 175 <span 176 className={cn("ml-auto text-xs tracking-widest opacity-60", className)} 177 {...props} 178 /> 179 ) 180} 181DropdownMenuShortcut.displayName = "DropdownMenuShortcut" 182 183export { 184 DropdownMenu, 185 DropdownMenuTrigger, 186 DropdownMenuContent, 187 DropdownMenuItem, 188 DropdownMenuCheckboxItem, 189 DropdownMenuRadioItem, 190 DropdownMenuLabel, 191 DropdownMenuSeparator, 192 DropdownMenuShortcut, 193 DropdownMenuGroup, 194 DropdownMenuPortal, 195 DropdownMenuSub, 196 DropdownMenuSubContent, 197 DropdownMenuSubTrigger, 198 DropdownMenuRadioGroup, 199}