-
Notifications
You must be signed in to change notification settings - Fork 0
/
boe-list.html
132 lines (109 loc) · 2.93 KB
/
boe-list.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
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
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../iron-flex-layout/iron-flex-layout.html">
<!--
A vertical flexbox list that shows a message when empty. Useful for lists with dismissible items.
Example:
<boe-list empty-msg="There are no more items in the queue.">
<paper-item>Hey.</paper-item>
</boe-list>
### Styling
The following custom properties and mixins are available for styling:
Custom property | Description | Default
------------------------------|----------------------------------------------|----------
`--boe-list-border` | Border style when no items are present. | `4px dashed #B7B7B7`
@demo demo/index.html
@hero hero.svg
-->
<dom-module id="boe-list">
<template>
<style>
:host {
position: relative;
flex: 1;
display: flex;
overflow: auto;
min-height: 56px;
}
#empty {
position: absolute;
height: 100%;
width: 100%;
@apply(--layout-horizontal);
@apply(--layout-center);
@apply(--layout-center-justified);
padding: 24px;
text-align: center;
border: var(--boe-list-border, 4px dashed #B7B7B7);
box-sizing: border-box;
}
#scroller {
@apply(--layout-vertical);
@apply(--boe-list-list-styles);
min-height: min-content; /* needs vendor prefixes */
width: 100%;
}
:host::-webkit-scrollbar {
width: 6px;
}
:host::-webkit-scrollbar-track {
-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
-webkit-border-radius: 10px;
border-radius: 10px;
}
:host::-webkit-scrollbar-thumb {
border-radius: 5px;
background: #757575;
-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.5);
}
:host::-webkit-scrollbar-thumb:window-inactive {
background: #b9b9b9;
}
</style>
<div id="empty">{{emptyMsg}}</div>
<div id="scroller">
<content id="content"></content>
</div>
</template>
<script>
Polymer({
is: 'boe-list',
properties: {
/**
* The message to show when the list is empty.
*/
emptyMsg: {
type: String,
value: 'There are no more items to display.'
}
},
ready: function () {
this._observer = Polymer.dom(this.$.content).observeNodes(function () {
var distributed = this.getContentChildren('#content').filter(function (tag) {
return tag.tagName !== 'TEMPLATE';
});
if (distributed.length > 0) {
this._showContent();
} else {
this._hideContent();
}
}.bind(this));
},
_showContent: function () {
if (this._contentShowing) {
return;
}
this._contentShowing = true;
this.$.content.style.visibility = 'visible';
this.$.empty.style.display = 'none';
},
_hideContent: function () {
if (!this._contentShowing) {
return;
}
this._contentShowing = false;
this.$.content.style.visibility = 'hidden';
this.$.empty.style.display = 'flex';
}
});
</script>
</dom-module>