Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(500)

Side by Side Diff: third_party/polymer/v1_0/components/paper-toolbar/paper-toolbar.html

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

Powered by Google App Engine
This is Rietveld 408576698