-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcollapse.html
64 lines (54 loc) · 1002 Bytes
/
collapse.html
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
<link rel="import" href="bower_components/iron-collapse/iron-collapse.html">
<dom-module id="form-collapse">
<template>
<style>
:host {
display: block;
}
div {
font-weight: bold;
cursor: pointer;
}
div::before {
content: '\25B6';
margin-right: 8px;
font-size: 10px;
}
div[opened]::before {
content: '\25BC';
}
iron-collapse {
margin: 0 16px;
}
</style>
<div on-tap="open" opened$="[[_opened]]">[[label]]</div>
<iron-collapse opened="[[_opened]]">
<content></content>
</iron-collapse>
</template>
<script>
Polymer({
is: "form-collapse",
properties: {
label: {
type: String
},
name: {
type: String
},
opened: {
type: String,
notify: true
},
_opened: {
type: Boolean,
computed: "_computeOpened(name, opened)"
}
},
_computeOpened: (name, opened) => name === opened,
open() {
this.opened = this.name;
}
})
</script>
</dom-module>