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

Commit 847dd1a

Browse files
authored
feat(textfield): add end-alignment (#5356)
* feat(textfield): add end-alignment * chore(textfield): update end-aligned screenshots * chore: fix FOUC in screenshot test * chore(textfield): remove endAligned component property * chore(textfield): add textarea end alignment test * chore(textfield): fix label linting issue * test(menu): increase animation delay for all menu tests * chore(textfield): add @noflip to end-alignment CSS
1 parent c8bb8dd commit 847dd1a

File tree

8 files changed

+230
-6
lines changed

8 files changed

+230
-6
lines changed

packages/mdc-textfield/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ CSS Class | Description
271271
`mdc-text-field--with-trailing-icon` | Styles the text field as a text field with a trailing icon.
272272
`mdc-text-field--focused` | Styles the text field as a text field in focus.
273273
`mdc-text-field--no-label` | Styles the text field that has no label.
274+
`mdc-text-field--end-aligned` | Styles the text field with an end-aligned input.
274275
`mdc-text-field-helper-line` | Styles the container of helper text and character counter elements.
275276

276277
#### Deprecation Notice

packages/mdc-textfield/_mixins.scss

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -829,6 +829,20 @@
829829
}
830830
}
831831

832+
// End aligned
833+
@mixin mdc-text-field-end-aligned_ {
834+
.mdc-text-field__input {
835+
// IE11 does not support text-align: end
836+
/* @noflip */
837+
text-align: right;
838+
839+
@include mdc-rtl {
840+
/* @noflip */
841+
text-align: left;
842+
}
843+
}
844+
}
845+
832846
// Customization
833847

834848
@mixin mdc-text-field-ink-color_($color) {

packages/mdc-textfield/mdc-text-field.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,10 @@
264264
@include mdc-text-field-textarea-disabled_;
265265
}
266266

