Skip to content

Commit 75d069a

Browse files
refactor(dialog): grid,spacing,font updates and fixes
1 parent 955d0f2 commit 75d069a

File tree

1 file changed

+63
-75
lines changed

1 file changed

+63
-75
lines changed

components/dialog/index.css

Lines changed: 63 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ governing permissions and limitations under the License.
2424
--spectrum-standard-dialog-description-font-size: var(--spectrum-standard-dialog-body-font-size);
2525
--spectrum-standard-dialog-description-font-style: var(--spectrum-body-sans-serif-font-style);
2626
--spectrum-standard-dialog-description-font-family: var(--spectrum-body-sans-serif-font-family);
27+
--spectrum-standard-dialog-header-content-font-size: var(--spectrum-standard-dialog-body-font-size);
2728

2829
--spectrum-standard-dialog-heading-line-height: var(--spectrum-title-line-height);
2930
--spectrum-standard-dialog-description-line-height: var(--spectrum-line-height-200);
@@ -71,12 +72,12 @@ governing permissions and limitations under the License.
7172
}
7273
}
7374

74-
.spectrum-Dialog--small {
75+
.spectrum-Dialog--sizeS {
7576
--spectrum-standard-dialog-max-width: var(--spectrum-standard-dialog-maximum-width-small);
7677
inline-size: var(--mod-standard-dialog-max-width-small, var(--spectrum-standard-dialog-max-width));
7778
}
7879

79-
.spectrum-Dialog--large {
80+
.spectrum-Dialog--sizeL {
8081
--spectrum-standard-dialog-max-width: var(--spectrum-standard-dialog-maximum-width-large);
8182
inline-size: var(--mod-standard-dialog-max-width-large, var(--spectrum-standard-dialog-max-width));
8283
}
@@ -98,6 +99,7 @@ governing permissions and limitations under the License.
9899
auto
99100
1fr
100101
auto
102+
var(--mod-standard-dialog-spacing-grid-padding, var(--spectrum-standard-dialog-spacing-grid-padding))
101103
minmax(0, auto)
102104
var(--mod-standard-dialog-spacing-grid-padding, var(--spectrum-standard-dialog-spacing-grid-padding));
103105
grid-template-rows:
@@ -108,22 +110,20 @@ governing permissions and limitations under the License.
108110
auto
109111
var(--mod-standard-dialog-spacing-grid-padding, var(--spectrum-standard-dialog-spacing-grid-padding));
110112
grid-template-areas:
111-
"hero hero hero hero hero hero"
112-
". . . . . ."
113-
". heading header header header ."
114-
". content content content content ."
115-
". footer footer buttonGroup buttonGroup ."
116-
". . . . . .";
113+
"hero hero hero hero hero hero hero"
114+
". . . . . . ."
115+
". heading header header header header ."
116+
". content content content content content ."
117+
". footer footer footer buttonGroup buttonGroup ."
118+
". . . . . . .";
117119
inline-size: 100%;
118120
}
119121

120122
/* the dialog's heading/title */
121123
.spectrum-Dialog-heading {
122124
grid-area: heading;
123125

124-
margin-block-start: 0;
125-
126-
margin-inline-end: var(--mod-standard-dialog-spacing-title-to-header-content, var(--spectrum-standard-dialog-spacing-title-to-header-content));
126+
margin-block: 0;
127127
font-size: var(--mod-standard-dialog-heading-font-size, var(--spectrum-standard-dialog-heading-font-size));
128128
font-weight: var(--mod-standard-dialog-heading-font-weight, var(--spectrum-standard-dialog-heading-font-weight));
129129
font-style: var(--spectrum-standard-dialog-heading-font-style);
@@ -132,18 +132,17 @@ governing permissions and limitations under the License.
132132
color: var(--mod-standard-dialog-heading-text-color, var(--spectrum-standard-dialog-heading-text-color));
133133
outline: none; /* Hide focus outline */
134134

135-
/* prevent the heading from moving out of the header element if additional content is long */
136-
min-inline-size: 50%;
135+
/* prevent the heading/title from moving out of the header element if additional content is long */
136+
min-inline-size: 40%;
137137

138-
&.spectrum-Dialog-heading--noHeader {
139-
grid-area: heading-start / heading-start / header-end / header-end;
140-
padding-inline-end: 0;
138+
&:has(~ .spectrum-Dialog-heading--noHeader) {
139+
margin-inline-end: 0;
141140
}
141+
}
142142

143-
/* Remove the default margin on the Typography elements in the heading */
144-
.spectrum-Heading {
145-
margin-block: 0;
146-
}
143+
.spectrum-Dialog-heading--noHeader {
144+
grid-area: header;
145+
padding-inline-end: 0;
147146
}
148147

149148
/* the container for the heading and any additional header content */
@@ -152,6 +151,7 @@ governing permissions and limitations under the License.
152151
display: flex;
153152
max-inline-size: 100%;
154153
margin-block-end: var(--spectrum-standard-dialog-spacing-title-to-description);
154+
gap: var(--mod-standard-dialog-spacing-title-to-header-content, var(--spectrum-standard-dialog-spacing-title-to-header-content));
155155

156156
/* Without this, buttons will be stretched */
157157
align-items: flex-start;
@@ -161,24 +161,18 @@ governing permissions and limitations under the License.
161161

162162
outline: none; /* Hide focus outline around header */
163163

164-
> .spectrum-Body {
165-
/* additional header content should grow/shrink with the text, but only until it takes up half of the footer */
166-
inline-size: fit-content;
167-
max-inline-size: 50%;
168-
169-
/* Remove the default margin on the Typography in the header */
170-
margin-block: 0;
164+
/* additional header content should grow/shrink with the text, but only until it takes up half of the header */
165+
> .spectrum-Dialog-header-content {
166+
max-inline-size: fit-content;
167+
flex: 1 1 100%;
168+
font-size: var(--spectrum-standard-dialog-header-content-font-size);
169+
text-wrap: pretty;
171170
}
172171
}
173172

174173
.spectrum-Dialog-content {
175174
grid-area: content;
176175
box-sizing: border-box;
177-
178-
/*
179-
v2 is currently worse, inputs that get focus rings get a slight clipping unless overflow: visible replaces this line
180-
we should think of a better way to handle this, see padding/margin below for fix
181-
*/
182176
overflow-y: auto;
183177
-webkit-overflow-scrolling: touch;
184178

@@ -189,39 +183,31 @@ governing permissions and limitations under the License.
189183
font-style: var(--spectrum-standard-dialog-description-font-style);
190184
line-height: var(--mod-standard-dialog-description-line-height, var(--spectrum-standard-dialog-description-line-height));
191185
color: var(--mod-standard-dialog-description-text-color, var(--spectrum-standard-dialog-description-text-color));
192-
193-
/* Remove the default margin on the Typography elements in the dialog's body content */
194-
.spectrum-Body {
195-
margin-block: 0;
196-
}
197186
}
198187

199188
.spectrum-Dialog-footer {
200-
grid-area: footer;
189+
grid-area: footer / footer / buttonGroup / buttonGroup;
201190
max-inline-size: 100%;
191+
display: flex;
192+
align-items: flex-end;
193+
194+
/* this recreates padding between the footer content and button group. It should be safe as button group is always end aligned */
195+
gap: var(--mod-standard-dialog-spacing-footer-to-button-group, var(--spectrum-standard-dialog-spacing-footer-to-button-group));
202196

203197
/* this padding isn't built into the grid because it disappears with this footer */
204198
padding-block-start: var(--mod-standard-dialog-spacing-description-to-footer, var(--spectrum-standard-dialog-spacing-description-to-footer));
205199

206-
display: flex;
207-
justify-content: space-between;
208-
align-items: flex-end;
209-
210200
outline: none; /* Hide focus outline */
211201

212-
/* Both selectors are required to override the button + button rule */
213-
> *,
214-
> .spectrum-Button + .spectrum-Button {
215-
margin-block-end: 0;
202+
.spectrum-Dialog-footer-content {
203+
/* this attempts to give as much space as possible for the button group, particularly to avoid stacking on mobile. Some sizes still may have to stack. */
204+
max-inline-size: calc(50% - var(--mod-standard-dialog-spacing-footer-to-button-group, var(--spectrum-standard-dialog-spacing-footer-to-button-group)));
205+
flex: 1 1 100%;
216206
}
217207

218-
.spectrum-Body {
219-
/* To keep the footer text from wrapping prematurely */
220-
inline-size: fit-content;
221-
max-inline-size: 50%;
222-
223-
/* Remove the default margin on the Typography in the footer content */
224-
margin-block-end: 0;
208+
&:has(.spectrum-Dialog-footer-content),
209+
&:has(.spectrum-Dialog-buttonGroup) {
210+
justify-content: space-between;
225211
}
226212
}
227213

@@ -232,17 +218,14 @@ governing permissions and limitations under the License.
232218
/* to override ButtonGroup's justify-content: normal and/or not having footer content */
233219
justify-content: flex-end;
234220
}
235-
236-
/* this padding should be safe as button group is always end aligned */
237-
padding-inline-start: var(--mod-standard-dialog-spacing-footer-to-button-group, var(--spectrum-standard-dialog-spacing-footer-to-button-group));
238221
}
239222

240223
.spectrum-Dialog-buttonGroup--noFooter {
241224
padding-block-start: var(--mod-standard-dialog-spacing-description-to-footer, var(--spectrum-standard-dialog-spacing-description-to-footer));
242225
}
243226

244227
/* Dismissible Dialog (with close button) */
245-
.spectrum-Dialog--dismissable .spectrum-Dialog-grid {
228+
.spectrum-Dialog--dismissible .spectrum-Dialog-grid {
246229
grid-template-columns:
247230
var(--mod-standard-dialog-spacing-grid-padding, var(--spectrum-standard-dialog-spacing-grid-padding))
248231
auto
@@ -258,19 +241,20 @@ governing permissions and limitations under the License.
258241
auto
259242
var(--mod-standard-dialog-spacing-grid-padding, var(--spectrum-standard-dialog-spacing-grid-padding));
260243
grid-template-areas:
261-
"hero hero hero hero hero hero"
262-
". . . . closeButton closeButton"
263-
". heading header header closeButton closeButton"
264-
". content content content content ."
265-
". footer footer footer footer ."
266-
". . . . . .";
244+
"hero hero hero hero hero hero"
245+
". . . . closeButton closeButton"
246+
". heading header header closeButton closeButton"
247+
". content content content content ."
248+
". footer footer footer footer ."
249+
". . . . . .";
267250

268251
.spectrum-Dialog-footer {
269252
grid-area: footer;
253+
}
270254

271-
> .spectrum-Body {
272-
max-inline-size: 100%;
273-
}
255+
/* remove the margin on the title/heading if there's not extra header content */
256+
.spectrum-Dialog-heading:has(+ .spectrum-Dialog-heading--noHeader) {
257+
margin-inline-end: 0;
274258
}
275259
}
276260

@@ -293,7 +277,6 @@ governing permissions and limitations under the License.
293277
.spectrum-Dialog--fullscreenTakeover {
294278
inline-size: 100%;
295279
block-size: 100%;
296-
297280
border-radius: 0;
298281
}
299282

@@ -302,7 +285,7 @@ governing permissions and limitations under the License.
302285
max-block-size: none;
303286
max-inline-size: none;
304287

305-
&.spectrum-Dialog .spectrum-Dialog-grid {
288+
.spectrum-Dialog-grid {
306289
display: grid;
307290
grid-template-columns:
308291
var(--mod-standard-dialog-spacing-grid-padding, var(--spectrum-standard-dialog-spacing-grid-padding))
@@ -326,7 +309,6 @@ governing permissions and limitations under the License.
326309
grid-area: heading;
327310
}
328311

329-
/* @todo: can fullscreen/fullscreenTakeover dialogs be dismissible/have a close button? */
330312
.spectrum-Dialog-closeButton {
331313
display: none;
332314
}
@@ -341,7 +323,6 @@ governing permissions and limitations under the License.
341323

342324
.spectrum-Dialog-buttonGroup {
343325
grid-area: buttonGroup;
344-
align-self: auto;
345326
}
346327
}
347328

@@ -372,7 +353,7 @@ governing permissions and limitations under the License.
372353
". . . . . .";
373354
}
374355

375-
.spectrum-Dialog--dismissable .spectrum-Dialog-grid {
356+
.spectrum-Dialog--dismissible .spectrum-Dialog-grid {
376357
grid-template-columns:
377358
var(--mod-standard-dialog-spacing-grid-padding, var(--spectrum-standard-dialog-spacing-grid-padding))
378359
auto
@@ -404,10 +385,7 @@ governing permissions and limitations under the License.
404385
flex-direction: column;
405386
align-items: flex-start;
406387
justify-content: flex-start;
407-
408-
> .spectrum-Body {
409-
max-inline-size: unset;
410-
}
388+
gap: 0;
411389
}
412390

413391
.spectrum-Dialog--fullscreen,
@@ -423,16 +401,26 @@ governing permissions and limitations under the License.
423401
auto
424402
auto
425403
1fr
404+
var(--mod-standard-dialog-spacing-grid-padding, var(--spectrum-standard-dialog-spacing-grid-padding))
426405
auto
427406
var(--mod-standard-dialog-spacing-grid-padding, var(--spectrum-standard-dialog-spacing-grid-padding));
428407
grid-template-areas:
429408
". . ."
430409
". heading ."
431410
". header ."
432411
". content ."
412+
". . ."
433413
". buttonGroup ."
434414
". . .";
435415
}
416+
417+
.spectrum-Dialog-header {
418+
margin-inline-end: 0;
419+
}
420+
421+
.spectrum-Dialog-heading {
422+
margin-inline-end: 0;
423+
}
436424
}
437425

438426
.spectrum-Dialog-heading {

0 commit comments

Comments
 (0)