Files
legolog/client/public/components/compact-listing.mjs
Benjamin Kyd 362f5cf048 navbar improvements and mroe responsive on mobile
Former-commit-id: e9ccecbc5798c3bf0c0987a08b0ad4a71688f9e1
2022-03-26 14:03:49 +00:00

86 lines
2.8 KiB
JavaScript

import { RegisterComponent, Component } from './components.mjs';
class CompactProductListing extends Component {
static __IDENTIFY() { return 'compact-listing'; }
constructor() {
super(CompactProductListing);
}
Render() {
console.log(this.state);
return {
template: `
<div class="product-listing">
<div class="product-listing-image">
<img class="product-image" src="{this.state.image}">
</div>
<div class="product-listing-info">
<div class="product-listing-name">{this.state.name}</div>
${this.state.discount
? '<span class="product-listing-price-full">£{this.state.price}</span><span class="product-listing-price-new">£{this.state.discount}</span>'
: '<span class="product-listing-price">£{this.state.price}</span>'}
</div>
</div>
`,
style: `
.product-listing {
display: flex;
flex-direction: column;
margin: 7px;
max-width: 320px;
}
.product-listing-image {
display: block;
margin: 0 auto;
max-width: 100%;
}
.product-listing-info {
display: flex;
align-items: flex-start;
flex-direction: column;
max-width: 100%;
}
.product-listing-name {
font-size: 1.2em;
font-weight: bold;
}
.product-listing-price {
font-size: 1.1em;
}
.product-listing-price-full {
text-decoration: line-through;
font-size: 0.9em;
}
.product-listing-price-new {
font-weight: bold;
color: red;
font-size: 1.1em;
}
@media (pointer:none), (pointer:coarse), screen and (max-width: 900px) {
.product-listing {
margin: 3px;
width: 400px;
}
.product-listing-image {
display: block;
}
.product-image {
max-width: 100%;
max-height: 100%;
}
}
`,
};
}
OnceRendered() {
}
}
RegisterComponent(CompactProductListing);