make component for react like bussiness card
- User
make component for react like bussiness card
Assistant
// BusinessCard.jsx import React from 'react'; import './BusinessCard.css'; // We'll create this next // A tiny placeholder for a profile image const DefaultAvatar = () => ( <svg viewBox="0 0 100 100" className="avatar-fallback"> <circle cx="50" cy="35" r="25" /> <path d="M50 70 C 30 90, 70 90, 50 70" /> </svg> ); const BusinessCard = ({ name, title, company, email, phone, website, address, avatar, // URL to an image theme = 'light', // 'light' | 'dark' onSave, // optional callback fired when user clicks "Save Contact" }) => { const handleSave = () => { // Very naive vCard generator const vcard = `BEGIN:VCARD VERSION:3.0 FN:${name} ORG:${company} TITLE:${title} TEL:${phone} EMAIL:${email} URL:${website} ADR:;;${address};;; END:VCARD`; const blob = new Blob([vcard], { type: 'text/vcard' }); const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = `${name.replace(/\s+/g, '_')}.vcf`; a.click(); URL.revokeObjectURL(url); onSave?.(); }; return ( <div className={`business-card ${theme}`}> <div className="card-header"> {avatar ? ( <img src={avatar} alt={name} className="avatar" /> ) : ( <DefaultAvatar /> )} <div className="name-title"> <h2>{name}</h2> <p>{title}</p> <p className="company">{company}</p> </div> </div> <div className="card-body"> {email && ( <a href={`mailto:${email}`} className="link"> 📧 {email} </a> )} {phone && ( <a href={`tel:${phone}`} className="link"> 📞 {phone} </a> )} {website && ( <a href={website} target="_blank" rel="noopener noreferrer" className="link"> 🌐 {website.replace(/^https?:\/\//, '')} </a> )} {address && <p className="address">📍 {address}</p>} </div> <div className="card-footer"> <button onClick={handleSave} className="save-btn"> Save Contact </button> </div> </div> ); }; export default BusinessCard;