Skip to content

Commit

Permalink
feat(textfield): add end-alignment (#5356)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
asyncLiz authored Jan 6, 2020
1 parent c8bb8dd commit 847dd1a
Show file tree
Hide file tree
Showing 8 changed files with 230 additions and 6 deletions.
1 change: 1 addition & 0 deletions packages/mdc-textfield/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ CSS Class | Description
`mdc-text-field--with-trailing-icon` | Styles the text field as a text field with a trailing icon.
`mdc-text-field--focused` | Styles the text field as a text field in focus.
`mdc-text-field--no-label` | Styles the text field that has no label.
`mdc-text-field--end-aligned` | Styles the text field with an end-aligned input.
`mdc-text-field-helper-line` | Styles the container of helper text and character counter elements.

#### Deprecation Notice
Expand Down
14 changes: 14 additions & 0 deletions packages/mdc-textfield/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,20 @@
}
}

// End aligned
@mixin mdc-text-field-end-aligned_ {
.mdc-text-field__input {
// IE11 does not support text-align: end
/* @noflip */
text-align: right;

@include mdc-rtl {
/* @noflip */
text-align: left;
}
}
}

// Customization

@mixin mdc-text-field-ink-color_($color) {
Expand Down
4 changes: 4 additions & 0 deletions packages/mdc-textfield/mdc-text-field.scss
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,10 @@
@include mdc-text-field-textarea-disabled_;
}

.mdc-text-field--end-aligned {
@include mdc-text-field-end-aligned_;
}

