73bcce88
luigser
COMPONENTS
|
1
2
3
4
5
6
7
8
9
10
|
<!--
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
-->
<link rel="import" href="../polymer/polymer.html">
|
c5169e0e
Renato De Donato
a new hope
|
11
|
<link rel="import" href="../paper-styles/paper-styles.html">
|
73bcce88
luigser
COMPONENTS
|
12
13
|
<!--
|
73bcce88
luigser
COMPONENTS
|
14
|
`paper-toolbar` is a horizontal bar containing items that can be used for
|
c5169e0e
Renato De Donato
a new hope
|
15
|
label, navigation, search and actions. The items place inside the
|
73bcce88
luigser
COMPONENTS
|
16
17
18
19
20
21
|
`paper-toolbar` are projected into a `class="horizontal center layout"` container inside of
`paper-toolbar`'s Shadow DOM. You can use flex attributes to control the items'
sizing.
Example:
|
c5169e0e
Renato De Donato
a new hope
|
22
23
24
25
26
|
<paper-toolbar>
<paper-icon-button icon="menu" on-tap="menuAction"></paper-icon-button>
<div class="title">Title</div>
<paper-icon-button icon="more-vert" on-tap="moreAction"></paper-icon-button>
</paper-toolbar>
|
73bcce88
luigser
COMPONENTS
|
27
28
29
30
|
`paper-toolbar` has a standard height, but can made be taller by setting `tall`
class on the `paper-toolbar`. This will make the toolbar 3x the normal height.
|
c5169e0e
Renato De Donato
a new hope
|
31
32
33
|
<paper-toolbar class="tall">
<paper-icon-button icon="menu"></paper-icon-button>
</paper-toolbar>
|
73bcce88
luigser
COMPONENTS
|
34
35
36
37
|
Apply `medium-tall` class to make the toolbar medium tall. This will make the
toolbar 2x the normal height.
|
c5169e0e
Renato De Donato
a new hope
|
38
39
40
|
<paper-toolbar class="medium-tall">
<paper-icon-button icon="menu"></paper-icon-button>
</paper-toolbar>
|
73bcce88
luigser
COMPONENTS
|
41
42
43
44
|
When `tall`, items can pin to either the top (default), middle or bottom. Use
`middle` class for middle content and `bottom` class for bottom content.
|
c5169e0e
Renato De Donato
a new hope
|
45
46
47
48
49
|
<paper-toolbar class="tall">
<paper-icon-button icon="menu"></paper-icon-button>
<div class="middle title">Middle Title</div>
<div class="bottom title">Bottom Title</div>
</paper-toolbar>
|
73bcce88
luigser
COMPONENTS
|
50
51
52
53
54
55
56
57
|
For `medium-tall` toolbar, the middle and bottom contents overlap and are
pinned to the bottom. But `middleJustify` and `bottomJustify` attributes are
still honored separately.
To make an element completely fit at the bottom of the toolbar, use `fit` along
with `bottom`.
|
c5169e0e
Renato De Donato
a new hope
|
58
59
60
|
<paper-toolbar class="tall">
<div id="progressBar" class="bottom fit"></div>
</paper-toolbar>
|
73bcce88
luigser
COMPONENTS
|
61
62
63
64
65
66
67
|
### Styling
The following custom properties and mixins are available for styling:
Custom property | Description | Default
----------------|-------------|----------
|
73bcce88
luigser
COMPONENTS
|
68
69
|
`--paper-toolbar-background` | Toolbar background color | `--default-primary-color`
`--paper-toolbar-color` | Toolbar foreground color | `--text-primary-color`
|
73bcce88
luigser
COMPONENTS
|
70
|
`--paper-toolbar` | Mixin applied to the toolbar | `{}`
|
73bcce88
luigser
COMPONENTS
|
71
72
73
74
75
76
77
78
79
80
|
### Accessibility
`<paper-toolbar>` has `role="toolbar"` by default. Any elements with the class `title` will
be used as the label of the toolbar via `aria-labelledby`.
@demo demo/index.html
-->
<dom-module id="paper-toolbar">
|
73bcce88
luigser
COMPONENTS
|
81
|
|
c5169e0e
Renato De Donato
a new hope
|
82
83
84
85
86
87
88
|
<style>
:host {
/* technical */
display: block;
position: relative;
box-sizing: border-box;
-moz-box-sizing: border-box;
|
73bcce88
luigser
COMPONENTS
|
89
|
|
c5169e0e
Renato De Donato
a new hope
|
90
91
|
/* size */
height: 64px;
|
73bcce88
luigser
COMPONENTS
|
92
|
|
c5169e0e
Renato De Donato
a new hope
|
93
94
|
background: var(--paper-toolbar-background, --default-primary-color);
color: var(--paper-toolbar-color, --text-primary-color);
|
73bcce88
luigser
COMPONENTS
|
95
|
|
c5169e0e
Renato De Donato
a new hope
|
96
97
|
@apply(--paper-toolbar);
}
|
73bcce88
luigser
COMPONENTS
|
98
|
|
c5169e0e
Renato De Donato
a new hope
|
99
100
101
102
|
:host(.animate) {
/* transition */
transition: height 0.18s ease-in;
}
|
73bcce88
luigser
COMPONENTS
|
103
|
|
c5169e0e
Renato De Donato
a new hope
|
104
105
106
|
:host(.medium-tall) {
height: 128px;
}
|
73bcce88
luigser
COMPONENTS
|
107
|
|
c5169e0e
Renato De Donato
a new hope
|
108
109
110
|
:host(.tall) {
height: 192px;
}
|
73bcce88
luigser
COMPONENTS
|
111
|
|
c5169e0e
Renato De Donato
a new hope
|
112
113
114
115
116
117
|
.toolbar-tools {
position: relative;
height: 64px;
padding: 0 16px;
pointer-events: none;
}
|
73bcce88
luigser
COMPONENTS
|
118
|
|
c5169e0e
Renato De Donato
a new hope
|
119
120
121
|
/*
* TODO: Where should media query breakpoints live so they can be shared between elements?
*/
|
73bcce88
luigser
COMPONENTS
|
122
|
|
c5169e0e
Renato De Donato
a new hope
|
123
124
125
|
@media (max-width: 639px) {
:host {
height: 56px;
|
73bcce88
luigser
COMPONENTS
|
126
127
|
}
|
c5169e0e
Renato De Donato
a new hope
|
128
129
|
:host(.medium-tall) {
height: 112px;
|
73bcce88
luigser
COMPONENTS
|
130
131
|
}
|
c5169e0e
Renato De Donato
a new hope
|
132
133
|
:host(.tall) {
height: 168px;
|
a1a3bc73
Luigi Serra
graphs updates
|
134
135
|
}
|
c5169e0e
Renato De Donato
a new hope
|
136
137
|
.toolbar-tools {
height: 56px;
|
73bcce88
luigser
COMPONENTS
|
138
|
}
|
c5169e0e
Renato De Donato
a new hope
|
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
|
}
#topBar {
position: relative;
}
/* middle bar */
#middleBar {
position: absolute;
top: 0;
right: 0;
left: 0;
}
:host(.tall) #middleBar,
:host(.medium-tall) #middleBar {
-webkit-transform: translateY(100%);
transform: translateY(100%);
}
/* bottom bar */
#bottomBar {
position: absolute;
right: 0;
bottom: 0;
left: 0;
}
/*
* make elements (e.g. buttons) respond to mouse/touch events
*
* `.toolbar-tools` disables touch events so multiple toolbars can stack and not
* absorb events. All children must have pointer events re-enabled to work as
* expected.
*/
.toolbar-tools > ::content > *:not([disabled]) {
pointer-events: auto;
}
.toolbar-tools > ::content .title {
@apply(--paper-font-title);
@apply(--layout-flex);
pointer-events: none;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
|
73bcce88
luigser
COMPONENTS
|
186
187
|
/*
|
c5169e0e
Renato De Donato
a new hope
|
188
189
190
191
192
|
* Polymer/polymer/issues/1525
* --paper-font-title defines a `font-weight`
* let's override its value, but we need `important!`
* because all mixins are resolved in rule's selector that has higher precedence
* than the current selector.
|
73bcce88
luigser
COMPONENTS
|
193
|
*/
|
c5169e0e
Renato De Donato
a new hope
|
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
|
font-weight: 400 !important;
}
/**
* TODO: Refactor these selectors
* Work in progress.
*/
.toolbar-tools > ::content paper-icon-button[icon=menu] {
margin-right: 24px;
}
.toolbar-tools > ::content > .title,
.toolbar-tools > ::content[select=".middle"] > .title,
.toolbar-tools > ::content[select=".bottom"] > .title {
margin-left: 56px;
}
.toolbar-tools > ::content > paper-icon-button + .title,
.toolbar-tools > ::content[select=".middle"] paper-icon-button + .title,
.toolbar-tools > ::content[select=".bottom"] paper-icon-button + .title {
margin-left: 0;
}
.toolbar-tools > ::content > .fit {
position: absolute;
top: auto;
right: 0;
bottom: 0;
left: 0;
width: auto;
margin: 0;
}
</style>
|
73bcce88
luigser
COMPONENTS
|
228
|
|
c5169e0e
Renato De Donato
a new hope
|
229
|
<template>
|
73bcce88
luigser
COMPONENTS
|
230
|
|
c5169e0e
Renato De Donato
a new hope
|
231
232
233
|
<div id="topBar" class$="[[_computeBarClassName(justify)]]">
<content select=":not(.middle):not(.bottom)"></content>
</div>
|
73bcce88
luigser
COMPONENTS
|
234
|
|
c5169e0e
Renato De Donato
a new hope
|
235
236
237
|
<div id="middleBar" class$="[[_computeBarClassName(middleJustify)]]">
<content select=".middle"></content>
</div>
|
73bcce88
luigser
COMPONENTS
|
238
|
|
c5169e0e
Renato De Donato
a new hope
|
239
240
241
|
<div id="bottomBar" class$="[[_computeBarClassName(bottomJustify)]]">
<content select=".bottom"></content>
</div>
|
a1a3bc73
Luigi Serra
graphs updates
|
242
|
|
c5169e0e
Renato De Donato
a new hope
|
243
|
</template>
|
73bcce88
luigser
COMPONENTS
|
244
|
|
c5169e0e
Renato De Donato
a new hope
|
245
|
</dom-module>
|
73bcce88
luigser
COMPONENTS
|
246
|
|
c5169e0e
Renato De Donato
a new hope
|
247
|
<script>
|
73bcce88
luigser
COMPONENTS
|
248
|
|
c5169e0e
Renato De Donato
a new hope
|
249
|
(function() {
|
73bcce88
luigser
COMPONENTS
|
250
|
|
c5169e0e
Renato De Donato
a new hope
|
251
|
'use strict';
|
73bcce88
luigser
COMPONENTS
|
252
|
|
c5169e0e
Renato De Donato
a new hope
|
253
254
255
256
257
258
|
function classNames(obj) {
var classNames = [];
for (var key in obj) {
if (obj.hasOwnProperty(key) && obj[key]) {
classNames.push(key);
}
|
a1a3bc73
Luigi Serra
graphs updates
|
259
|
}
|
73bcce88
luigser
COMPONENTS
|
260
|
|
c5169e0e
Renato De Donato
a new hope
|
261
262
|
return classNames.join(' ');
}
|
73bcce88
luigser
COMPONENTS
|
263
|
|
a1a3bc73
Luigi Serra
graphs updates
|
264
|
Polymer({
|
c5169e0e
Renato De Donato
a new hope
|
265
|
|
73bcce88
luigser
COMPONENTS
|
266
267
268
269
270
271
272
|
is: 'paper-toolbar',
hostAttributes: {
'role': 'toolbar'
},
properties: {
|
c5169e0e
Renato De Donato
a new hope
|
273
|
|
73bcce88
luigser
COMPONENTS
|
274
275
276
277
|
/**
* Controls how the items are aligned horizontally when they are placed
* at the bottom.
* Options are `start`, `center`, `end`, `justified` and `around`.
|
c5169e0e
Renato De Donato
a new hope
|
278
279
280
281
|
*
* @attribute bottomJustify
* @type string
* @default ''
|
73bcce88
luigser
COMPONENTS
|
282
283
284
285
286
287
288
289
290
|
*/
bottomJustify: {
type: String,
value: ''
},
/**
* Controls how the items are aligned horizontally.
* Options are `start`, `center`, `end`, `justified` and `around`.
|
c5169e0e
Renato De Donato
a new hope
|
291
292
293
294
|
*
* @attribute justify
* @type string
* @default ''
|
73bcce88
luigser
COMPONENTS
|
295
296
297
298
299
300
301
302
303
304
|
*/
justify: {
type: String,
value: ''
},
/**
* Controls how the items are aligned horizontally when they are placed
* in the middle.
* Options are `start`, `center`, `end`, `justified` and `around`.
|
c5169e0e
Renato De Donato
a new hope
|
305
306
307
308
|
*
* @attribute middleJustify
* @type string
* @default ''
|
73bcce88
luigser
COMPONENTS
|
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
|
*/
middleJustify: {
type: String,
value: ''
}
},
attached: function() {
this._observer = this._observe(this);
this._updateAriaLabelledBy();
},
detached: function() {
if (this._observer) {
this._observer.disconnect();
}
},
_observe: function(node) {
var observer = new MutationObserver(function() {
this._updateAriaLabelledBy();
}.bind(this));
observer.observe(node, {
childList: true,
subtree: true
});
return observer;
},
_updateAriaLabelledBy: function() {
var labelledBy = [];
var contents = Polymer.dom(this.root).querySelectorAll('content');
for (var content, index = 0; content = contents[index]; index++) {
var nodes = Polymer.dom(content).getDistributedNodes();
for (var node, jndex = 0; node = nodes[jndex]; jndex++) {
if (node.classList && node.classList.contains('title')) {
if (node.id) {
labelledBy.push(node.id);
} else {
var id = 'paper-toolbar-label-' + Math.floor(Math.random() * 10000);
node.id = id;
labelledBy.push(id);
}
}
}
}
if (labelledBy.length > 0) {
this.setAttribute('aria-labelledby', labelledBy.join(' '));
}
},
|
c5169e0e
Renato De Donato
a new hope
|
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
|
_computeBarClassName: function(barJustify) {
var classObj = {
'center': true,
'horizontal': true,
'layout': true,
'toolbar-tools': true
};
// If a blank string or any falsy value is given, no other class name is
// added.
if (barJustify) {
var justifyClassName = (barJustify === 'justified') ?
barJustify :
barJustify + '-justified';
classObj[justifyClassName] = true;
}
|
73bcce88
luigser
COMPONENTS
|
378
|
|
c5169e0e
Renato De Donato
a new hope
|
379
|
return classNames(classObj);
|
73bcce88
luigser
COMPONENTS
|
380
|
}
|
c5169e0e
Renato De Donato
a new hope
|
381
|
|
73bcce88
luigser
COMPONENTS
|
382
|
});
|
c5169e0e
Renato De Donato
a new hope
|
383
384
385
386
|
}());
</script>
|