| 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 <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 | |
| 20 <!-- | |
| 21 Material Design: <a href="http://www.google.com/design/spec/components/buttons.h
tml">Button</a> | |
| 22 | |
| 23 `paper-fab` is a floating action button. It contains an image placed in the cent
er and | |
| 24 comes in two sizes: regular size and a smaller size by applying the attribute `m
ini`. When | |
| 25 the user touches the button, a ripple effect emanates from the center of the but
ton. | |
| 26 | |
| 27 You may import `iron-icons` to use with this element, or provide a URL to a cust
om icon. | |
| 28 See `iron-iconset` for more information about how to use a custom icon set. | |
| 29 | |
| 30 Example: | |
| 31 | |
| 32 <link href="path/to/iron-icons/iron-icons.html" rel="import"> | |
| 33 | |
| 34 <paper-fab icon="add"></paper-fab> | |
| 35 <paper-fab mini icon="favorite"></paper-fab> | |
| 36 <paper-fab src="star.png"></paper-fab> | |
| 37 | |
| 38 | |
| 39 ### Styling | |
| 40 | |
| 41 The following custom properties and mixins are available for styling: | |
| 42 | |
| 43 Custom property | Description | Default | |
| 44 ----------------|-------------|---------- | |
| 45 `--paper-fab-background` | The background color of the button | `--accent-color` | |
| 46 `--paper-fab-keyboard-focus-background` | The background color of the button whe
n focused | `--paper-pink-900` | |
| 47 `--paper-fab-disabled-background` | The background color of the button when it's
disabled | `--paper-grey-300` | |
| 48 `--paper-fab-disabled-text` | The text color of the button when it's disabled |
`--paper-grey-500` | |
| 49 `--paper-fab` | Mixin applied to the button | `{}` | |
| 50 `--paper-fab-mini` | Mixin applied to a mini button | `{}` | |
| 51 `--paper-fab-disabled` | Mixin applied to a disabled button | `{}` | |
| 52 | |
| 53 @group Paper Elements | |
| 54 @demo demo/index.html | |
| 55 | |
| 56 --> | |
| 57 | |
| 58 <dom-module id="paper-fab"> | |
| 59 <style> | |
| 60 | |
| 61 :host { | |
| 62 display: inline-block; | |
| 63 position: relative; | |
| 64 outline: none; | |
| 65 -moz-user-select: none; | |
| 66 -ms-user-select: none; | |
| 67 -webkit-user-select: none; | |
| 68 user-select: none; | |
| 69 cursor: pointer; | |
| 70 | |
| 71 box-sizing: border-box; | |
| 72 min-width: 0; | |
| 73 width: 56px; | |
| 74 height: 56px; | |
| 75 background: var(--paper-fab-background, --accent-color); | |
| 76 color: var(--text-primary-color); | |
| 77 border-radius: 50%; | |
| 78 padding: 16px; | |
| 79 | |
| 80 z-index: 0; | |
| 81 | |
| 82 @apply(--paper-fab); | |
| 83 } | |
| 84 | |
| 85 :host([mini]) { | |
| 86 width: 40px; | |
| 87 height: 40px; | |
| 88 padding: 8px; | |
| 89 | |
| 90 @apply(--paper-fab-mini); | |
| 91 } | |
| 92 | |
| 93 :host([disabled]) { | |
| 94 color: var(--paper-fab-disabled-text, --paper-grey-500); | |
| 95 background: var(--paper-fab-disabled-background, --paper-grey-300); | |
| 96 @apply(--paper-fab-disabled); | |
| 97 } | |
| 98 | |
| 99 paper-material { | |
| 100 border-radius: inherit; | |
| 101 @apply(--layout-fit); | |
| 102 @apply(--layout-vertical); | |
| 103 @apply(--layout-center-center); | |
| 104 } | |
| 105 | |
| 106 .keyboard-focus { | |
| 107 background: var(--paper-fab-keyboard-focus-background, --paper-pink-900); | |
| 108 } | |
| 109 </style> | |
| 110 <template> | |
| 111 <paper-ripple></paper-ripple> | |
| 112 <paper-material class$="[[_computeContentClass(receivedFocusFromKeyboard)]]"
elevation="[[_elevation]]" animated> | |
| 113 <iron-icon id="icon" src="[[src]]" icon="[[icon]]"></iron-icon> | |
| 114 </paper-material> | |
| 115 </template> | |
| 116 </dom-module> | |
| 117 <script> | |
| 118 Polymer({ | |
| 119 is: 'paper-fab', | |
| 120 | |
| 121 behaviors: [ | |
| 122 Polymer.PaperButtonBehavior | |
| 123 ], | |
| 124 | |
| 125 properties: { | |
| 126 /** | |
| 127 * The URL of an image for the icon. If the src property is specified, | |
| 128 * the icon property should not be. | |
| 129 * | |
| 130 * @attribute src | |
| 131 * @type string | |
| 132 * @default '' | |
| 133 */ | |
| 134 src: { | |
| 135 type: String, | |
| 136 value: '' | |
| 137 }, | |
| 138 | |
| 139 /** | |
| 140 * Specifies the icon name or index in the set of icons available in | |
| 141 * the icon's icon set. If the icon property is specified, | |
| 142 * the src property should not be. | |
| 143 * | |
| 144 * @attribute icon | |
| 145 * @type string | |
| 146 * @default '' | |
| 147 */ | |
| 148 icon: { | |
| 149 type: String, | |
| 150 value: '' | |
| 151 }, | |
| 152 | |
| 153 /** | |
| 154 * Set this to true to style this is a "mini" FAB. | |
| 155 * | |
| 156 * @attribute mini | |
| 157 * @type boolean | |
| 158 * @default false | |
| 159 */ | |
| 160 mini: { | |
| 161 type: Boolean, | |
| 162 value: false | |
| 163 } | |
| 164 }, | |
| 165 | |
| 166 _computeContentClass: function(receivedFocusFromKeyboard) { | |
| 167 var className = 'content'; | |
| 168 if (receivedFocusFromKeyboard) { | |
| 169 className += ' keyboard-focus'; | |
| 170 } | |
| 171 return className; | |
| 172 } | |
| 173 | |
| 174 }); | |
| 175 </script> | |
| OLD | NEW |