CoolFace
Apppublic

FLASHback1/bingo

sourceHugging Facemitupdated 3y agoView on Hugging Face
0likes
dropdown-menu.tsx129 linesDownload Raw Back to ui
1'use client'2 3import * as React from 'react'4import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu'5 6import { cn } from '@/lib/utils'7 8const DropdownMenu = DropdownMenuPrimitive.Root9 10const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger11 12const DropdownMenuGroup = DropdownMenuPrimitive.Group13 14const DropdownMenuPortal = DropdownMenuPrimitive.Portal15 16const DropdownMenuSub = DropdownMenuPrimitive.Sub17 18const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup19 20const DropdownMenuSubContent = React.forwardRef<21  React.ElementRef<typeof DropdownMenuPrimitive.SubContent>,22  React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubContent>23>(({ className, ...props }, ref) => (24  <DropdownMenuPrimitive.SubContent25    ref={ref}26    className={cn(27      'z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md animate-in data-[side=bottom]:slide-in-from-top-1 data-[side=left]:slide-in-from-right-1 data-[side=right]:slide-in-from-left-1 data-[side=top]:slide-in-from-bottom-1',28      className29    )}30    {...props}31  />32))33DropdownMenuSubContent.displayName =34  DropdownMenuPrimitive.SubContent.displayName35 36const DropdownMenuContent = React.forwardRef<37  React.ElementRef<typeof DropdownMenuPrimitive.Content>,38  React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content>39>(({ className, sideOffset = 4, ...props }, ref) => (40  <DropdownMenuPrimitive.Portal>41    <DropdownMenuPrimitive.Content42      ref={ref}43      sideOffset={sideOffset}44      className={cn(45        'z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow animate-in 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',46        className47      )}48      {...props}49    />50  </DropdownMenuPrimitive.Portal>51))52DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName53 54const DropdownMenuItem = React.forwardRef<55  React.ElementRef<typeof DropdownMenuPrimitive.Item>,56  React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & {57    inset?: boolean58  }59>(({ className, inset, ...props }, ref) => (60  <DropdownMenuPrimitive.Item61    ref={ref}62    className={cn(63      'relative flex cursor-default select-none items-center 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',64      inset && 'pl-8',65      className66    )}67    {...props}68  />69))70DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName71 72const DropdownMenuLabel = React.forwardRef<73  React.ElementRef<typeof DropdownMenuPrimitive.Label>,74  React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label> & {75    inset?: boolean76  }77>(({ className, inset, ...props }, ref) => (78  <DropdownMenuPrimitive.Label79    ref={ref}80    className={cn(81      'px-2 py-1.5 text-sm font-semibold',82      inset && 'pl-8',83      className84    )}85    {...props}86  />87))88DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName89 90const DropdownMenuSeparator = React.forwardRef<91  React.ElementRef<typeof DropdownMenuPrimitive.Separator>,92  React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator>93>(({ className, ...props }, ref) => (94  <DropdownMenuPrimitive.Separator95    ref={ref}96    className={cn('-mx-1 my-1 h-px bg-muted', className)}97    {...props}98  />99))100DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName101 102const DropdownMenuShortcut = ({103  className,104  ...props105}: React.HTMLAttributes<HTMLSpanElement>) => {106  return (107    <span108      className={cn('ml-auto text-xs tracking-widest opacity-60', className)}109      {...props}110    />111  )112}113DropdownMenuShortcut.displayName = 'DropdownMenuShortcut'114 115export {116  DropdownMenu,117  DropdownMenuTrigger,118  DropdownMenuContent,119  DropdownMenuItem,120  DropdownMenuLabel,121  DropdownMenuSeparator,122  DropdownMenuShortcut,123  DropdownMenuGroup,124  DropdownMenuPortal,125  DropdownMenuSub,126  DropdownMenuSubContent,127  DropdownMenuRadioGroup128}129