Blame view

bower_components/paper-icon-button/paper-icon-button.html 4.94 KB
73bcce88   luigser   COMPONENTS
1
2
3
  <!--
  @license
  Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
c5169e0e   Renato De Donato   a new hope
4
5
6
  This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE
  The complete set of authors may be found at http://polymer.github.io/AUTHORS
  The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS
73bcce88   luigser   COMPONENTS
7
  Code distributed by Google as part of the polymer project is also
c5169e0e   Renato De Donato   a new hope
8
  subject to an additional IP rights grant found at http://polymer.github.io/PATENTS
73bcce88   luigser   COMPONENTS
9
10
11
12
13
14
15
16
17
18
19
  -->
  
  <link rel="import" href="../polymer/polymer.html">
  <link rel="import" href="../iron-icon/iron-icon.html">
  <link rel="import" href="../iron-flex-layout/iron-flex-layout.html">
  <link rel="import" href="../paper-styles/default-theme.html">
  <link rel="import" href="../paper-behaviors/paper-button-behavior.html">
  <link rel="import" href="../paper-behaviors/paper-inky-focus-behavior.html">
  <link rel="import" href="../paper-ripple/paper-ripple.html">
  
  <!--
eb240478   Luigi Serra   public room cards...
20
  Material design: [Icon toggles](https://www.google.com/design/spec/components/buttons.html#buttons-toggle-buttons)
73bcce88   luigser   COMPONENTS
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
  
  `paper-icon-button` is a button with an image placed at the center. When the user touches
  the button, a ripple effect emanates from the center of the button.
  
  `paper-icon-button` includes a default icon set.  Use `icon` to specify which icon
  from the icon set to use.
  
      <paper-icon-button icon="menu"></paper-icon-button>
  
  See [`iron-iconset`](#iron-iconset) for more information about
  how to use a custom icon set.
  
  Example:
  
      <link href="path/to/iron-icons/iron-icons.html" rel="import">
  
      <paper-icon-button icon="favorite"></paper-icon-button>
      <paper-icon-button src="star.png"></paper-icon-button>
  
eb240478   Luigi Serra   public room cards...
40
  ### Styling
73bcce88   luigser   COMPONENTS
41
42
43
44
45
46
47
48
  
  Style the button with CSS as you would a normal DOM element. If you are using the icons
  provided by `iron-icons`, they will inherit the foreground color of the button.
  
      /* make a red "favorite" button */
      <paper-icon-button icon="favorite" style="color: red;"></paper-icon-button>
  
  By default, the ripple is the same color as the foreground at 25% opacity. You may
eb240478   Luigi Serra   public room cards...
49
  customize the color using the `--paper-icon-button-ink-color` custom property.
73bcce88   luigser   COMPONENTS
50
51
52
53
54
  
  The following custom properties and mixins are available for styling:
  
  Custom property | Description | Default
  ----------------|-------------|----------
eb240478   Luigi Serra   public room cards...
55
56
  `--paper-icon-button-disabled-text` | The color of the disabled button | `--disabled-text-color`
  `--paper-icon-button-ink-color` | Selected/focus ripple color | `--primary-text-color`
73bcce88   luigser   COMPONENTS
57
58
  `--paper-icon-button` | Mixin for a button | `{}`
  `--paper-icon-button-disabled` | Mixin for a disabled button | `{}`
73bcce88   luigser   COMPONENTS
59
60
61
62
63
64
65
  
  @group Paper Elements
  @element paper-icon-button
  @demo demo/index.html
  -->
  
  <dom-module id="paper-icon-button">
eb240478   Luigi Serra   public room cards...
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
    <template strip-whitespace>
      <style>
        :host {
          display: inline-block;
          position: relative;
          padding: 8px;
          outline: none;
          -webkit-tap-highlight-color: rgba(0,0,0,0);
          -webkit-user-select: none;
          -moz-user-select: none;
          -ms-user-select: none;
          user-select: none;
          cursor: pointer;
          z-index: 0;
          line-height: 1;
          
          width: 40px;
          height: 40px;
  
          /* Because of polymer/2558, this style has lower specificity than * */
          box-sizing: border-box !important;
          @apply(--paper-icon-button);
        }
  
        :host #ink {
          color: var(--paper-icon-button-ink-color, --primary-text-color);
          opacity: 0.6;
        }
  
        :host([disabled]) {
          color: var(--paper-icon-button-disabled-text, --disabled-text-color);
          pointer-events: none;
          cursor: auto;
          @apply(--paper-icon-button-disabled);
        }
eb240478   Luigi Serra   public room cards...
101
102
103
104
105
106
  
        iron-icon {
          --iron-icon-width: 100%;
          --iron-icon-height: 100%;
        }
      </style>
73bcce88   luigser   COMPONENTS
107
108
      <iron-icon id="icon" src="[[src]]" icon="[[icon]]" alt$="[[alt]]"></iron-icon>
    </template>
73bcce88   luigser   COMPONENTS
109
  
eb240478   Luigi Serra   public room cards...
110
111
112
113
114
115
116
    <script>
      Polymer({
        is: 'paper-icon-button',
  
        hostAttributes: {
          role: 'button',
          tabindex: '0'
73bcce88   luigser   COMPONENTS
117
118
        },
  
eb240478   Luigi Serra   public room cards...
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
        behaviors: [
          Polymer.PaperInkyFocusBehavior
        ],
  
        properties: {
          /**
           * The URL of an image for the icon. If the src property is specified,
           * the icon property should not be.
           */
          src: {
            type: String
          },
  
          /**
           * Specifies the icon name or index in the set of icons available in
           * the icon's icon set. If the icon property is specified,
           * the src property should not be.
           */
          icon: {
            type: String
          },
  
          /**
           * Specifies the alternate text for the button, for accessibility.
           */
          alt: {
            type: String,
            observer: "_altChanged"
          }
        },
73bcce88   luigser   COMPONENTS
149
  
eb240478   Luigi Serra   public room cards...
150
151
        _altChanged: function(newValue, oldValue) {
          var label = this.getAttribute('aria-label');
73bcce88   luigser   COMPONENTS
152
  
eb240478   Luigi Serra   public room cards...
153
154
155
156
          // Don't stomp over a user-set aria-label.
          if (!label || oldValue == label) {
            this.setAttribute('aria-label', newValue);
          }
73bcce88   luigser   COMPONENTS
157
        }
eb240478   Luigi Serra   public room cards...
158
159
160
      });
    </script>
  </dom-module>