@include mdc-floating-label-shake-keyframes(
text-field-dense,
$mdc-text-field-dense-label-position-y,
Expand Down
6 changes: 1 addition & 5 deletions test/screenshot/diffing.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,7 @@
"desktop_windows_firefox@69"
],
"url_regex_patterns": [
"mdc-menu/classes/baseline.html",
"mdc-menu/classes/bottom-anchored.html",
"mdc-menu/classes/menu-selection-group-only.html",
"mdc-menu/classes/menu-selection-group.html",
"mdc-menu/classes/multiple-menu-selection-group.html"
"mdc-menu"
],
"custom_config": {
"fonts_loaded_reflow_delay_ms": 300
Expand Down
16 changes: 16 additions & 0 deletions test/screenshot/golden.json
Original file line number Diff line number Diff line change
Expand Up @@ -1199,6 +1199,14 @@
"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"
}
},
"spec/mdc-textfield/classes/baseline-end-aligned.html": {
"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",
"screenshots": {
"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",
"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",
"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"
}
},
"spec/mdc-textfield/classes/baseline-fullwidth.html": {
"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",
"screenshots": {
Expand Down Expand Up @@ -1623,6 +1631,14 @@
"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"
}
},
"spec/mdc-textfield/classes/textarea-end-aligned.html": {
"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",
"screenshots": {
"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",
"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",
"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"
}
},
"spec/mdc-textfield/classes/textarea-focused.html": {
"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",
"screenshots": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<!DOCTYPE html>
<!--
Copyright 2018 Google Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->
<html lang="en">
<head>
<meta charset="utf-8">
<title>Baseline Text Field Element end-aligned - MDC Web Screenshot Test</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="../../../out/mdc.textfield.css">
<link rel="stylesheet" href="../../../out/mdc.typography.css">
<link rel="stylesheet" href="../../../out/spec/fixture.css">
<link rel="stylesheet" href="../../../out/spec/mdc-textfield/fixture.css">
</head>

<body class="test-container">
<main class="test-viewport test-viewport--mobile">
<div class="test-layout">

<div class="test-cell test-cell--textfield">
<div class="mdc-text-field mdc-text-field--end-aligned mdc-text-field--no-label">
<!-- htmllint-disable -->
<input type="text" class="mdc-text-field__input test-text-field__input" aria-label="Label" placeholder="Placeholder">
<!-- htmllint-enable -->
<div class="mdc-line-ripple"></div>
</div>
</div>

<div class="test-cell test-cell--textfield">
<div class="mdc-text-field mdc-text-field--end-aligned mdc-text-field--outlined mdc-text-field--no-label">
<!-- htmllint-disable -->
<input type="text" class="mdc-text-field__input test-text-field__input" aria-label="Label" placeholder="Placeholder">
<!-- htmllint-enable -->
<div class="mdc-notched-outline">
<div class="mdc-notched-outline__leading"></div>
<div class="mdc-notched-outline__trailing"></div>
</div>
</div>
</div>

<div class="test-cell test-cell--textfield">
<div class="mdc-text-field mdc-text-field--end-aligned mdc-text-field--label-floating">
<input type="text" id="filled-text-field" class="mdc-text-field__input test-text-field__input" value="Filled value">
<label for="filled-text-field" class="mdc-floating-label mdc-floating-label--float-above">Label</label>
<div class="mdc-line-ripple"></div>
</div>
</div>

<div class="test-cell test-cell--textfield">
<div class="mdc-text-field mdc-text-field--end-aligned mdc-text-field--outlined mdc-text-field--label-floating">
<input type="text" id="outlined-text-field" class="mdc-text-field__input test-text-field__input" value="Filled value">
<div class="mdc-notched-outline mdc-notched-outline--notched">
<div class="mdc-notched-outline__leading"></div>
<div class="mdc-notched-outline__notch">
<label for="outlined-text-field" class="mdc-floating-label mdc-floating-label--float-above">Label</label>
</div>
<div class="mdc-notched-outline__trailing"></div>
</div>
</div>
</div>

</div>
</main>

<!-- Automatically provides/replaces `Promise` if missing or broken. -->
<script src="https://cdn.jsdelivr.net/npm/es6-promise@4/dist/es6-promise.js"></script>
<script src="https://cdn.jsdelivr.net/npm/es6-promise@4/dist/es6-promise.auto.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fontfaceobserver/2.0.13/fontfaceobserver.standalone.js"></script>
<script src="../../../out/material-components-web.js"></script>
<script src="../../../out/spec/fixture.js"></script>
<script src="../../../out/spec/mdc-textfield/fixture.js"></script>
</body>
</html>
105 changes: 105 additions & 0 deletions test/screenshot/spec/mdc-textfield/classes/textarea-end-aligned.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<!DOCTYPE html>
<!--
Copyright 2018 Google Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->
<html lang="en">
<head>
<meta charset="utf-8">
<title>Textarea Text Field end aligned - MDC Web Screenshot Test</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="../../../out/mdc.textfield.css">
<link rel="stylesheet" href="../../../out/mdc.typography.css">
<link rel="stylesheet" href="../../../out/spec/fixture.css">
<link rel="stylesheet" href="../../../out/spec/mdc-textfield/fixture.css">

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-118996389-2"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-118996389-2');
</script>
</head>

<body class="test-container">
<main class="test-viewport test-viewport--mobile">
<div class="test-layout">

<div class="test-cell test-cell--textarea">
<div class="mdc-text-field mdc-text-field--textarea mdc-text-field--end-aligned">
<textarea id="full-width-textarea"
class="mdc-text-field__input test-text-field__input"
rows="2"></textarea>
<div class="mdc-notched-outline">
<div class="mdc-notched-outline__leading"></div>
<div class="mdc-notched-outline__notch">
<label for="full-width-textarea" class="mdc-floating-label">Textarea Label</label>
</div>
<div class="mdc-notched-outline__trailing"></div>
</div>
</div>
</div>

<div class="test-cell test-cell--textarea">
<div class="mdc-text-field mdc-text-field--textarea mdc-text-field--end-aligned">
<textarea id="full-width-textarea-filled"
class="mdc-text-field__input test-text-field__input"
rows="2">Xyz</textarea>
<div class="mdc-notched-outline mdc-notched-outline--notched">
<div class="mdc-notched-outline__leading"></div>
<div class="mdc-notched-outline__notch">
<label for="full-width-textarea-filled" class="mdc-floating-label mdc-floating-label--float-above">Textarea Label</label>
</div>
<div class="mdc-notched-outline__trailing"></div>
</div>
</div>
</div>

<div class="test-cell test-cell--textarea">
<div class="mdc-text-field mdc-text-field--textarea mdc-text-field--end-aligned">
<!-- htmllint-disable -->
<textarea id="full-width-textarea-long-filled"
class="mdc-text-field__input test-text-field__input"
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>
<div class="mdc-notched-outline mdc-notched-outline--notched">
<div class="mdc-notched-outline__leading"></div>
<div class="mdc-notched-outline__notch">
<label for="full-width-textarea-long-filled" class="mdc-floating-label mdc-floating-label--float-above">Textarea Label</label>
</div>
<div class="mdc-notched-outline__trailing"></div>
</div>
<!-- htmllint-enable -->
</div>
</div>

</div>
</main>

<!-- Automatically provides/replaces `Promise` if missing or broken. -->
<script src="https://cdn.jsdelivr.net/npm/es6-promise@4/dist/es6-promise.js"></script>
<script src="https://cdn.jsdelivr.net/npm/es6-promise@4/dist/es6-promise.auto.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fontfaceobserver/2.0.13/fontfaceobserver.standalone.js"></script>
<script src="../../../out/material-components-web.js"></script>
<script src="../../../out/spec/fixture.js"></script>
<script src="../../../out/spec/mdc-textfield/fixture.js"></script>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

<body class="test-container">
<main class="test-viewport test-top-app-bar-viewport">
<header class="mdc-top-app-bar mdc-top-app-bar--short mdc-top-app-bar--short-collapsed">
<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">
<div class="mdc-top-app-bar__row">
<section class="mdc-top-app-bar__section mdc-top-app-bar__section--align-start">
<button class="material-icons mdc-top-app-bar__navigation-icon mdc-icon-button">menu</button>
Expand Down

0 comments on commit 847dd1a

Please sign in to comment.