Blame view

bower_components/iron-icon/iron-icon.html 5.25 KB
73bcce88   luigser   COMPONENTS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
  <!--
  @license
  Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
  This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
  The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
  The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
  Code distributed by Google as part of the polymer project is also
  subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
  -->
  
  <link rel="import" href="../polymer/polymer.html">
  <link rel="import" href="../iron-meta/iron-meta.html">
  <link rel="import" href="../iron-flex-layout/iron-flex-layout.html">
  
  <!--
  
  The `iron-icon` element displays an icon. By default an icon renders as a 24px square.
  
  Example using src:
  
      <iron-icon src="star.png"></iron-icon>
  
  Example setting size to 32px x 32px:
  
      <iron-icon class="big" src="big_star.png"></iron-icon>
  
      <style is="custom-style">
        .big {
          --iron-icon-height: 32px;
          --iron-icon-width: 32px;
        }
      </style>
  
  The iron elements include several sets of icons.
  To use the default set of icons, import `iron-icons.html` and use the `icon` attribute to specify an icon:
  
      <link rel="import" href="/components/iron-icons/iron-icons.html">
  
      <iron-icon icon="menu"></iron-icon>
  
  To use a different built-in set of icons, import the specific `iron-icons/<iconset>-icons.html`, and
  specify the icon as `<iconset>:<icon>`. For example, to use a communication icon, you would
  use:
  
      <link rel="import" href="/components/iron-icons/communication-icons.html">
  
      <iron-icon icon="communication:email"></iron-icon>
  
  You can also create custom icon sets of bitmap or SVG icons.
  
  Example of using an icon named `cherry` from a custom iconset with the ID `fruit`:
  
      <iron-icon icon="fruit:cherry"></iron-icon>
  
eb240478   Luigi Serra   public room cards...
55
  See [iron-iconset](iron-iconset) and [iron-iconset-svg](iron-iconset-svg) for more information about
73bcce88   luigser   COMPONENTS
56
57
  how to create a custom iconset.
  
eb240478   Luigi Serra   public room cards...
58
59
  See the [iron-icons demo](iron-icons?view=demo:demo/index.html) to see the icons available
  in the various iconsets.
73bcce88   luigser   COMPONENTS
60
61
62
63
64
65
66
67
68
69
  
  
  ### Styling
  
  The following custom properties are available for styling:
  
  Custom property | Description | Default
  ----------------|-------------|----------
  `--iron-icon-width` | Width of the icon | `24px`
  `--iron-icon-height` | Height of the icon | `24px`
eb240478   Luigi Serra   public room cards...
70
71
  `--iron-icon-fill-color` | Fill color of the svg icon | `currentcolor`
  `--iron-icon-stroke-color` | Stroke color of the svg icon | none
73bcce88   luigser   COMPONENTS
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
  
  @group Iron Elements
  @element iron-icon
  @demo demo/index.html
  @hero hero.svg
  @homepage polymer.github.io
  -->
  
  <dom-module id="iron-icon">
  
    <style>
      :host {
        @apply(--layout-inline);
        @apply(--layout-center-center);
        position: relative;
  
        vertical-align: middle;
  
eb240478   Luigi Serra   public room cards...
90
91
        fill: var(--iron-icon-fill-color, currentcolor);
        stroke: var(--iron-icon-stroke-color, none);
73bcce88   luigser   COMPONENTS
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
  
        width: var(--iron-icon-width, 24px);
        height: var(--iron-icon-height, 24px);
      }
    </style>
  
    <template>
    </template>
  
    <script>
  
      Polymer({
  
        is: 'iron-icon',
  
        properties: {
  
          /**
           * The name of the icon to use. The name should be of the form:
           * `iconset_name:icon_name`.
           */
          icon: {
            type: String,
            observer: '_iconChanged'
          },
  
          /**
           * The name of the theme to used, if one is specified by the
           * iconset.
           */
          theme: {
            type: String,
            observer: '_updateIcon'
          },
  
          /**
           * If using iron-icon without an iconset, you can set the src to be
           * the URL of an individual icon image file. Note that this will take
           * precedence over a given icon attribute.
           */
          src: {
            type: String,
            observer: '_srcChanged'
          },
e619a3b0   Luigi Serra   Controllet cross ...
136
137
138
139
  
          /**
           * @type {!Polymer.IronMeta}
           */
73bcce88   luigser   COMPONENTS
140
141
142
          _meta: {
            value: Polymer.Base.create('iron-meta', {type: 'iconset'})
          }
e619a3b0   Luigi Serra   Controllet cross ...
143
  
73bcce88   luigser   COMPONENTS
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
        },
  
        _DEFAULT_ICONSET: 'icons',
  
        _iconChanged: function(icon) {
          var parts = (icon || '').split(':');
          this._iconName = parts.pop();
          this._iconsetName = parts.pop() || this._DEFAULT_ICONSET;
          this._updateIcon();
        },
  
        _srcChanged: function(src) {
          this._updateIcon();
        },
  
        _usesIconset: function() {
          return this.icon || !this.src;
        },
  
        /** @suppress {visibility} */
        _updateIcon: function() {
          if (this._usesIconset()) {
            if (this._iconsetName) {
e619a3b0   Luigi Serra   Controllet cross ...
167
168
              this._iconset = /** @type {?Polymer.Iconset} */ (
                this._meta.byKey(this._iconsetName));
73bcce88   luigser   COMPONENTS
169
170
              if (this._iconset) {
                this._iconset.applyIcon(this, this._iconName, this.theme);
e619a3b0   Luigi Serra   Controllet cross ...
171
                this.unlisten(window, 'iron-iconset-added', '_updateIcon');
73bcce88   luigser   COMPONENTS
172
              } else {
e619a3b0   Luigi Serra   Controllet cross ...
173
                this.listen(window, 'iron-iconset-added', '_updateIcon');
73bcce88   luigser   COMPONENTS
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
              }
            }
          } else {
            if (!this._img) {
              this._img = document.createElement('img');
              this._img.style.width = '100%';
              this._img.style.height = '100%';
              this._img.draggable = false;
            }
            this._img.src = this.src;
            Polymer.dom(this.root).appendChild(this._img);
          }
        }
  
      });
  
    </script>
  
  </dom-module>