OLD | NEW |
(Empty) | |
| 1 <!-- |
| 2 @license |
| 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 |
| 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 |
| 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 |
| 9 --> |
| 10 |
| 11 <!-- |
| 12 @group Paper Elements |
| 13 |
| 14 Material Design: <a href="http://www.google.com/design/spec/components/buttons.h
tml">Button</a> |
| 15 |
| 16 `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 |
| 18 the user touches the button, a ripple effect emanates from the center of the but
ton. |
| 19 |
| 20 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. |
| 22 |
| 23 Example: |
| 24 |
| 25 <link href="path/to/iron-icons/iron-icons.html" rel="import"> |
| 26 |
| 27 <paper-fab icon="add"></paper-fab> |
| 28 <paper-fab mini icon="favorite"></paper-fab> |
| 29 <paper-fab src="star.png"></paper-fab> |
| 30 |
| 31 Styling |
| 32 ------- |
| 33 |
| 34 Style the button with CSS as you would a normal DOM element. If you are using th
e icons |
| 35 provided by `iron-icons`, the icon will inherit the foreground color of the butt
on. |
| 36 |
| 37 /* make a blue "cloud" button */ |
| 38 <paper-fab icon="cloud" style="color: blue;"></paper-fab> |
| 39 |
| 40 By default, the ripple is the same color as the foreground at 25% opacity. You m
ay |
| 41 customize the color using this selector: |
| 42 |
| 43 /* make #my-button use a blue ripple instead of foreground color */ |
| 44 #my-button::shadow #ripple { |
| 45 color: blue; |
| 46 } |
| 47 |
| 48 The opacity of the ripple is not customizable via CSS. |
| 49 |
| 50 @element paper-fab |
| 51 @status unstable |
| 52 --> |
| 53 |
| 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"> |
| 70 <style> |
| 71 |
| 72 :host { |
| 73 display: inline-block; |
| 74 position: relative; |
| 75 outline: none; |
| 76 -moz-user-select: none; |
| 77 -ms-user-select: none; |
| 78 -webkit-user-select: none; |
| 79 user-select: none; |
| 80 cursor: pointer; |
| 81 |
| 82 box-sizing: border-box; |
| 83 min-width: 0; |
| 84 width: 56px; |
| 85 height: 56px; |
| 86 background: var(--accent-color); |
| 87 color: var(--text-primary-color); |
| 88 border-radius: 50%; |
| 89 padding: 16px; |
| 90 |
| 91 z-index: 0; |
| 92 |
| 93 mixin(--paper-fab); |
| 94 } |
| 95 |
| 96 :host([mini]) { |
| 97 width: 40px; |
| 98 height: 40px; |
| 99 padding: 8px; |
| 100 |
| 101 mixin(--paper-fab-mini); |
| 102 } |
| 103 |
| 104 :host([disabled]) { |
| 105 color: var(--paper-fab-disabled-text); |
| 106 |
| 107 mixin(--paper-fab-disabled); |
| 108 } |
| 109 |
| 110 paper-material { |
| 111 border-radius: inherit; |
| 112 } |
| 113 </style> |
| 114 <template> |
| 115 <paper-ripple></paper-ripple> |
| 116 <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> |
| 118 </paper-material> |
| 119 </template> |
| 120 </dom-module> |
| 121 <script> |
| 122 Polymer({ |
| 123 is: 'paper-fab', |
| 124 |
| 125 enableCustomStyleProperties: true, |
| 126 |
| 127 behaviors: [ |
| 128 Polymer.PaperButtonBehavior |
| 129 ], |
| 130 |
| 131 properties: { |
| 132 /** |
| 133 * The URL of an image for the icon. If the src property is specified, |
| 134 * the icon property should not be. |
| 135 * |
| 136 * @attribute src |
| 137 * @type string |
| 138 * @default '' |
| 139 */ |
| 140 src: { |
| 141 type: String, |
| 142 value: '' |
| 143 }, |
| 144 |
| 145 /** |
| 146 * Specifies the icon name or index in the set of icons available in |
| 147 * the icon's icon set. If the icon property is specified, |
| 148 * the src property should not be. |
| 149 * |
| 150 * @attribute icon |
| 151 * @type string |
| 152 * @default '' |
| 153 */ |
| 154 icon: { |
| 155 type: String, |
| 156 value: '' |
| 157 }, |
| 158 |
| 159 /** |
| 160 * Set this to true to style this is a "mini" FAB. |
| 161 * |
| 162 * @attribute mini |
| 163 * @type boolean |
| 164 * @default false |
| 165 */ |
| 166 mini: { |
| 167 type: Boolean, |
| 168 value: false |
| 169 } |
| 170 } |
| 171 }); |
| 172 </script> |
OLD | NEW |