dees-catalog/ts_web/elements/dees-input-quantityselector.ts

86 lines
1.9 KiB
TypeScript
Raw Normal View History

2020-09-13 16:24:48 +00:00
import { customElement, property, html, TemplateResult, LitElement } from 'lit-element';
import * as domtools from '@designestate/dees-domtools';
@customElement('dees-input-quantityselector')
export class DeesInputQuantitySelector extends LitElement {
public static demo = () => html`<dees-input-quantityselector></dees-input-quantityselector>`;
@property()
public key: string;
@property({
type: Number
})
public value: number = 1;
public render(): TemplateResult {
return html`
${domtools.elementBasic.styles}
<style>
:host {
display: block;
width: 110px;
user-select: none;
}
.maincontainer {
transition: all 0.1s;
font-size: 14px;
display: grid;
grid-template-columns: 33% 34% 33%;
text-align: center;
background:none;
line-height: 40px;
padding: 0px;
min-width: 100px;
color: #CCC;
border: 1px solid #CCC;
}
.minus {
padding-left: 5px;
}
.plus {
padding-right: 5px;
}
.selector {
text-align: center;
font-size: 20px;
}
.selector:hover {
cursor: pointer;
}
.quantity {
text-align: center;
}
.mainContainer:hover {
color: #fff;
border: 1px solid #fff;
}
</style>
<div class="maincontainer">
<div class="selector minus" @click="${() => {this.decrease();}}">-</div>
<div class="quantity">${this.value}</div>
<div class="selector plus" @click="${() => {this.increase();}}">+</div>
</div>
`;
}
public increase () {
this.value++;
}
public decrease () {
if (this.value > 0) {
this.value--;
} else {
// nothing to do here
}
}
}