Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

Commit 4da83dd

Browse files
acdvorakkfranqueiro
authored andcommitted
fix(dialog): Add redlines to dialog screenshots; update to match spec (#3602)
1 parent 443087f commit 4da83dd

File tree

10 files changed

+474
-312
lines changed

10 files changed

+474
-312
lines changed

packages/mdc-dialog/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ The Simple Dialog contains a list of potential actions. It does not contain butt
115115
-->Choose a Ringtone<!--
116116
--></h2>
117117
<section class="mdc-dialog__content" id="my-dialog-content">
118-
<ul class="mdc-list">
118+
<ul class="mdc-list mdc-list--avatar-list">
119119
<li class="mdc-list-item" data-mdc-dialog-action="none">
120120
<span class="mdc-list-item__text">None</span>
121121
</li>
@@ -130,6 +130,8 @@ The Simple Dialog contains a list of potential actions. It does not contain butt
130130
</div>
131131
```
132132

133+
> Note the inclusion of the `mdc-list--avatar-list` class, which aligns with the Simple Dialog spec.
134+
133135
### Confirmation Dialog
134136

135137
The Confirmation Dialog contains a list of choices, and buttons to confirm or cancel. Choices are accompanied by

packages/mdc-dialog/_variables.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ $mdc-dialog-scroll-divider-opacity: .12;
3333
$mdc-dialog-min-width: 280px;
3434
$mdc-dialog-max-width: 560px;
3535
$mdc-dialog-margin: 16px;
36+
$mdc-dialog-title-bottom-padding: 9px;
3637

3738
$mdc-dialog-corner-radius: 4px;
3839

packages/mdc-dialog/mdc-dialog.scss

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,16 +98,22 @@
9898
position: relative;
9999
flex-shrink: 0;
100100
box-sizing: border-box;
101-
min-height: 64px;
102101
margin: 0;
103-
padding: 0 24px 15px;
102+
padding: 0 24px $mdc-dialog-title-bottom-padding;
104103
border-bottom: 1px solid transparent;
105104

106105
@include mdc-rtl(".mdc-dialog") {
107106
text-align: right;
108107
}
109108
}
110109

110+
// stylelint-disable-next-line plugin/selector-bem-pattern
111+
.mdc-dialog--scrollable .mdc-dialog__title {
112+
// Adjust bottom padding to make title height align to spec when divider is present.
113+
// (Titles for alert dialogs w/o dividers align based on text baseline instead. All spec values are divisible by 4.)
114+
padding-bottom: $mdc-dialog-title-bottom-padding + 6px;
115+
}
116+
111117
.mdc-dialog__content {
112118
@include mdc-typography(body1);
113119

@@ -146,6 +152,12 @@
146152

147153
// stylelint-disable-next-line plugin/selector-bem-pattern
148154
.mdc-dialog__content .mdc-list:first-child:last-child {
155+
// Override default .mdc-list padding for content consisting exclusively of a MDC List
156+
padding: 6px 0 0; // Top padding balances with title height
157+
}
158+
159+
// stylelint-disable-next-line plugin/selector-bem-pattern
160+
.mdc-dialog--scrollable .mdc-dialog__content .mdc-list:first-child:last-child {
149161
// Override default .mdc-list padding for content consisting exclusively of a MDC List
150162
padding: 0;
151163
}

packages/mdc-list/_mixins.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,5 @@
8888

8989
width: $size;
9090
height: $size;
91+
font-size: $size; // To support icon font
9192
}

test/screenshot/diffing.json

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -64,19 +64,6 @@
6464
"min_changed_pixel_count": 25,
6565
"fonts_loaded_reflow_delay_ms": 250
6666
}
67-
},
68-
{
69-
"description": "IE consistently flakes sometimes on some dialog pages.",
70-
"browser_regex_patterns": [
71-
"desktop_windows_ie@11"
72-
],
73-
"url_regex_patterns": [
74-
"mdc-dialog/classes/overflow",
75-
"mdc-dialog/mixins"
76-
],
77-
"custom_config": {
78-
"skip_all": true
79-
}
8067
}
8168
]
8269
}

test/screenshot/golden.json

Lines changed: 90 additions & 78 deletions
Large diffs are not rendered by default.

test/screenshot/spec/fixture.js

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,15 @@ window.mdc = window.mdc || {};
3333
* fromSide: string,
3434
* toEl: ?Element,
3535
* toSide: string,
36+
* orientation: ?string,
3637
* specDistancePx: number,
3738
* displayOffsetPx: number,
3839
* displayAlignment: string,
3940
* displayTargetEl: ?Element,
4041
* lineEl: ?Element,
4142
* labelEl: ?Element,
43+
* flipLabel: ?boolean,
44+
* conditionFn: ?function(): boolean,
4245
* }} RedlineConfig
4346
*/
4447

@@ -146,12 +149,14 @@ class TestFixture {
146149

147150
this.redlineContainerEl_.appendChild(lineEl);
148151

149-
this.redlineConfigs_.push(Object.assign({
152+
/** @type {!RedlineConfig} */
153+
const mergedConfig = Object.assign({
150154
lineEl,
151155
labelEl,
152156
displayOffsetPx: 0,
153157
displayAlignment: 'center',
154-
}, config));
158+
flipLabel: false,
159+
}, config);
155160

156161
mergedConfig.orientation = this.getOrientation_(mergedConfig);
157162

@@ -175,21 +180,25 @@ class TestFixture {
175180
}
176181

177182
this.redlineConfigs_.forEach((config) => {
178-
const {lineEl, fromSide} = config;
179-
lineEl.classList.remove(
180-
'test-redline--vertical',
181-
'test-redline--horizontal',
182-
'test-redline--pass',
183-
'test-redline--warn',
184-
'test-redline--small',
185-
);
186-
if (fromSide === 'top' || fromSide === 'bottom' ||
187-
fromSide === 'first-baseline' || fromSide === 'last-baseline') {
183+
const {lineEl, orientation, flipLabel, conditionFn} = config;
184+
185+
// Remove all modifier classes
186+
lineEl.className = 'test-redline';
187+
188+
if (conditionFn && !conditionFn()) {
189+
lineEl.classList.add('test-redline--hidden');
190+
}
191+
192+
if (flipLabel) {
193+
lineEl.classList.add('test-redline--flipped');
194+
}
195+
196+
if (orientation === 'vertical') {
188197
this.drawVerticalRedline_(config);
189-
} else if (fromSide === 'left' || fromSide === 'right') {
198+
} else if (orientation === 'horizontal') {
190199
this.drawHorizontalRedline_(config);
191200
} else {
192-
throw new Error(`Unsupported \`fromSide\` value: "${fromSide}"`);
201+
throw new Error(`Unsupported 'orientation' value: "${orientation}"`);
193202
}
194203
});
195204
});
@@ -200,7 +209,9 @@ class TestFixture {
200209
* @private
201210
*/
202211
drawVerticalRedline_(config) {
203-
const {lineEl, labelEl, fromEl, fromSide, toEl, toSide, specDistancePx, displayOffsetPx, displayAlignment} = config;
212+
const {lineEl, labelEl, fromEl, toEl, fromSide, toSide} = config;
213+
const {specDistancePx, displayOffsetPx, displayAlignment} = config;
214+
204215
lineEl.classList.add('test-redline--vertical');
205216

206217
const fromRect = fromEl.getBoundingClientRect();
@@ -235,7 +246,7 @@ class TestFixture {
235246
labelEl.innerHTML = `${actualDistancePx}px`;
236247
lineEl.classList.add('test-redline--pass');
237248
} else if (Math.abs(actualDistancePx - specDistancePx) <= 1) {
238-
labelEl.innerHTML = `Spec: ${specDistancePx}px<br>Actual: ${actualDistancePx}px`;
249+
labelEl.innerHTML = `${actualDistancePx}px`;
239250
lineEl.classList.add('test-redline--warn');
240251
} else {
241252
labelEl.innerHTML = `Spec: ${specDistancePx}px<br>Actual: ${actualDistancePx}px`;
@@ -296,7 +307,7 @@ class TestFixture {
296307
labelEl.innerHTML = `${actualDistancePx}px`;
297308
lineEl.classList.add('test-redline--pass');
298309
} else if (Math.abs(actualDistancePx - specDistancePx) <= 1) {
299-
labelEl.innerHTML = `Spec: ${specDistancePx}px<br>Actual: ${actualDistancePx}px`;
310+
labelEl.innerHTML = `${actualDistancePx}px`;
300311
lineEl.classList.add('test-redline--warn');
301312
} else {
302313
labelEl.innerHTML = `Spec: ${specDistancePx}px<br>Actual: ${actualDistancePx}px`;
@@ -320,6 +331,7 @@ class TestFixture {
320331
const borderTopWidth = parseInt(getComputedStyle(el).borderTopWidth, 10);
321332
const borderLeftWidth = parseInt(getComputedStyle(el).borderLeftWidth, 10);
322333
const borderRightWidth = parseInt(getComputedStyle(el).borderRightWidth, 10);
334+
const scrollbarWidth = this.getScrollbarWidth_(el);
323335

324336
if (side === 'top') {
325337
return rect.top + borderTopWidth;
@@ -331,7 +343,7 @@ class TestFixture {
331343
return rect.left + borderLeftWidth;
332344
}
333345
if (side === 'right') {
334-
return rect.right - borderRightWidth;
346+
return rect.right - borderRightWidth + scrollbarWidth;
335347
}
336348

337349
if (side === 'first-baseline' || side === 'last-baseline') {

test/screenshot/spec/fixture.scss

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,11 @@ $test-layout-cell-grid-color: #ddd;
175175
}
176176

177177
.test-redline--warn {
178-
color: deeppink;
178+
color: darkorange;
179+
}
180+
181+
.test-redline--hidden {
182+
display: none;
179183
}
180184

181185
.test-redline__tick {
@@ -237,14 +241,34 @@ $test-layout-cell-grid-color: #ddd;
237241
transform: translateX(-50%);
238242
}
239243

240-
.test-redline--small.test-redline--vertical .test-redline__label {
244+
.test-redline--vertical.test-redline--flipped .test-redline__label {
245+
right: auto;
246+
left: 2px;
247+
}
248+
249+
.test-redline--horizontal.test-redline--flipped .test-redline__label {
250+
bottom: auto;
251+
left: 50%;
252+
}
253+
254+
.test-redline--vertical.test-redline--small .test-redline__label {
241255
right: 13px;
242256
}
243257

244-
.test-redline--small.test-redline--horizontal .test-redline__label {
258+
.test-redline--horizontal.test-redline--small .test-redline__label {
245259
bottom: 13px;
246260
}
247261

262+
.test-redline--vertical.test-redline--small.test-redline--flipped .test-redline__label {
263+
right: auto;
264+
left: 13px;
265+
}
266+
267+
.test-redline--horizontal.test-redline--small.test-redline--flipped .test-redline__label {
268+
top: 13px;
269+
bottom: auto;
270+
}
271+
248272
.test-baseline-probe {
249273
display: inline-block;
250274
width: 0;

test/screenshot/spec/mdc-dialog/classes/baseline-simple.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939

4040
<button class="test-dialog-open-button" data-test-dialog-id="test-dialog" autofocus>Open Dialog</button>
4141

42-
<div class="mdc-dialog mdc-dialog--open test-dialog"
42+
<div class="mdc-dialog mdc-dialog--open test-dialog test-dialog--simple"
4343
role="alertdialog"
4444
aria-modal="true"
4545
aria-labelledby="test-dialog__title--simple"
@@ -56,7 +56,7 @@ <h2 class="mdc-dialog__title test-dialog__title" id="test-dialog__title--simple"
5656
Inline `style="list-style-type: none"` needed to prevent rendering bug in Edge and IE 11.
5757
See https://stackoverflow.com/a/23717689/467582
5858
-->
59-
<ul class="mdc-list" aria-orientation="vertical" style="list-style-type: none;">
59+
<ul class="mdc-list mdc-list--avatar-list" aria-orientation="vertical" style="list-style-type: none;">
6060
<li class="mdc-list-item" tabindex="0" data-mdc-dialog-action="wifi">
6161
<i class="material-icons mdc-list-item__graphic">network_wifi</i>
6262
<span class="test-list-item__label">Wi-Fi</span>

0 commit comments

Comments
 (0)