@vaadin/icon 25.0.0-alpha2 → 25.0.0-alpha21

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/icon",
3
- "version": "25.0.0-alpha2",
3
+ "version": "25.0.0-alpha21",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -21,7 +21,6 @@
21
21
  "type": "module",
22
22
  "files": [
23
23
  "src",
24
- "theme",
25
24
  "vaadin-*.d.ts",
26
25
  "vaadin-*.js",
27
26
  "web-types.json",
@@ -35,20 +34,20 @@
35
34
  ],
36
35
  "dependencies": {
37
36
  "@open-wc/dedupe-mixin": "^1.3.0",
38
- "@vaadin/component-base": "25.0.0-alpha2",
39
- "@vaadin/vaadin-lumo-styles": "25.0.0-alpha2",
40
- "@vaadin/vaadin-themable-mixin": "25.0.0-alpha2",
37
+ "@vaadin/component-base": "25.0.0-alpha21",
38
+ "@vaadin/vaadin-themable-mixin": "25.0.0-alpha21",
41
39
  "lit": "^3.0.0"
42
40
  },
43
41
  "devDependencies": {
44
- "@vaadin/chai-plugins": "25.0.0-alpha2",
45
- "@vaadin/test-runner-commands": "25.0.0-alpha2",
42
+ "@vaadin/chai-plugins": "25.0.0-alpha21",
43
+ "@vaadin/test-runner-commands": "25.0.0-alpha21",
46
44
  "@vaadin/testing-helpers": "^2.0.0",
47
- "sinon": "^18.0.0"
45
+ "@vaadin/vaadin-lumo-styles": "25.0.0-alpha21",
46
+ "sinon": "^21.0.0"
48
47
  },
49
48
  "web-types": [
50
49
  "web-types.json",
51
50
  "web-types.lit.json"
52
51
  ],
53
- "gitHead": "67ffcd5355cf21ce1b5039c598525109fc4c164b"
52
+ "gitHead": "8fb9e9710c01449edf623a1aaac4655cdc11a933"
54
53
  }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2017 - 2025 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ import type { CSSResult } from 'lit';
7
+
8
+ export const iconStyles: CSSResult;
@@ -3,7 +3,7 @@
3
3
  * Copyright (c) 2017 - 2025 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
- import { css } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
6
+ import { css } from 'lit';
7
7
 
8
8
  export const iconStyles = css`
9
9
  :host {
@@ -12,16 +12,17 @@ export const iconStyles = css`
12
12
  align-items: center;
13
13
  box-sizing: border-box;
14
14
  vertical-align: middle;
15
- width: 24px;
16
- height: 24px;
17
- fill: currentColor;
15
+ width: var(--vaadin-icon-size, 1lh);
16
+ height: var(--vaadin-icon-size, 1lh);
17
+ flex: none;
18
+ fill: var(--vaadin-icon-color, currentColor);
18
19
  container-type: size;
19
20
  }
20
21
 
21
22
  :host::after,
