{ "$schema": "https://ui.shadcn.com/schema/registry-item.json", "name": "native-avatar-expand-shadcnui", "type": "registry:component", "title": "Native Avatar Expand", "description": "Avatar component that expands to reveal the name on click with smooth animations.", "dependencies": [ "framer-motion", "react" ], "files": [ { "path": "@uitripled/react-shadcn/src/components/native/native-avatar-expand-shadcnui.tsx", "content": "\"use client\";\n\nimport { Avatar, AvatarFallback, AvatarImage } from \"@/components/ui/avatar\";\nimport { cn } from \"@/lib/utils\";\nimport { AnimatePresence, motion, MotionConfig } from \"framer-motion\";\nimport { useState } from \"react\";\n\nexport interface NativeAvatarExpandProps {\n /**\n * URL of the avatar image\n */\n src?: string;\n /**\n * Name of the person or entity\n */\n name: string;\n /**\n * Size variant\n * @default \"md\"\n */\n size?: \"sm\" | \"md\" | \"lg\" | \"xl\";\n /**\n * Additional classes for the container\n */\n className?: string;\n /**\n * Additional classes for the avatar\n */\n avatarClassName?: string;\n /**\n * Additional classes for the name text\n */\n nameClassName?: string;\n}\n\nconst sizeConfig = {\n sm: {\n avatar: \"h-10 w-10\",\n text: \"text-sm\",\n },\n md: {\n avatar: \"h-12 w-12\",\n text: \"text-base\",\n },\n lg: {\n avatar: \"h-16 w-16\",\n text: \"text-lg\",\n },\n xl: {\n avatar: \"h-20 w-20\",\n text: \"text-xl\",\n },\n};\n\nexport function NativeAvatarExpand({\n src,\n name,\n size = \"md\",\n className,\n avatarClassName,\n nameClassName,\n}: NativeAvatarExpandProps) {\n const [isExpanded, setIsExpanded] = useState(false);\n const { avatar, text } = sizeConfig[size];\n\n const getInitials = (name: string) => {\n return name\n .split(\" \")\n .filter(Boolean)\n .map((n) => n[0])\n .join(\"\")\n .toUpperCase()\n .slice(0, 2);\n };\n\n return (\n \n setIsExpanded(!isExpanded)}\n >\n \n \n \n {getInitials(name)}\n \n \n \n\n \n {isExpanded && (\n \n \n {name}\n \n \n )}\n \n \n \n );\n}\n", "type": "registry:component", "target": "components/uitripled/native-avatar-expand-shadcnui.tsx" } ] }