abeb4a17
Luigi Serra
Update components...
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
<!--
@license
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<!doctype html>
<html>
<head>
|
eb240478
Luigi Serra
public room cards...
|
15
|
<title>Collapsable items using iron-list</title>
|
abeb4a17
Luigi Serra
Update components...
|
16
17
18
19
20
21
22
23
24
25
|
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="../../polymer/polymer.html">
<link rel="import" href="../../iron-flex-layout/iron-flex-layout.html">
|
eb240478
Luigi Serra
public room cards...
|
26
27
28
|
<link rel="import" href="../../paper-toolbar/paper-toolbar.html">
<link rel="import" href="../../paper-scroll-header-panel/paper-scroll-header-panel.html">
<link rel="import" href="../../paper-icon-button/paper-icon-button.html">
|
abeb4a17
Luigi Serra
Update components...
|
29
|
<link rel="import" href="../../iron-ajax/iron-ajax.html">
|
abeb4a17
Luigi Serra
Update components...
|
30
|
<link rel="import" href="../../iron-icons/iron-icons.html">
|
eb240478
Luigi Serra
public room cards...
|
31
|
<link rel="import" href="../iron-list.html">
|
abeb4a17
Luigi Serra
Update components...
|
32
|
|
eb240478
Luigi Serra
public room cards...
|
33
34
|
</head>
<body unresolved>
|
abeb4a17
Luigi Serra
Update components...
|
35
|
|
eb240478
Luigi Serra
public room cards...
|
36
37
|
<dom-module id="x-collapse">
<template>
|
abeb4a17
Luigi Serra
Update components...
|
38
|
<style>
|
abeb4a17
Luigi Serra
Update components...
|
39
40
41
|
:host {
@apply(--layout-fit);
@apply(--layout-vertical);
|
eb240478
Luigi Serra
public room cards...
|
42
|
@apply(--paper-font-common-base);
|
abeb4a17
Luigi Serra
Update components...
|
43
44
|
}
|
eb240478
Luigi Serra
public room cards...
|
45
46
|
paper-toolbar {
background: var(--google-green-700);
|
abeb4a17
Luigi Serra
Update components...
|
47
|
box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.26);
|
eb240478
Luigi Serra
public room cards...
|
48
49
|
font-weight: bold;
z-index: 1;
|
abeb4a17
Luigi Serra
Update components...
|
50
51
|
}
|
eb240478
Luigi Serra
public room cards...
|
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
paper-toolbar paper-icon-button {
--paper-icon-button-ink-color: white;
}
iron-list {
background-color: var(--paper-grey-200, #eee);
padding-top: 1px;
padding-bottom: 16px;
--iron-list-items-container: {
max-width: 800px;
margin: auto;
margin-top: 60px;
margin-bottom: 60px;
border-bottom: 1px solid #ddd;
};
|
abeb4a17
Luigi Serra
Update components...
|
67
68
69
|
}
.item {
|
abeb4a17
Luigi Serra
Update components...
|
70
|
@apply(--layout-horizontal);
|
eb240478
Luigi Serra
public room cards...
|
71
72
73
74
75
76
77
78
79
80
81
|
padding: 20px;
background-color: white;
border: 1px solid #ddd;
cursor: pointer;
margin-bottom: 10px;
}
.item:focus {
outline: 0;
border-color: #666;
|
abeb4a17
Luigi Serra
Update components...
|
82
83
84
85
86
87
88
|
}
.avatar {
height: 40px;
width: 40px;
border-radius: 20px;
box-sizing: border-box;
|
abeb4a17
Luigi Serra
Update components...
|
89
90
91
92
93
94
95
96
97
98
99
|
background-color: #DDD;
}
.pad {
padding: 0 16px;
@apply(--layout-flex);
@apply(--layout-vertical);
}
.primary {
font-size: 16px;
|
eb240478
Luigi Serra
public room cards...
|
100
|
font-weight: bold;
|
abeb4a17
Luigi Serra
Update components...
|
101
102
|
}
|
eb240478
Luigi Serra
public room cards...
|
103
|
.shortText, .longText {
|
abeb4a17
Luigi Serra
Update components...
|
104
105
106
|
font-size: 14px;
}
|
eb240478
Luigi Serra
public room cards...
|
107
|
.longText {
|
abeb4a17
Luigi Serra
Update components...
|
108
|
color: gray;
|
eb240478
Luigi Serra
public room cards...
|
109
|
display: none;
|
abeb4a17
Luigi Serra
Update components...
|
110
111
|
}
|
eb240478
Luigi Serra
public room cards...
|
112
113
114
|
.item:hover .shortText::after {
content: ' [+]';
color: gray;
|
abeb4a17
Luigi Serra
Update components...
|
115
116
|
}
|
eb240478
Luigi Serra
public room cards...
|
117
118
|
.item.expanded:hover .shortText::after {
content: '';
|
abeb4a17
Luigi Serra
Update components...
|
119
120
|
}
|
eb240478
Luigi Serra
public room cards...
|
121
122
123
|
.item.expanded .longText {
display: block;
}
|
abeb4a17
Luigi Serra
Update components...
|
124
|
|
eb240478
Luigi Serra
public room cards...
|
125
126
127
128
129
130
131
132
133
134
135
|
.item.expanded:hover .longText::after {
content: ' [–]';
}
</style>
<iron-ajax url="data/contacts.json" last-response="{{items}}" auto></iron-ajax>
<paper-toolbar>
<paper-icon-button icon="arrow-back" alt="Back"></paper-icon-button>
<div class="flex"></div>
<paper-icon-button icon="search" alt="Search"></paper-icon-button>
<paper-icon-button icon="more-vert" alt="More options"></paper-icon-button>
<div class="bottom title">Collapsable items using iron-list</div>
|
abeb4a17
Luigi Serra
Update components...
|
136
|
</paper-toolbar>
|
eb240478
Luigi Serra
public room cards...
|
137
|
<iron-list id="list" items="[[items]]" as="item">
|
abeb4a17
Luigi Serra
Update components...
|
138
|
<template>
|
eb240478
Luigi Serra
public room cards...
|
139
140
|
<div on-tap="_collapseExpand">
<div class$="[[getClassForItem(item, item.expanded)]]" tabindex="0">
|
abeb4a17
Luigi Serra
Update components...
|
141
142
|
<img class="avatar" src="[[item.image]]">
<div class="pad">
|
eb240478
Luigi Serra
public room cards...
|
143
144
145
|
<div class="primary">[[item.name]]</div>
<div class="shortText">[[item.shortText]]</div>
<div class="longText">[[item.longText]]</div>
|
abeb4a17
Luigi Serra
Update components...
|
146
147
148
|
</div>
<iron-icon icon$="[[iconForItem(item)]]"></iron-icon>
</div>
|
abeb4a17
Luigi Serra
Update components...
|
149
150
151
|
</div>
</template>
</iron-list>
|
eb240478
Luigi Serra
public room cards...
|
152
|
</template>
|
abeb4a17
Luigi Serra
Update components...
|
153
|
<script>
|
eb240478
Luigi Serra
public room cards...
|
154
|
HTMLImports.whenReady(function() {
|
abeb4a17
Luigi Serra
Update components...
|
155
|
Polymer({
|
eb240478
Luigi Serra
public room cards...
|
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
is: 'x-collapse',
properties: {
items: {
type: Array
}
},
_collapseExpand: function(e) {
var list = this.$.list;
var index = e.model.index;
var isExpanded = list.items[index].expanded;
list.set('items.' + index + '.expanded', !isExpanded);
list.updateSizeForItem(e.model.index);
},
|
abeb4a17
Luigi Serra
Update components...
|
171
172
173
|
iconForItem: function(item) {
return item ? (item.integer < 50 ? 'star-border' : 'star') : '';
|
eb240478
Luigi Serra
public room cards...
|
174
|
},
|
abeb4a17
Luigi Serra
Update components...
|
175
|
|
eb240478
Luigi Serra
public room cards...
|
176
177
178
|
getClassForItem: function(item, expanded) {
return expanded ? 'item expanded' : 'item';
}
|
abeb4a17
Luigi Serra
Update components...
|
179
|
});
|
eb240478
Luigi Serra
public room cards...
|
180
|
});
|
abeb4a17
Luigi Serra
Update components...
|
181
|
</script>
|
eb240478
Luigi Serra
public room cards...
|
182
|
</dom-module>
|
abeb4a17
Luigi Serra
Update components...
|
183
|
|
eb240478
Luigi Serra
public room cards...
|
184
|
<x-collapse></x-collapse>
|
abeb4a17
Luigi Serra
Update components...
|
185
186
187
|
</body>
</html>
|