| OLD | NEW |
| 1 <!-- | 1 <!-- |
| 2 @license | 2 @license |
| 3 Copyright (c) 2015 The Polymer Project Authors. All rights reserved. | 3 Copyright (c) 2015 The Polymer Project Authors. All rights reserved. |
| 4 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt | 4 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt |
| 5 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt | 5 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt |
| 6 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt | 6 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt |
| 7 Code distributed by Google as part of the polymer project is also | 7 Code distributed by Google as part of the polymer project is also |
| 8 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt | 8 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt |
| 9 --> | 9 --> |
| 10 | 10 |
| 11 <link rel="import" href="../polymer/polymer.html"> |
| 12 <link rel="import" href="../iron-icon/iron-icon.html"> |
| 13 <link rel="import" href="../iron-flex-layout/classes/iron-flex-layout.html"> |
| 14 <link rel="import" href="../paper-styles/default-theme.html"> |
| 15 <link rel="import" href="../paper-styles/color.html"> |
| 16 <link rel="import" href="../paper-material/paper-material.html"> |
| 17 <link rel="import" href="../paper-ripple/paper-ripple.html"> |
| 18 <link rel="import" href="../paper-behaviors/paper-button-behavior.html"> |
| 19 |
| 11 <!-- | 20 <!-- |
| 12 @group Paper Elements | |
| 13 | |
| 14 Material Design: <a href="http://www.google.com/design/spec/components/buttons.h
tml">Button</a> | 21 Material Design: <a href="http://www.google.com/design/spec/components/buttons.h
tml">Button</a> |
| 15 | 22 |
| 16 `paper-fab` is a floating action button. It contains an image placed in the cent
er and | 23 `paper-fab` is a floating action button. It contains an image placed in the cent
er and |
| 17 comes in two sizes: regular size and a smaller size by applying the attribute `m
ini`. When | 24 comes in two sizes: regular size and a smaller size by applying the attribute `m
ini`. When |
| 18 the user touches the button, a ripple effect emanates from the center of the but
ton. | 25 the user touches the button, a ripple effect emanates from the center of the but
ton. |
| 19 | 26 |
| 20 You may import `iron-icons` to use with this element, or provide a URL to a cust
om icon. | 27 You may import `iron-icons` to use with this element, or provide a URL to a cust
om icon. |
| 21 See `iron-iconset` for more information about how to use a custom icon set. | 28 See `iron-iconset` for more information about how to use a custom icon set. |
| 22 | 29 |
| 23 Example: | 30 Example: |
| 24 | 31 |
| 25 <link href="path/to/iron-icons/iron-icons.html" rel="import"> | 32 <link href="path/to/iron-icons/iron-icons.html" rel="import"> |
| 26 | 33 |
| 27 <paper-fab icon="add"></paper-fab> | 34 <paper-fab icon="add"></paper-fab> |
| 28 <paper-fab mini icon="favorite"></paper-fab> | 35 <paper-fab mini icon="favorite"></paper-fab> |
| 29 <paper-fab src="star.png"></paper-fab> | 36 <paper-fab src="star.png"></paper-fab> |
| 30 | 37 |
| 31 Styling | |
| 32 ------- | |
| 33 | 38 |
| 34 Style the button with CSS as you would a normal DOM element. If you are using th
e icons | 39 ### Styling |
| 35 provided by `iron-icons`, the icon will inherit the foreground color of the butt
on. | |
| 36 | 40 |
| 37 /* make a blue "cloud" button */ | 41 The following custom properties and mixins are available for styling: |
| 38 <paper-fab icon="cloud" style="color: blue;"></paper-fab> | |
| 39 | 42 |
| 40 By default, the ripple is the same color as the foreground at 25% opacity. You m
ay | 43 Custom property | Description | Default |
| 41 customize the color using this selector: | 44 ----------------|-------------|---------- |
| 45 `--paper-fab-background` | The background color of the button | `--paper-indigo-
500` |
| 46 `--paper-fab-disabled-background` | The background color of the button when it's
disabled | `--paper-grey-300` |
| 47 `--paper-fab-disabled-text` | The text color of the button when it's disabled |
`--paper-grey-500` |
| 48 `--paper-fab` | Mixin applied to the button | `{}` |
| 49 `--paper-fab-mini` | Mixin applied to a mini button | `{}` |
| 50 `--paper-fab-disabled` | Mixin applied to a disabled button | `{}` |
| 42 | 51 |
| 43 /* make #my-button use a blue ripple instead of foreground color */ | 52 @group Paper Elements |
| 44 #my-button::shadow #ripple { | 53 @demo demo/index.html |
| 45 color: blue; | |
| 46 } | |
| 47 | 54 |
| 48 The opacity of the ripple is not customizable via CSS. | |
| 49 | |
| 50 @element paper-fab | |
| 51 @status unstable | |
| 52 --> | 55 --> |
| 53 | 56 |
| 54 <link rel="import" href="../polymer/polymer.html"> | |
| 55 <link rel="import" href="../iron-icon/iron-icon.html"> | |
| 56 <link rel="import" href="../iron-flex-layout/classes/iron-flex-layout.html"> | |
| 57 <link rel="import" href="../paper-styles/default-theme.html"> | |
| 58 <link rel="import" href="../paper-material/paper-material.html"> | |
| 59 <link rel="import" href="../paper-ripple/paper-ripple.html"> | |
| 60 <link rel="import" href="../paper-behaviors/paper-button-behavior.html"> | |
| 61 | |
| 62 <style is="x-style"> | |
| 63 * { | |
| 64 --paper-fab-disabled-text: #c9c9c9; | |
| 65 --paper-fab-disabled-background: var(--accent-color); | |
| 66 } | |
| 67 </style> | |
| 68 | |
| 69 <dom-module id="paper-fab"> | 57 <dom-module id="paper-fab"> |
| 70 <style> | 58 <style> |
| 71 | 59 |
| 72 :host { | 60 :host { |
| 73 display: inline-block; | 61 display: inline-block; |
| 74 position: relative; | 62 position: relative; |
| 75 outline: none; | 63 outline: none; |
| 76 -moz-user-select: none; | 64 -moz-user-select: none; |
| 77 -ms-user-select: none; | 65 -ms-user-select: none; |
| 78 -webkit-user-select: none; | 66 -webkit-user-select: none; |
| 79 user-select: none; | 67 user-select: none; |
| 80 cursor: pointer; | 68 cursor: pointer; |
| 81 | 69 |
| 82 box-sizing: border-box; | 70 box-sizing: border-box; |
| 83 min-width: 0; | 71 min-width: 0; |
| 84 width: 56px; | 72 width: 56px; |
| 85 height: 56px; | 73 height: 56px; |
| 86 background: var(--accent-color); | 74 background: var(--paper-fab-background, --paper-indigo-500); |
| 87 color: var(--text-primary-color); | 75 color: var(--text-primary-color); |
| 88 border-radius: 50%; | 76 border-radius: 50%; |
| 89 padding: 16px; | 77 padding: 16px; |
| 90 | 78 |
| 91 z-index: 0; | 79 z-index: 0; |
| 92 | 80 |
| 93 mixin(--paper-fab); | 81 @apply(--paper-fab); |
| 94 } | 82 } |
| 95 | 83 |
| 96 :host([mini]) { | 84 :host([mini]) { |
| 97 width: 40px; | 85 width: 40px; |
| 98 height: 40px; | 86 height: 40px; |
| 99 padding: 8px; | 87 padding: 8px; |
| 100 | 88 |
| 101 mixin(--paper-fab-mini); | 89 @apply(--paper-fab-mini); |
| 102 } | 90 } |
| 103 | 91 |
| 104 :host([disabled]) { | 92 :host([disabled]) { |
| 105 color: var(--paper-fab-disabled-text); | 93 color: var(--paper-fab-disabled-text, --paper-grey-500); |
| 106 | 94 background: var(--paper-fab-disabled-background, --paper-grey-300); |
| 107 mixin(--paper-fab-disabled); | 95 @apply(--paper-fab-disabled); |
| 108 } | 96 } |
| 109 | 97 |
| 110 paper-material { | 98 paper-material { |
| 111 border-radius: inherit; | 99 border-radius: inherit; |
| 112 } | 100 } |
| 113 </style> | 101 </style> |
| 114 <template> | 102 <template> |
| 115 <paper-ripple></paper-ripple> | 103 <paper-ripple></paper-ripple> |
| 116 <paper-material class="content fit flex layout vertical center-center" eleva
tion="[[elevation]]" animated> | 104 <paper-material class="content fit flex layout vertical center-center" eleva
tion="[[elevation]]" animated> |
| 117 <iron-icon id="icon" src="[[src]]" icon="[[icon]]"></iron-icon> | 105 <iron-icon id="icon" src="[[src]]" icon="[[icon]]"></iron-icon> |
| 118 </paper-material> | 106 </paper-material> |
| 119 </template> | 107 </template> |
| 120 </dom-module> | 108 </dom-module> |
| 121 <script> | 109 <script> |
| 122 Polymer({ | 110 Polymer({ |
| 123 is: 'paper-fab', | 111 is: 'paper-fab', |
| 124 | 112 |
| 125 enableCustomStyleProperties: true, | |
| 126 | |
| 127 behaviors: [ | 113 behaviors: [ |
| 128 Polymer.PaperButtonBehavior | 114 Polymer.PaperButtonBehavior |
| 129 ], | 115 ], |
| 130 | 116 |
| 131 properties: { | 117 properties: { |
| 132 /** | 118 /** |
| 133 * The URL of an image for the icon. If the src property is specified, | 119 * The URL of an image for the icon. If the src property is specified, |
| 134 * the icon property should not be. | 120 * the icon property should not be. |
| 135 * | 121 * |
| 136 * @attribute src | 122 * @attribute src |
| (...skipping 24 matching lines...) Expand all Loading... |
| 161 * | 147 * |
| 162 * @attribute mini | 148 * @attribute mini |
| 163 * @type boolean | 149 * @type boolean |
| 164 * @default false | 150 * @default false |
| 165 */ | 151 */ |
| 166 mini: { | 152 mini: { |
| 167 type: Boolean, | 153 type: Boolean, |
| 168 value: false | 154 value: false |
| 169 } | 155 } |
| 170 } | 156 } |
| 157 |
| 171 }); | 158 }); |
| 172 </script> | 159 </script> |
| OLD | NEW |