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="http://www.google.com/design/spec/components/buttons.h
tml">Buttons</a> | |
14 | |
15 `paper-button` is a button. When the user touches the button, a ripple effect em
anates | |
16 from the point of contact. It may be flat or raised. A raised button is styled w
ith a | |
17 shadow. | |
18 | |
19 Example: | |
20 | |
21 <paper-button>flat button</paper-button> | |
22 <paper-button raised>raised button</paper-button> | |
23 | |
24 You may use custom DOM in the button body to create a variety of buttons. For ex
ample, to | |
25 create a button with an icon and some text: | |
26 | |
27 <paper-button> | |
28 <core-icon icon="favorite"> | |
29 custom button content | |
30 </paper-button> | |
31 | |
32 Styling | |
33 ------- | |
34 | |
35 Style the button with CSS as you would a normal DOM element. | |
36 | |
37 /* make #my-button green with yellow text */ | |
38 #my-button { | |
39 background: green; | |
40 color: yellow; | |
41 } | |
42 | |
43 By default, the ripple is the same color as the foreground at 25% opacity. You m
ay | |
44 customize the color using this selector: | |
45 | |
46 /* make #my-button use a blue ripple instead of foreground color */ | |
47 #my-button::shadow #ripple { | |
48 color: blue; | |
49 } | |
50 | |
51 The opacity of the ripple is not customizable via CSS. | |
52 | |
53 @element paper-button | |
54 @extends paper-button-base | |
55 @status unstable | |
56 --> | |
57 | |
58 <link href="../polymer/polymer.html" rel="import"> | |
59 <link href="../core-icon/core-icon.html" rel="import"> | |
60 <link href="../paper-ripple/paper-ripple.html" rel="import"> | |
61 <link href="../paper-shadow/paper-shadow.html" rel="import"> | |
62 | |
63 <link href="paper-button-base.html" rel="import"> | |
64 | |
65 <polymer-element name="paper-button" extends="paper-button-base" attributes="rai
sed recenteringTouch fill" | |
66 role="button"> | |
67 | |
68 <template> | |
69 | |
70 <style> | |
71 | |
72 :host { | |
73 display: inline-block; | |
74 position: relative; | |
75 box-sizing: border-box; | |
76 min-width: 5.14em; | |
77 padding: 0.7em 0.57em; | |
78 margin: 0 0.29em; | |
79 background: transparent; | |
80 text-align: center; | |
81 font: inherit; | |
82 text-transform: uppercase; | |
83 outline: none; | |
84 border-radius: 3px; | |
85 -webkit-user-select: none; | |
86 user-select: none; | |
87 cursor: pointer; | |
88 z-index: 0; | |
89 } | |
90 | |
91 :host([disabled]) { | |
92 background: #eaeaea !important; | |
93 color: #a8a8a8 !important; | |
94 cursor: auto; | |
95 pointer-events: none; | |
96 } | |
97 | |
98 ::content * { | |
99 text-transform: inherit; | |
100 } | |
101 | |
102 #ripple { | |
103 pointer-events: none; | |
104 z-index: -1; | |
105 } | |
106 | |
107 </style> | |
108 | |
109 <template if="{{raisedButton || raised}}"> | |
110 <paper-shadow id="shadow" z="{{z}}" animated></paper-shadow> | |
111 </template> | |
112 | |
113 <!-- this div is needed to position the ripple behind text content --> | |
114 <div relative> | |
115 <content></content> | |
116 {{label}} | |
117 </div> | |
118 | |
119 </template> | |
120 | |
121 <script> | |
122 Polymer({ | |
123 | |
124 publish: { | |
125 | |
126 label: '', | |
127 | |
128 /** | |
129 * If true, the button will be styled with a shadow. | |
130 * | |
131 * @attribute raised | |
132 * @type boolean | |
133 * @default false | |
134 */ | |
135 raised: false, | |
136 raisedButton: false, | |
137 | |
138 /** | |
139 * By default the ripple emanates from where the user touched the button
. | |
140 * Set this to true to always center the ripple. | |
141 * | |
142 * @attribute recenteringTouch | |
143 * @type boolean | |
144 * @default false | |
145 */ | |
146 recenteringTouch: false, | |
147 | |
148 /** | |
149 * By default the ripple expands to fill the button. Set this to true to | |
150 * constrain the ripple to a circle within the button. | |
151 * | |
152 * @attribute fill | |
153 * @type boolean | |
154 * @default true | |
155 */ | |
156 fill: true | |
157 | |
158 }, | |
159 | |
160 labelChanged: function() { | |
161 if (this.label) { | |
162 console.warn('The "label" property is deprecated.'); | |
163 } | |
164 }, | |
165 | |
166 raisedButtonChanged: function() { | |
167 if (this.raisedButton) { | |
168 console.warn('The "raisedButton" property is deprecated.'); | |
169 } | |
170 } | |
171 | |
172 }); | |
173 </script> | |
174 </polymer-element> | |
OLD | NEW |