267+
.mdc-text-field--end-aligned {
268+
@include mdc-text-field-end-aligned_;
269+
}
270+
267271
@include mdc-floating-label-shake-keyframes(
268272
text-field-dense,
269273
$mdc-text-field-dense-label-position-y,

test/screenshot/diffing.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,7 @@
9898
"desktop_windows_firefox@69"
9999
],
100100
"url_regex_patterns": [
101-
"mdc-menu/classes/baseline.html",
102-
"mdc-menu/classes/bottom-anchored.html",
103-
"mdc-menu/classes/menu-selection-group-only.html",
104-
"mdc-menu/classes/menu-selection-group.html",
105-
"mdc-menu/classes/multiple-menu-selection-group.html"
101+
"mdc-menu"
106102
],
107103
"custom_config": {
108104
"fonts_loaded_reflow_delay_ms": 300

test/screenshot/golden.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,6 +1199,14 @@
11991199
"desktop_windows_ie@11": "https://storage.googleapis.com/mdc-web-screenshot-tests/abhiomkar/2019/11/01/18_25_15_143/spec/mdc-textfield/classes/baseline-character-counter.html.windows_ie_11.png"
12001200
}
12011201
},
1202+
"spec/mdc-textfield/classes/baseline-end-aligned.html": {
1203+
"public_url": "https://storage.googleapis.com/mdc-web-screenshot-tests/lizmitchell/2019/12/18/19_42_39_069/spec/mdc-textfield/classes/baseline-end-aligned.html?utm_source=golden_json",
1204+
"screenshots": {
1205+
"desktop_windows_chrome@77": "https://storage.googleapis.com/mdc-web-screenshot-tests/lizmitchell/2019/12/18/19_17_22_556/spec/mdc-textfield/classes/baseline-end-aligned.html.windows_chrome_77.png",
1206+
"desktop_windows_firefox@69": "https://storage.googleapis.com/mdc-web-screenshot-tests/lizmitchell/2019/12/18/19_17_22_556/spec/mdc-textfield/classes/baseline-end-aligned.html.windows_firefox_69.png",
1207+
"desktop_windows_ie@11": "https://storage.googleapis.com/mdc-web-screenshot-tests/lizmitchell/2019/12/18/19_42_39_069/spec/mdc-textfield/classes/baseline-end-aligned.html.windows_ie_11.png"
1208+
}
1209+
},
12021210
"spec/mdc-textfield/classes/baseline-fullwidth.html": {
12031211
"public_url": "https://storage.googleapis.com/mdc-web-screenshot-tests/travis/2019/02/08/19_22_02_713/spec/mdc-textfield/classes/baseline-fullwidth.html?utm_source=golden_json",
12041212
"screenshots": {
@@ -1623,6 +1631,14 @@
16231631
"desktop_windows_ie@11": "https://storage.googleapis.com/mdc-web-screenshot-tests/travis/2019/01/22/20_34_34_568/spec/mdc-textfield/classes/textarea-disabled.html.windows_ie_11.png"
16241632
}
16251633
},
1634+
"spec/mdc-textfield/classes/textarea-end-aligned.html": {
1635+
"public_url": "https://storage.googleapis.com/mdc-web-screenshot-tests/lizmitchell/2019/12/18/22_08_30_352/spec/mdc-textfield/classes/textarea-end-aligned.html?utm_source=golden_json",
1636+
"screenshots": {
1637+
"desktop_windows_chrome@77": "https://storage.googleapis.com/mdc-web-screenshot-tests/lizmitchell/2019/12/18/22_08_30_352/spec/mdc-textfield/classes/textarea-end-aligned.html.windows_chrome_77.png",
1638+
"desktop_windows_firefox@69": "https://storage.googleapis.com/mdc-web-screenshot-tests/lizmitchell/2019/12/18/22_08_30_352/spec/mdc-textfield/classes/textarea-end-aligned.html.windows_firefox_69.png",
1639+
"desktop_windows_ie@11": "https://storage.googleapis.com/mdc-web-screenshot-tests/lizmitchell/2019/12/18/22_08_30_352/spec/mdc-textfield/classes/textarea-end-aligned.html.windows_ie_11.png"
1640+
}
1641+
},
16261642
"spec/mdc-textfield/classes/textarea-focused.html": {
16271643
"public_url": "https://storage.googleapis.com/mdc-web-screenshot-tests/travis/2019/01/22/20_34_34_568/spec/mdc-textfield/classes/textarea-focused.html?utm_source=golden_json",
16281644
"screenshots": {
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<!DOCTYPE html>
2+
<!--
3+
Copyright 2018 Google Inc.
4+
Permission is hereby granted, free of charge, to any person obtaining a copy
5+
of this software and associated documentation files (the "Software"), to deal
6+
in the Software without restriction, including without limitation the rights
7+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
copies of the Software, and to permit persons to whom the Software is
9+
furnished to do so, subject to the following conditions:
10+
The above copyright notice and this permission notice shall be included in
11+
all copies or substantial portions of the Software.
12+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
18+
THE SOFTWARE.
19+
-->
20+
<html lang="en">
21+
<head>
22+
<meta charset="utf-8">
23+
<title>Baseline Text Field Element end-aligned - MDC Web Screenshot Test</title>
24+
<meta name="viewport" content="width=device-width, initial-scale=1">
25+
<link rel="stylesheet" href="../../../out/mdc.textfield.css">
26+
<link rel="stylesheet" href="../../../out/mdc.typography.css">
27+
<link rel="stylesheet" href="../../../out/spec/fixture.css">
28+
<link rel="stylesheet" href="../../../out/spec/mdc-textfield/fixture.css">
29+
</head>
30+
31+
<body class="test-container">
32+
<main class="test-viewport test-viewport--mobile">
33+
<div class="test-layout">
34+
35+
<div class="test-cell test-cell--textfield">
36+
<div class="mdc-text-field mdc-text-field--end-aligned mdc-text-field--no-label">
37+
<!-- htmllint-disable -->
38+
<input type="text" class="mdc-text-field__input test-text-field__input" aria-label="Label" placeholder="Placeholder">
39+
<!-- htmllint-enable -->
40+
<div class="mdc-line-ripple"></div>
41+
</div>
42+
</div>
43+
44+
<div class="test-cell test-cell--textfield">
45+
<div class="mdc-text-field mdc-text-field--end-aligned mdc-text-field--outlined mdc-text-field--no-label">
46+
<!-- htmllint-disable -->
47+
<input type="text" class="mdc-text-field__input test-text-field__input" aria-label="Label" placeholder="Placeholder">
48+
<!-- htmllint-enable -->
49+
<div class="mdc-notched-outline">
50+
<div class="mdc-notched-outline__leading"></div>
51+
<div class="mdc-notched-outline__trailing"></div>
52+
</div>
53+
</div>
54+
</div>
55+
56+
<div class="test-cell test-cell--textfield">
57+
<div class="mdc-text-field mdc-text-field--end-aligned mdc-text-field--label-floating">
58+
<input type="text" id="filled-text-field" class="mdc-text-field__input test-text-field__input" value="Filled value">
59+
<label for="filled-text-field" class="mdc-floating-label mdc-floating-label--float-above">Label</label>
60+
<div class="mdc-line-ripple"></div>
61+
</div>
62+
</div>
63+
64+
<div class="test-cell test-cell--textfield">
65+
<div class="mdc-text-field mdc-text-field--end-aligned mdc-text-field--outlined mdc-text-field--label-floating">
66+
<input type="text" id="outlined-text-field" class="mdc-text-field__input test-text-field__input" value="Filled value">
67+
<div class="mdc-notched-outline mdc-notched-outline--notched">
68+
<div class="mdc-notched-outline__leading"></div>
69+
<div class="mdc-notched-outline__notch">
70+
<label for="outlined-text-field" class="mdc-floating-label mdc-floating-label--float-above">Label</label>
71+
</div>
72+
<div class="mdc-notched-outline__trailing"></div>
73+
</div>
74+
</div>
75+
</div>
76+
77+
</div>
78+
</main>
79+
80+
<!-- Automatically provides/replaces `Promise` if missing or broken. -->
81+
<script src="https://cdn.jsdelivr.net/npm/es6-promise@4/dist/es6-promise.js"></script>
82+
<script src="https://cdn.jsdelivr.net/npm/es6-promise@4/dist/es6-promise.auto.js"></script>
83+
<script src="https://cdnjs.cloudflare.com/ajax/libs/fontfaceobserver/2.0.13/fontfaceobserver.standalone.js"></script>
84+
<script src="../../../out/material-components-web.js"></script>
85+
<script src="../../../out/spec/fixture.js"></script>
86+
<script src="../../../out/spec/mdc-textfield/fixture.js"></script>
87+
</body>
88+
</html>
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
<!DOCTYPE html>
2+
<!--
3+
Copyright 2018 Google Inc.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.
22+
-->
23+
<html lang="en">
24+
<head>
25+
<meta charset="utf-8">
26+
<title>Textarea Text Field end aligned - MDC Web Screenshot Test</title>
27+
<meta name="viewport" content="width=device-width, initial-scale=1">
28+
<link rel="stylesheet" href="../../../out/mdc.textfield.css">
29+
<link rel="stylesheet" href="../../../out/mdc.typography.css">
30+
<link rel="stylesheet" href="../../../out/spec/fixture.css">
31+
<link rel="stylesheet" href="../../../out/spec/mdc-textfield/fixture.css">
32+
33+
<!-- Global site tag (gtag.js) - Google Analytics -->
34+
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-118996389-2"></script>
35+
<script>
36+
window.dataLayer = window.dataLayer || [];
37+
function gtag(){dataLayer.push(arguments);}
38+
gtag('js', new Date());
39+
gtag('config', 'UA-118996389-2');
40+
</script>
41+
</head>
42+
43+
<body class="test-container">
44+
<main class="test-viewport test-viewport--mobile">
45+
<div class="test-layout">
46+
47+
<div class="test-cell test-cell--textarea">
48+
<div class="mdc-text-field mdc-text-field--textarea mdc-text-field--end-aligned">
49+
<textarea id="full-width-textarea"
50+
class="mdc-text-field__input test-text-field__input"
51+
rows="2"></textarea>
52+
<div class="mdc-notched-outline">
53+
<div class="mdc-notched-outline__leading"></div>
54+
<div class="mdc-notched-outline__notch">
55+
<label for="full-width-textarea" class="mdc-floating-label">Textarea Label</label>
56+
</div>
57+
<div class="mdc-notched-outline__trailing"></div>
58+
</div>
59+
</div>
60+
</div>
61+
62+
<div class="test-cell test-cell--textarea">
63+
<div class="mdc-text-field mdc-text-field--textarea mdc-text-field--end-aligned">
64+
<textarea id="full-width-textarea-filled"
65+
class="mdc-text-field__input test-text-field__input"
66+
rows="2">Xyz</textarea>
67+
<div class="mdc-notched-outline mdc-notched-outline--notched">
68+
<div class="mdc-notched-outline__leading"></div>
69+
<div class="mdc-notched-outline__notch">
70+
<label for="full-width-textarea-filled" class="mdc-floating-label mdc-floating-label--float-above">Textarea Label</label>
71+
</div>
72+
<div class="mdc-notched-outline__trailing"></div>
73+
</div>
74+
</div>
75+
</div>
76+
77+
<div class="test-cell test-cell--textarea">
78+
<div class="mdc-text-field mdc-text-field--textarea mdc-text-field--end-aligned">
79+
<!-- htmllint-disable -->
80+
<textarea id="full-width-textarea-long-filled"
81+
class="mdc-text-field__input test-text-field__input"
82+
rows="2">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur rhoncus ac risus a eleifend. Phasellus dictum luctus leo quis ultricies. Vivamus fringilla vehicula turpis eu eleifend. Donec ultricies, est a scelerisque laoreet, arcu eros commodo nunc, sit amet hendrerit diam nisi id velit. Suspendisse porta nibh orci. Donec velit nisl, accumsan vitae eros a, consectetur interdum eros. Aenean dapibus vulputate semper. Aliquam finibus nec leo sed ultricies. Integer luctus convallis risus. Etiam suscipit suscipit ante vel volutpat. Ut venenatis dapibus elit dictum fringilla.</textarea>
83+
<div class="mdc-notched-outline mdc-notched-outline--notched">
84+
<div class="mdc-notched-outline__leading"></div>
85+
<div class="mdc-notched-outline__notch">
86+
<label for="full-width-textarea-long-filled" class="mdc-floating-label mdc-floating-label--float-above">Textarea Label</label>
87+
</div>
88+
<div class="mdc-notched-outline__trailing"></div>
89+
</div>
90+
<!-- htmllint-enable -->
91+
</div>
92+
</div>
93+
94+
</div>
95+
</main>
96+
97+
<!-- Automatically provides/replaces `Promise` if missing or broken. -->
98+
<script src="https://cdn.jsdelivr.net/npm/es6-promise@4/dist/es6-promise.js"></script>
99+
<script src="https://cdn.jsdelivr.net/npm/es6-promise@4/dist/es6-promise.auto.js"></script>
100+
<script src="https://cdnjs.cloudflare.com/ajax/libs/fontfaceobserver/2.0.13/fontfaceobserver.standalone.js"></script>
101+
<script src="../../../out/material-components-web.js"></script>
102+
<script src="../../../out/spec/fixture.js"></script>
103+
<script src="../../../out/spec/mdc-textfield/fixture.js"></script>
104+
</body>
105+
</html>

test/screenshot/spec/mdc-top-app-bar/classes/baseline-short-collapsed-with-action-items.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
<body class="test-container">
4545
<main class="test-viewport test-top-app-bar-viewport">
46-
<header class="mdc-top-app-bar mdc-top-app-bar--short mdc-top-app-bar--short-collapsed">
46+
<header class="mdc-top-app-bar mdc-top-app-bar--short mdc-top-app-bar--short-collapsed mdc-top-app-bar--short-has-action-item">
4747
<div class="mdc-top-app-bar__row">
4848
<section class="mdc-top-app-bar__section mdc-top-app-bar__section--align-start">
4949
<button class="material-icons mdc-top-app-bar__navigation-icon mdc-icon-button">menu</button>

0 commit comments

Comments
 (0)