Download apps/web/src/components/ui/index.tsx from myagent10101/codesync-collaborative-platform: direct link, hf CLI and curl.
- Browser
- Download file 5.08 kB
-
https://huggingface.co/myagent10101/codesync-collaborative-platform/resolve/main/apps/web/src/components/ui/index.tsx
- Command line
-
hf download hf://myagent10101/codesync-collaborative-platform/apps/web/src/components/ui/index.tsx
-
curl -L -o index.tsx https://huggingface.co/myagent10101/codesync-collaborative-platform/resolve/main/apps/web/src/components/ui/index.tsx
5.08 kB
| // βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| // UI Components β Reusable UI primitives | |
| // βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| 'use client'; | |
| import { forwardRef, type ButtonHTMLAttributes, type InputHTMLAttributes } from 'react'; | |
| import { cn } from '../../lib/utils'; | |
| // βββ Button ββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> { | |
| variant?: 'primary' | 'secondary' | 'ghost' | 'danger'; | |
| size?: 'sm' | 'md' | 'lg'; | |
| } | |
| export const Button = forwardRef<HTMLButtonElement, ButtonProps>( | |
| ({ className, variant = 'primary', size = 'md', ...props }, ref) => { | |
| const variants = { | |
| primary: 'bg-editor-accent hover:bg-editor-accent-hover text-white', | |
| secondary: 'bg-editor-surface hover:bg-editor-hover text-editor-text border border-editor-border', | |
| ghost: 'hover:bg-editor-hover text-editor-text-muted hover:text-editor-text', | |
| danger: 'bg-editor-error hover:bg-red-600 text-white', | |
| }; | |
| const sizes = { | |
| sm: 'px-2.5 py-1 text-xs', | |
| md: 'px-4 py-2 text-sm', | |
| lg: 'px-6 py-2.5 text-base', | |
| }; | |
| return ( | |
| <button | |
| ref={ref} | |
| className={cn( | |
| 'inline-flex items-center justify-center rounded-md font-medium transition-colors focus-ring disabled:opacity-50 disabled:pointer-events-none', | |
| variants[variant], | |
| sizes[size], | |
| className | |
| )} | |
| {...props} | |
| /> | |
| ); | |
| } | |
| ); | |
| Button.displayName = 'Button'; | |
| // βββ Input βββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| export const Input = forwardRef<HTMLInputElement, InputHTMLAttributes<HTMLInputElement>>( | |
| ({ className, ...props }, ref) => ( | |
| <input | |
| ref={ref} | |
| className={cn('input-field w-full', className)} | |
| {...props} | |
| /> | |
| ) | |
| ); | |
| Input.displayName = 'Input'; | |
| // βββ Skeleton ββββββββββββββββββββββββββββββββββββββββββββββββ | |
| export function Skeleton({ className }: { className?: string }) { | |
| return ( | |
| <div className={cn('animate-pulse rounded bg-editor-hover', className)} /> | |
| ); | |
| } | |
| // βββ Badge βββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| interface BadgeProps { | |
| children: React.ReactNode; | |
| variant?: 'default' | 'success' | 'warning' | 'error'; | |
| className?: string; | |
| } | |
| export function Badge({ children, variant = 'default', className }: BadgeProps) { | |
| const variants = { | |
| default: 'bg-editor-hover text-editor-text-muted', | |
| success: 'bg-editor-success/10 text-editor-success', | |
| warning: 'bg-editor-warning/10 text-editor-warning', | |
| error: 'bg-editor-error/10 text-editor-error', | |
| }; | |
| return ( | |
| <span | |
| className={cn( | |
| 'inline-flex items-center rounded-full px-2 py-0.5 text-[10px] font-medium', | |
| variants[variant], | |
| className | |
| )} | |
| > | |
| {children} | |
| </span> | |
| ); | |
| } | |
| // βββ Modal βββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| interface ModalProps { | |
| isOpen: boolean; | |
| onClose: () => void; | |
| title: string; | |
| children: React.ReactNode; | |
| } | |
| export function Modal({ isOpen, onClose, title, children }: ModalProps) { | |
| if (!isOpen) return null; | |
| return ( | |
| <div className="fixed inset-0 z-50 flex items-center justify-center"> | |
| <div className="absolute inset-0 bg-black/60 backdrop-blur-sm" onClick={onClose} /> | |
| <div className="relative w-full max-w-md rounded-lg border border-editor-border bg-editor-surface p-6 shadow-xl animate-fade-in"> | |
| <h2 className="text-lg font-bold mb-4">{title}</h2> | |
| {children} | |
| </div> | |
| </div> | |
| ); | |
| } | |
| // βββ Tooltip βββββββββββββββββββββββββββββββββββββββββββββββββ | |
| interface TooltipProps { | |
| children: React.ReactNode; | |
| content: string; | |
| } | |
| export function Tooltip({ children, content }: TooltipProps) { | |
| return ( | |
| <div className="group relative inline-flex"> | |
| {children} | |
| <div className="pointer-events-none absolute -top-8 left-1/2 -translate-x-1/2 opacity-0 transition-opacity group-hover:opacity-100"> | |
| <div className="rounded bg-editor-bg border border-editor-border px-2 py-1 text-[10px] text-editor-text whitespace-nowrap shadow-lg"> | |
| {content} | |
| </div> | |
| </div> | |
| </div> | |
| ); | |
| } | |