@vaadin/icon 25.0.0-alpha3 → 25.0.0-alpha5
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 +9 -7
- package/src/styles/vaadin-icon-base-styles.d.ts +8 -0
- package/src/styles/vaadin-icon-base-styles.js +53 -0
- package/src/styles/vaadin-icon-core-styles.d.ts +8 -0
- package/src/{vaadin-icon-styles.js → styles/vaadin-icon-core-styles.js} +1 -1
- package/src/vaadin-icon-mixin.d.ts +1 -2
- package/src/vaadin-icon-mixin.js +5 -44
- package/src/vaadin-icon-svg.d.ts +0 -5
- package/src/vaadin-icon-svg.js +1 -12
- package/src/vaadin-icon.js +7 -6
- package/web-types.json +5 -5
- package/web-types.lit.json +4 -4
- package/src/vaadin-icon-font-size-mixin.d.ts +0 -16
- package/src/vaadin-icon-font-size-mixin.js +0 -74
- package/src/vaadin-icon-helpers.js +0 -52
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/icon",
|
|
3
|
-
"version": "25.0.0-
|
|
3
|
+
"version": "25.0.0-alpha5",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -21,6 +21,8 @@
|
|
|
21
21
|
"type": "module",
|
|
22
22
|
"files": [
|
|
23
23
|
"src",
|
|
24
|
+
"!src/styles/*-base-styles.d.ts",
|
|
25
|
+
"!src/styles/*-base-styles.js",
|
|
24
26
|
"theme",
|
|
25
27
|
"vaadin-*.d.ts",
|
|
26
28
|
"vaadin-*.js",
|
|
@@ -35,14 +37,14 @@
|
|
|
35
37
|
],
|
|
36
38
|
"dependencies": {
|
|
37
39
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
38
|
-
"@vaadin/component-base": "25.0.0-
|
|
39
|
-
"@vaadin/vaadin-lumo-styles": "25.0.0-
|
|
40
|
-
"@vaadin/vaadin-themable-mixin": "25.0.0-
|
|
40
|
+
"@vaadin/component-base": "25.0.0-alpha5",
|
|
41
|
+
"@vaadin/vaadin-lumo-styles": "25.0.0-alpha5",
|
|
42
|
+
"@vaadin/vaadin-themable-mixin": "25.0.0-alpha5",
|
|
41
43
|
"lit": "^3.0.0"
|
|
42
44
|
},
|
|
43
45
|
"devDependencies": {
|
|
44
|
-
"@vaadin/chai-plugins": "25.0.0-
|
|
45
|
-
"@vaadin/test-runner-commands": "25.0.0-
|
|
46
|
+
"@vaadin/chai-plugins": "25.0.0-alpha5",
|
|
47
|
+
"@vaadin/test-runner-commands": "25.0.0-alpha5",
|
|
46
48
|
"@vaadin/testing-helpers": "^2.0.0",
|
|
47
49
|
"sinon": "^18.0.0"
|
|
48
50
|
},
|
|
@@ -50,5 +52,5 @@
|
|
|
50
52
|
"web-types.json",
|
|
51
53
|
"web-types.lit.json"
|
|
52
54
|
],
|
|
53
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "7dc87bb2a3cae81ed53259fa10b58f990d50c6fd"
|
|
54
56
|
}
|
|
@@ -0,0 +1,53 @@
|
|
|
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 { css } from 'lit';
|
|
7
|
+
|
|
8
|
+
export const iconStyles = css`
|
|
9
|
+
@layer base {
|
|
10
|
+
:host {
|
|
11
|
+
display: inline-flex;
|
|
12
|
+
justify-content: center;
|
|
13
|
+
align-items: center;
|
|
14
|
+
box-sizing: border-box;
|
|
15
|
+
vertical-align: middle;
|
|
16
|
+
width: var(--vaadin-icon-size, 1lh);
|
|
17
|
+
height: var(--vaadin-icon-size, 1lh);
|
|
18
|
+
flex: none;
|
|
19
|
+
fill: var(--vaadin-icon-color, currentColor);
|
|
20
|
+
container-type: size;
|
|
21
|
+
contain: layout;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
:host::after,
|
|
25
|
+
:host::before {
|
|
26
|
+
line-height: 1;
|
|
27
|
+
font-size: 100cqh;
|
|
28
|
+
-webkit-font-smoothing: antialiased;
|
|
29
|
+
text-rendering: optimizeLegibility;
|
|
30
|
+
-moz-osx-font-smoothing: grayscale;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
:host([hidden]) {
|
|
34
|
+
display: none !important;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
svg {
|
|
38
|
+
display: block;
|
|
39
|
+
width: 100%;
|
|
40
|
+
height: 100%;
|
|
41
|
+
/* prevent overflowing icon from clipping, see https://github.com/vaadin/flow-components/issues/5872 */
|
|
42
|
+
overflow: visible;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
:host(:is([icon-class], [font-icon-content])) svg {
|
|
46
|
+
display: none;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
:host([font-icon-content])::before {
|
|
50
|
+
content: attr(font-icon-content);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
`;
|
|
@@ -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 '
|
|
6
|
+
import { css } from 'lit';
|
|
7
7
|
|
|
8
8
|
export const iconStyles = css`
|
|
9
9
|
:host {
|
|
@@ -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<
|
|
15
|
+
): Constructor<IconMixinClass> & Constructor<SlotStylesMixinClass> & T;
|
|
17
16
|
|
|
18
17
|
export declare class IconMixinClass {
|
|
19
18
|
/**
|
package/src/vaadin-icon-mixin.js
CHANGED
|
@@ -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 {
|
|
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
|
|
19
|
+
class extends SlotStylesMixin(superClass) {
|
|
22
20
|
static get properties() {
|
|
23
21
|
return {
|
|
24
22
|
/**
|
|
@@ -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:
|
|
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 =
|
|
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 || []));
|
package/src/vaadin-icon-svg.d.ts
CHANGED
|
@@ -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
|
*/
|
package/src/vaadin-icon-svg.js
CHANGED
|
@@ -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,
|
|
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
|
|
|
@@ -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
|
*
|
package/src/vaadin-icon.js
CHANGED
|
@@ -11,8 +11,9 @@ import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
|
11
11
|
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
12
12
|
import { CSSInjectionMixin } from '@vaadin/vaadin-themable-mixin/css-injection-mixin.js';
|
|
13
13
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
14
|
+
import { iconStyles } from './styles/vaadin-icon-core-styles.js';
|
|
14
15
|
import { IconMixin } from './vaadin-icon-mixin.js';
|
|
15
|
-
import {
|
|
16
|
+
import { ensureSvgLiteral } from './vaadin-icon-svg.js';
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
19
|
* `<vaadin-icon>` is a Web Component for displaying SVG icons.
|
|
@@ -75,8 +76,8 @@ class Icon extends IconMixin(ElementMixin(CSSInjectionMixin(ThemableMixin(Polyli
|
|
|
75
76
|
version="1.1"
|
|
76
77
|
xmlns="http://www.w3.org/2000/svg"
|
|
77
78
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
78
|
-
viewBox="${this.
|
|
79
|
-
preserveAspectRatio="${this.
|
|
79
|
+
viewBox="${this.__viewBox || `0 0 ${this.size} ${this.size}`}"
|
|
80
|
+
preserveAspectRatio="${this.__preserveAspectRatio || 'xMidYMid meet'}"
|
|
80
81
|
fill="${ifDefined(this.__fill)}"
|
|
81
82
|
stroke="${ifDefined(this.__stroke)}"
|
|
82
83
|
stroke-width="${ifDefined(this.__strokeWidth)}"
|
|
@@ -84,9 +85,9 @@ class Icon extends IconMixin(ElementMixin(CSSInjectionMixin(ThemableMixin(Polyli
|
|
|
84
85
|
stroke-linejoin="${ifDefined(this.__strokeLinejoin)}"
|
|
85
86
|
aria-hidden="true"
|
|
86
87
|
>
|
|
87
|
-
<g id="svg-group"
|
|
88
|
-
<g id="use-group" visibility="${this.
|
|
89
|
-
<use href="${this.__useRef}" />
|
|
88
|
+
<g id="svg-group">${ensureSvgLiteral(this.svg)}</g>
|
|
89
|
+
<g id="use-group" visibility="${this.__useRef ? 'visible' : 'hidden'}">
|
|
90
|
+
<use href="${ifDefined(this.__useRef)}" />
|
|
90
91
|
</g>
|
|
91
92
|
</svg>
|
|
92
93
|
|
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-
|
|
4
|
+
"version": "25.0.0-alpha5",
|
|
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-
|
|
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-alpha5/#/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-
|
|
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-alpha5/#/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-alpha5/#/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```",
|
|
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-
|
|
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-alpha5/#/elements/vaadin-iconset#property-name) property of `vaadin-iconset`.",
|
|
56
56
|
"value": {
|
|
57
57
|
"type": [
|
|
58
58
|
"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-
|
|
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-alpha5/#/elements/vaadin-iconset#property-name) property of `vaadin-iconset`.",
|
|
144
144
|
"value": {
|
|
145
145
|
"type": [
|
|
146
146
|
"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.0.0-
|
|
4
|
+
"version": "25.0.0-alpha5",
|
|
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-
|
|
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-alpha5/#/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-
|
|
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-alpha5/#/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-alpha5/#/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/25.0.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/25.0.0-alpha5/#/elements/vaadin-iconset#property-name) property of `vaadin-iconset`.",
|
|
46
46
|
"value": {
|
|
47
47
|
"kind": "expression"
|
|
48
48
|
}
|
|
@@ -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
|
-
}
|