@vaadin/icon 24.1.0-alpha9 → 24.1.0-beta1
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.js +20 -2
- package/src/vaadin-iconset.d.ts +9 -1
- package/src/vaadin-iconset.js +1 -0
- package/web-types.json +6 -6
- package/web-types.lit.json +4 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/icon",
|
|
3
|
-
"version": "24.1.0-
|
|
3
|
+
"version": "24.1.0-beta1",
|
|
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.1.0-
|
|
39
|
-
"@vaadin/vaadin-lumo-styles": "24.1.0-
|
|
40
|
-
"@vaadin/vaadin-themable-mixin": "24.1.0-
|
|
38
|
+
"@vaadin/component-base": "24.1.0-beta1",
|
|
39
|
+
"@vaadin/vaadin-lumo-styles": "24.1.0-beta1",
|
|
40
|
+
"@vaadin/vaadin-themable-mixin": "24.1.0-beta1",
|
|
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": "f0ddb6576073a6af05ab29867bc5ec82e334f9d7"
|
|
53
53
|
}
|
package/src/vaadin-icon.js
CHANGED
|
@@ -85,7 +85,7 @@ class Icon extends ThemableMixin(ElementMixin(ControllerMixin(PolymerElement)))
|
|
|
85
85
|
xmlns="http://www.w3.org/2000/svg"
|
|
86
86
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
87
87
|
viewBox="[[__computeViewBox(size, __viewBox)]]"
|
|
88
|
-
preserveAspectRatio="
|
|
88
|
+
preserveAspectRatio="[[__computePAR(__defaultPAR, __preserveAspectRatio)]]"
|
|
89
89
|
aria-hidden="true"
|
|
90
90
|
></svg>
|
|
91
91
|
|
|
@@ -129,6 +129,15 @@ class Icon extends ThemableMixin(ElementMixin(ControllerMixin(PolymerElement)))
|
|
|
129
129
|
value: 24,
|
|
130
130
|
},
|
|
131
131
|
|
|
132
|
+
/** @private */
|
|
133
|
+
__defaultPAR: {
|
|
134
|
+
type: String,
|
|
135
|
+
value: 'xMidYMid meet',
|
|
136
|
+
},
|
|
137
|
+
|
|
138
|
+
/** @private */
|
|
139
|
+
__preserveAspectRatio: String,
|
|
140
|
+
|
|
132
141
|
/** @private */
|
|
133
142
|
__svgElement: Object,
|
|
134
143
|
|
|
@@ -166,12 +175,16 @@ class Icon extends ThemableMixin(ElementMixin(ControllerMixin(PolymerElement)))
|
|
|
166
175
|
|
|
167
176
|
/** @protected */
|
|
168
177
|
_applyIcon() {
|
|
169
|
-
const { svg, size, viewBox } = Iconset.getIconSvg(this.icon);
|
|
178
|
+
const { preserveAspectRatio, svg, size, viewBox } = Iconset.getIconSvg(this.icon);
|
|
170
179
|
|
|
171
180
|
if (viewBox) {
|
|
172
181
|
this.__viewBox = viewBox;
|
|
173
182
|
}
|
|
174
183
|
|
|
184
|
+
if (preserveAspectRatio) {
|
|
185
|
+
this.__preserveAspectRatio = preserveAspectRatio;
|
|
186
|
+
}
|
|
187
|
+
|
|
175
188
|
if (size && size !== this.size) {
|
|
176
189
|
this.size = size;
|
|
177
190
|
}
|
|
@@ -197,6 +210,11 @@ class Icon extends ThemableMixin(ElementMixin(ControllerMixin(PolymerElement)))
|
|
|
197
210
|
renderSvg(svg, svgElement);
|
|
198
211
|
}
|
|
199
212
|
|
|
213
|
+
/** @private */
|
|
214
|
+
__computePAR(defaultPAR, preserveAspectRatio) {
|
|
215
|
+
return preserveAspectRatio || defaultPAR;
|
|
216
|
+
}
|
|
217
|
+
|
|
200
218
|
/** @private */
|
|
201
219
|
__computeViewBox(size, viewBox) {
|
|
202
220
|
return viewBox || `0 0 ${size} ${size}`;
|
package/src/vaadin-iconset.d.ts
CHANGED
|
@@ -30,7 +30,15 @@ declare class Iconset extends ElementMixin(HTMLElement) {
|
|
|
30
30
|
* Returns SVGTemplateResult for the `icon` ID matching `name` of the
|
|
31
31
|
* iconset, or `nothing` literal if there is no matching icon found.
|
|
32
32
|
*/
|
|
33
|
-
static getIconSvg(
|
|
33
|
+
static getIconSvg(
|
|
34
|
+
icon: string,
|
|
35
|
+
name?: string,
|
|
36
|
+
): {
|
|
37
|
+
preserveAspectRatio?: string | null;
|
|
38
|
+
svg: IconSvgLiteral;
|
|
39
|
+
size?: number;
|
|
40
|
+
viewBox?: string | null;
|
|
41
|
+
};
|
|
34
42
|
|
|
35
43
|
/**
|
|
36
44
|
* The name of the iconset. Every iconset is required to have its own unique name.
|
package/src/vaadin-iconset.js
CHANGED
|
@@ -114,6 +114,7 @@ class Iconset extends ElementMixin(PolymerElement) {
|
|
|
114
114
|
const iconSvg = iconset._icons[iconId];
|
|
115
115
|
|
|
116
116
|
return {
|
|
117
|
+
preserveAspectRatio: iconSvg ? iconSvg.getAttribute('preserveAspectRatio') : null,
|
|
117
118
|
svg: cloneSvgNode(iconSvg),
|
|
118
119
|
size: iconset.size,
|
|
119
120
|
viewBox: iconSvg ? iconSvg.getAttribute('viewBox') : null,
|
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.1.0-
|
|
4
|
+
"version": "24.1.0-beta1",
|
|
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.1.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.1.0-beta1/#/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.1.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.1.0-beta1/#/elements/vaadin-icon#property-name) property of `vaadin-icon`.",
|
|
52
52
|
"value": {
|
|
53
53
|
"type": [
|
|
54
54
|
"string",
|
|
@@ -74,11 +74,11 @@
|
|
|
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.1.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.1.0-beta1/#/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.1.0-beta1/#/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.1.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.1.0-beta1/#/elements/vaadin-iconset#property-name) property of `vaadin-iconset`.",
|
|
82
82
|
"value": {
|
|
83
83
|
"type": [
|
|
84
84
|
"string",
|
|
@@ -114,7 +114,7 @@
|
|
|
114
114
|
"properties": [
|
|
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/24.1.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/24.1.0-beta1/#/elements/vaadin-iconset#property-name) property of `vaadin-iconset`.",
|
|
118
118
|
"value": {
|
|
119
119
|
"type": [
|
|
120
120
|
"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": "24.1.0-
|
|
4
|
+
"version": "24.1.0-beta1",
|
|
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.1.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.1.0-beta1/#/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.1.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.1.0-beta1/#/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.1.0-beta1/#/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.1.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.1.0-beta1/#/elements/vaadin-iconset#property-name) property of `vaadin-iconset`.",
|
|
46
46
|
"value": {
|
|
47
47
|
"kind": "expression"
|
|
48
48
|
}
|