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 | |
4 The complete set of authors may be found at http://polymer.github.io/AUTHORS | |
5 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS | |
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 | |
8 --> | |
9 | |
10 <!-- | |
11 @group Paper Elements | |
12 | |
13 Material Design: <a href="https://spec.googleplex.com/quantum/components/buttons
.html">Buttons</a> | |
14 | |
15 `paper-icon-button` is a button with an image placed at the center. When the use
r touches | |
16 the button, a ripple effect emanates from the center of the button. | |
17 | |
18 You may import `core-icons` to use with this element, or provide an URL to a cus
tom icon. | |
19 See `core-iconset` for more information about how to use a custom icon set. | |
20 | |
21 Example: | |
22 | |
23 <link href="path/to/core-icons/core-icons.html" rel="import"> | |
24 | |
25 <paper-icon-button icon="favorite"></paper-icon-button> | |
26 <paper-icon-button src="star.png"></paper-icon-button> | |
27 | |
28 Styling | |
29 ------- | |
30 | |
31 Style the button with CSS as you would a normal DOM element. If you are using th
e icons | |
32 provided by `core-icons`, they will inherit the foreground color of the button. | |
33 | |
34 /* make a red "favorite" button */ | |
35 <paper-icon-button icon="favorite" style="color: red;"></paper-icon-button> | |
36 | |
37 By default, the ripple is the same color as the foreground at 25% opacity. You m
ay | |
38 customize the color using this selector: | |
39 | |
40 /* make #my-button use a blue ripple instead of foreground color */ | |
41 #my-button::shadow #ripple { | |
42 color: blue; | |
43 } | |
44 | |
45 The opacity of the ripple is not customizable via CSS. | |
46 | |
47 Accessibility | |
48 ------------- | |
49 | |
50 The button is accessible by default if you use the `icon` property. By default,
the | |
51 `aria-label` attribute will be set to the `icon` property. If you use a custom i
con, | |
52 you should ensure that the `aria-label` attribute is set. | |
53 | |
54 <paper-icon-button src="star.png" aria-label="star"></paper-icon-button> | |
55 | |
56 @element paper-icon-button | |
57 @extends paper-button-base | |
58 @homepage github.io | |
59 --> | |
60 | |
61 <link href="../polymer/polymer.html" rel="import"> | |
62 <link href="../core-icon/core-icon.html" rel="import"> | |
63 <link href="../paper-button/paper-button-base.html" rel="import"> | |
64 <link href="../paper-ripple/paper-ripple.html" rel="import"> | |
65 | |
66 <polymer-element name="paper-icon-button" extends="paper-button-base" attributes
="src icon" role="button"> | |
67 | |
68 <template> | |
69 | |
70 <style> | |
71 :host { | |
72 display: inline-block; | |
73 position: relative; | |
74 padding: 8px; | |
75 outline: none; | |
76 -webkit-user-select: none; | |
77 user-select: none; | |
78 cursor: pointer; | |
79 z-index: 0; | |
80 } | |
81 | |
82 :host([disabled]) { | |
83 color: #c9c9c9; | |
84 pointer-events: none; | |
85 cursor: auto; | |
86 } | |
87 | |
88 #ripple { | |
89 pointer-events: none; | |
90 z-index: -1; | |
91 } | |
92 </style> | |
93 | |
94 <!-- to position to ripple behind the icon --> | |
95 <core-icon relative id="icon" src="{{src}}" icon="{{icon}}"></core-icon> | |
96 | |
97 </template> | |
98 | |
99 <script> | |
100 Polymer({ | |
101 | |
102 publish: { | |
103 | |
104 /** | |
105 * The URL of an image for the icon. If the src property is specified, | |
106 * the icon property should not be. | |
107 * | |
108 * @attribute src | |
109 * @type string | |
110 * @default '' | |
111 */ | |
112 src: '', | |
113 | |
114 /** | |
115 * Specifies the icon name or index in the set of icons available in | |
116 * the icon's icon set. If the icon property is specified, | |
117 * the src property should not be. | |
118 * | |
119 * @attribute icon | |
120 * @type string | |
121 * @default '' | |
122 */ | |
123 icon: '', | |
124 | |
125 recenteringTouch: true, | |
126 fill: false | |
127 | |
128 }, | |
129 | |
130 iconChanged: function(oldIcon) { | |
131 this.setAttribute('aria-label', this.icon); | |
132 } | |
133 | |
134 }); | |
135 | |
136 </script> | |
137 | |
138 </polymer-element> | |
OLD | NEW |