Blame view

bower_components/iron-list/demo/collapse.html 5.65 KB
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);

a1a3bc73   Luigi Serra   graphs updates
43
          background-color: var(--paper-grey-200, #eee);

abeb4a17   Luigi Serra   Update components...
44
45
        }

  

eb240478   Luigi Serra   public room cards...
46
47
        paper-toolbar {

          background: var(--google-green-700);

a1a3bc73   Luigi Serra   graphs updates
48
          box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.3);

eb240478   Luigi Serra   public room cards...
49
50
          font-weight: bold;

          z-index: 1;

a1a3bc73   Luigi Serra   graphs updates
51
52
53
          --paper-toolbar-title: {

            overflow: visible;

          };

abeb4a17   Luigi Serra   Update components...
54
55
        }

  

eb240478   Luigi Serra   public room cards...
56
57
58
59
60
        paper-toolbar paper-icon-button {

          --paper-icon-button-ink-color: white;

        }

  

        iron-list {

eb240478   Luigi Serra   public room cards...
61
62
          padding-top: 1px;

          padding-bottom: 16px;

a1a3bc73   Luigi Serra   graphs updates
63
64
          -webkit-flex: 1 1;

          flex: 1 1;

eb240478   Luigi Serra   public room cards...
65
66
67
68
69
70
71
          --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...
72
73
74
        }

  

        .item {

abeb4a17   Luigi Serra   Update components...
75
          @apply(--layout-horizontal);

eb240478   Luigi Serra   public room cards...
76
77
78
79
80
81
82
83
84
85
86
          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...
87
88
89
90
91
92
93
        }

  

        .avatar {

          height: 40px;

          width: 40px;

          border-radius: 20px;

          box-sizing: border-box;

abeb4a17   Luigi Serra   Update components...
94
95
96
97
98
99
100
101
102
103
104
          background-color: #DDD;

        }

  

        .pad {

          padding: 0 16px;

          @apply(--layout-flex);

          @apply(--layout-vertical);

        }

  

        .primary {

          font-size: 16px;

eb240478   Luigi Serra   public room cards...
105
          font-weight: bold;

abeb4a17   Luigi Serra   Update components...
106
107
        }

  

eb240478   Luigi Serra   public room cards...
108
        .shortText, .longText {

abeb4a17   Luigi Serra   Update components...
109
110
111
          font-size: 14px;

        }

  

eb240478   Luigi Serra   public room cards...
112
        .longText {

abeb4a17   Luigi Serra   Update components...
113
          color: gray;

eb240478   Luigi Serra   public room cards...
114
          display: none;

abeb4a17   Luigi Serra   Update components...
115
116
        }

  

eb240478   Luigi Serra   public room cards...
117
118
119
        .item:hover .shortText::after {

          content: ' [+]';

          color: gray;

abeb4a17   Luigi Serra   Update components...
120
121
        }

  

eb240478   Luigi Serra   public room cards...
122
123
        .item.expanded:hover .shortText::after {

          content: '';

abeb4a17   Luigi Serra   Update components...
124
125
        }

  

eb240478   Luigi Serra   public room cards...
126
127
128
        .item.expanded .longText {

          display: block;

        }

abeb4a17   Luigi Serra   Update components...
129
  

eb240478   Luigi Serra   public room cards...
130
131
132
        .item.expanded:hover .longText::after {

          content: ' [–]';

        }

a1a3bc73   Luigi Serra   graphs updates
133
134
135
136
137
138
139
140
141
142
  

        .spacer {

          @apply(--layout-flex);

        }

  

        @media (max-width: 460px) {

          paper-toolbar .bottom.title {

            font-size: 14px;

          }

        }

eb240478   Luigi Serra   public room cards...
143
144
145
146
      </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>

a1a3bc73   Luigi Serra   graphs updates
147
          <div class="spacer"></div>

eb240478   Luigi Serra   public room cards...
148
149
150
          <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...
151
        </paper-toolbar>

eb240478   Luigi Serra   public room cards...
152
        <iron-list id="list" items="[[items]]" as="item">

abeb4a17   Luigi Serra   Update components...
153
          <template>

eb240478   Luigi Serra   public room cards...
154
155
            <div on-tap="_collapseExpand">

              <div class$="[[getClassForItem(item, item.expanded)]]" tabindex="0">

abeb4a17   Luigi Serra   Update components...
156
157
                <img class="avatar" src="[[item.image]]">

                <div class="pad">

eb240478   Luigi Serra   public room cards...
158
159
160
                  <div class="primary">[[item.name]]</div>

                  <div class="shortText">[[item.shortText]]</div>

                  <div class="longText">[[item.longText]]</div>

abeb4a17   Luigi Serra   Update components...
161
162
163
                </div>

                <iron-icon icon$="[[iconForItem(item)]]"></iron-icon>

              </div>

abeb4a17   Luigi Serra   Update components...
164
165
166
            </div>

          </template>

        </iron-list>

eb240478   Luigi Serra   public room cards...
167
    </template>

abeb4a17   Luigi Serra   Update components...
168
    <script>

eb240478   Luigi Serra   public room cards...
169
    HTMLImports.whenReady(function() {

abeb4a17   Luigi Serra   Update components...
170
        Polymer({

eb240478   Luigi Serra   public room cards...
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
          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...
186
187
188
  

          iconForItem: function(item) {

            return item ? (item.integer < 50 ? 'star-border' : 'star') : '';

eb240478   Luigi Serra   public room cards...
189
          },

abeb4a17   Luigi Serra   Update components...
190
  

eb240478   Luigi Serra   public room cards...
191
192
193
          getClassForItem: function(item, expanded) {

            return expanded ? 'item expanded' : 'item';

          }

abeb4a17   Luigi Serra   Update components...
194
        });

eb240478   Luigi Serra   public room cards...
195
      });

abeb4a17   Luigi Serra   Update components...
196
    </script>

eb240478   Luigi Serra   public room cards...
197
  </dom-module>

abeb4a17   Luigi Serra   Update components...
198
  

eb240478   Luigi Serra   public room cards...
199
  <x-collapse></x-collapse>

abeb4a17   Luigi Serra   Update components...
200
201
202
  

  </body>

  </html>