VirtualBusinessCardGenerator

InfoGenerateCreated ByPackages

The provided code defines a `VirtualBusinessCard` class in TypeScript/JavaScript that models a virtual business card for individuals, capturing their name, title, company, and email. The class has a constructor that initializes these properties and a `template()` method that returns an HTML string template. This template generates a styled virtual business card with the individual's name, title, company, and email as contact information, formatted in a card layout. The example usage demonstrates creating an instance of `VirtualBusinessCard` with sample data and logging the generated HTML template to the console.

class VirtualBusinessCard {
  constructor(public name: string, public title: string, public company: string, public email: string) {}

  template(): string {
    return `
      <div class="card w-96 bg-base-100 shadow-xl">
        <div class="card-body">
          <h2 class="card-title">${this.name}</h2>
          <p><strong>${this.title}</strong> at <em>${this.company}</em></p>
          <p>Contact: <a href="mailto:${this.email}">${this.email}</a></p>
        </div>
      </div>
    `;
  }
}

// Example usage:
const myCard = new VirtualBusinessCard(
  'John Doe',
  'Software Engineer',
  'Tech Company',
  '[email protected]'
);

console.log(myCard.template());