forked from Hackception/hc-tree-view
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhc-nested-list-item.html
57 lines (50 loc) · 1.43 KB
/
hc-nested-list-item.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
<link rel="import" href="../polymer/polymer.html">
<!--
`hc-nested-list-item` used to wrap content within an instanced of `hc-nested-list` to properly handle
tap events for triggering open/close state changes as well as circumventing the broken bindings
limitation of iron-list.
### Styling
Custom property | Description | Default
----------------|-------------|----------
`--hc-nested-list-item` | A mixin for styling this element | {}
@demo demo/hc-nested-list.html
-->
<dom-module id="hc-nested-list-item">
<template>
<style>
:host {
display: inline-block;
cursor: pointer;
@apply --hc-nested-list-item;
}
</style>
<slot></slot>
</template>
<script>
Polymer({
is: 'hc-nested-list-item',
properties: {
/* The item holding all data */
item: Object
},
listeners: {
tap: 'fireOpenEvent'
},
/**
* Fires the toggle event required by hc-nested-list to open/close content sections.
*
* @fires hc-nested-list-behavior#item-open-changed
* @param {TapEvent} event
*/
fireOpenEvent(event) {
// Prevent this from changing selected state in iron-list.
event.stopPropagation();
// Trigger an event to toggle open state instead.
this.fire('item-open-changed', {
item: this.item,
open: !this.item.open
});
}
});
</script>
</dom-module>