-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathhint-button.js
More file actions
30 lines (25 loc) · 818 Bytes
/
hint-button.js
File metadata and controls
30 lines (25 loc) · 818 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import '@vaadin/vaadin-button/vaadin-button.js';
import { LitElement, html } from "lit-element";
const PRIMARY_THRESHOLD = 0.3;
const SECONDARY_THRESHOLD = 0.1;
export class HintButton extends LitElement {
static get properties() {
return {
id: {type: String},
probability: {type: Number}
};
}
render() {
let theme = 'secondary';
if (this.probability !== -1) {
if (this.probability <= SECONDARY_THRESHOLD) {
theme = 'tertiary'
}
if (this.probability > PRIMARY_THRESHOLD) {
theme = 'primary'
}
}
return html`<vaadin-button theme='${theme}' id='${this.id}'><slot></slot></vaadin-button>`
}
}
window.customElements.define('hint-button', HintButton)