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

85 lines
2.1 KiB
TypeScript
Raw Normal View History

2020-12-09 23:05:13 +00:00
import {customElement, DeesElement, TemplateResult, property, html} from '@designestate/dees-element';
2021-08-19 22:25:14 +00:00
import * as domtools from '@designestate/dees-domtools';
2020-09-13 16:24:48 +00:00
2021-03-06 15:48:02 +00:00
declare global {
interface HTMLElementTagNameMap {
'dees-input-text': DeesInputText;
}
}
2020-09-13 16:24:48 +00:00
@customElement('dees-input-text')
2020-12-09 23:05:13 +00:00
export class DeesInputText extends DeesElement {
2020-09-13 16:24:48 +00:00
public static demo = () => html`<dees-input-text></dees-input-text>`;
2021-08-19 22:25:14 +00:00
// INSTANCE
public changeSubject = new domtools.rxjs.Subject();
2020-09-13 16:24:48 +00:00
@property()
public label: string = 'Label';
@property()
public key: string;
@property()
public value: string;
public render(): TemplateResult {
return html `
<style>
* {
box-sizing: border-box;
}
:host {
position: relative;
display: grid;
margin: 10px 0px;
margin-bottom: 24px;
}
.maincontainer {
2020-12-09 23:05:13 +00:00
color: ${this.goBright ? '#333' : '#ccc'};
2020-09-13 16:24:48 +00:00
}
.label {
font-size: 14px;
margin-bottom: 5px;
}
input {
margin-top: 5px;
2020-12-09 23:05:13 +00:00
background: ${this.goBright ? '#fafafa' : '#222'};
border-top: ${this.goBright ? '1px solid #CCC' : '1px solid #444'};
border-bottom: ${this.goBright ? '1px solid #CCC' : '1px solid #333'};
border-right: ${this.goBright ? '1px solid #CCC' : 'none'};
border-left: ${this.goBright ? '1px solid #CCC' : 'none'};
2020-09-13 16:24:48 +00:00
padding-left:10px;
padding-right: 10px;
border-radius: 2px;
width: 100%;
line-height: 48px;
transition: all 0.2s;
outline: none;
color: #ccc;
font-size: 16px;
}
input:focus {
outline: none;
border-bottom: 1px solid #e4002b;
}
</style>
<div class="maincontainer">
<div class="label">${this.label}</div>
<input type="text" @input="${this.updateValue}" />
</div>
`;
}
public async updateValue(eventArg: Event) {
const target: any = eventArg.target;
this.value = target.value;
2021-08-19 22:25:14 +00:00
this.changeSubject.next(this);
2020-09-13 16:24:48 +00:00
}
}