@vaadin/icon 25.4.0-alpha5 → 25.4.0-alpha7
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/custom-elements.json +25 -4
- package/package.json +8 -8
- package/src/vaadin-icon-helpers.js +125 -0
- package/src/vaadin-icon-mixin.d.ts +3 -0
- package/src/vaadin-icon-mixin.js +41 -34
- package/web-types.json +7 -7
- package/web-types.lit.json +5 -5
package/custom-elements.json
CHANGED
|
@@ -71,6 +71,19 @@
|
|
|
71
71
|
"kind": "function",
|
|
72
72
|
"name": "needsFontIconSizingFallback",
|
|
73
73
|
"description": "Checks if the current browser needs a fallback for sizing font icons instead of relying on CSS Container Queries."
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"kind": "function",
|
|
77
|
+
"name": "parseSvg",
|
|
78
|
+
"parameters": [
|
|
79
|
+
{
|
|
80
|
+
"name": "source",
|
|
81
|
+
"type": {
|
|
82
|
+
"text": "string"
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
],
|
|
86
|
+
"description": "Parse the first `<svg>` element in the source string. Returns its static\ncontent as SVG literal, and the element without children for its attributes.\nReturns `null` if there is no `<svg>`."
|
|
74
87
|
}
|
|
75
88
|
],
|
|
76
89
|
"exports": [
|
|
@@ -89,6 +102,14 @@
|
|
|
89
102
|
"name": "needsFontIconSizingFallback",
|
|
90
103
|
"module": "src/vaadin-icon-helpers.js"
|
|
91
104
|
}
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"kind": "js",
|
|
108
|
+
"name": "parseSvg",
|
|
109
|
+
"declaration": {
|
|
110
|
+
"name": "parseSvg",
|
|
111
|
+
"module": "src/vaadin-icon-helpers.js"
|
|
112
|
+
}
|
|
92
113
|
}
|
|
93
114
|
]
|
|
94
115
|
},
|
|
@@ -168,7 +189,7 @@
|
|
|
168
189
|
"type": {
|
|
169
190
|
"text": "string"
|
|
170
191
|
},
|
|
171
|
-
"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",
|
|
192
|
+
"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\n\nAn SVG loaded without an ID only renders static SVG content, so use presentation attributes such as `fill`\ninstead of a `<style>` element.",
|
|
172
193
|
"attribute": "src"
|
|
173
194
|
},
|
|
174
195
|
{
|
|
@@ -248,7 +269,7 @@
|
|
|
248
269
|
"type": {
|
|
249
270
|
"text": "string"
|
|
250
271
|
},
|
|
251
|
-
"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",
|
|
272
|
+
"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\n\nAn SVG loaded without an ID only renders static SVG content, so use presentation attributes such as `fill`\ninstead of a `<style>` element.",
|
|
252
273
|
"fieldName": "src"
|
|
253
274
|
},
|
|
254
275
|
{
|
|
@@ -476,7 +497,7 @@
|
|
|
476
497
|
"type": {
|
|
477
498
|
"text": "string"
|
|
478
499
|
},
|
|
479
|
-
"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",
|
|
500
|
+
"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\n\nAn SVG loaded without an ID only renders static SVG content, so use presentation attributes such as `fill`\ninstead of a `<style>` element.",
|
|
480
501
|
"attribute": "src",
|
|
481
502
|
"inheritedFrom": {
|
|
482
503
|
"name": "IconMixin",
|
|
@@ -596,7 +617,7 @@
|
|
|
596
617
|
"type": {
|
|
597
618
|
"text": "string"
|
|
598
619
|
},
|
|
599
|
-
"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",
|
|
620
|
+
"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\n\nAn SVG loaded without an ID only renders static SVG content, so use presentation attributes such as `fill`\ninstead of a `<style>` element.",
|
|
600
621
|
"fieldName": "src",
|
|
601
622
|
"inheritedFrom": {
|
|
602
623
|
"name": "IconMixin",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/icon",
|
|
3
|
-
"version": "25.4.0-
|
|
3
|
+
"version": "25.4.0-alpha7",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -35,16 +35,16 @@
|
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
38
|
-
"@vaadin/component-base": "25.4.0-
|
|
39
|
-
"@vaadin/vaadin-themable-mixin": "25.4.0-
|
|
38
|
+
"@vaadin/component-base": "25.4.0-alpha7",
|
|
39
|
+
"@vaadin/vaadin-themable-mixin": "25.4.0-alpha7",
|
|
40
40
|
"lit": "^3.0.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@vaadin/aura": "25.4.0-
|
|
44
|
-
"@vaadin/chai-plugins": "25.4.0-
|
|
45
|
-
"@vaadin/test-runner-commands": "25.4.0-
|
|
43
|
+
"@vaadin/aura": "25.4.0-alpha7",
|
|
44
|
+
"@vaadin/chai-plugins": "25.4.0-alpha7",
|
|
45
|
+
"@vaadin/test-runner-commands": "25.4.0-alpha7",
|
|
46
46
|
"@vaadin/testing-helpers": "^2.0.0",
|
|
47
|
-
"@vaadin/vaadin-lumo-styles": "25.4.0-
|
|
47
|
+
"@vaadin/vaadin-lumo-styles": "25.4.0-alpha7",
|
|
48
48
|
"sinon": "^22.0.0"
|
|
49
49
|
},
|
|
50
50
|
"customElements": "custom-elements.json",
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
"web-types.json",
|
|
53
53
|
"web-types.lit.json"
|
|
54
54
|
],
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "368fb0f0df09ec6f51766d9c44047c8d7620d6bd"
|
|
56
56
|
}
|
|
@@ -3,8 +3,114 @@
|
|
|
3
3
|
* Copyright (c) 2021 - 2026 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
+
import { svg } from 'lit';
|
|
7
|
+
import { templateContent } from 'lit/directives/template-content.js';
|
|
6
8
|
import { isSafari } from '@vaadin/component-base/src/browser-utils.js';
|
|
7
9
|
|
|
10
|
+
const SVG_NS = 'http://www.w3.org/2000/svg';
|
|
11
|
+
|
|
12
|
+
const SUPPORTED_ELEMENTS = new Set([
|
|
13
|
+
'svg',
|
|
14
|
+
'g',
|
|
15
|
+
'defs',
|
|
16
|
+
'symbol',
|
|
17
|
+
'use',
|
|
18
|
+
'switch',
|
|
19
|
+
'title',
|
|
20
|
+
'desc',
|
|
21
|
+
'path',
|
|
22
|
+
'rect',
|
|
23
|
+
'circle',
|
|
24
|
+
'ellipse',
|
|
25
|
+
'line',
|
|
26
|
+
'polyline',
|
|
27
|
+
'polygon',
|
|
28
|
+
'text',
|
|
29
|
+
'tspan',
|
|
30
|
+
'textPath',
|
|
31
|
+
'linearGradient',
|
|
32
|
+
'radialGradient',
|
|
33
|
+
'stop',
|
|
34
|
+
'clipPath',
|
|
35
|
+
'mask',
|
|
36
|
+
'pattern',
|
|
37
|
+
'marker',
|
|
38
|
+
'filter',
|
|
39
|
+
'feBlend',
|
|
40
|
+
'feColorMatrix',
|
|
41
|
+
'feComponentTransfer',
|
|
42
|
+
'feComposite',
|
|
43
|
+
'feConvolveMatrix',
|
|
44
|
+
'feDiffuseLighting',
|
|
45
|
+
'feDisplacementMap',
|
|
46
|
+
'feDistantLight',
|
|
47
|
+
'feDropShadow',
|
|
48
|
+
'feFlood',
|
|
49
|
+
'feFuncA',
|
|
50
|
+
'feFuncB',
|
|
51
|
+
'feFuncG',
|
|
52
|
+
'feFuncR',
|
|
53
|
+
'feGaussianBlur',
|
|
54
|
+
'feMerge',
|
|
55
|
+
'feMergeNode',
|
|
56
|
+
'feMorphology',
|
|
57
|
+
'feOffset',
|
|
58
|
+
'fePointLight',
|
|
59
|
+
'feSpecularLighting',
|
|
60
|
+
'feSpotLight',
|
|
61
|
+
'feTile',
|
|
62
|
+
'feTurbulence',
|
|
63
|
+
'animate',
|
|
64
|
+
'animateTransform',
|
|
65
|
+
]);
|
|
66
|
+
|
|
67
|
+
const ANIMATED_ATTRIBUTES = new Set([
|
|
68
|
+
'd',
|
|
69
|
+
'fill',
|
|
70
|
+
'opacity',
|
|
71
|
+
'r',
|
|
72
|
+
'stroke',
|
|
73
|
+
'stroke-dasharray',
|
|
74
|
+
'stroke-dashoffset',
|
|
75
|
+
'transform',
|
|
76
|
+
]);
|
|
77
|
+
|
|
78
|
+
const CSS_REFERENCE = /(?:url|src)\s*\((?!\s*['"]?#)|image-set|cross-fade|\bimage\s*\(|element\s*\(/iu;
|
|
79
|
+
|
|
80
|
+
function isSupportedElement(el) {
|
|
81
|
+
if (el.namespaceURI !== SVG_NS || !SUPPORTED_ELEMENTS.has(el.localName)) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
return !el.localName.startsWith('animate') || ANIMATED_ATTRIBUTES.has(el.getAttribute('attributeName'));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function isSupportedAttribute({ name, value }) {
|
|
88
|
+
// Keep presentation attributes and xlink:href
|
|
89
|
+
if (name.startsWith('on') || (name.includes(':') && name !== 'xlink:href')) {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
// Local references only
|
|
93
|
+
if (name === 'href' || name === 'xlink:href') {
|
|
94
|
+
return value.startsWith('#');
|
|
95
|
+
}
|
|
96
|
+
// Keep url(#id) references only
|
|
97
|
+
return !value.includes('\\') && !CSS_REFERENCE.test(value);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function prepareSvg(svgElement) {
|
|
101
|
+
svgElement.querySelectorAll('*').forEach((el) => {
|
|
102
|
+
if (!isSupportedElement(el)) {
|
|
103
|
+
el.remove();
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
[...el.attributes].forEach((attr) => {
|
|
107
|
+
if (!isSupportedAttribute(attr)) {
|
|
108
|
+
el.removeAttribute(attr.name);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
|
|
8
114
|
/**
|
|
9
115
|
* Checks if the current browser supports CSS Container Query units for pseudo elements.
|
|
10
116
|
* i.e. if the fix for https://bugs.webkit.org/show_bug.cgi?id=253939 is available.
|
|
@@ -59,3 +165,22 @@ export function needsFontIconSizingFallback() {
|
|
|
59
165
|
// Check if the browser does not support CSS Container Query units for pseudo elements.
|
|
60
166
|
return !supportsCQUnitsForPseudoElements();
|
|
61
167
|
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Parse the first `<svg>` element in the source string. Returns its static
|
|
171
|
+
* content as SVG literal, and the element without children for its attributes.
|
|
172
|
+
* Returns `null` if there is no `<svg>`.
|
|
173
|
+
*
|
|
174
|
+
* @param {string} source
|
|
175
|
+
*/
|
|
176
|
+
export function parseSvg(source) {
|
|
177
|
+
const template = document.createElement('template');
|
|
178
|
+
template.innerHTML = source;
|
|
179
|
+
const svgElement = template.content.querySelector('svg');
|
|
180
|
+
if (!svgElement) {
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
prepareSvg(svgElement);
|
|
184
|
+
template.content.replaceChildren(...svgElement.childNodes);
|
|
185
|
+
return { svg: svg`${templateContent(template)}`, svgElement };
|
|
186
|
+
}
|
|
@@ -41,6 +41,9 @@ export declare class IconMixinClass {
|
|
|
41
41
|
* inside the SVG referenced by the path. Note that the file needs to follow the same-origin policy.
|
|
42
42
|
* - a string in the format `data:image/svg+xml,<svg>...</svg>`. You may need to use the `encodeURIComponent`
|
|
43
43
|
* function for the SVG content passed
|
|
44
|
+
*
|
|
45
|
+
* An SVG loaded without an ID only renders static SVG content, so use presentation attributes such as `fill`
|
|
46
|
+
* instead of a `<style>` element.
|
|
44
47
|
*/
|
|
45
48
|
src: string | null;
|
|
46
49
|
|
package/src/vaadin-icon-mixin.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { setOrRemoveAttribute } from '@vaadin/component-base/src/dom-utils.js';
|
|
7
7
|
import { TooltipController } from '@vaadin/component-base/src/tooltip-controller.js';
|
|
8
8
|
import { IconFontSizeMixin } from './vaadin-icon-font-size-mixin.js';
|
|
9
|
-
import {
|
|
9
|
+
import { parseSvg } from './vaadin-icon-helpers.js';
|
|
10
10
|
|
|
11
11
|
const srcCache = new Map();
|
|
12
12
|
|
|
@@ -50,6 +50,9 @@ export const IconMixin = (superClass) =>
|
|
|
50
50
|
* inside the SVG referenced by the path. Note that the file needs to follow the same-origin policy.
|
|
51
51
|
* - a string in the format `data:image/svg+xml,<svg>...</svg>`. You may need to use the `encodeURIComponent`
|
|
52
52
|
* function for the SVG content passed
|
|
53
|
+
*
|
|
54
|
+
* An SVG loaded without an ID only renders static SVG content, so use presentation attributes such as `fill`
|
|
55
|
+
* instead of a `<style>` element.
|
|
53
56
|
*/
|
|
54
57
|
src: {
|
|
55
58
|
type: String,
|
|
@@ -207,6 +210,7 @@ export const IconMixin = (superClass) =>
|
|
|
207
210
|
|
|
208
211
|
/** @private */
|
|
209
212
|
async __srcChanged(src, symbol) {
|
|
213
|
+
this.__useRef = undefined;
|
|
210
214
|
if (!src) {
|
|
211
215
|
this.svg = null;
|
|
212
216
|
return;
|
|
@@ -215,47 +219,50 @@ export const IconMixin = (superClass) =>
|
|
|
215
219
|
// Need to add the "icon" attribute to avoid issues as described in
|
|
216
220
|
// https://github.com/vaadin/web-components/issues/6301
|
|
217
221
|
this.icon = '';
|
|
218
|
-
if (
|
|
222
|
+
if (!/^\s*data:/iu.test(src) && (symbol || src.includes('#'))) {
|
|
219
223
|
const [path, iconId] = src.split('#');
|
|
220
224
|
this.__useRef = `${path}#${symbol || iconId}`;
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
try {
|
|
228
|
+
if (!srcCache.has(src)) {
|
|
229
|
+
srcCache.set(
|
|
230
|
+
src,
|
|
231
|
+
this.__fetch(src, {
|
|
232
|
+
mode: 'cors',
|
|
233
|
+
})
|
|
234
|
+
.then((data) => {
|
|
229
235
|
if (!data.ok) {
|
|
230
236
|
throw new Error('Error loading icon');
|
|
231
237
|
}
|
|
232
238
|
return data.text();
|
|
239
|
+
})
|
|
240
|
+
.then((text) => {
|
|
241
|
+
const parsed = parseSvg(text);
|
|
242
|
+
if (!parsed) {
|
|
243
|
+
throw new Error(`SVG element not found on path: ${src}`);
|
|
244
|
+
}
|
|
245
|
+
return parsed;
|
|
233
246
|
}),
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
}
|
|
240
|
-
const parsedResponse = superClass.__domParser.parseFromString(svgData, 'text/html');
|
|
241
|
-
const svgElement = parsedResponse.querySelector('svg');
|
|
242
|
-
if (!svgElement) {
|
|
243
|
-
throw new Error(`SVG element not found on path: ${src}`);
|
|
244
|
-
}
|
|
245
|
-
this.svg = unsafeSvgLiteral(svgElement.innerHTML);
|
|
246
|
-
if (symbol) {
|
|
247
|
-
this.__useRef = `#${symbol}`;
|
|
248
|
-
}
|
|
249
|
-
this.__viewBox = svgElement.getAttribute('viewBox');
|
|
250
|
-
this.__fill = svgElement.getAttribute('fill');
|
|
251
|
-
this.__stroke = svgElement.getAttribute('stroke');
|
|
252
|
-
this.__strokeWidth = svgElement.getAttribute('stroke-width');
|
|
253
|
-
this.__strokeLinecap = svgElement.getAttribute('stroke-linecap');
|
|
254
|
-
this.__strokeLinejoin = svgElement.getAttribute('stroke-linejoin');
|
|
255
|
-
} catch (e) {
|
|
256
|
-
console.error(e);
|
|
257
|
-
this.svg = null;
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
const { svg, svgElement } = await srcCache.get(src);
|
|
250
|
+
if (src !== this.src || symbol !== this.symbol) {
|
|
251
|
+
return;
|
|
258
252
|
}
|
|
253
|
+
this.svg = svg;
|
|
254
|
+
if (symbol) {
|
|
255
|
+
this.__useRef = `#${symbol}`;
|
|
256
|
+
}
|
|
257
|
+
this.__viewBox = svgElement.getAttribute('viewBox');
|
|
258
|
+
this.__fill = svgElement.getAttribute('fill');
|
|
259
|
+
this.__stroke = svgElement.getAttribute('stroke');
|
|
260
|
+
this.__strokeWidth = svgElement.getAttribute('stroke-width');
|
|
261
|
+
this.__strokeLinecap = svgElement.getAttribute('stroke-linecap');
|
|
262
|
+
this.__strokeLinejoin = svgElement.getAttribute('stroke-linejoin');
|
|
263
|
+
} catch (e) {
|
|
264
|
+
console.error(e);
|
|
265
|
+
this.svg = null;
|
|
259
266
|
}
|
|
260
267
|
}
|
|
261
268
|
|
package/web-types.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/web-types",
|
|
3
3
|
"name": "@vaadin/icon",
|
|
4
|
-
"version": "25.4.0-
|
|
4
|
+
"version": "25.4.0-alpha7",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"contributions": {
|
|
7
7
|
"html": {
|
|
8
8
|
"elements": [
|
|
9
9
|
{
|
|
10
10
|
"name": "vaadin-icon",
|
|
11
|
-
"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/25.4.0-
|
|
11
|
+
"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/25.4.0-alpha7/#/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/25.4.0-alpha7/#/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```\n\n### Styling\n\nThe following custom CSS properties are available for styling:\n\nCustom CSS property |\n:------------------------------|\n| `--vaadin-icon-color` |\n| `--vaadin-icon-size` |\n| `--vaadin-icon-stroke-width` |\n| `--vaadin-icon-visual-size` |\n\nThe following state attributes are available for styling:\n\nAttribute | Description\n---------------|-------------\n`has-tooltip` | Set when the icon has a slotted tooltip\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.",
|
|
12
12
|
"attributes": [
|
|
13
13
|
{
|
|
14
14
|
"name": "char",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
{
|
|
32
32
|
"name": "icon",
|
|
33
|
-
"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/25.4.0-
|
|
33
|
+
"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/25.4.0-alpha7/#/elements/vaadin-iconset#property-name) property of `vaadin-iconset`.",
|
|
34
34
|
"value": {
|
|
35
35
|
"type": [
|
|
36
36
|
"string"
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
},
|
|
67
67
|
{
|
|
68
68
|
"name": "src",
|
|
69
|
-
"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",
|
|
69
|
+
"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\n\nAn SVG loaded without an ID only renders static SVG content, so use presentation attributes such as `fill`\ninstead of a `<style>` element.",
|
|
70
70
|
"value": {
|
|
71
71
|
"type": [
|
|
72
72
|
"string"
|
|
@@ -114,7 +114,7 @@
|
|
|
114
114
|
},
|
|
115
115
|
{
|
|
116
116
|
"name": "icon",
|
|
117
|
-
"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/25.4.0-
|
|
117
|
+
"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/25.4.0-alpha7/#/elements/vaadin-iconset#property-name) property of `vaadin-iconset`.",
|
|
118
118
|
"value": {
|
|
119
119
|
"type": [
|
|
120
120
|
"string"
|
|
@@ -150,7 +150,7 @@
|
|
|
150
150
|
},
|
|
151
151
|
{
|
|
152
152
|
"name": "src",
|
|
153
|
-
"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",
|
|
153
|
+
"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\n\nAn SVG loaded without an ID only renders static SVG content, so use presentation attributes such as `fill`\ninstead of a `<style>` element.",
|
|
154
154
|
"value": {
|
|
155
155
|
"type": [
|
|
156
156
|
"string"
|
|
@@ -187,7 +187,7 @@
|
|
|
187
187
|
"properties": [
|
|
188
188
|
{
|
|
189
189
|
"name": "name",
|
|
190
|
-
"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/25.4.0-
|
|
190
|
+
"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/25.4.0-alpha7/#/elements/vaadin-icon#property-name) property of `vaadin-icon`.",
|
|
191
191
|
"value": {
|
|
192
192
|
"type": [
|
|
193
193
|
"string"
|
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": "25.4.0-
|
|
4
|
+
"version": "25.4.0-alpha7",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"framework": "lit",
|
|
7
7
|
"framework-config": {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"elements": [
|
|
17
17
|
{
|
|
18
18
|
"name": "vaadin-icon",
|
|
19
|
-
"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/25.4.0-
|
|
19
|
+
"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/25.4.0-alpha7/#/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/25.4.0-alpha7/#/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```\n\n### Styling\n\nThe following custom CSS properties are available for styling:\n\nCustom CSS property |\n:------------------------------|\n| `--vaadin-icon-color` |\n| `--vaadin-icon-size` |\n| `--vaadin-icon-stroke-width` |\n| `--vaadin-icon-visual-size` |\n\nThe following state attributes are available for styling:\n\nAttribute | Description\n---------------|-------------\n`has-tooltip` | Set when the icon has a slotted tooltip\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.",
|
|
20
20
|
"extension": true,
|
|
21
21
|
"attributes": [
|
|
22
22
|
{
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
},
|
|
36
36
|
{
|
|
37
37
|
"name": ".icon",
|
|
38
|
-
"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/25.4.0-
|
|
38
|
+
"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/25.4.0-alpha7/#/elements/vaadin-iconset#property-name) property of `vaadin-iconset`.",
|
|
39
39
|
"value": {
|
|
40
40
|
"kind": "expression"
|
|
41
41
|
}
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
},
|
|
64
64
|
{
|
|
65
65
|
"name": ".src",
|
|
66
|
-
"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",
|
|
66
|
+
"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\n\nAn SVG loaded without an ID only renders static SVG content, so use presentation attributes such as `fill`\ninstead of a `<style>` element.",
|
|
67
67
|
"value": {
|
|
68
68
|
"kind": "expression"
|
|
69
69
|
}
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
"attributes": [
|
|
92
92
|
{
|
|
93
93
|
"name": ".name",
|
|
94
|
-
"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/25.4.0-
|
|
94
|
+
"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/25.4.0-alpha7/#/elements/vaadin-icon#property-name) property of `vaadin-icon`.",
|
|
95
95
|
"value": {
|
|
96
96
|
"kind": "expression"
|
|
97
97
|
}
|