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="../paper-material/paper-material.html"> |
| 13 <link rel="import" href="../paper-ripple/paper-ripple.html"> |
| 14 <link rel="import" href="../paper-behaviors/paper-button-behavior.html"> |
| 15 <link rel="import" href="../iron-flex-layout/iron-flex-layout.html"> |
| 16 |
| 17 <!-- |
| 18 Material design: [Buttons](https://www.google.com/design/spec/components/buttons
.html) |
| 19 |
| 20 `paper-button` is a button. When the user touches the button, a ripple effect em
anates |
| 21 from the point of contact. It may be flat or raised. A raised button is styled w
ith a |
| 22 shadow. |
| 23 |
| 24 Example: |
| 25 |
| 26 <paper-button>Flat button</paper-button> |
| 27 <paper-button raised>Raised button</paper-button> |
| 28 <paper-button noink>No ripple effect</paper-button> |
| 29 <paper-button toggles>Toggle-able button</paper-button> |
| 30 |
| 31 A button that has `toggles` true will remain `active` after being clicked (and |
| 32 will have an `active` attribute set). For more information, see the `Polymer.Iro
nButtonState` |
| 33 behavior. |
| 34 |
| 35 You may use custom DOM in the button body to create a variety of buttons. For ex
ample, to |
| 36 create a button with an icon and some text: |
| 37 |
| 38 <paper-button> |
| 39 <iron-icon icon="favorite"></iron-icon> |
| 40 custom button content |
| 41 </paper-button> |
| 42 |
| 43 ### Styling |
| 44 |
| 45 Style the button with CSS as you would a normal DOM element. |
| 46 |
| 47 paper-button.fancy { |
| 48 background: green; |
| 49 color: yellow; |
| 50 } |
| 51 |
| 52 paper-button.fancy:hover { |
| 53 background: lime; |
| 54 } |
| 55 |
| 56 paper-button[disabled], |
| 57 paper-button[toggles][active] { |
| 58 background: red; |
| 59 } |
| 60 |
| 61 By default, the ripple is the same color as the foreground at 25% opacity. You m
ay |
| 62 customize the color using the `--paper-button-ink-color` custom property. |
| 63 |
| 64 The following custom properties and mixins are also available for styling: |
| 65 |
| 66 Custom property | Description | Default |
| 67 ----------------|-------------|---------- |
| 68 `--paper-button-ink-color` | Background color of the ripple | `Based on the butt
on's color` |
| 69 `--paper-button` | Mixin applied to the button | `{}` |
| 70 `--paper-button-disabled` | Mixin applied to the disabled button. Note that you
can also use the `paper-button[disabled]` selector | `{}` |
| 71 `--paper-button-flat-keyboard-focus` | Mixin applied to a flat button after it's
been focused using the keyboard | `{}` |
| 72 `--paper-button-raised-keyboard-focus` | Mixin applied to a raised button after
it's been focused using the keyboard | `{}` |
| 73 |
| 74 @demo demo/index.html |
| 75 --> |
| 76 |
| 77 <dom-module id="paper-button"> |
| 78 <template strip-whitespace> |
| 79 |
| 80 <style include="paper-material"> |
| 81 :host { |
| 82 display: inline-block; |
| 83 position: relative; |
| 84 box-sizing: border-box; |
| 85 min-width: 5.14em; |
| 86 margin: 0 0.29em; |
| 87 background: transparent; |
| 88 text-align: center; |
| 89 font: inherit; |
| 90 text-transform: uppercase; |
| 91 outline-width: 0; |
| 92 border-radius: 3px; |
| 93 -moz-user-select: none; |
| 94 -ms-user-select: none; |
| 95 -webkit-user-select: none; |
| 96 user-select: none; |
| 97 cursor: pointer; |
| 98 z-index: 0; |
| 99 padding: 0.7em 0.57em; |
| 100 |
| 101 @apply(--paper-button); |
| 102 } |
| 103 |
| 104 :host([raised].keyboard-focus) { |
| 105 font-weight: bold; |
| 106 @apply(--paper-button-raised-keyboard-focus); |
| 107 } |
| 108 |
| 109 :host(:not([raised]).keyboard-focus) { |
| 110 font-weight: bold; |
| 111 @apply(--paper-button-flat-keyboard-focus); |
| 112 } |
| 113 |
| 114 :host([disabled]) { |
| 115 background: #eaeaea; |
| 116 color: #a8a8a8; |
| 117 cursor: auto; |
| 118 pointer-events: none; |
| 119 |
| 120 @apply(--paper-button-disabled); |
| 121 } |
| 122 |
| 123 paper-ripple { |
| 124 color: var(--paper-button-ink-color); |
| 125 } |
| 126 |
| 127 :host > ::content * { |
| 128 text-transform: inherit; |
| 129 } |
| 130 </style> |
| 131 <content></content> |
| 132 </template> |
| 133 </dom-module> |
| 134 |
| 135 <script> |
| 136 Polymer({ |
| 137 is: 'paper-button', |
| 138 |
| 139 behaviors: [ |
| 140 Polymer.PaperButtonBehavior |
| 141 ], |
| 142 |
| 143 properties: { |
| 144 /** |
| 145 * If true, the button should be styled with a shadow. |
| 146 */ |
| 147 raised: { |
| 148 type: Boolean, |
| 149 reflectToAttribute: true, |
| 150 value: false, |
| 151 observer: '_calculateElevation' |
| 152 } |
| 153 }, |
| 154 |
| 155 _calculateElevation: function() { |
| 156 if (!this.raised) { |
| 157 this._setElevation(0); |
| 158 } else { |
| 159 Polymer.PaperButtonBehaviorImpl._calculateElevation.apply(this); |
| 160 } |
| 161 } |
| 162 /** |
| 163 |
| 164 Fired when the animation finishes. |
| 165 This is useful if you want to wait until |
| 166 the ripple animation finishes to perform some action. |
| 167 |
| 168 @event transitionend |
| 169 @param {{node: Object}} detail Contains the animated node. |
| 170 */ |
| 171 }); |
| 172 </script> |
OLD | NEW |