~didrocks/+junk/face-detection-15.04

« back to all changes in this revision

Viewing changes to facedetection/www/bower_components/paper-icon-button/paper-icon-button.html

  • Committer: Didier Roche
  • Date: 2016-05-10 23:09:11 UTC
  • Revision ID: didier.roche@canonical.com-20160510230911-c7xr490zrj3yrzxd
New version

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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.github.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/CONTRIBUTORS.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/PATENTS.txt
 
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="../paper-behaviors/paper-inky-focus-behavior.html">
 
14
<link rel="import" href="../paper-styles/default-theme.html">
 
15
 
 
16
<!--
 
17
Material design: [Icon toggles](https://www.google.com/design/spec/components/buttons.html#buttons-toggle-buttons)
 
18
 
 
19
`paper-icon-button` is a button with an image placed at the center. When the user touches
 
20
the button, a ripple effect emanates from the center of the button.
 
21
 
 
22
`paper-icon-button` includes a default icon set.  Use `icon` to specify which icon
 
23
from the icon set to use.
 
24
 
 
25
    <paper-icon-button icon="menu"></paper-icon-button>
 
26
 
 
27
See [`iron-iconset`](iron-iconset) for more information about
 
28
how to use a custom icon set.
 
29
 
 
30
Example:
 
31
 
 
32
    <link href="path/to/iron-icons/iron-icons.html" rel="import">
 
33
 
 
34
    <paper-icon-button icon="favorite"></paper-icon-button>
 
35
    <paper-icon-button src="star.png"></paper-icon-button>
 
36
 
 
37
To use `paper-icon-button` as a link, wrap it in an anchor tag. Since `paper-icon-button`
 
38
will already receive focus, you may want to prevent the anchor tag from receiving focus
 
39
as well by setting its tabindex to -1.
 
40
 
 
41
    <a href="https://www.polymer-project.org" tabindex="-1">
 
42
      <paper-icon-button icon="polymer"></paper-icon-button>
 
43
    </a>
 
44
 
 
45
### Styling
 
46
 
 
47
Style the button with CSS as you would a normal DOM element. If you are using the icons
 
48
provided by `iron-icons`, they will inherit the foreground color of the button.
 
49
 
 
50
    /* make a red "favorite" button */
 
51
    <paper-icon-button icon="favorite" style="color: red;"></paper-icon-button>
 
52
 
 
53
By default, the ripple is the same color as the foreground at 25% opacity. You may
 
54
customize the color using the `--paper-icon-button-ink-color` custom property.
 
55
 
 
56
The following custom properties and mixins are available for styling:
 
57
 
 
58
Custom property | Description | Default
 
59
----------------|-------------|----------
 
60
`--paper-icon-button-disabled-text` | The color of the disabled button | `--disabled-text-color`
 
61
`--paper-icon-button-ink-color` | Selected/focus ripple color | `--primary-text-color`
 
62
`--paper-icon-button` | Mixin for a button | `{}`
 
63
`--paper-icon-button-disabled` | Mixin for a disabled button | `{}`
 
64
`--paper-icon-button-hover` | Mixin for button on hover | `{}`
 
65
 
 
66
@group Paper Elements
 
67
@element paper-icon-button
 
68
@demo demo/index.html
 
69
-->
 
70
 
 
71
<dom-module id="paper-icon-button">
 
72
  <template strip-whitespace>
 
73
    <style>
 
74
      :host {
 
75
        display: inline-block;
 
76
        position: relative;
 
77
        padding: 8px;
 
78
        outline: none;
 
79
        -webkit-tap-highlight-color: rgba(0,0,0,0);
 
80
        -webkit-user-select: none;
 
81
        -moz-user-select: none;
 
82
        -ms-user-select: none;
 
83
        user-select: none;
 
84
        cursor: pointer;
 
85
        z-index: 0;
 
86
        line-height: 1;
 
87
 
 
88
        width: 40px;
 
89
        height: 40px;
 
90
 
 
91
        /* Because of polymer/2558, this style has lower specificity than * */
 
92
        box-sizing: border-box !important;
 
93
 
 
94
        @apply(--paper-icon-button);
 
95
      }
 
96
 
 
97
      :host #ink {
 
98
        color: var(--paper-icon-button-ink-color, --primary-text-color);
 
99
        opacity: 0.6;
 
100
      }
 
101
 
 
102
      :host([disabled]) {
 
103
        color: var(--paper-icon-button-disabled-text, --disabled-text-color);
 
104
        pointer-events: none;
 
105
        cursor: auto;
 
106
 
 
107
        @apply(--paper-icon-button-disabled);
 
108
      }
 
109
 
 
110
      :host(:hover) {
 
111
        @apply(--paper-icon-button-hover);
 
112
      }
 
113
 
 
114
      iron-icon {
 
115
        --iron-icon-width: 100%;
 
116
        --iron-icon-height: 100%;
 
117
      }
 
118
    </style>
 
119
 
 
120
    <iron-icon id="icon" src="[[src]]" icon="[[icon]]" alt$="[[alt]]"></iron-icon>
 
121
  </template>
 
122
 
 
123
  <script>
 
124
    Polymer({
 
125
      is: 'paper-icon-button',
 
126
 
 
127
      hostAttributes: {
 
128
        role: 'button',
 
129
        tabindex: '0'
 
130
      },
 
131
 
 
132
      behaviors: [
 
133
        Polymer.PaperInkyFocusBehavior
 
134
      ],
 
135
 
 
136
      properties: {
 
137
        /**
 
138
         * The URL of an image for the icon. If the src property is specified,
 
139
         * the icon property should not be.
 
140
         */
 
141
        src: {
 
142
          type: String
 
143
        },
 
144
 
 
145
        /**
 
146
         * Specifies the icon name or index in the set of icons available in
 
147
         * the icon's icon set. If the icon property is specified,
 
148
         * the src property should not be.
 
149
         */
 
150
        icon: {
 
151
          type: String
 
152
        },
 
153
 
 
154
        /**
 
155
         * Specifies the alternate text for the button, for accessibility.
 
156
         */
 
157
        alt: {
 
158
          type: String,
 
159
          observer: "_altChanged"
 
160
        }
 
161
      },
 
162
 
 
163
      _altChanged: function(newValue, oldValue) {
 
164
        var label = this.getAttribute('aria-label');
 
165
 
 
166
        // Don't stomp over a user-set aria-label.
 
167
        if (!label || oldValue == label) {
 
168
          this.setAttribute('aria-label', newValue);
 
169
        }
 
170
      }
 
171
    });
 
172
  </script>
 
173
</dom-module>