22
23
  :host::before {
23
24
  line-height: 1;
24
- font-size: 100cqh;
25
+ font-size: var(--vaadin-icon-visual-size, 100cqh);
25
26
  -webkit-font-smoothing: antialiased;
26
27
  text-rendering: optimizeLegibility;
27
28
  -moz-osx-font-smoothing: grayscale;
@@ -33,10 +34,14 @@ export const iconStyles = css`
33
34
 
34
35
  svg {
35
36
  display: block;
36
- width: 100%;
37
- height: 100%;
37
+ width: var(--vaadin-icon-visual-size, 100%);
38
+ height: var(--vaadin-icon-visual-size, 100%);
38
39
  /* prevent overflowing icon from clipping, see https://github.com/vaadin/flow-components/issues/5872 */
39
40
  overflow: visible;
41
+
42
+ @container style(--vaadin-icon-stroke-width) {
43
+ stroke-width: var(--vaadin-icon-stroke-width);
44
+ }
40
45
  }
41
46
 
42
47
  :host(:is([icon-class], [font-icon-content])) svg {
@@ -46,4 +51,14 @@ export const iconStyles = css`
46
51
  :host([font-icon-content])::before {
47
52
  content: attr(font-icon-content);
48
53
  }
54
+
55
+ .baseline {
56
+ order: -1;
57
+ }
58
+
59
+ .baseline::before {
60
+ content: '\\2003' / '';
61
+ display: inline-block;
62
+ width: 0;
63
+ }
49
64
  `;
@@ -5,7 +5,6 @@
5
5
  */
6
6
  import type { Constructor } from '@open-wc/dedupe-mixin';
7
7
  import type { SlotStylesMixinClass } from '@vaadin/component-base/src/slot-styles-mixin.js';
8
- import type { IconFontSizeMixinClass } from './vaadin-icon-font-size-mixin.js';
9
8
  import type { IconSvgLiteral } from './vaadin-icon-svg.js';
10
9
 
11
10
  /**
@@ -13,7 +12,7 @@ import type { IconSvgLiteral } from './vaadin-icon-svg.js';
13
12
  */
14
13
  export declare function IconMixin<T extends Constructor<HTMLElement>>(
15
14
  base: T,
16
- ): Constructor<IconFontSizeMixinClass> & Constructor<IconMixinClass> & Constructor<SlotStylesMixinClass> & T;
15
+ ): Constructor<IconMixinClass> & Constructor<SlotStylesMixinClass> & T;
17
16
 
18
17
  export declare class IconMixinClass {
19
18
  /**
@@ -38,9 +37,9 @@ export declare class IconMixinClass {
38
37
  /**
39
38
  * The SVG source to be loaded as the icon. It can be:
40
39
  * - an URL to a file containing the icon
41
- * - an URL in the format "/path/to/file.svg#objectID", where the "objectID" refers to an ID attribute contained
40
+ * - an URL in the format `/path/to/file.svg#objectID`, where the `objectID` refers to an ID attribute contained
42
41
  * inside the SVG referenced by the path. Note that the file needs to follow the same-origin policy.
43
- * - a string in the format "data:image/svg+xml,<svg>...</svg>". You may need to use the "encodeURIComponent"
42
+ * - a string in the format `data:image/svg+xml,<svg>...</svg>`. You may need to use the `encodeURIComponent`
44
43
  * function for the SVG content passed
45
44
  */
46
45
  src: string | null;
@@ -5,8 +5,7 @@
5
5
  */
6
6
  import { SlotStylesMixin } from '@vaadin/component-base/src/slot-styles-mixin.js';
7
7
  import { TooltipController } from '@vaadin/component-base/src/tooltip-controller.js';
8
- import { IconFontSizeMixin } from './vaadin-icon-font-size-mixin.js';
9
- import { ensureSvgLiteral, renderSvg, unsafeSvgLiteral } from './vaadin-icon-svg.js';
8
+ import { unsafeSvgLiteral } from './vaadin-icon-svg.js';
10
9
 
11
10
  const srcCache = new Map();
12
11
 
@@ -15,10 +14,9 @@ const Iconset = customElements.get('vaadin-iconset');
15
14
  /**
16
15
  * @polymerMixin
17
16
  * @mixes SlotStylesMixin
18
- * @mixes IconFontSizeMixin
19
17
  */
20
18
  export const IconMixin = (superClass) =>
21
- class extends IconFontSizeMixin(SlotStylesMixin(superClass)) {
19
+ class extends SlotStylesMixin(superClass) {
22
20
  static get properties() {
23
21
  return {
24
22
  /**
@@ -52,9 +50,9 @@ export const IconMixin = (superClass) =>
52
50
  /**
53
51
  * The SVG source to be loaded as the icon. It can be:
54
52
  * - an URL to a file containing the icon
55
- * - an URL in the format "/path/to/file.svg#objectID", where the "objectID" refers to an ID attribute contained
53
+ * - an URL in the format `/path/to/file.svg#objectID`, where the `objectID` refers to an ID attribute contained
56
54
  * inside the SVG referenced by the path. Note that the file needs to follow the same-origin policy.
57
- * - a string in the format "data:image/svg+xml,<svg>...</svg>". You may need to use the "encodeURIComponent"
55
+ * - a string in the format `data:image/svg+xml,<svg>...</svg>`. You may need to use the `encodeURIComponent`
58
56
  * function for the SVG content passed
59
57
  *
60
58
  * @type {string}
@@ -134,20 +132,11 @@ export const IconMixin = (superClass) =>
134
132
  sync: true,
135
133
  },
136
134
 
137
- /** @private */
138
- __defaultPAR: {
139
- type: String,
140
- value: 'xMidYMid meet',
141
- },
142
-
143
135
  /** @private */
144
136
  __preserveAspectRatio: String,
145
137
 
146
138
  /** @private */
147
- __useRef: Object,
148
-
149
- /** @private */
150
- __svgElement: String,
139
+ __useRef: String,
151
140
 
152
141
  /** @private */
153
142
  __viewBox: String,
@@ -170,11 +159,7 @@ export const IconMixin = (superClass) =>
170
159
  }
171
160
 
172
161
  static get observers() {
173
- return [
174
- '__svgChanged(svg, __svgElement)',
175
- '__fontChanged(iconClass, char, ligature)',
176
- '__srcChanged(src, symbol)',
177
- ];
162
+ return ['__fontChanged(iconClass, char, ligature)', '__srcChanged(src, symbol)'];
178
163
  }
179
164
 
180
165
  static get observedAttributes() {
@@ -208,7 +193,6 @@ export const IconMixin = (superClass) =>
208
193
  /** @protected */
209
194
  ready() {
210
195
  super.ready();
211
- this.__svgElement = this.shadowRoot.querySelector('#svg-group');
212
196
  this._tooltipController = new TooltipController(this);
213
197
  this.addController(this._tooltipController);
214
198
  }
@@ -245,7 +229,7 @@ export const IconMixin = (superClass) =>
245
229
  if (icon) {
246
230
  this._applyIcon();
247
231
  } else {
248
- this.svg = ensureSvgLiteral(null);
232
+ this.svg = null;
249
233
  }
250
234
  }
251
235
 
@@ -303,29 +287,6 @@ export const IconMixin = (superClass) =>
303
287
  }
304
288
  }
305
289
 
306
- /** @private */
307
- __svgChanged(svg, svgElement) {
308
- if (!svgElement) {
309
- return;
310
- }
311
- renderSvg(svg, svgElement);
312
- }
313
-
314
- /** @private */
315
- __computePAR(defaultPAR, preserveAspectRatio) {
316
- return preserveAspectRatio || defaultPAR;
317
- }
318
-
319
- /** @private */
320
- __computeVisibility(__useRef) {
321
- return __useRef ? 'visible' : 'hidden';
322
- }
323
-
324
- /** @private */
325
- __computeViewBox(size, viewBox) {
326
- return viewBox || `0 0 ${size} ${size}`;
327
- }
328
-
329
290
  /** @private */
330
291
  __fontChanged(iconClass, char, ligature) {
331
292
  this.classList.remove(...(this.__addedIconClasses || []));
@@ -22,11 +22,6 @@ export function isValidSvg(source: unknown): source is IconSvgLiteral;
22
22
  */
23
23
  export function ensureSvgLiteral(source: unknown): IconSvgLiteral;
24
24
 
25
- /**
26
- * Render a given SVG literal to the container.
27
- */
28
- export function renderSvg(source: unknown, container: SVGElement): void;
29
-
30
25
  /**
31
26
  * Create an SVG literal from source string.
32
27
  */
@@ -3,7 +3,7 @@
3
3
  * Copyright (c) 2021 - 2025 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
- import { nothing, render, svg } from 'lit';
6
+ import { nothing, svg } from 'lit';
7
7
  import { isTemplateResult, TemplateResultType } from 'lit/directive-helpers.js';
8
8
  import { unsafeSVG } from 'lit/directives/unsafe-svg.js';
9
9
 
@@ -35,7 +35,7 @@ export function isValidSvg(source) {
35
35
  /**
36
36
  * Create a valid SVG literal based on the argument.
37
37
  *
38
- * @param {unknown} svg
38
+ * @param {unknown} source
39
39
  */
40
40
  export function ensureSvgLiteral(source) {
41
41
  let result = source == null || source === '' ? nothing : source;
@@ -48,17 +48,6 @@ export function ensureSvgLiteral(source) {
48
48
  return result;
49
49
  }
50
50
 
51
- /**
52
- * Render a given SVG literal to the container.
53
- *
54
- * @param {unknown} source
55
- * @param {SVGElement} container
56
- */
57
- export function renderSvg(source, container) {
58
- const result = ensureSvgLiteral(source);
59
- render(result, container);
60
- }
61
-
62
51
  /**
63
52
  * Create an SVG literal from source string.
64
53
  *
@@ -45,6 +45,24 @@ import { IconMixin } from './vaadin-icon-mixin.js';
45
45
  * `;
46
46
  * }
47
47
  * ```
48
+ *
49
+ * ### Styling
50
+ *
51
+ * The following custom CSS properties are available for styling:
52
+ *
53
+ * Custom CSS property | Description
54
+ * -----------------------------|-------------
55
+ * `--vaadin-icon-size` | Size (width and height) of the icon
56
+ * `--vaadin-icon-stroke-width` | Stroke width of the SVG icon
57
+ * `--vaadin-icon-visual-size` | Visual size of the icon
58
+ *
59
+ * The following state attributes are available for styling:
60
+ *
61
+ * Attribute | Description
62
+ * ---------------|-------------
63
+ * `has-tooltip` | Set when the icon has a slotted tooltip
64
+ *
65
+ * See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
48
66
  */
49
67
  declare class Icon extends ThemableMixin(ElementMixin(IconMixin(HTMLElement))) {}
50
68
 
@@ -9,10 +9,11 @@ import { ifDefined } from 'lit/directives/if-defined.js';
9
9
  import { defineCustomElement } from '@vaadin/component-base/src/define.js';
10
10
  import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
11
11
  import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
12
- import { CSSInjectionMixin } from '@vaadin/vaadin-themable-mixin/css-injection-mixin.js';
12
+ import { LumoInjectionMixin } from '@vaadin/vaadin-themable-mixin/lumo-injection-mixin.js';
13
13
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
14
+ import { iconStyles } from './styles/vaadin-icon-base-styles.js';
14
15
  import { IconMixin } from './vaadin-icon-mixin.js';
15
- import { iconStyles } from './vaadin-icon-styles.js';
16
+ import { ensureSvgLiteral } from './vaadin-icon-svg.js';
16
17
 
17
18
  /**
18
19
  * `<vaadin-icon>` is a Web Component for displaying SVG icons.
@@ -53,13 +54,31 @@ import { iconStyles } from './vaadin-icon-styles.js';
53
54
  * }
54
55
  * ```
55
56
  *
57
+ * ### Styling
58
+ *
59
+ * The following custom CSS properties are available for styling:
60
+ *
61
+ * Custom CSS property | Description
62
+ * -----------------------------|-------------
63
+ * `--vaadin-icon-size` | Size (width and height) of the icon
64
+ * `--vaadin-icon-stroke-width` | Stroke width of the SVG icon
65
+ * `--vaadin-icon-visual-size` | Visual size of the icon
66
+ *
67
+ * The following state attributes are available for styling:
68
+ *
69
+ * Attribute | Description
70
+ * ---------------|-------------
71
+ * `has-tooltip` | Set when the icon has a slotted tooltip
72
+ *
73
+ * See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
74
+ *
56
75
  * @customElement
57
76
  * @extends HTMLElement
58
77
  * @mixes IconMixin
59
78
  * @mixes ThemableMixin
60
79
  * @mixes ElementMixin
61
80
  */
62
- class Icon extends IconMixin(ElementMixin(CSSInjectionMixin(ThemableMixin(PolylitMixin(LitElement))))) {
81
+ class Icon extends IconMixin(ElementMixin(ThemableMixin(PolylitMixin(LumoInjectionMixin(LitElement))))) {
63
82
  static get is() {
64
83
  return 'vaadin-icon';
65
84
  }
@@ -68,15 +87,22 @@ class Icon extends IconMixin(ElementMixin(CSSInjectionMixin(ThemableMixin(Polyli
68
87
  return iconStyles;
69
88
  }
70
89
 
90
+ static get lumoInjector() {
91
+ return {
92
+ includeBaseStyles: true,
93
+ };
94
+ }
95
+
71
96
  /** @protected */
72
97
  render() {
73
98
  return html`
99
+ <span class="baseline"></span>
74
100
  <svg
75
101
  version="1.1"
76
102
  xmlns="http://www.w3.org/2000/svg"
77
103
  xmlns:xlink="http://www.w3.org/1999/xlink"
78
- viewBox="${this.__computeViewBox(this.size, this.__viewBox)}"
79
- preserveAspectRatio="${this.__computePAR(this.__defaultPAR, this.__preserveAspectRatio)}"
104
+ viewBox="${this.__viewBox || `0 0 ${this.size} ${this.size}`}"
105
+ preserveAspectRatio="${this.__preserveAspectRatio || 'xMidYMid meet'}"
80
106
  fill="${ifDefined(this.__fill)}"
81
107
  stroke="${ifDefined(this.__stroke)}"
82
108
  stroke-width="${ifDefined(this.__strokeWidth)}"
@@ -84,9 +110,9 @@ class Icon extends IconMixin(ElementMixin(CSSInjectionMixin(ThemableMixin(Polyli
84
110
  stroke-linejoin="${ifDefined(this.__strokeLinejoin)}"
85
111
  aria-hidden="true"
86
112
  >
87
- <g id="svg-group"></g>
88
- <g id="use-group" visibility="${this.__computeVisibility(this.__useRef, this.svg)}">
89
- <use href="${this.__useRef}" />
113
+ <g id="svg-group">${ensureSvgLiteral(this.svg)}</g>
114
+ <g id="use-group" visibility="${this.__useRef ? 'visible' : 'hidden'}">
115
+ <use href="${ifDefined(this.__useRef)}" />
90
116
  </g>
91
117
  </svg>
92
118
 
package/vaadin-icon.js CHANGED
@@ -1,4 +1,4 @@
1
- import './theme/lumo/vaadin-icon.js';
1
+ import './src/vaadin-icon.js';
2
2
 
3
3
  export * from './src/vaadin-icon-svg.js';
4
4
  export * from './src/vaadin-icon.js';
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": "25.0.0-alpha2",
4
+ "version": "25.0.0-alpha21",
5
5
  "description-markup": "markdown",
6
6
  "contributions": {
7
7
  "html": {
@@ -26,7 +26,7 @@
26
26
  "properties": [
27
27
  {
28
28
  "name": "name",
29
- "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.0.0-alpha2/#/elements/vaadin-icon#property-name) property of `vaadin-icon`.",
29
+ "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.0.0-alpha21/#/elements/vaadin-icon#property-name) property of `vaadin-icon`.",
30
30
  "value": {
31
31
  "type": [
32
32
  "string"
@@ -48,11 +48,11 @@
48
48
  },
49
49
  {
50
50
  "name": "vaadin-icon",
51
- "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.0.0-alpha2/#/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.0.0-alpha2/#/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```",
51
+ "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.0.0-alpha21/#/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.0.0-alpha21/#/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 | Description\n-----------------------------|-------------\n`--vaadin-icon-size` | Size (width and height) of the icon\n`--vaadin-icon-stroke-width` | Stroke width of the SVG icon\n`--vaadin-icon-visual-size` | Visual size of the icon\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.",
52
52
  "attributes": [
53
53
  {
54
54
  "name": "icon",
55
- "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.0.0-alpha2/#/elements/vaadin-iconset#property-name) property of `vaadin-iconset`.",
55
+ "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.0.0-alpha21/#/elements/vaadin-iconset#property-name) property of `vaadin-iconset`.",
56
56
  "value": {
57
57
  "type": [
58
58
  "string"
@@ -61,7 +61,7 @@
61
61
  },
62
62
  {
63
63
  "name": "src",
64
- "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",
64
+ "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",
65
65
  "value": {
66
66
  "type": [
67
67
  "string"
@@ -140,7 +140,7 @@
140
140
  "properties": [
141
141
  {
142
142
  "name": "icon",
143
- "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.0.0-alpha2/#/elements/vaadin-iconset#property-name) property of `vaadin-iconset`.",
143
+ "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.0.0-alpha21/#/elements/vaadin-iconset#property-name) property of `vaadin-iconset`.",
144
144
  "value": {
145
145
  "type": [
146
146
  "string"
@@ -160,7 +160,7 @@
160
160
  },
161
161
  {
162
162
  "name": "src",
163
- "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",
163
+ "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",
164
164
  "value": {
165
165
  "type": [
166
166
  "string"
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/icon",
4
- "version": "25.0.0-alpha2",
4
+ "version": "25.0.0-alpha21",
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/25.0.0-alpha2/#/elements/vaadin-icon#property-name) property of `vaadin-icon`.",
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/25.0.0-alpha21/#/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/25.0.0-alpha2/#/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.0.0-alpha2/#/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```",
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/25.0.0-alpha21/#/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.0.0-alpha21/#/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 | Description\n-----------------------------|-------------\n`--vaadin-icon-size` | Size (width and height) of the icon\n`--vaadin-icon-stroke-width` | Stroke width of the SVG icon\n`--vaadin-icon-visual-size` | Visual size of the icon\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.",
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/25.0.0-alpha2/#/elements/vaadin-iconset#property-name) property of `vaadin-iconset`.",
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/25.0.0-alpha21/#/elements/vaadin-iconset#property-name) property of `vaadin-iconset`.",
46
46
  "value": {
47
47
  "kind": "expression"
48
48
  }
@@ -56,7 +56,7 @@
56
56
  },
57
57
  {
58
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",
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
60
  "value": {
61
61
  "kind": "expression"
62
62
  }
@@ -1,16 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright (c) 2021 - 2025 Vaadin Ltd.
4
- * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
- */
6
- import type { Constructor } from '@open-wc/dedupe-mixin';
7
-
8
- /**
9
- * Mixin which enables the font icon sizing fallback for browsers that do not support CSS Container Queries.
10
- * The mixin does nothing if the browser supports CSS Container Query units for pseudo elements.
11
- */
12
- export declare function IconFontSizeMixin<T extends Constructor<HTMLElement>>(
13
- base: T,
14
- ): Constructor<IconFontSizeMixinClass> & T;
15
-
16
- export declare class IconFontSizeMixinClass {}
@@ -1,74 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright (c) 2021 - 2025 Vaadin Ltd.
4
- * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
- */
6
- import { ResizeMixin } from '@vaadin/component-base/src/resize-mixin.js';
7
- import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
8
- import { needsFontIconSizingFallback } from './vaadin-icon-helpers.js';
9
-
10
- const usesFontIconSizingFallback = needsFontIconSizingFallback();
11
-
12
- if (usesFontIconSizingFallback) {
13
- registerStyles(
14
- 'vaadin-icon',
15
- css`
16
- :host::after,
17
- :host::before {
18
- font-size: var(--_vaadin-font-icon-size);
19
- }
20
- `,
21
- 'vaadin-icon-font-size-mixin-styles',
22
- );
23
- }
24
-
25
- /**
26
- * Mixin which enables the font icon sizing fallback for browsers that do not support CSS Container Queries.
27
- * The mixin does nothing if the browser supports CSS Container Query units for pseudo elements.
28
- *
29
- * @polymerMixin
30
- */
31
- export const IconFontSizeMixin = (superclass) =>
32
- !usesFontIconSizingFallback
33
- ? superclass
34
- : class extends ResizeMixin(superclass) {
35
- static get observers() {
36
- return ['__iconFontSizeMixinfontChanged(iconClass, char, ligature)'];
37
- }
38
-
39
- /** @protected */
40
- ready() {
41
- super.ready();
42
-
43
- // Update once initially to avoid a fouc
44
- this.__updateFontIconSize();
45
- }
46
-
47
- /** @private */
48
- __iconFontSizeMixinfontChanged(_iconClass, _char, _ligature) {
49
- // Update when iconClass, char or ligature changes
50
- this.__updateFontIconSize();
51
- }
52
-
53
- /**
54
- * @protected
55
- * @override
56
- */
57
- _onResize() {
58
- // Update when the element is resized
59
- this.__updateFontIconSize();
60
- }
61
-
62
- /**
63
- * Updates the --_vaadin-font-icon-size CSS variable value if font icons are used.
64
- *
65
- * @private
66
- */
67
- __updateFontIconSize() {
68
- if (this.char || this.iconClass || this.ligature) {
69
- const { paddingTop, paddingBottom, height } = getComputedStyle(this);
70
- const fontIconSize = parseFloat(height) - parseFloat(paddingTop) - parseFloat(paddingBottom);
71
- this.style.setProperty('--_vaadin-font-icon-size', `${fontIconSize}px`);
72
- }
73
- }
74
- };
@@ -1,52 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright (c) 2016 - 2025 Vaadin Ltd.
4
- * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
- */
6
-
7
- import { isSafari } from '@vaadin/component-base/src/browser-utils.js';
8
-
9
- /**
10
- * Checks if the current browser supports CSS Container Query units for pseudo elements.
11
- * i.e. if the fix for https://bugs.webkit.org/show_bug.cgi?id=253939 is available.
12
- */
13
- export function supportsCQUnitsForPseudoElements() {
14
- const testStyle = document.createElement('style');
15
- testStyle.textContent = `
16
- .vaadin-icon-test-element {
17
- container-type: size;
18
- height: 2px;
19
- visibility: hidden;
20
- position: fixed;
21
- }
22
-
23
- .vaadin-icon-test-element::before {
24
- content: '';
25
- display: block;
26
- height: 100cqh;
27
- `;
28
- const testElement = document.createElement('div');
29
- testElement.classList.add('vaadin-icon-test-element');
30
-
31
- document.body.append(testStyle, testElement);
32
- const { height } = getComputedStyle(testElement, '::before');
33
- testStyle.remove();
34
- testElement.remove();
35
- return height === '2px';
36
- }
37
-
38
- /**
39
- * Checks if the current browser needs a fallback for sizing font icons instead of relying on CSS Container Queries.
40
- */
41
- export function needsFontIconSizingFallback() {
42
- if (!CSS.supports('container-type: inline-size')) {
43
- // The browser does not support CSS Container Queries at all.
44
- return true;
45
- }
46
- if (!isSafari) {
47
- // Browsers other than Safari support CSS Container Queries as expected.
48
- return false;
49
- }
50
- // Check if the browser does not support CSS Container Query units for pseudo elements.
51
- return !supportsCQUnitsForPseudoElements();
52
- }
@@ -1 +0,0 @@
1
- import '@vaadin/vaadin-lumo-styles/sizing.js';
@@ -1,13 +0,0 @@
1
- import '@vaadin/vaadin-lumo-styles/sizing.js';
2
- import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
3
-
4
- registerStyles(
5
- 'vaadin-icon',
6
- css`
7
- :host {
8
- width: var(--lumo-icon-size-m);
9
- height: var(--lumo-icon-size-m);
10
- }
11
- `,
12
- { moduleId: 'lumo-icon' },
13
- );
@@ -1,2 +0,0 @@
1
- import './vaadin-icon-styles.js';
2
- import '../../src/vaadin-icon.js';
@@ -1,2 +0,0 @@
1
- import './vaadin-icon-styles.js';
2
- import '../../src/vaadin-icon.js';