-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvellum-sheet-box.js
98 lines (85 loc) · 2.01 KB
/
vellum-sheet-box.js
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import { LitElement, html, css } from 'lit-element'
import { StoreValueBehaviour } from './lib/store-value-behaviour.js'
class SheetBox extends StoreValueBehaviour(LitElement) {
static get is() { return 'vellum-sheet-box' }
static get styles() {
return css`
:host {
background: white;
border: 1px var(--char-sheet-border-color, black) solid;
padding-left: 0.5em;
padding-right: 0.5em;
border-radius: 5px;
display: flex;
flex-direction: column;
justify-content: space-between;
}
::slotted(ul) {
margin: 0;
padding: 0;
padding-left: 0;
list-style-type: none;
}
h2 {
text-align: center;
margin-top: 1em;
border: 0;
border-top: 1px black solid;
font-weight: bold;
font-size: inherit;
text-transform: uppercase;
padding: 0.2em 0 0 0;
margin: 1em 0 0 0;
color: black;
}
textarea,
p {
font-family: inherit;
background: transparent;
border: none;
height: 100%;
width: 100%;
resize: none;
line-height: 170%;
}`
}
static get properties() {
return {
label: {
type: String
},
editable: {
type: Boolean
},
sync: {
type: Boolean
},
store: {
type: Boolean
},
docid: {
type: String
},
value: {
type: String
}
}
}
connectedCallback() {
super.connectedCallback()
this.sync = this.sync === true
this.editable = this.editable === true
}
updateValue(event) {
if (this.editable) this.value = event.target.value
}
render() {
return html`
${this.editable || this.sync ? this.renderEditable() : html`<p><slot></slot></p>`}
${this.label ? html`<h2>${this.label}</h2>` : html``}`
}
renderEditable() {
return html`<textarea id="input" ?disabled=${!this.editable} @input=${this.updateValue}>${this.value || ''}</textarea>`
}
}
customElements.define(SheetBox.is, SheetBox)