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">
|
a1a3bc73
Luigi Serra
graphs updates
|
11
12
13
|
<link rel="import" href="../paper-styles/default-theme.html">
<link rel="import" href="../paper-styles/typography.html">
<link rel="import" href="../iron-flex-layout/iron-flex-layout.html">
|
73bcce88
luigser
COMPONENTS
|
14
15
|
<!--
|
a1a3bc73
Luigi Serra
graphs updates
|
16
17
|
Material design: [Toolbars](https://www.google.com/design/spec/components/toolbars.html)
|
73bcce88
luigser
COMPONENTS
|
18
|
`paper-toolbar` is a horizontal bar containing items that can be used for
|
a1a3bc73
Luigi Serra
graphs updates
|
19
|
label, navigation, search and actions. The items placed inside the
|
73bcce88
luigser
COMPONENTS
|
20
21
22
23
24
25
|
`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:
|
a1a3bc73
Luigi Serra
graphs updates
|
26
27
28
29
30
31
32
|
```html
<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
|
33
34
35
36
|
`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.
|
a1a3bc73
Luigi Serra
graphs updates
|
37
38
39
40
41
|
```html
<paper-toolbar class="tall">
<paper-icon-button icon="menu"></paper-icon-button>
</paper-toolbar>
```
|
73bcce88
luigser
COMPONENTS
|
42
43
44
45
|
Apply `medium-tall` class to make the toolbar medium tall. This will make the
toolbar 2x the normal height.
|
a1a3bc73
Luigi Serra
graphs updates
|
46
47
48
49
50
|
```html
<paper-toolbar class="medium-tall">
<paper-icon-button icon="menu"></paper-icon-button>
</paper-toolbar>
```
|
73bcce88
luigser
COMPONENTS
|
51
52
53
54
|
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.
|
a1a3bc73
Luigi Serra
graphs updates
|
55
56
57
58
59
60
61
|
```html
<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
|
62
63
64
65
66
67
68
69
|
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`.
|
a1a3bc73
Luigi Serra
graphs updates
|
70
71
72
73
74
|
```html
<paper-toolbar class="tall">
<div id="progressBar" class="bottom fit"></div>
</paper-toolbar>
```
|
73bcce88
luigser
COMPONENTS
|
75
76
77
78
79
80
81
|
### Styling
The following custom properties and mixins are available for styling:
Custom property | Description | Default
----------------|-------------|----------
|
a1a3bc73
Luigi Serra
graphs updates
|
82
|
`--paper-toolbar-title` | Mixin applied to the title of the toolbar | `{}`
|
73bcce88
luigser
COMPONENTS
|
83
84
|
`--paper-toolbar-background` | Toolbar background color | `--default-primary-color`
`--paper-toolbar-color` | Toolbar foreground color | `--text-primary-color`
|
a1a3bc73
Luigi Serra
graphs updates
|
85
86
|
`--paper-toolbar-height` | Custom height for toolbar | `64px`
`--paper-toolbar-sm-height` | Custom height for small screen toolbar | `56px`
|
73bcce88
luigser
COMPONENTS
|
87
|
`--paper-toolbar` | Mixin applied to the toolbar | `{}`
|
a1a3bc73
Luigi Serra
graphs updates
|
88
89
90
|
`--paper-toolbar-content` | Mixin applied to the content section of the toolbar | `{}`
`--paper-toolbar-medium` | Mixin applied to medium height toolbar | `{}`
`--paper-toolbar-tall` | Mixin applied to tall height toolbar | `{}`
|
73bcce88
luigser
COMPONENTS
|
91
92
93
94
95
96
97
98
99
100
|
### 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">
|
a1a3bc73
Luigi Serra
graphs updates
|
101
102
103
104
105
106
107
108
|
<template>
<style>
:host {
/* technical */
display: block;
position: relative;
box-sizing: border-box;
-moz-box-sizing: border-box;
|
73bcce88
luigser
COMPONENTS
|
109
|
|
a1a3bc73
Luigi Serra
graphs updates
|
110
111
|
/* size */
height: var(--paper-toolbar-height, 64px);
|
73bcce88
luigser
COMPONENTS
|
112
|
|
a1a3bc73
Luigi Serra
graphs updates
|
113
114
|
background: var(--paper-toolbar-background, --default-primary-color);
color: var(--paper-toolbar-color, --text-primary-color);
|
73bcce88
luigser
COMPONENTS
|
115
|
|
a1a3bc73
Luigi Serra
graphs updates
|
116
117
|
@apply(--paper-toolbar);
}
|
73bcce88
luigser
COMPONENTS
|
118
|
|
a1a3bc73
Luigi Serra
graphs updates
|
119
120
121
122
|
:host(.animate) {
/* transition */
transition: height 0.18s ease-in;
}
|
73bcce88
luigser
COMPONENTS
|
123
|
|
a1a3bc73
Luigi Serra
graphs updates
|
124
125
126
127
|
:host(.medium-tall) {
height: calc(var(--paper-toolbar-height, 64px) * 2);
@apply(--paper-toolbar-medium);
}
|
73bcce88
luigser
COMPONENTS
|
128
|
|
a1a3bc73
Luigi Serra
graphs updates
|
129
130
131
132
|
:host(.tall) {
height: calc(var(--paper-toolbar-height, 64px) * 3);
@apply(--paper-toolbar-tall);
}
|
73bcce88
luigser
COMPONENTS
|
133
|
|
a1a3bc73
Luigi Serra
graphs updates
|
134
135
136
137
138
139
140
141
142
143
144
145
146
|
.toolbar-tools {
position: relative;
height: var(--paper-toolbar-height, 64px);
padding: 0 16px;
pointer-events: none;
@apply(--layout-horizontal);
@apply(--layout-center);
@apply(--paper-toolbar-content);
}
/*
* TODO: Where should media query breakpoints live so they can be shared between elements?
*/
|
73bcce88
luigser
COMPONENTS
|
147
|
|
a1a3bc73
Luigi Serra
graphs updates
|
148
149
150
151
|
@media (max-width: 600px) {
:host {
height: var(--paper-toolbar-sm-height, 56px);
}
|
73bcce88
luigser
COMPONENTS
|
152
|
|
a1a3bc73
Luigi Serra
graphs updates
|
153
154
155
|
:host(.medium-tall) {
height: calc(var(--paper-toolbar-sm-height, 56px) * 2);
}
|
73bcce88
luigser
COMPONENTS
|
156
|
|
a1a3bc73
Luigi Serra
graphs updates
|
157
158
159
160
161
162
163
|
:host(.tall) {
height: calc(var(--paper-toolbar-sm-height, 56px) * 3);
}
.toolbar-tools {
height: var(--paper-toolbar-sm-height, 56px);
}
|
73bcce88
luigser
COMPONENTS
|
164
165
|
}
|
a1a3bc73
Luigi Serra
graphs updates
|
166
167
|
#topBar {
position: relative;
|
73bcce88
luigser
COMPONENTS
|
168
169
|
}
|
a1a3bc73
Luigi Serra
graphs updates
|
170
171
172
173
174
175
|
/* middle bar */
#middleBar {
position: absolute;
top: 0;
right: 0;
left: 0;
|
73bcce88
luigser
COMPONENTS
|
176
177
|
}
|
a1a3bc73
Luigi Serra
graphs updates
|
178
179
180
181
182
183
184
185
186
187
188
189
|
: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;
|
73bcce88
luigser
COMPONENTS
|
190
|
}
|
73bcce88
luigser
COMPONENTS
|
191
192
|
/*
|
a1a3bc73
Luigi Serra
graphs updates
|
193
194
195
196
197
|
* 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.
|
73bcce88
luigser
COMPONENTS
|
198
|
*/
|
a1a3bc73
Luigi Serra
graphs updates
|
199
200
201
|
.toolbar-tools > ::content > *:not([disabled]) {
pointer-events: auto;
}
|
73bcce88
luigser
COMPONENTS
|
202
|
|
a1a3bc73
Luigi Serra
graphs updates
|
203
204
|
.toolbar-tools > ::content .title {
@apply(--paper-font-common-base);
|
73bcce88
luigser
COMPONENTS
|
205
|
|
a1a3bc73
Luigi Serra
graphs updates
|
206
207
208
209
210
211
212
|
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
font-size: 20px;
font-weight: 400;
line-height: 1;
pointer-events: none;
|
73bcce88
luigser
COMPONENTS
|
213
|
|
a1a3bc73
Luigi Serra
graphs updates
|
214
215
216
|
@apply(--layout-flex);
@apply(--paper-toolbar-title);
}
|
73bcce88
luigser
COMPONENTS
|
217
|
|
a1a3bc73
Luigi Serra
graphs updates
|
218
219
220
221
222
223
224
|
/**
* TODO: Refactor these selectors
* Work in progress.
*/
.toolbar-tools > ::content paper-icon-button[icon=menu] {
margin-right: 24px;
}
|
73bcce88
luigser
COMPONENTS
|
225
|
|
a1a3bc73
Luigi Serra
graphs updates
|
226
227
228
229
230
|
.toolbar-tools > ::content > .title,
.toolbar-tools > ::content[select=".middle"] > .title,
.toolbar-tools > ::content[select=".bottom"] > .title {
margin-left: 56px;
}
|
73bcce88
luigser
COMPONENTS
|
231
|
|
a1a3bc73
Luigi Serra
graphs updates
|
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
|
.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;
}
|
73bcce88
luigser
COMPONENTS
|
247
|
|
a1a3bc73
Luigi Serra
graphs updates
|
248
249
250
251
252
253
|
/* TODO(noms): Until we have a better solution for classes that don't use
* /deep/ create our own.
*/
.start-justified {
@apply(--layout-start-justified);
}
|
73bcce88
luigser
COMPONENTS
|
254
|
|
a1a3bc73
Luigi Serra
graphs updates
|
255
256
257
|
.center-justified {
@apply(--layout-center-justified);
}
|
73bcce88
luigser
COMPONENTS
|
258
|
|
a1a3bc73
Luigi Serra
graphs updates
|
259
260
261
|
.end-justified {
@apply(--layout-end-justified);
}
|
73bcce88
luigser
COMPONENTS
|
262
|
|
a1a3bc73
Luigi Serra
graphs updates
|
263
264
|
.around-justified {
@apply(--layout-around-justified);
|
73bcce88
luigser
COMPONENTS
|
265
266
|
}
|
a1a3bc73
Luigi Serra
graphs updates
|
267
268
269
270
|
.justified {
@apply(--layout-justified);
}
</style>
|
73bcce88
luigser
COMPONENTS
|
271
|
|
a1a3bc73
Luigi Serra
graphs updates
|
272
273
274
275
276
277
278
279
280
281
282
283
|
<div id="topBar" class$="toolbar-tools [[_computeBarExtraClasses(justify)]]">
<content select=":not(.middle):not(.bottom)"></content>
</div>
<div id="middleBar" class$="toolbar-tools [[_computeBarExtraClasses(middleJustify)]]">
<content select=".middle"></content>
</div>
<div id="bottomBar" class$="toolbar-tools [[_computeBarExtraClasses(bottomJustify)]]">
<content select=".bottom"></content>
</div>
</template>
|
73bcce88
luigser
COMPONENTS
|
284
|
|
a1a3bc73
Luigi Serra
graphs updates
|
285
286
|
<script>
Polymer({
|
73bcce88
luigser
COMPONENTS
|
287
288
289
290
291
292
293
|
is: 'paper-toolbar',
hostAttributes: {
'role': 'toolbar'
},
properties: {
|
73bcce88
luigser
COMPONENTS
|
294
295
296
297
|
/**
* Controls how the items are aligned horizontally when they are placed
* at the bottom.
* Options are `start`, `center`, `end`, `justified` and `around`.
|
73bcce88
luigser
COMPONENTS
|
298
299
300
301
302
303
304
305
306
|
*/
bottomJustify: {
type: String,
value: ''
},
/**
* Controls how the items are aligned horizontally.
* Options are `start`, `center`, `end`, `justified` and `around`.
|
73bcce88
luigser
COMPONENTS
|
307
308
309
310
311
312
313
314
315
316
|
*/
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`.
|
73bcce88
luigser
COMPONENTS
|
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
361
362
363
364
365
366
367
368
|
*/
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(' '));
}
},
|
a1a3bc73
Luigi Serra
graphs updates
|
369
370
|
_computeBarExtraClasses: function(barJustify) {
if (!barJustify) return '';
|
73bcce88
luigser
COMPONENTS
|
371
|
|
a1a3bc73
Luigi Serra
graphs updates
|
372
|
return barJustify + (barJustify === 'justified' ? '' : '-justified');
|
73bcce88
luigser
COMPONENTS
|
373
|
}
|
73bcce88
luigser
COMPONENTS
|
374
|
});
|
a1a3bc73
Luigi Serra
graphs updates
|
375
376
|
</script>
</dom-module>
|