Skip to content

Commit e024063

Browse files
authored
fix: add explicit element to enforce icon baseline alignment (#9661)
1 parent 180b4d2 commit e024063

File tree

5 files changed

+17
-39
lines changed

5 files changed

+17
-39
lines changed

packages/icon/src/styles/vaadin-icon-base-styles.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ export const iconStyles = css`
1717
flex: none;
1818
fill: var(--vaadin-icon-color, currentColor);
1919
container-type: size;
20-
contain: layout;
2120
}
2221
2322
:host::after,
@@ -48,4 +47,14 @@ export const iconStyles = css`
4847
:host([font-icon-content])::before {
4948
content: attr(font-icon-content);
5049
}
50+
51+
.baseline {
52+
order: -1;
53+
}
54+
55+
.baseline::before {
56+
content: '\\2003' / '';
57+
display: inline-block;
58+
width: 0;
59+
}
5160
`;

packages/icon/src/vaadin-icon.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,16 @@ class Icon extends IconMixin(ElementMixin(LumoInjectionMixin(ThemableMixin(Polyl
6969
return iconStyles;
7070
}
7171

72+
static get lumoInjector() {
73+
return {
74+
includeBaseStyles: true,
75+
};
76+
}
77+
7278
/** @protected */
7379
render() {
7480
return html`
81+
<span class="baseline"></span>
7582
<svg
7683
version="1.1"
7784
xmlns="http://www.w3.org/2000/svg"

packages/vaadin-lumo-styles/src/components/button.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,6 @@ Note, to make it work, the form fields should have the same "::before" pseudo-el
266266
/* Icons */
267267

268268
[part] ::slotted(vaadin-icon) {
269-
display: inline-block;
270269
width: var(--lumo-icon-size-m);
271270
height: var(--lumo-icon-size-m);
272271
}

packages/vaadin-lumo-styles/src/components/icon.css

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,43 +5,7 @@
55
*/
66
@media lumo_components_icon {
77
:host {
8-
display: inline-flex;
9-
justify-content: center;
10-
align-items: center;
11-
box-sizing: border-box;
12-
vertical-align: middle;
138
width: var(--lumo-icon-size-m);
149
height: var(--lumo-icon-size-m);
15-
fill: currentColor;
16-
container-type: size;
17-
}
18-
19-
:host::after,
20-
:host::before {
21-
line-height: 1;
22-
font-size: 100cqh;
23-
-webkit-font-smoothing: antialiased;
24-
text-rendering: optimizeLegibility;
25-
-moz-osx-font-smoothing: grayscale;
26-
}
27-
28-
:host([hidden]) {
29-
display: none !important;
30-
}
31-
32-
svg {
33-
display: block;
34-
width: 100%;
35-
height: 100%;
36-
/* prevent overflowing icon from clipping, see https://github.com/vaadin/flow-components/issues/5872 */
37-
overflow: visible;
38-
}
39-
40-
:host(:is([icon-class], [font-icon-content])) svg {
41-
display: none;
42-
}
43-
44-
:host([font-icon-content])::before {
45-
content: attr(font-icon-content);
4610
}
4711
}

packages/vaadin-lumo-styles/src/components/menu-bar-item.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
}
1313

1414
[part='content'] ::slotted(vaadin-icon) {
15-
display: inline-block;
1615
width: var(--lumo-icon-size-m);
1716
height: var(--lumo-icon-size-m);
1817
}

0 commit comments

Comments
 (0)