import { Component, Prop, Event, EventEmitter, h } from '@stencil/core'; import { Product } from '../../classes/product'; import { formatCurrency } from '../../classes/helpers'; @Component({ tag: 'product-card', styleUrl: 'product-card.css', scoped: true, }) export class ProductCard { @Prop() product: Product; @Event() productChanged: EventEmitter; onQuantityChange = (event: CustomEvent) => { this.product.quantity = event.detail; this.productChanged.emit(this.product); }; renderPremium() { if (this.product.isPremium) { return ( Premium cut ); } } render() { return (
{this.product.name} {this.renderPremium()}
{this.product.name}
{formatCurrency(this.product.price)}
{this.product.description}
); } }