OLD | NEW |
(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 <!-- |
| 11 `paper-toolbar` is a horizontal bar containing items that can be used for |
| 12 label, navigation, search and actions. The items place inside the |
| 13 `paper-toolbar` are projected into a `class="horizontal center layout"` containe
r inside of |
| 14 `paper-toolbar`'s Shadow DOM. You can use flex attributes to control the items' |
| 15 sizing. |
| 16 |
| 17 Example: |
| 18 |
| 19 <paper-toolbar> |
| 20 <paper-icon-button icon="menu" on-tap="{{menuAction}}"></paper-icon-button
> |
| 21 <div flex>Title</div> |
| 22 <paper-icon-button icon="more" on-tap="{{moreAction}}"></paper-icon-button
> |
| 23 </paper-toolbar> |
| 24 |
| 25 `paper-toolbar` has a standard height, but can made be taller by setting `tall` |
| 26 class on the `paper-toolbar`. This will make the toolbar 3x the normal height. |
| 27 |
| 28 <paper-toolbar class="tall"> |
| 29 <paper-icon-button icon="menu"></paper-icon-button> |
| 30 </paper-toolbar> |
| 31 |
| 32 Apply `medium-tall` class to make the toolbar medium tall. This will make the |
| 33 toolbar 2x the normal height. |
| 34 |
| 35 <paper-toolbar class="medium-tall"> |
| 36 <paper-icon-button icon="menu"></paper-icon-button> |
| 37 </paper-toolbar> |
| 38 |
| 39 When `tall`, items can pin to either the top (default), middle or bottom. Use |
| 40 `middle` class for middle content and `bottom` class for bottom content. |
| 41 |
| 42 <paper-toolbar class="tall"> |
| 43 <paper-icon-button icon="menu"></paper-icon-button> |
| 44 <div class="middle">Middle Title</div> |
| 45 <div class="bottom">Bottom Title</div> |
| 46 </paper-toolbar> |
| 47 |
| 48 For `medium-tall` toolbar, the middle and bottom contents overlap and are |
| 49 pinned to the bottom. But `middleJustify` and `bottomJustify` attributes are |
| 50 still honored separately. |
| 51 |
| 52 @group Polymer Core Elements |
| 53 @element paper-toolbar |
| 54 @homepage github.io |
| 55 --> |
| 56 |
| 57 <link rel="import" href="../polymer/polymer.html"> |
| 58 <link rel="import" href="../paper-styles/paper-styles.html"> |
| 59 |
| 60 <style is="x-style"> |
| 61 |
| 62 * { |
| 63 |
| 64 --paper-toolbar-background: var(--default-primary-color); |
| 65 --paper-toolbar-color: var(--text-primary-color); |
| 66 } |
| 67 </style> |
| 68 |
| 69 <dom-module id="paper-toolbar"> |
| 70 |
| 71 <style> |
| 72 :host { |
| 73 /* technical */ |
| 74 display: block; |
| 75 position: relative; |
| 76 box-sizing: border-box; |
| 77 -moz-box-sizing: border-box; |
| 78 |
| 79 /* size */ |
| 80 height: 64px; |
| 81 |
| 82 background: var(--paper-toolbar-background); |
| 83 color: var(--paper-toolbar-color); |
| 84 mixin(--paper-font-title); |
| 85 |
| 86 mixin(--paper-toolbar); |
| 87 } |
| 88 |
| 89 :host(.animate) { |
| 90 /* transition */ |
| 91 transition: height 0.18s ease-in; |
| 92 } |
| 93 |
| 94 :host(.medium-tall) { |
| 95 height: 128px; |
| 96 } |
| 97 |
| 98 :host(.tall) { |
| 99 height: 192px; |
| 100 } |
| 101 |
| 102 .toolbar-tools { |
| 103 position: relative; |
| 104 height: 64px; |
| 105 padding: 0 16px; |
| 106 pointer-events: none; |
| 107 } |
| 108 |
| 109 /* |
| 110 * TODO: Where should media query breakpoints live so they can be shared bet
ween elements? |
| 111 */ |
| 112 |
| 113 @media (max-width: 639px) { |
| 114 :host { |
| 115 height: 56px; |
| 116 } |
| 117 |
| 118 :host(.medium-tall) { |
| 119 height: 112px; |
| 120 } |
| 121 |
| 122 :host(.tall) { |
| 123 height: 168px; |
| 124 } |
| 125 |
| 126 .toolbar-tools { |
| 127 height: 56px; |
| 128 padding: 0; |
| 129 } |
| 130 } |
| 131 |
| 132 /* middle bar */ |
| 133 #middleBar { |
| 134 position: absolute; |
| 135 top: 0; |
| 136 right: 0; |
| 137 left: 0; |
| 138 } |
| 139 |
| 140 :host(.tall) #middleBar, |
| 141 :host(.medium-tall) #middleBar { |
| 142 -webkit-transform: translateY(100%); |
| 143 transform: translateY(100%); |
| 144 } |
| 145 |
| 146 /* bottom bar */ |
| 147 #bottomBar { |
| 148 position: absolute; |
| 149 right: 0; |
| 150 bottom: 0; |
| 151 left: 0; |
| 152 } |
| 153 |
| 154 /* |
| 155 * make elements (e.g. buttons) respond to mouse/touch events |
| 156 * |
| 157 * `.toolbar-tools` disables touch events so multiple toolbars can stack and
not |
| 158 * absorb events. All children must have pointer events re-enabled to work a
s |
| 159 * expected. |
| 160 */ |
| 161 .toolbar-tools > ::content > *:not([disabled]) { |
| 162 pointer-events: auto; |
| 163 } |
| 164 |
| 165 </style> |
| 166 |
| 167 <template> |
| 168 |
| 169 <div id="bottomBar" class$="[[_computeBarClassName(bottomJustify)]]"> |
| 170 <content select=".bottom"></content> |
| 171 </div> |
| 172 |
| 173 <div id="middleBar" class$="[[_computeBarClassName(middleJustify)]]"> |
| 174 <content select=".middle"></content> |
| 175 </div> |
| 176 |
| 177 <div id="topBar" class$="[[_computeBarClassName(justify)]]"> |
| 178 <content></content> |
| 179 </div> |
| 180 |
| 181 </template> |
| 182 |
| 183 </dom-module> |
| 184 |
| 185 <script> |
| 186 |
| 187 (function() { |
| 188 |
| 189 'use strict'; |
| 190 |
| 191 function classNames(obj) { |
| 192 var classNames = []; |
| 193 for (var key in obj) { |
| 194 if (obj.hasOwnProperty(key) && obj[key]) { |
| 195 classNames.push(key); |
| 196 } |
| 197 } |
| 198 |
| 199 return classNames.join(' '); |
| 200 } |
| 201 |
| 202 Polymer({ |
| 203 |
| 204 is: 'paper-toolbar', |
| 205 |
| 206 enableCustomStyleProperties: true, |
| 207 |
| 208 properties: { |
| 209 |
| 210 /** |
| 211 * Controls how the items are aligned horizontally when they are placed |
| 212 * at the bottom. |
| 213 * Options are `start`, `center`, `end`, `justified` and `around`. |
| 214 * |
| 215 * @attribute bottomJustify |
| 216 * @type string |
| 217 * @default '' |
| 218 */ |
| 219 bottomJustify: { |
| 220 type: String, |
| 221 value: '' |
| 222 }, |
| 223 |
| 224 /** |
| 225 * Controls how the items are aligned horizontally. |
| 226 * Options are `start`, `center`, `end`, `justified` and `around`. |
| 227 * |
| 228 * @attribute justify |
| 229 * @type string |
| 230 * @default '' |
| 231 */ |
| 232 justify: { |
| 233 type: String, |
| 234 value: '' |
| 235 }, |
| 236 |
| 237 /** |
| 238 * Controls how the items are aligned horizontally when they are placed |
| 239 * in the middle. |
| 240 * Options are `start`, `center`, `end`, `justified` and `around`. |
| 241 * |
| 242 * @attribute middleJustify |
| 243 * @type string |
| 244 * @default '' |
| 245 */ |
| 246 middleJustify: { |
| 247 type: String, |
| 248 value: '' |
| 249 } |
| 250 |
| 251 }, |
| 252 |
| 253 _computeBarClassName: function(barJustify) { |
| 254 var classObj = { |
| 255 center: true, |
| 256 horizontal: true, |
| 257 layout: true, |
| 258 'toolbar-tools': true |
| 259 }; |
| 260 |
| 261 // If a blank string or any falsy value is given, no other class name is |
| 262 // added. |
| 263 if (barJustify) { |
| 264 var justifyClassName = (barJustify === 'justified') ? |
| 265 barJustify : |
| 266 barJustify + '-justified'; |
| 267 |
| 268 classObj[justifyClassName] = true; |
| 269 } |
| 270 |
| 271 return classNames(classObj); |
| 272 } |
| 273 |
| 274 }); |
| 275 |
| 276 }()); |
| 277 |
| 278 </script> |
OLD | NEW |