| 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 | |
| 5 The complete set of authors may be found at http://polymer.github.io/AUTHORS | |
| 6 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS | |
| 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 | |
| 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/iron-flex-layout.html"> | |
| 14 <link rel="import" href="../paper-styles/default-theme.html"> | |
| 15 <link rel="import" href="../paper-behaviors/paper-button-behavior.html"> | |
| 16 <link rel="import" href="../paper-behaviors/paper-radio-button-behavior.html"> | |
| 17 <link rel="import" href="../paper-ripple/paper-ripple.html"> | |
| 18 | |
| 19 <style is="custom-style"> | |
| 20 :root { | |
| 21 --paper-icon-button-disabled-text: var(--disabled-text-color); | |
| 22 } | |
| 23 </style> | |
| 24 | |
| 25 <!-- | |
| 26 Material Design: <a href="http://www.google.com/design/spec/components/buttons.h
tml">Buttons</a> | |
| 27 | |
| 28 `paper-icon-button` is a button with an image placed at the center. When the use
r touches | |
| 29 the button, a ripple effect emanates from the center of the button. | |
| 30 | |
| 31 `paper-icon-button` includes a default icon set. Use `icon` to specify which ic
on | |
| 32 from the icon set to use. | |
| 33 | |
| 34 <paper-icon-button icon="menu"></paper-icon-button> | |
| 35 | |
| 36 See [`iron-iconset`](#iron-iconset) for more information about | |
| 37 how to use a custom icon set. | |
| 38 | |
| 39 Example: | |
| 40 | |
| 41 <link href="path/to/iron-icons/iron-icons.html" rel="import"> | |
| 42 | |
| 43 <paper-icon-button icon="favorite"></paper-icon-button> | |
| 44 <paper-icon-button src="star.png"></paper-icon-button> | |
| 45 | |
| 46 ###Styling | |
| 47 | |
| 48 Style the button with CSS as you would a normal DOM element. If you are using th
e icons | |
| 49 provided by `iron-icons`, they will inherit the foreground color of the button. | |
| 50 | |
| 51 /* make a red "favorite" button */ | |
| 52 <paper-icon-button icon="favorite" style="color: red;"></paper-icon-button> | |
| 53 | |
| 54 By default, the ripple is the same color as the foreground at 25% opacity. You m
ay | |
| 55 customize the color using this selector: | |
| 56 | |
| 57 /* make #my-button use a blue ripple instead of foreground color */ | |
| 58 #my-button::shadow #ripple { | |
| 59 color: blue; | |
| 60 } | |
| 61 | |
| 62 The opacity of the ripple is not customizable via CSS. | |
| 63 | |
| 64 The following custom properties and mixins are available for styling: | |
| 65 | |
| 66 Custom property | Description | Default | |
| 67 ----------------|-------------|---------- | |
| 68 `--paper-icon-button-disabled-text` | The color of the disabled button | `--prim
ary-text-color` | |
| 69 `--paper-icon-button-ink-color` | Selected/focus ripple color | `--default-prima
ry-color` | |
| 70 `--paper-icon-button` | Mixin for a button | `{}` | |
| 71 `--paper-icon-button-disabled` | Mixin for a disabled button | `{}` | |
| 72 | |
| 73 @group Paper Elements | |
| 74 @element paper-icon-button | |
| 75 @demo demo/index.html | |
| 76 --> | |
| 77 | |
| 78 <dom-module id="paper-icon-button"> | |
| 79 <style> | |
| 80 | |
| 81 :host { | |
| 82 display: inline-block; | |
| 83 position: relative; | |
| 84 padding: 8px; | |
| 85 outline: none; | |
| 86 -webkit-user-select: none; | |
| 87 -moz-user-select: none; | |
| 88 -ms-user-select: none; | |
| 89 user-select: none; | |
| 90 cursor: pointer; | |
| 91 z-index: 0; | |
| 92 | |
| 93 @apply(--paper-icon-button); | |
| 94 } | |
| 95 | |
| 96 :host #ink { | |
| 97 color: var(--paper-icon-button-ink-color, --primary-text-color); | |
| 98 opacity: 0.6; | |
| 99 } | |
| 100 | |
| 101 :host([disabled]) { | |
| 102 color: var(--paper-icon-button-disabled-text, #fff); | |
| 103 pointer-events: none; | |
| 104 cursor: auto; | |
| 105 @apply(--paper-icon-button-disabled); | |
| 106 } | |
| 107 </style> | |
| 108 <template> | |
| 109 <paper-ripple id="ink" class="circle" center></paper-ripple> | |
| 110 <iron-icon id="icon" src="[[src]]" icon="[[icon]]"></iron-icon> | |
| 111 </template> | |
| 112 </dom-module> | |
| 113 <script> | |
| 114 Polymer({ | |
| 115 is: 'paper-icon-button', | |
| 116 | |
| 117 behaviors: [ | |
| 118 Polymer.PaperButtonBehavior, | |
| 119 Polymer.PaperRadioButtonBehavior | |
| 120 ], | |
| 121 | |
| 122 properties: { | |
| 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 src: { | |
| 128 type: String | |
| 129 }, | |
| 130 | |
| 131 /** | |
| 132 * Specifies the icon name or index in the set of icons available in | |
| 133 * the icon's icon set. If the icon property is specified, | |
| 134 * the src property should not be. | |
| 135 */ | |
| 136 icon: { | |
| 137 type: String | |
| 138 } | |
| 139 } | |
| 140 }); | |
| 141 </script> | |
| OLD | NEW |