Skip to content

Commit 2603683

Browse files
authored
refactor: simplify selectors in dialog styles (#3735)
1 parent 1f9603f commit 2603683

8 files changed

Lines changed: 27 additions & 42 deletions

File tree

‎packages/confirm-dialog/src/vaadin-confirm-dialog-overlay.js‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@ registerStyles(
2020
height: var(--_vaadin-confirm-dialog-content-height);
2121
}
2222
23-
/* Override display: contents */
24-
:host([has-header]) ::slotted([slot='header']) {
25-
display: block;
26-
}
27-
2823
/* Make buttons clickable */
2924
[part='footer'] > * {
3025
pointer-events: all;

‎packages/confirm-dialog/theme/lumo/vaadin-confirm-dialog-styles.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themab
55
registerStyles(
66
'vaadin-confirm-dialog-overlay',
77
css`
8-
:host([has-header]) [part='header'] ::slotted(h3) {
8+
[part='header'] ::slotted(h3) {
99
margin-top: 0 !important;
1010
margin-bottom: 0 !important;
1111
margin-inline-start: calc(var(--lumo-space-l) - var(--lumo-space-m));
@@ -27,7 +27,7 @@ registerStyles(
2727
}
2828
2929
@media (max-width: 360px) {
30-
:host([has-footer]) [part='footer'] {
30+
[part='footer'] {
3131
flex-direction: column-reverse;
3232
align-items: stretch;
3333
padding: var(--lumo-space-s) var(--lumo-space-l);

‎packages/crud/src/vaadin-crud-dialog.js‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,11 @@ registerStyles(
1515
min-width: 20em;
1616
}
1717
18-
footer[part='footer'] {
18+
[part='footer'] {
1919
justify-content: flex-start;
2020
flex-direction: row-reverse;
2121
}
2222
23-
/* Override display: contents */
24-
:host([has-header]) ::slotted([slot='header']) {
25-
display: block;
26-
}
27-
2823
/* Make buttons clickable */
2924
[part='footer'] ::slotted(:not([disabled])) {
3025
pointer-events: all;

‎packages/crud/theme/lumo/vaadin-crud-styles.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ registerStyles(
131131
[
132132
editorStyles,
133133
css`
134-
:host([has-header]) [part='header'] ::slotted(h3) {
134+
[part='header'] ::slotted(h3) {
135135
margin-top: 0 !important;
136136
margin-bottom: 0 !important;
137137
margin-inline-start: var(--lumo-space-s);

‎packages/crud/theme/material/vaadin-crud-styles.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ registerStyles(
129129
animation: 0.25s material-overlay-dummy-animation;
130130
}
131131
132-
:host([has-header]) [part='header'] ::slotted(h3) {
132+
[part='header'] ::slotted(h3) {
133133
margin-top: 0 !important;
134134
margin-bottom: 0 !important;
135135
}

‎packages/dialog/src/vaadin-dialog.js‎

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@ import { DialogResizableMixin } from './vaadin-dialog-resizable-mixin.js';
1515
registerStyles(
1616
'vaadin-dialog-overlay',
1717
css`
18-
/* prefixing with the element tags to avoid styling confirm-dialog header part */
19-
header[part='header'],
18+
[part='header'],
2019
[part='header-content'],
21-
footer[part='footer'] {
20+
[part='footer'] {
2221
display: flex;
2322
align-items: center;
2423
flex-wrap: wrap;
@@ -27,10 +26,9 @@ registerStyles(
2726
z-index: 1;
2827
}
2928
30-
:host(:is([has-title], [has-header])) ::slotted([slot='header']),
3129
::slotted([slot='header-content']),
3230
::slotted([slot='title']),
33-
:host([has-footer]) ::slotted([slot='footer']) {
31+
::slotted([slot='footer']) {
3432
display: contents;
3533
pointer-events: auto;
3634
}
@@ -39,19 +37,16 @@ registerStyles(
3937
flex: 1;
4038
}
4139
42-
/* prefixing with the element tag to avoid styling confirm-dialog footer part */
4340
:host([has-title]) [part='header-content'],
44-
footer[part='footer'] {
41+
[part='footer'] {
4542
justify-content: flex-end;
4643
}
4744
48-
:host(:not([has-title]):not([has-header])) header[part='header'],
49-
:host(:not([has-title])) [part='title'] {
50-
display: none;
51-
}
52-
53-
:host(:not([has-footer])) footer[part='footer'] {
54-
display: none;
45+
:host(:not([has-title]):not([has-header])) [part='header'],
46+
:host(:not([has-header])) [part='header-content'],
47+
:host(:not([has-title])) [part='title'],
48+
:host(:not([has-footer])) [part='footer'] {
49+
display: none !important;
5550
}
5651
5752
:host(:is([has-title], [has-header], [has-footer])) [part='content'] {

‎packages/dialog/theme/lumo/vaadin-dialog-styles.js‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,20 @@ const dialogOverlay = css`
3131
padding-top: 0;
3232
}
3333
34-
:host(:is([has-header], [has-title])) [part='header'],
35-
:host([has-header]) [part='header-content'],
36-
:host([has-footer]) [part='footer'] {
34+
[part='header'],
35+
[part='header-content'],
36+
[part='footer'] {
3737
gap: var(--lumo-space-xs) var(--lumo-space-s);
3838
line-height: var(--lumo-line-height-s);
3939
}
4040
41-
:host(:is([has-header], [has-title])) [part='header'] {
41+
[part='header'] {
4242
padding: var(--lumo-space-m);
4343
background-color: var(--lumo-base-color);
4444
border-radius: var(--lumo-border-radius-l) var(--lumo-border-radius-l) 0 0; /* Needed for Safari */
4545
}
4646
47-
:host([has-footer]) [part='footer'] {
47+
[part='footer'] {
4848
padding: var(--lumo-space-s) var(--lumo-space-m);
4949
background-color: var(--lumo-contrast-5pct);
5050
border-radius: 0 0 var(--lumo-border-radius-l) var(--lumo-border-radius-l); /* Needed for Safari */
@@ -63,7 +63,7 @@ const dialogOverlay = css`
6363
}
6464
6565
@media (min-height: 320px) {
66-
:host(:is([has-header], [has-title])[overflow~='top']) [part='header'] {
66+
:host([overflow~='top']) [part='header'] {
6767
box-shadow: 0 1px 0 0 var(--lumo-contrast-10pct);
6868
}
6969
}

‎packages/dialog/theme/material/vaadin-dialog-styles.js‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ const dialogOverlay = css`
1616
padding: 24px;
1717
}
1818
19-
:host(:is([has-header], [has-title])) [part='header'] {
19+
[part='header'] {
2020
padding: 16px;
2121
}
2222
2323
:host(:is([has-header], [has-title])) [part='header'] + [part='content'] {
2424
padding-top: 0;
2525
}
2626
27-
:host(:is([has-header], [has-title])) [part='header'],
28-
:host([has-header]) [part='header-content'],
29-
:host([has-footer]) [part='footer'] {
27+
[part='header'],
28+
[part='header-content'],
29+
[part='footer'] {
3030
gap: 8px;
3131
line-height: 1.2;
3232
}
@@ -37,16 +37,16 @@ const dialogOverlay = css`
3737
margin-inline-start: 8px;
3838
}
3939
40-
:host([has-footer]) [part='footer'] {
40+
[part='footer'] {
4141
padding: 8px;
4242
}
4343
4444
@media (min-height: 320px) {
45-
:host(:is([has-header], [has-title])[overflow~='top']) [part='header'] {
45+
:host([overflow~='top']) [part='header'] {
4646
box-shadow: 0 1px 0 0 var(--material-divider-color);
4747
}
4848
49-
:host([has-footer][overflow~='bottom']) [part='footer'] {
49+
:host([overflow~='bottom']) [part='footer'] {
5050
box-shadow: 0 -1px 0 0 var(--material-divider-color);
5151
}
5252
}

0 commit comments

Comments
 (0)