@vaadin/icon 25.0.0-alpha8 → 25.0.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 +8 -11
- package/src/styles/vaadin-icon-base-styles.js +7 -3
- package/src/vaadin-icon-font-size-mixin.d.ts +19 -0
- package/src/vaadin-icon-font-size-mixin.js +64 -0
- package/src/vaadin-icon-helpers.js +61 -0
- package/src/vaadin-icon-mixin.d.ts +4 -3
- package/src/vaadin-icon-mixin.js +5 -3
- package/src/vaadin-icon-svg.js +1 -1
- package/src/vaadin-icon.d.ts +18 -0
- package/src/vaadin-icon.js +21 -2
- package/vaadin-icon.js +1 -1
- package/web-types.json +7 -7
- package/web-types.lit.json +5 -5
- package/src/styles/vaadin-icon-core-styles.d.ts +0 -8
- package/src/styles/vaadin-icon-core-styles.js +0 -49
- package/theme/lumo/vaadin-icon-styles.d.ts +0 -1
- package/theme/lumo/vaadin-icon-styles.js +0 -13
- package/theme/lumo/vaadin-icon.d.ts +0 -2
- package/theme/lumo/vaadin-icon.js +0 -2
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-beta1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -21,9 +21,6 @@
|
|
|
21
21
|
"type": "module",
|
|
22
22
|
"files": [
|
|
23
23
|
"src",
|
|
24
|
-
"!src/styles/*-base-styles.d.ts",
|
|
25
|
-
"!src/styles/*-base-styles.js",
|
|
26
|
-
"theme",
|
|
27
24
|
"vaadin-*.d.ts",
|
|
28
25
|
"vaadin-*.js",
|
|
29
26
|
"web-types.json",
|
|
@@ -37,20 +34,20 @@
|
|
|
37
34
|
],
|
|
38
35
|
"dependencies": {
|
|
39
36
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
40
|
-
"@vaadin/component-base": "25.0.0-
|
|
41
|
-
"@vaadin/vaadin-
|
|
42
|
-
"@vaadin/vaadin-themable-mixin": "25.0.0-alpha8",
|
|
37
|
+
"@vaadin/component-base": "25.0.0-beta1",
|
|
38
|
+
"@vaadin/vaadin-themable-mixin": "25.0.0-beta1",
|
|
43
39
|
"lit": "^3.0.0"
|
|
44
40
|
},
|
|
45
41
|
"devDependencies": {
|
|
46
|
-
"@vaadin/chai-plugins": "25.0.0-
|
|
47
|
-
"@vaadin/test-runner-commands": "25.0.0-
|
|
42
|
+
"@vaadin/chai-plugins": "25.0.0-beta1",
|
|
43
|
+
"@vaadin/test-runner-commands": "25.0.0-beta1",
|
|
48
44
|
"@vaadin/testing-helpers": "^2.0.0",
|
|
49
|
-
"
|
|
45
|
+
"@vaadin/vaadin-lumo-styles": "25.0.0-beta1",
|
|
46
|
+
"sinon": "^21.0.0"
|
|
50
47
|
},
|
|
51
48
|
"web-types": [
|
|
52
49
|
"web-types.json",
|
|
53
50
|
"web-types.lit.json"
|
|
54
51
|
],
|
|
55
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "1d20cf54e582d1f2e209126d4586f8b4c01c50e0"
|
|
56
53
|
}
|
|
@@ -22,7 +22,7 @@ export const iconStyles = css`
|
|
|
22
22
|
:host::after,
|
|
23
23
|
:host::before {
|
|
24
24
|
line-height: 1;
|
|
25
|
-
font-size: 100cqh;
|
|
25
|
+
font-size: var(--vaadin-icon-visual-size, 100cqh);
|
|
26
26
|
-webkit-font-smoothing: antialiased;
|
|
27
27
|
text-rendering: optimizeLegibility;
|
|
28
28
|
-moz-osx-font-smoothing: grayscale;
|
|
@@ -34,10 +34,14 @@ export const iconStyles = css`
|
|
|
34
34
|
|
|
35
35
|
svg {
|
|
36
36
|
display: block;
|
|
37
|
-
width: 100
|
|
38
|
-
height: 100
|
|
37
|
+
width: var(--vaadin-icon-visual-size, 100%);
|
|
38
|
+
height: var(--vaadin-icon-visual-size, 100%);
|
|
39
39
|
/* prevent overflowing icon from clipping, see https://github.com/vaadin/flow-components/issues/5872 */
|
|
40
40
|
overflow: visible;
|
|
41
|
+
|
|
42
|
+
@container style(--vaadin-icon-stroke-width) {
|
|
43
|
+
stroke-width: var(--vaadin-icon-stroke-width);
|
|
44
|
+
}
|
|
41
45
|
}
|
|
42
46
|
|
|
43
47
|
:host(:is([icon-class], [font-icon-content])) svg {
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
* In older versions of Safari, it didn't support Container Queries units used in pseudo-elements. It has been fixed in
|
|
11
|
+
* recent versions, but there's an regression in Safari 26, which caused the same issue to happen when the icon is
|
|
12
|
+
* attached to an element with shadow root.
|
|
13
|
+
* The mixin does nothing if the browser supports CSS Container Query units for pseudo elements.
|
|
14
|
+
*/
|
|
15
|
+
export declare function IconFontSizeMixin<T extends Constructor<HTMLElement>>(
|
|
16
|
+
base: T,
|
|
17
|
+
): Constructor<IconFontSizeMixinClass> & T;
|
|
18
|
+
|
|
19
|
+
export declare class IconFontSizeMixinClass {}
|
|
@@ -0,0 +1,64 @@
|
|
|
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 { css } from 'lit';
|
|
7
|
+
import { ResizeMixin } from '@vaadin/component-base/src/resize-mixin.js';
|
|
8
|
+
import { needsFontIconSizingFallback } from './vaadin-icon-helpers.js';
|
|
9
|
+
|
|
10
|
+
const usesFontIconSizingFallback = needsFontIconSizingFallback();
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Mixin which enables the font icon sizing fallback for browsers that do not support CSS Container Queries.
|
|
14
|
+
* In older versions of Safari, it didn't support Container Queries units used in pseudo-elements. It has been fixed in
|
|
15
|
+
* recent versions, but there's an regression in Safari 26, which caused the same issue to happen when the icon is
|
|
16
|
+
* attached to an element with shadow root.
|
|
17
|
+
* The mixin does nothing if the browser supports CSS Container Query units for pseudo elements.
|
|
18
|
+
*
|
|
19
|
+
* @polymerMixin
|
|
20
|
+
*/
|
|
21
|
+
export const IconFontSizeMixin = (superclass) =>
|
|
22
|
+
!usesFontIconSizingFallback
|
|
23
|
+
? superclass
|
|
24
|
+
: class extends ResizeMixin(superclass) {
|
|
25
|
+
static get styles() {
|
|
26
|
+
return css`
|
|
27
|
+
:host::after,
|
|
28
|
+
:host::before {
|
|
29
|
+
font-size: var(--vaadin-icon-visual-size, var(--_vaadin-font-icon-size));
|
|
30
|
+
}
|
|
31
|
+
`;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** @protected */
|
|
35
|
+
updated(props) {
|
|
36
|
+
super.updated(props);
|
|
37
|
+
|
|
38
|
+
if (props.has('char') || props.has('iconClass') || props.has('ligature')) {
|
|
39
|
+
this.__updateFontIconSize();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @protected
|
|
45
|
+
* @override
|
|
46
|
+
*/
|
|
47
|
+
_onResize() {
|
|
48
|
+
// Update when the element is resized
|
|
49
|
+
this.__updateFontIconSize();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Updates the --_vaadin-font-icon-size CSS variable value if font icons are used.
|
|
54
|
+
*
|
|
55
|
+
* @private
|
|
56
|
+
*/
|
|
57
|
+
__updateFontIconSize() {
|
|
58
|
+
if (this.char || this.iconClass || this.ligature) {
|
|
59
|
+
const { paddingTop, paddingBottom, height } = getComputedStyle(this);
|
|
60
|
+
const fontIconSize = parseFloat(height) - parseFloat(paddingTop) - parseFloat(paddingBottom);
|
|
61
|
+
this.style.setProperty('--_vaadin-font-icon-size', `${fontIconSize}px`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
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 { isSafari } from '@vaadin/component-base/src/browser-utils.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Checks if the current browser supports CSS Container Query units for pseudo elements.
|
|
10
|
+
* i.e. if the fix for https://bugs.webkit.org/show_bug.cgi?id=253939 is available.
|
|
11
|
+
*/
|
|
12
|
+
export function supportsCQUnitsForPseudoElements() {
|
|
13
|
+
const testStyle = document.createElement('style');
|
|
14
|
+
testStyle.textContent = `
|
|
15
|
+
.vaadin-icon-test-element {
|
|
16
|
+
container-type: size;
|
|
17
|
+
height: 2px;
|
|
18
|
+
visibility: hidden;
|
|
19
|
+
position: fixed;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.vaadin-icon-test-element::before {
|
|
23
|
+
content: '';
|
|
24
|
+
display: block;
|
|
25
|
+
height: 100cqh;
|
|
26
|
+
`;
|
|
27
|
+
const testElement = document.createElement('div');
|
|
28
|
+
testElement.classList.add('vaadin-icon-test-element');
|
|
29
|
+
|
|
30
|
+
const shadowParent = document.createElement('div');
|
|
31
|
+
shadowParent.attachShadow({ mode: 'open' });
|
|
32
|
+
shadowParent.shadowRoot.innerHTML = '<slot></slot>';
|
|
33
|
+
shadowParent.append(testElement.cloneNode());
|
|
34
|
+
|
|
35
|
+
document.body.append(testStyle, testElement, shadowParent);
|
|
36
|
+
|
|
37
|
+
const needsFallback = [...document.querySelectorAll('.vaadin-icon-test-element')].find(
|
|
38
|
+
(el) => getComputedStyle(el, '::before').height !== '2px',
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
testStyle.remove();
|
|
42
|
+
testElement.remove();
|
|
43
|
+
shadowParent.remove();
|
|
44
|
+
return !needsFallback;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Checks if the current browser needs a fallback for sizing font icons instead of relying on CSS Container Queries.
|
|
49
|
+
*/
|
|
50
|
+
export function needsFontIconSizingFallback() {
|
|
51
|
+
if (!CSS.supports('container-type: inline-size')) {
|
|
52
|
+
// The browser does not support CSS Container Queries at all.
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
if (!isSafari) {
|
|
56
|
+
// Browsers other than Safari support CSS Container Queries as expected.
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
// Check if the browser does not support CSS Container Query units for pseudo elements.
|
|
60
|
+
return !supportsCQUnitsForPseudoElements();
|
|
61
|
+
}
|
|
@@ -5,6 +5,7 @@
|
|
|
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';
|
|
8
9
|
import type { IconSvgLiteral } from './vaadin-icon-svg.js';
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -12,7 +13,7 @@ import type { IconSvgLiteral } from './vaadin-icon-svg.js';
|
|
|
12
13
|
*/
|
|
13
14
|
export declare function IconMixin<T extends Constructor<HTMLElement>>(
|
|
14
15
|
base: T,
|
|
15
|
-
): Constructor<IconMixinClass> & Constructor<SlotStylesMixinClass> & T;
|
|
16
|
+
): Constructor<IconFontSizeMixinClass> & Constructor<IconMixinClass> & Constructor<SlotStylesMixinClass> & T;
|
|
16
17
|
|
|
17
18
|
export declare class IconMixinClass {
|
|
18
19
|
/**
|
|
@@ -37,9 +38,9 @@ export declare class IconMixinClass {
|
|
|
37
38
|
/**
|
|
38
39
|
* The SVG source to be loaded as the icon. It can be:
|
|
39
40
|
* - an URL to a file containing the icon
|
|
40
|
-
* - an URL in the format
|
|
41
|
+
* - an URL in the format `/path/to/file.svg#objectID`, where the `objectID` refers to an ID attribute contained
|
|
41
42
|
* inside the SVG referenced by the path. Note that the file needs to follow the same-origin policy.
|
|
42
|
-
* - a string in the format
|
|
43
|
+
* - a string in the format `data:image/svg+xml,<svg>...</svg>`. You may need to use the `encodeURIComponent`
|
|
43
44
|
* function for the SVG content passed
|
|
44
45
|
*/
|
|
45
46
|
src: string | null;
|
package/src/vaadin-icon-mixin.js
CHANGED
|
@@ -5,6 +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';
|
|
8
9
|
import { unsafeSvgLiteral } from './vaadin-icon-svg.js';
|
|
9
10
|
|
|
10
11
|
const srcCache = new Map();
|
|
@@ -14,9 +15,10 @@ const Iconset = customElements.get('vaadin-iconset');
|
|
|
14
15
|
/**
|
|
15
16
|
* @polymerMixin
|
|
16
17
|
* @mixes SlotStylesMixin
|
|
18
|
+
* @mixes IconFontSizeMixin
|
|
17
19
|
*/
|
|
18
20
|
export const IconMixin = (superClass) =>
|
|
19
|
-
class extends SlotStylesMixin(superClass) {
|
|
21
|
+
class extends IconFontSizeMixin(SlotStylesMixin(superClass)) {
|
|
20
22
|
static get properties() {
|
|
21
23
|
return {
|
|
22
24
|
/**
|
|
@@ -50,9 +52,9 @@ export const IconMixin = (superClass) =>
|
|
|
50
52
|
/**
|
|
51
53
|
* The SVG source to be loaded as the icon. It can be:
|
|
52
54
|
* - an URL to a file containing the icon
|
|
53
|
-
* - an URL in the format
|
|
55
|
+
* - an URL in the format `/path/to/file.svg#objectID`, where the `objectID` refers to an ID attribute contained
|
|
54
56
|
* inside the SVG referenced by the path. Note that the file needs to follow the same-origin policy.
|
|
55
|
-
* - a string in the format
|
|
57
|
+
* - a string in the format `data:image/svg+xml,<svg>...</svg>`. You may need to use the `encodeURIComponent`
|
|
56
58
|
* function for the SVG content passed
|
|
57
59
|
*
|
|
58
60
|
* @type {string}
|
package/src/vaadin-icon-svg.js
CHANGED
|
@@ -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}
|
|
38
|
+
* @param {unknown} source
|
|
39
39
|
*/
|
|
40
40
|
export function ensureSvgLiteral(source) {
|
|
41
41
|
let result = source == null || source === '' ? nothing : source;
|
package/src/vaadin-icon.d.ts
CHANGED
|
@@ -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
|
|
package/src/vaadin-icon.js
CHANGED
|
@@ -11,7 +11,7 @@ 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 { 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-
|
|
14
|
+
import { iconStyles } from './styles/vaadin-icon-base-styles.js';
|
|
15
15
|
import { IconMixin } from './vaadin-icon-mixin.js';
|
|
16
16
|
import { ensureSvgLiteral } from './vaadin-icon-svg.js';
|
|
17
17
|
|
|
@@ -54,6 +54,24 @@ import { ensureSvgLiteral } from './vaadin-icon-svg.js';
|
|
|
54
54
|
* }
|
|
55
55
|
* ```
|
|
56
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
|
+
*
|
|
57
75
|
* @customElement
|
|
58
76
|
* @extends HTMLElement
|
|
59
77
|
* @mixes IconMixin
|
|
@@ -66,7 +84,8 @@ class Icon extends IconMixin(ElementMixin(ThemableMixin(PolylitMixin(LumoInjecti
|
|
|
66
84
|
}
|
|
67
85
|
|
|
68
86
|
static get styles() {
|
|
69
|
-
|
|
87
|
+
// Apply `super.styles` only if the fallback is used
|
|
88
|
+
return [iconStyles, super.styles].filter(Boolean);
|
|
70
89
|
}
|
|
71
90
|
|
|
72
91
|
static get lumoInjector() {
|
package/vaadin-icon.js
CHANGED
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-beta1",
|
|
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-beta1/#/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-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/25.0.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```\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-
|
|
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-beta1/#/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
|
|
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-
|
|
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-beta1/#/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
|
|
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"
|
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-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/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-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/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-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/25.0.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```\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-
|
|
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-beta1/#/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
|
|
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,49 +0,0 @@
|
|
|
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
|
-
:host {
|
|
10
|
-
display: inline-flex;
|
|
11
|
-
justify-content: center;
|
|
12
|
-
align-items: center;
|
|
13
|
-
box-sizing: border-box;
|
|
14
|
-
vertical-align: middle;
|
|
15
|
-
width: 24px;
|
|
16
|
-
height: 24px;
|
|
17
|
-
fill: currentColor;
|
|
18
|
-
container-type: size;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
:host::after,
|
|
22
|
-
:host::before {
|
|
23
|
-
line-height: 1;
|
|
24
|
-
font-size: 100cqh;
|
|
25
|
-
-webkit-font-smoothing: antialiased;
|
|
26
|
-
text-rendering: optimizeLegibility;
|
|
27
|
-
-moz-osx-font-smoothing: grayscale;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
:host([hidden]) {
|
|
31
|
-
display: none !important;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
svg {
|
|
35
|
-
display: block;
|
|
36
|
-
width: 100%;
|
|
37
|
-
height: 100%;
|
|
38
|
-
/* prevent overflowing icon from clipping, see https://github.com/vaadin/flow-components/issues/5872 */
|
|
39
|
-
overflow: visible;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
:host(:is([icon-class], [font-icon-content])) svg {
|
|
43
|
-
display: none;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
:host([font-icon-content])::before {
|
|
47
|
-
content: attr(font-icon-content);
|
|
48
|
-
}
|
|
49
|
-
`;
|
|
@@ -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
|
-
);
|