OLD | NEW |
| (Empty) |
1 <!-- | |
2 Copyright (c) 2014 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 @group Paper Elements | |
12 | |
13 Material Design: <a href="https://spec.googleplex.com/quantum/components/buttons
.html">Button</a> | |
14 | |
15 `paper-fab` is a floating action button. It contains an image placed in the cent
er and | |
16 comes in two sizes: regular size and a smaller size by applying the class `mini`
. When | |
17 the user touches the button, a ripple effect emanates from the center of the but
ton. | |
18 | |
19 You may import `core-icons` to use with this element, or provide an URL to a cus
tom icon. | |
20 See `core-iconset` for more information about how to use a custom icon set. | |
21 | |
22 Example: | |
23 | |
24 <link href="path/to/core-icons/core-icons.html" rel="import"> | |
25 | |
26 <paper-fab icon="add"></paper-fab> | |
27 <paper-fab mini icon="favorite"></paper-fab> | |
28 <paper-fab src="star.png"></paper-fab> | |
29 | |
30 Styling | |
31 ------- | |
32 | |
33 Style the button with CSS as you would a normal DOM element. If you are using th
e icons | |
34 provided by `core-icons`, the icon will inherit the foreground color of the butt
on. | |
35 | |
36 /* make a blue "cloud" button */ | |
37 <paper-fab icon="cloud" style="color: blue;"></paper-fab> | |
38 | |
39 By default, the ripple is the same color as the foreground at 25% opacity. You m
ay | |
40 customize the color using this selector: | |
41 | |
42 /* make #my-button use a blue ripple instead of foreground color */ | |
43 #my-button::shadow #ripple { | |
44 color: blue; | |
45 } | |
46 | |
47 The opacity of the ripple is not customizable via CSS. | |
48 | |
49 Accessibility | |
50 ------------- | |
51 | |
52 The button is accessible by default if you use the `icon` property. By default,
the | |
53 `aria-label` attribute will be set to the `icon` property. If you use a custom i
con, | |
54 you should ensure that the `aria-label` attribute is set. | |
55 | |
56 <paper-fab src="star.png" aria-label="star"></paper-fab> | |
57 | |
58 @element paper-fab | |
59 @extends paper-button-base | |
60 @status unstable | |
61 --> | |
62 | |
63 <link href="../polymer/polymer.html" rel="import"> | |
64 <link href="../paper-button/paper-button-base.html" rel="import"> | |
65 <link href="../paper-ripple/paper-ripple.html" rel="import"> | |
66 <link href="../paper-shadow/paper-shadow.html" rel="import"> | |
67 | |
68 <polymer-element name="paper-fab" extends="paper-button-base" attributes="src ic
on mini" role="button"> | |
69 | |
70 <template> | |
71 | |
72 <style> | |
73 :host { | |
74 display: inline-block; | |
75 position: relative; | |
76 outline: none; | |
77 -webkit-user-select: none; | |
78 user-select: none; | |
79 cursor: pointer; | |
80 z-index: 0; | |
81 | |
82 box-sizing: border-box; | |
83 width: 56px; | |
84 height: 56px; | |
85 background: #d23f31; | |
86 color: #fff; | |
87 border-radius: 50%; | |
88 padding: 16px; | |
89 } | |
90 | |
91 :host([mini]) { | |
92 width: 40px; | |
93 height: 40px; | |
94 padding: 8px; | |
95 } | |
96 | |
97 :host([disabled]) { | |
98 color: #c9c9c9; | |
99 pointer-events: none; | |
100 cursor: auto; | |
101 } | |
102 | |
103 #ripple { | |
104 pointer-events: none; | |
105 z-index: -1; | |
106 } | |
107 </style> | |
108 | |
109 <template if="{{raised}}"> | |
110 <paper-shadow id="shadow" z="{{z}}" animated></paper-shadow> | |
111 </template> | |
112 | |
113 <!-- to position to ripple behind the icon --> | |
114 <core-icon relative id="icon" src="{{src}}" icon="{{icon}}"></core-icon> | |
115 | |
116 </template> | |
117 | |
118 <script> | |
119 Polymer({ | |
120 | |
121 publish: { | |
122 | |
123 /** | |
124 * The URL of an image for the icon. If the src property is specified, | |
125 * the icon property should not be. | |
126 * | |
127 * @attribute src | |
128 * @type string | |
129 * @default '' | |
130 */ | |
131 src: '', | |
132 | |
133 /** | |
134 * Specifies the icon name or index in the set of icons available in | |
135 * the icon's icon set. If the icon property is specified, | |
136 * the src property should not be. | |
137 * | |
138 * @attribute icon | |
139 * @type string | |
140 * @default '' | |
141 */ | |
142 icon: '', | |
143 | |
144 /** | |
145 * Set this to true to style this is a "mini" FAB. | |
146 * | |
147 * @attribute mini | |
148 * @type boolean | |
149 * @default false | |
150 */ | |
151 mini: false, | |
152 | |
153 raised: true, | |
154 recenteringTouch: false, | |
155 fill: true | |
156 | |
157 }, | |
158 | |
159 iconChanged: function(oldIcon) { | |
160 this.setAttribute('aria-label', this.icon); | |
161 } | |
162 | |
163 }); | |
164 | |
165 </script> | |
166 </polymer-element> | |
OLD | NEW |