/** * Template: Glassmorphism UI Kit * * Reusable glassmorphic components for premium dark interfaces. * Features: Cards, buttons, inputs, badges, modals, navigation */ import React, { forwardRef, HTMLAttributes, InputHTMLAttributes, ButtonHTMLAttributes } from 'react'; import { motion, HTMLMotionProps } from 'framer-motion'; // ============================================================================= // TYPES // ============================================================================= interface GlassProps { blur?: 'sm' | 'md' | 'lg' | 'xl'; opacity?: number; border?: boolean; glow?: string; hoverGlow?: boolean; } interface GlassCardProps extends HTMLMotionProps<'div'>, GlassProps { children: React.ReactNode; } interface GlassButtonProps extends ButtonHTMLAttributes, GlassProps { variant?: 'default' | 'primary' | 'ghost'; size?: 'sm' | 'md' | 'lg'; loading?: boolean; icon?: React.ReactNode; } interface GlassInputProps extends InputHTMLAttributes { label?: string; error?: string; icon?: React.ReactNode; } interface GlassBadgeProps { children: React.ReactNode; variant?: 'default' | 'success' | 'warning' | 'error' | 'info'; pulse?: boolean; icon?: React.ReactNode; } interface GlassModalProps { isOpen: boolean; onClose: () => void; title?: string; children: React.ReactNode; size?: 'sm' | 'md' | 'lg' | 'xl'; } // ============================================================================= // CONSTANTS // ============================================================================= const BLUR_VALUES = { sm: '8px', md: '12px', lg: '16px', xl: '24px', }; const COLORS = { glass: 'rgba(255,255,255,0.05)', border: 'rgba(255,255,255,0.1)', borderHover: 'rgba(255,255,255,0.2)', text: '#ffffff', textMuted: '#a1a1aa', primary: '#ff4d00', success: '#22c55e', warning: '#eab308', error: '#ef4444', info: '#00f3ff', }; // ============================================================================= // GLASS CARD // ============================================================================= export const GlassCard = forwardRef( ( { children, blur = 'md', opacity = 0.05, border = true, glow, hoverGlow = false, className = '', style, ...props }, ref ) => { const baseStyles: React.CSSProperties = { background: `rgba(255,255,255,${opacity})`, backdropFilter: `blur(${BLUR_VALUES[blur]})`, WebkitBackdropFilter: `blur(${BLUR_VALUES[blur]})`, border: border ? `1px solid ${COLORS.border}` : 'none', boxShadow: glow ? `0 0 30px ${glow}30` : undefined, ...style, }; return ( {children} ); } ); GlassCard.displayName = 'GlassCard'; // ============================================================================= // GLASS BUTTON // ============================================================================= export const GlassButton = forwardRef( ( { children, variant = 'default', size = 'md', loading = false, icon, blur = 'md', className = '', disabled, ...props }, ref ) => { const sizeClasses = { sm: 'px-3 py-1.5 text-sm', md: 'px-4 py-2', lg: 'px-6 py-3 text-lg', }; const variantStyles = { default: { background: COLORS.glass, border: `1px solid ${COLORS.border}`, color: COLORS.text, }, primary: { background: COLORS.primary, border: 'none', color: '#000000', boxShadow: `0 0 20px ${COLORS.primary}50`, }, ghost: { background: 'transparent', border: 'none', color: COLORS.text, }, }; return ( ); } ); GlassButton.displayName = 'GlassButton'; // ============================================================================= // GLASS INPUT // ============================================================================= export const GlassInput = forwardRef( ({ label, error, icon, className = '', ...props }, ref) => { return (
{label && ( )}
{icon && (
{icon}
)}
{error &&

{error}

}
); } ); GlassInput.displayName = 'GlassInput'; // ============================================================================= // GLASS BADGE // ============================================================================= export const GlassBadge: React.FC = ({ children, variant = 'default', pulse = false, icon, }) => { const variantColors = { default: COLORS.primary, success: COLORS.success, warning: COLORS.warning, error: COLORS.error, info: COLORS.info, }; const color = variantColors[variant]; return ( {pulse && ( )} {icon} {children} ); }; // ============================================================================= // GLASS MODAL // ============================================================================= export const GlassModal: React.FC = ({ isOpen, onClose, title, children, size = 'md', }) => { const sizeClasses = { sm: 'max-w-sm', md: 'max-w-md', lg: 'max-w-lg', xl: 'max-w-xl', }; if (!isOpen) return null; return ( e.stopPropagation()} > {title && (

{title}

)} {children}
); }; // ============================================================================= // GLASS NAVBAR // ============================================================================= interface NavItem { id: string; label: string; icon?: React.ReactNode; } interface GlassNavbarProps { items: NavItem[]; activeId: string; onNavigate: (id: string) => void; logo?: React.ReactNode; actions?: React.ReactNode; } export const GlassNavbar: React.FC = ({ items, activeId, onNavigate, logo, actions, }) => { return ( ); }; // ============================================================================= // GLASS TOOLTIP // ============================================================================= interface GlassTooltipProps { content: string; children: React.ReactNode; position?: 'top' | 'bottom' | 'left' | 'right'; } export const GlassTooltip: React.FC = ({ content, children, position = 'top', }) => { const positionClasses = { top: 'bottom-full left-1/2 -translate-x-1/2 mb-2', bottom: 'top-full left-1/2 -translate-x-1/2 mt-2', left: 'right-full top-1/2 -translate-y-1/2 mr-2', right: 'left-full top-1/2 -translate-y-1/2 ml-2', }; return (
{children}
{content}
); }; // ============================================================================= // USAGE EXAMPLES // ============================================================================= /* // Card Example

Card Title

Card content here

// Button Examples Get Started }> With Icon // Input Example // Badge Example System Online // Modal Example setIsOpen(false)} title="Modal Title" size="md" >

Modal content here

// Navbar Example } actions={Sign Up} /> */ export default { GlassCard, GlassButton, GlassInput, GlassBadge, GlassModal, GlassNavbar, GlassTooltip, };