Skip to content

Commit 65fd684

Browse files
sissbrueckerjouni
andauthored
fix: reset font styles in overlays (#10110)
* improve CSS reset for Lumo * add CSS reset for base styles * fix CSS lint issue * remove some properties from base styles * use initial for all properties * Apply suggestions from code review Co-authored-by: Jouni Koivuviita <[email protected]> --------- Co-authored-by: Jouni Koivuviita <[email protected]>
1 parent c09939f commit 65fd684

File tree

6 files changed

+68
-0
lines changed

6 files changed

+68
-0
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,17 @@ export const overlayStyles = css`
6565
overscroll-behavior: contain;
6666
pointer-events: auto;
6767
-webkit-tap-highlight-color: initial;
68+
69+
/* CSS reset for font styles */
70+
color: initial;
71+
font: initial;
72+
letter-spacing: initial;
73+
text-align: initial;
74+
text-decoration: initial;
75+
text-indent: initial;
76+
text-transform: initial;
77+
white-space: initial;
78+
word-spacing: initial;
6879
}
6980
7081
[part='backdrop'] {

packages/overlay/test/visual/base/overlay.test.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,28 @@ describe('overlay', () => {
2525
element.opened = true;
2626
await visualDiff(div, 'with-backdrop');
2727
});
28+
29+
it('text-style-reset', async () => {
30+
Object.assign(div.style, {
31+
color: 'red',
32+
fontFamily: "'Comic Sans MS', cursive",
33+
fontSize: '20px',
34+
fontStyle: 'italic',
35+
fontWeight: 'bold',
36+
fontVariant: 'small-caps',
37+
lineHeight: '2',
38+
letterSpacing: '2px',
39+
textAlign: 'center',
40+
textDecoration: 'underline',
41+
textTransform: 'uppercase',
42+
textIndent: '20px',
43+
whiteSpace: 'nowrap',
44+
wordSpacing: '20px',
45+
});
46+
// Make overlay smaller to force text wrapping, also tests text-align on wrapped text
47+
element.$.overlay.style.width = '150px';
48+
element.opened = true;
49+
50+
await visualDiff(div, 'text-style-reset');
51+
});
2852
});
7.19 KB
Loading

packages/overlay/test/visual/lumo/overlay.test.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,28 @@ describe('overlay', () => {
2727
element.opened = true;
2828
await visualDiff(div, 'with-backdrop');
2929
});
30+
31+
it('text-style-reset', async () => {
32+
Object.assign(div.style, {
33+
color: 'red',
34+
fontFamily: "'Comic Sans MS', cursive",
35+
fontSize: '20px',
36+
fontStyle: 'italic',
37+
fontWeight: 'bold',
38+
fontVariant: 'small-caps',
39+
lineHeight: '2',
40+
letterSpacing: '2px',
41+
textAlign: 'center',
42+
textDecoration: 'underline',
43+
textIndent: '20px',
44+
textTransform: 'uppercase',
45+
whiteSpace: 'nowrap',
46+
wordSpacing: '20px',
47+
});
48+
// Make overlay smaller to force text wrapping, also tests text-align on wrapped text
49+
element.$.overlay.style.width = '150px';
50+
element.opened = true;
51+
52+
await visualDiff(div, 'text-style-reset');
53+
});
3054
});
9.58 KB
Loading

packages/vaadin-lumo-styles/src/mixins/overlay.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,22 @@
6565
box-shadow:
6666
0 0 0 1px var(--lumo-shade-5pct),
6767
var(--lumo-box-shadow-m);
68+
69+
/* CSS reset for font styles */
6870
color: var(--lumo-body-text-color);
6971
font-family: var(--lumo-font-family);
7072
font-size: var(--lumo-font-size-m);
73+
font-style: normal;
7174
font-weight: 400;
75+
font-variant: normal;
7276
line-height: var(--lumo-line-height-m);
7377
letter-spacing: 0;
78+
text-align: initial;
79+
text-decoration: none;
80+
text-indent: initial;
7481
text-transform: none;
82+
white-space: initial;
83+
word-spacing: initial;
7584
-webkit-text-size-adjust: 100%;
7685
-webkit-font-smoothing: antialiased;
7786
-moz-osx-font-smoothing: grayscale;

0 commit comments

Comments
 (0)