@vaadin/icon 24.2.0-alpha11 → 24.2.0-alpha12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -5
- package/src/vaadin-icon.d.ts +15 -0
- package/src/vaadin-icon.js +92 -11
- package/web-types.json +46 -6
- package/web-types.lit.json +18 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/icon",
|
|
3
|
-
"version": "24.2.0-
|
|
3
|
+
"version": "24.2.0-alpha12",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@polymer/polymer": "^3.0.0",
|
|
38
|
-
"@vaadin/component-base": "24.2.0-
|
|
39
|
-
"@vaadin/vaadin-lumo-styles": "24.2.0-
|
|
40
|
-
"@vaadin/vaadin-themable-mixin": "24.2.0-
|
|
38
|
+
"@vaadin/component-base": "24.2.0-alpha12",
|
|
39
|
+
"@vaadin/vaadin-lumo-styles": "24.2.0-alpha12",
|
|
40
|
+
"@vaadin/vaadin-themable-mixin": "24.2.0-alpha12",
|
|
41
41
|
"lit": "^2.0.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"web-types.json",
|
|
50
50
|
"web-types.lit.json"
|
|
51
51
|
],
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "854d2809340ef73f765350808bb92ed5c840d147"
|
|
53
53
|
}
|
package/src/vaadin-icon.d.ts
CHANGED
|
@@ -68,6 +68,16 @@ declare class Icon extends ThemableMixin(ElementMixin(ControllerMixin(SlotStyles
|
|
|
68
68
|
*/
|
|
69
69
|
svg: IconSvgLiteral | null;
|
|
70
70
|
|
|
71
|
+
/**
|
|
72
|
+
* The SVG source to be loaded as the icon. It can be:
|
|
73
|
+
* - an URL to a file containing the icon
|
|
74
|
+
* - an URL in the format "/path/to/file.svg#objectID", where the "objectID" refers to an ID attribute contained
|
|
75
|
+
* inside the SVG referenced by the path. Note that the file needs to follow the same-origin policy.
|
|
76
|
+
* - a string in the format "data:image/svg+xml,<svg>...</svg>". You may need to use the "encodeURIComponent"
|
|
77
|
+
* function for the SVG content passed
|
|
78
|
+
*/
|
|
79
|
+
src: string | null;
|
|
80
|
+
|
|
71
81
|
/**
|
|
72
82
|
* Class names defining an icon font and/or a specific glyph inside an icon font.
|
|
73
83
|
*
|
|
@@ -83,6 +93,11 @@ declare class Icon extends ThemableMixin(ElementMixin(ControllerMixin(SlotStyles
|
|
|
83
93
|
*/
|
|
84
94
|
char: string | null;
|
|
85
95
|
|
|
96
|
+
/**
|
|
97
|
+
* The font family to use for the font icon.
|
|
98
|
+
*/
|
|
99
|
+
fontFamily: string | null;
|
|
100
|
+
|
|
86
101
|
/**
|
|
87
102
|
* The size of an icon, used to set the `viewBox` attribute.
|
|
88
103
|
*/
|
package/src/vaadin-icon.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
7
|
+
import { svg } from 'lit';
|
|
7
8
|
import { isSafari } from '@vaadin/component-base/src/browser-utils.js';
|
|
8
9
|
import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
|
|
9
10
|
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
@@ -11,7 +12,7 @@ import { ResizeMixin } from '@vaadin/component-base/src/resize-mixin.js';
|
|
|
11
12
|
import { SlotStylesMixin } from '@vaadin/component-base/src/slot-styles-mixin.js';
|
|
12
13
|
import { TooltipController } from '@vaadin/component-base/src/tooltip-controller.js';
|
|
13
14
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
14
|
-
import { ensureSvgLiteral, renderSvg } from './vaadin-icon-svg.js';
|
|
15
|
+
import { ensureSvgLiteral, renderSvg, unsafeSvgLiteral } from './vaadin-icon-svg.js';
|
|
15
16
|
import { Iconset } from './vaadin-iconset.js';
|
|
16
17
|
|
|
17
18
|
const supportsCSSContainerQueries = CSS.supports('container-type: inline-size');
|
|
@@ -152,6 +153,18 @@ class Icon extends ThemableMixin(
|
|
|
152
153
|
type: Object,
|
|
153
154
|
},
|
|
154
155
|
|
|
156
|
+
/**
|
|
157
|
+
* The SVG source to be loaded as the icon. It can be:
|
|
158
|
+
* - an URL to a file containing the icon
|
|
159
|
+
* - an URL in the format "/path/to/file.svg#objectID", where the "objectID" refers to an ID attribute contained
|
|
160
|
+
* inside the SVG referenced by the path. Note that the file needs to follow the same-origin policy.
|
|
161
|
+
* - a string in the format "data:image/svg+xml,<svg>...</svg>". You may need to use the "encodeURIComponent"
|
|
162
|
+
* function for the SVG content passed
|
|
163
|
+
*/
|
|
164
|
+
src: {
|
|
165
|
+
type: String,
|
|
166
|
+
},
|
|
167
|
+
|
|
155
168
|
/**
|
|
156
169
|
* Class names defining an icon font and/or a specific glyph inside an icon font.
|
|
157
170
|
*
|
|
@@ -175,6 +188,16 @@ class Icon extends ThemableMixin(
|
|
|
175
188
|
reflectToAttribute: true,
|
|
176
189
|
},
|
|
177
190
|
|
|
191
|
+
/**
|
|
192
|
+
* The font family to use for the font icon.
|
|
193
|
+
*
|
|
194
|
+
* @type {string}
|
|
195
|
+
*/
|
|
196
|
+
fontFamily: {
|
|
197
|
+
type: String,
|
|
198
|
+
observer: '__fontFamilyChanged',
|
|
199
|
+
},
|
|
200
|
+
|
|
178
201
|
/**
|
|
179
202
|
* The size of an icon, used to set the `viewBox` attribute.
|
|
180
203
|
*/
|
|
@@ -201,7 +224,13 @@ class Icon extends ThemableMixin(
|
|
|
201
224
|
}
|
|
202
225
|
|
|
203
226
|
static get observers() {
|
|
204
|
-
return ['__svgChanged(svg, __svgElement)', '__fontChanged(font, char)'];
|
|
227
|
+
return ['__svgChanged(svg, __svgElement)', '__fontChanged(font, char)', '__srcChanged(src)'];
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
constructor() {
|
|
231
|
+
super();
|
|
232
|
+
|
|
233
|
+
this.__fetch = fetch.bind(window);
|
|
205
234
|
}
|
|
206
235
|
|
|
207
236
|
/** @protected */
|
|
@@ -212,6 +241,7 @@ class Icon extends ThemableMixin(
|
|
|
212
241
|
${tag}[font] {
|
|
213
242
|
display: inline-flex;
|
|
214
243
|
vertical-align: middle;
|
|
244
|
+
font-size: inherit;
|
|
215
245
|
}
|
|
216
246
|
`,
|
|
217
247
|
];
|
|
@@ -225,10 +255,8 @@ class Icon extends ThemableMixin(
|
|
|
225
255
|
this._tooltipController = new TooltipController(this);
|
|
226
256
|
this.addController(this._tooltipController);
|
|
227
257
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
this._onResize();
|
|
231
|
-
}
|
|
258
|
+
// Call once initially to avoid a fouc
|
|
259
|
+
this._onResize();
|
|
232
260
|
}
|
|
233
261
|
|
|
234
262
|
/** @protected */
|
|
@@ -273,6 +301,47 @@ class Icon extends ThemableMixin(
|
|
|
273
301
|
}
|
|
274
302
|
}
|
|
275
303
|
|
|
304
|
+
/** @private */
|
|
305
|
+
async __srcChanged(src) {
|
|
306
|
+
if (!src) {
|
|
307
|
+
this.svg = null;
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
// Need to add the "icon" attribute to avoid issues as described in
|
|
312
|
+
// https://github.com/vaadin/web-components/issues/6301
|
|
313
|
+
this.icon = '';
|
|
314
|
+
|
|
315
|
+
if (src.includes('#')) {
|
|
316
|
+
this.svg = svg`<use href="${src}"/>`;
|
|
317
|
+
} else {
|
|
318
|
+
try {
|
|
319
|
+
const data = await this.__fetch(src, { mode: 'cors' });
|
|
320
|
+
if (!data.ok) {
|
|
321
|
+
throw new Error('Error loading icon');
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
const svgData = await data.text();
|
|
325
|
+
|
|
326
|
+
if (!Icon.__domParser) {
|
|
327
|
+
Icon.__domParser = new DOMParser();
|
|
328
|
+
}
|
|
329
|
+
const parsedResponse = Icon.__domParser.parseFromString(svgData, 'text/html');
|
|
330
|
+
|
|
331
|
+
const svgElement = parsedResponse.querySelector('svg');
|
|
332
|
+
if (!svgElement) {
|
|
333
|
+
throw new Error(`SVG element not found on path: ${src}`);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
this.__viewBox = svgElement.getAttribute('viewBox');
|
|
337
|
+
this.svg = unsafeSvgLiteral(svgElement.innerHTML);
|
|
338
|
+
} catch (e) {
|
|
339
|
+
console.error(e);
|
|
340
|
+
this.svg = null;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
276
345
|
/** @private */
|
|
277
346
|
__svgChanged(svg, svgElement) {
|
|
278
347
|
if (!svgElement) {
|
|
@@ -300,19 +369,31 @@ class Icon extends ThemableMixin(
|
|
|
300
369
|
this.classList.add(...this.__addedFontClasses);
|
|
301
370
|
}
|
|
302
371
|
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
372
|
+
if (font || char) {
|
|
373
|
+
if (!this.icon) {
|
|
374
|
+
// The "icon" attribute needs to be set on the host also when using font icons
|
|
375
|
+
// to avoid issues such as https://github.com/vaadin/web-components/issues/6301
|
|
376
|
+
this.icon = '';
|
|
377
|
+
}
|
|
378
|
+
this._onResize();
|
|
307
379
|
}
|
|
308
380
|
}
|
|
309
381
|
|
|
382
|
+
/** @private */
|
|
383
|
+
__fontFamilyChanged(fontFamily) {
|
|
384
|
+
this.style.fontFamily = fontFamily;
|
|
385
|
+
}
|
|
386
|
+
|
|
310
387
|
/**
|
|
311
388
|
* @protected
|
|
312
389
|
* @override
|
|
313
390
|
*/
|
|
314
391
|
_onResize() {
|
|
315
|
-
this.
|
|
392
|
+
if (needsFontIconSizingFallback && (this.char || this.font)) {
|
|
393
|
+
const { paddingTop, paddingBottom, height } = getComputedStyle(this);
|
|
394
|
+
const fontIconSize = parseFloat(height) - parseFloat(paddingTop) - parseFloat(paddingBottom);
|
|
395
|
+
this.style.setProperty('--_vaadin-font-icon-size', `${fontIconSize}px`);
|
|
396
|
+
}
|
|
316
397
|
}
|
|
317
398
|
}
|
|
318
399
|
|
package/web-types.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/web-types",
|
|
3
3
|
"name": "@vaadin/icon",
|
|
4
|
-
"version": "24.2.0-
|
|
4
|
+
"version": "24.2.0-alpha12",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"contributions": {
|
|
7
7
|
"html": {
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"attributes": [
|
|
13
13
|
{
|
|
14
14
|
"name": "name",
|
|
15
|
-
"description": "The name of the iconset. Every iconset is required to have its own unique name.\nAll the SVG icons in the iconset must have IDs conforming to its name.\n\nSee also [`name`](https://cdn.vaadin.com/vaadin-web-components/24.2.0-
|
|
15
|
+
"description": "The name of the iconset. Every iconset is required to have its own unique name.\nAll the SVG icons in the iconset must have IDs conforming to its name.\n\nSee also [`name`](https://cdn.vaadin.com/vaadin-web-components/24.2.0-alpha12/#/elements/vaadin-icon#property-name) property of `vaadin-icon`.",
|
|
16
16
|
"value": {
|
|
17
17
|
"type": [
|
|
18
18
|
"string",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"properties": [
|
|
49
49
|
{
|
|
50
50
|
"name": "name",
|
|
51
|
-
"description": "The name of the iconset. Every iconset is required to have its own unique name.\nAll the SVG icons in the iconset must have IDs conforming to its name.\n\nSee also [`name`](https://cdn.vaadin.com/vaadin-web-components/24.2.0-
|
|
51
|
+
"description": "The name of the iconset. Every iconset is required to have its own unique name.\nAll the SVG icons in the iconset must have IDs conforming to its name.\n\nSee also [`name`](https://cdn.vaadin.com/vaadin-web-components/24.2.0-alpha12/#/elements/vaadin-icon#property-name) property of `vaadin-icon`.",
|
|
52
52
|
"value": {
|
|
53
53
|
"type": [
|
|
54
54
|
"string",
|
|
@@ -74,17 +74,28 @@
|
|
|
74
74
|
},
|
|
75
75
|
{
|
|
76
76
|
"name": "vaadin-icon",
|
|
77
|
-
"description": "`<vaadin-icon>` is a Web Component for displaying SVG icons.\n\n### Icon property\n\nThe `<vaadin-icon>` component is designed to be used as a drop-in replacement for `<iron-icon>`.\nFor example, you can use it with `vaadin-icons` like this:\n\n```html\n<vaadin-icon icon=\"vaadin:angle-down\"></vaadin-icon>\n```\n\nAlternatively, you can also pick one of the Lumo icons:\n\n```html\n<vaadin-icon icon=\"lumo:user\"></vaadin-icon>\n```\n\n### Custom SVG icon\n\nAlternatively, instead of selecting an icon from an iconset by name, you can pass any custom `svg`\nliteral using the [`svg`](https://cdn.vaadin.com/vaadin-web-components/24.2.0-
|
|
77
|
+
"description": "`<vaadin-icon>` is a Web Component for displaying SVG icons.\n\n### Icon property\n\nThe `<vaadin-icon>` component is designed to be used as a drop-in replacement for `<iron-icon>`.\nFor example, you can use it with `vaadin-icons` like this:\n\n```html\n<vaadin-icon icon=\"vaadin:angle-down\"></vaadin-icon>\n```\n\nAlternatively, you can also pick one of the Lumo icons:\n\n```html\n<vaadin-icon icon=\"lumo:user\"></vaadin-icon>\n```\n\n### Custom SVG icon\n\nAlternatively, instead of selecting an icon from an iconset by name, you can pass any custom `svg`\nliteral using the [`svg`](https://cdn.vaadin.com/vaadin-web-components/24.2.0-alpha12/#/elements/vaadin-icon#property-svg) property. In this case you can also\ndefine the size of the SVG `viewBox` using the [`size`](https://cdn.vaadin.com/vaadin-web-components/24.2.0-alpha12/#/elements/vaadin-icon#property-size) property:\n\n```js\nimport { html, svg } from 'lit';\n\n// in your component\nrender() {\n const svgIcon = svg`<path d=\"M13 4v2l-5 5-5-5v-2l5 5z\"></path>`;\n return html`\n <vaadin-icon\n .svg=\"${svgIcon}\"\n size=\"16\"\n ></vaadin-icon>\n `;\n}\n```",
|
|
78
78
|
"attributes": [
|
|
79
79
|
{
|
|
80
80
|
"name": "icon",
|
|
81
|
-
"description": "The name of the icon to use. The name should be of the form:\n`iconset_name:icon_name`. When using `vaadin-icons` it is possible\nto omit the first part and only use `icon_name` as a value.\n\nSetting the `icon` property updates the `svg` and `size` based on the\nvalues provided by the corresponding `vaadin-iconset` element.\n\nSee also [`name`](https://cdn.vaadin.com/vaadin-web-components/24.2.0-
|
|
81
|
+
"description": "The name of the icon to use. The name should be of the form:\n`iconset_name:icon_name`. When using `vaadin-icons` it is possible\nto omit the first part and only use `icon_name` as a value.\n\nSetting the `icon` property updates the `svg` and `size` based on the\nvalues provided by the corresponding `vaadin-iconset` element.\n\nSee also [`name`](https://cdn.vaadin.com/vaadin-web-components/24.2.0-alpha12/#/elements/vaadin-iconset#property-name) property of `vaadin-iconset`.",
|
|
82
82
|
"value": {
|
|
83
83
|
"type": [
|
|
84
84
|
"string"
|
|
85
85
|
]
|
|
86
86
|
}
|
|
87
87
|
},
|
|
88
|
+
{
|
|
89
|
+
"name": "src",
|
|
90
|
+
"description": "The SVG source to be loaded as the icon. It can be:\n- an URL to a file containing the icon\n- an URL in the format \"/path/to/file.svg#objectID\", where the \"objectID\" refers to an ID attribute contained\n inside the SVG referenced by the path. Note that the file needs to follow the same-origin policy.\n- a string in the format \"data:image/svg+xml,<svg>...</svg>\". You may need to use the \"encodeURIComponent\"\n function for the SVG content passed",
|
|
91
|
+
"value": {
|
|
92
|
+
"type": [
|
|
93
|
+
"string",
|
|
94
|
+
"null",
|
|
95
|
+
"undefined"
|
|
96
|
+
]
|
|
97
|
+
}
|
|
98
|
+
},
|
|
88
99
|
{
|
|
89
100
|
"name": "font",
|
|
90
101
|
"description": "Class names defining an icon font and/or a specific glyph inside an icon font.",
|
|
@@ -103,6 +114,15 @@
|
|
|
103
114
|
]
|
|
104
115
|
}
|
|
105
116
|
},
|
|
117
|
+
{
|
|
118
|
+
"name": "font-family",
|
|
119
|
+
"description": "The font family to use for the font icon.",
|
|
120
|
+
"value": {
|
|
121
|
+
"type": [
|
|
122
|
+
"string"
|
|
123
|
+
]
|
|
124
|
+
}
|
|
125
|
+
},
|
|
106
126
|
{
|
|
107
127
|
"name": "size",
|
|
108
128
|
"description": "The size of an icon, used to set the `viewBox` attribute.",
|
|
@@ -130,7 +150,7 @@
|
|
|
130
150
|
"properties": [
|
|
131
151
|
{
|
|
132
152
|
"name": "icon",
|
|
133
|
-
"description": "The name of the icon to use. The name should be of the form:\n`iconset_name:icon_name`. When using `vaadin-icons` it is possible\nto omit the first part and only use `icon_name` as a value.\n\nSetting the `icon` property updates the `svg` and `size` based on the\nvalues provided by the corresponding `vaadin-iconset` element.\n\nSee also [`name`](https://cdn.vaadin.com/vaadin-web-components/24.2.0-
|
|
153
|
+
"description": "The name of the icon to use. The name should be of the form:\n`iconset_name:icon_name`. When using `vaadin-icons` it is possible\nto omit the first part and only use `icon_name` as a value.\n\nSetting the `icon` property updates the `svg` and `size` based on the\nvalues provided by the corresponding `vaadin-iconset` element.\n\nSee also [`name`](https://cdn.vaadin.com/vaadin-web-components/24.2.0-alpha12/#/elements/vaadin-iconset#property-name) property of `vaadin-iconset`.",
|
|
134
154
|
"value": {
|
|
135
155
|
"type": [
|
|
136
156
|
"string"
|
|
@@ -148,6 +168,17 @@
|
|
|
148
168
|
]
|
|
149
169
|
}
|
|
150
170
|
},
|
|
171
|
+
{
|
|
172
|
+
"name": "src",
|
|
173
|
+
"description": "The SVG source to be loaded as the icon. It can be:\n- an URL to a file containing the icon\n- an URL in the format \"/path/to/file.svg#objectID\", where the \"objectID\" refers to an ID attribute contained\n inside the SVG referenced by the path. Note that the file needs to follow the same-origin policy.\n- a string in the format \"data:image/svg+xml,<svg>...</svg>\". You may need to use the \"encodeURIComponent\"\n function for the SVG content passed",
|
|
174
|
+
"value": {
|
|
175
|
+
"type": [
|
|
176
|
+
"string",
|
|
177
|
+
"null",
|
|
178
|
+
"undefined"
|
|
179
|
+
]
|
|
180
|
+
}
|
|
181
|
+
},
|
|
151
182
|
{
|
|
152
183
|
"name": "font",
|
|
153
184
|
"description": "Class names defining an icon font and/or a specific glyph inside an icon font.",
|
|
@@ -166,6 +197,15 @@
|
|
|
166
197
|
]
|
|
167
198
|
}
|
|
168
199
|
},
|
|
200
|
+
{
|
|
201
|
+
"name": "fontFamily",
|
|
202
|
+
"description": "The font family to use for the font icon.",
|
|
203
|
+
"value": {
|
|
204
|
+
"type": [
|
|
205
|
+
"string"
|
|
206
|
+
]
|
|
207
|
+
}
|
|
208
|
+
},
|
|
169
209
|
{
|
|
170
210
|
"name": "size",
|
|
171
211
|
"description": "The size of an icon, used to set the `viewBox` attribute.",
|
package/web-types.lit.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/web-types",
|
|
3
3
|
"name": "@vaadin/icon",
|
|
4
|
-
"version": "24.2.0-
|
|
4
|
+
"version": "24.2.0-alpha12",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"framework": "lit",
|
|
7
7
|
"framework-config": {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"attributes": [
|
|
22
22
|
{
|
|
23
23
|
"name": ".name",
|
|
24
|
-
"description": "The name of the iconset. Every iconset is required to have its own unique name.\nAll the SVG icons in the iconset must have IDs conforming to its name.\n\nSee also [`name`](https://cdn.vaadin.com/vaadin-web-components/24.2.0-
|
|
24
|
+
"description": "The name of the iconset. Every iconset is required to have its own unique name.\nAll the SVG icons in the iconset must have IDs conforming to its name.\n\nSee also [`name`](https://cdn.vaadin.com/vaadin-web-components/24.2.0-alpha12/#/elements/vaadin-icon#property-name) property of `vaadin-icon`.",
|
|
25
25
|
"value": {
|
|
26
26
|
"kind": "expression"
|
|
27
27
|
}
|
|
@@ -37,12 +37,12 @@
|
|
|
37
37
|
},
|
|
38
38
|
{
|
|
39
39
|
"name": "vaadin-icon",
|
|
40
|
-
"description": "`<vaadin-icon>` is a Web Component for displaying SVG icons.\n\n### Icon property\n\nThe `<vaadin-icon>` component is designed to be used as a drop-in replacement for `<iron-icon>`.\nFor example, you can use it with `vaadin-icons` like this:\n\n```html\n<vaadin-icon icon=\"vaadin:angle-down\"></vaadin-icon>\n```\n\nAlternatively, you can also pick one of the Lumo icons:\n\n```html\n<vaadin-icon icon=\"lumo:user\"></vaadin-icon>\n```\n\n### Custom SVG icon\n\nAlternatively, instead of selecting an icon from an iconset by name, you can pass any custom `svg`\nliteral using the [`svg`](https://cdn.vaadin.com/vaadin-web-components/24.2.0-
|
|
40
|
+
"description": "`<vaadin-icon>` is a Web Component for displaying SVG icons.\n\n### Icon property\n\nThe `<vaadin-icon>` component is designed to be used as a drop-in replacement for `<iron-icon>`.\nFor example, you can use it with `vaadin-icons` like this:\n\n```html\n<vaadin-icon icon=\"vaadin:angle-down\"></vaadin-icon>\n```\n\nAlternatively, you can also pick one of the Lumo icons:\n\n```html\n<vaadin-icon icon=\"lumo:user\"></vaadin-icon>\n```\n\n### Custom SVG icon\n\nAlternatively, instead of selecting an icon from an iconset by name, you can pass any custom `svg`\nliteral using the [`svg`](https://cdn.vaadin.com/vaadin-web-components/24.2.0-alpha12/#/elements/vaadin-icon#property-svg) property. In this case you can also\ndefine the size of the SVG `viewBox` using the [`size`](https://cdn.vaadin.com/vaadin-web-components/24.2.0-alpha12/#/elements/vaadin-icon#property-size) property:\n\n```js\nimport { html, svg } from 'lit';\n\n// in your component\nrender() {\n const svgIcon = svg`<path d=\"M13 4v2l-5 5-5-5v-2l5 5z\"></path>`;\n return html`\n <vaadin-icon\n .svg=\"${svgIcon}\"\n size=\"16\"\n ></vaadin-icon>\n `;\n}\n```",
|
|
41
41
|
"extension": true,
|
|
42
42
|
"attributes": [
|
|
43
43
|
{
|
|
44
44
|
"name": ".icon",
|
|
45
|
-
"description": "The name of the icon to use. The name should be of the form:\n`iconset_name:icon_name`. When using `vaadin-icons` it is possible\nto omit the first part and only use `icon_name` as a value.\n\nSetting the `icon` property updates the `svg` and `size` based on the\nvalues provided by the corresponding `vaadin-iconset` element.\n\nSee also [`name`](https://cdn.vaadin.com/vaadin-web-components/24.2.0-
|
|
45
|
+
"description": "The name of the icon to use. The name should be of the form:\n`iconset_name:icon_name`. When using `vaadin-icons` it is possible\nto omit the first part and only use `icon_name` as a value.\n\nSetting the `icon` property updates the `svg` and `size` based on the\nvalues provided by the corresponding `vaadin-iconset` element.\n\nSee also [`name`](https://cdn.vaadin.com/vaadin-web-components/24.2.0-alpha12/#/elements/vaadin-iconset#property-name) property of `vaadin-iconset`.",
|
|
46
46
|
"value": {
|
|
47
47
|
"kind": "expression"
|
|
48
48
|
}
|
|
@@ -54,6 +54,13 @@
|
|
|
54
54
|
"kind": "expression"
|
|
55
55
|
}
|
|
56
56
|
},
|
|
57
|
+
{
|
|
58
|
+
"name": ".src",
|
|
59
|
+
"description": "The SVG source to be loaded as the icon. It can be:\n- an URL to a file containing the icon\n- an URL in the format \"/path/to/file.svg#objectID\", where the \"objectID\" refers to an ID attribute contained\n inside the SVG referenced by the path. Note that the file needs to follow the same-origin policy.\n- a string in the format \"data:image/svg+xml,<svg>...</svg>\". You may need to use the \"encodeURIComponent\"\n function for the SVG content passed",
|
|
60
|
+
"value": {
|
|
61
|
+
"kind": "expression"
|
|
62
|
+
}
|
|
63
|
+
},
|
|
57
64
|
{
|
|
58
65
|
"name": ".font",
|
|
59
66
|
"description": "Class names defining an icon font and/or a specific glyph inside an icon font.",
|
|
@@ -68,6 +75,13 @@
|
|
|
68
75
|
"kind": "expression"
|
|
69
76
|
}
|
|
70
77
|
},
|
|
78
|
+
{
|
|
79
|
+
"name": ".fontFamily",
|
|
80
|
+
"description": "The font family to use for the font icon.",
|
|
81
|
+
"value": {
|
|
82
|
+
"kind": "expression"
|
|
83
|
+
}
|
|
84
|
+
},
|
|
71
85
|
{
|
|
72
86
|
"name": ".size",
|
|
73
87
|
"description": "The size of an icon, used to set the `viewBox` attribute.",
|