-
Notifications
You must be signed in to change notification settings - Fork 4
/
vellum-stat-block.js
140 lines (110 loc) · 2.97 KB
/
vellum-stat-block.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
import { LitElement, html, css } from 'lit-element'
import './vellum-stat-block-divider.js'
export class StatBlock extends LitElement {
static get styles() {
return css`
:host {
display: block;
overflow: hidden;
font-family: sans-serif;
width: var(--stat-block-width, 350px);
font-size: 10pt;
margin-bottom: 1em;
-webkit-column-break-inside: avoid;
page-break-inside: avoid;
break-inside: avoid;
}
.bar {
height: 5px;
border: var(--stat-block-bar-border, 1px solid #000);
position: relative;
z-index: 1;
background: var(--stat-block-bar-background, white);
}
.stat-block {
margin-left: 0.2em;
margin-right: 0.2em;
}
.content-wrapper {
background: var(--stat-block-background, white);
border-left: 1px var(--stat-block-border-color, black) solid;
border-right: 1px var(--stat-block-border-color, black) solid;
padding: 0.5em;
box-shadow: 0.1em 0 0.1em rgba(0, 0, 0, 0.3), -0.1em 0 0.1em rgba(0, 0, 0, 0.3);
}
:host(.two-column) {
width: var(--stat-block-two-column-width, 840px)
}
:host(.two-column) .content-wrapper {
-webkit-columns: var(--stat-block-two-column-column-width, 388px) 2;
-moz-columns: var(--stat-block-two-column-column-width, 388px) 2;
columns: var(--stat-block-two-column-column-width, 388px) 2;
-webkit-column-gap: 40px;
-moz-column-gap: 40px;
column-gap: 40px;
}
header h1:first-child {
font-family: var(--stat-block-heading-font-family, serif);
font-weight: bold;
margin: 0px;
font-size: 2em;
font-variant: small-caps;
color: var(--stat-block-header-color, black);
}
:host p {
margin-top: 1pt;
margin-left: 0;
margin-right: 0;
margin-bottom: 1pt;
}
header *:nth-child(2) {
font-weight: normal;
font-style: italic;
font-size: 1em;
margin: 0;
}
ol, ul {
margin-top: 1em;
padding-left: 0;
margin-bottom: 0;
line-spacing: 0;
}
ul {
list-style-type: none;
}
:host p.description {
font-style: italics;
margin-bottom: 0;
}`
}
static get is() { return 'vellum-stat-block' }
static get properties() {
return {
name: String,
description: String
}
}
render() {
return html`
<div class="bar"></div>
<div class="stat-block">
<div class="content-wrapper">
<header id="header">
${this.renderHeader()}
</header>
<vellum-stat-block-divider></vellum-stat-block-divider>
<div id="stats">${this.renderStats()}</div>
</div>
</div>
<div class="bar"></div>`
}
renderHeader() {
return html`
<h1>${this.name}</h1>
<p>${this.description}</p>`
}
renderStats() {
return html`<slot></slot>`
}
}
customElements.define(StatBlock.is, StatBlock)