Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(text-field): Move final JS colors to mixins. Update demos #2006

Merged
merged 14 commits into from
Jan 22, 2018

Conversation

williamernest
Copy link
Contributor

@williamernest williamernest commented Jan 19, 2018

BREAKING CHANGE: Moves the text-field colors to mixins. Removes css only. Refer to the docs/demo for usage.

resolves #1526
fixes #1925

@codecov-io
Copy link

codecov-io commented Jan 19, 2018

Codecov Report

Merging #2006 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2006   +/-   ##
=======================================
  Coverage   99.43%   99.43%           
=======================================
  Files          84       84           
  Lines        3717     3717           
  Branches      485      485           
=======================================
  Hits         3696     3696           
  Misses         21       21

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bf653a7...421ca50. Read the comment docs.

@lynnmercier
Copy link
Contributor

Talked offline, we're going to split this into two PRs: one to remove the CSS only version of text field, and one to finish the Sass color mixin story


&.mdc-text-field--focused {
@include mdc-text-field-label-color(rgba(blue, .87));
@include mdc-text-field-focused-textarea-stroke-color($focused-border);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this belong under the .mdc-text-field--focused selector?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this should just be renamed. It's our "double border" for the text area. There's a div and a textarea together with the outer div being non-focused and both of them together being the focused state.

`mdc-text-field-outline-color($color)` | Customizes the color of the border of the outlined text-field.
`mdc-text-field-hover-outline-color($color)` | Customizes the hover color of the border of the outlined text-field.
`mdc-text-field-focused-outline-color($color)` | Customizes the outlined border color when the text-field is focused.
`mdc-text-field-box-background-color($color)` | Customizes the background color of the text-field box.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

box-fill-color, not background

`mdc-text-field-outline-color($color)` | Customizes the color of the border of the outlined text-field.
`mdc-text-field-hover-outline-color($color)` | Customizes the hover color of the border of the outlined text-field.
`mdc-text-field-focused-outline-color($color)` | Customizes the outlined border color when the text-field is focused.
`mdc-text-field-box-background-color($color)` | Customizes the background color of the text-field box.
`mdc-text-field-textarea-stroke-color($color)` | Customizes the color of the border of the textarea.
`mdc-text-field-textarea-background-color($color)` | Customizes the color of the background of the textarea.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

textarea-fill-color, not background

`mdc-text-field-helper-text-color($color)` | Customizes the color of the helper text following a text-field.
`mdc-text-field-helper-text-validation-color($color)` | Customizes the color of the helper text when it's used as a validation message.
`mdc-text-field-label-background-color` | Customizes the background color of the label. Used only by the textarea.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm, I think we should only allow clients to customize the fill color of the entire textarea, not specific to the label. I think we should delete this mixin (At least publicly)

}

@mixin mdc-text-field-textarea-background-color($color) {
&.mdc-text-field--textarea:not(.mdc-text-field--disabled) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't have mdc-text-field--textarea within this mixin. We should assume the developer calling this mixin has already specified a CSS selector which only selects mdc-text-field--textarea elements. So, mdc-text-field--textarea is unnecessarily specific.

@@ -126,6 +164,10 @@
@include mdc-text-field-hover-outline-color($mdc-text-field-error-on-light);
@include mdc-text-field-focused-outline-color($mdc-text-field-error-on-light);

// Textarea specific mixins
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move this to mdc-text-field-textarea-invalid_ mixin. Its at HEAD of master now

Copy link
Contributor Author

@williamernest williamernest Jan 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we move all of the variants to their own invalid mixins? textarea is the only one that has an -invalid mixin.

I opted to condense everything here, but if we break out textarea, shouldn't we also break out outline ?
textfield mixin in master

@mixin mdc-text-field-textarea-invalid_ {

invalid mixin in master

@include mdc-text-field-outline-color($mdc-text-field-error-on-light);

}

@mixin mdc-text-field-fullwidth-bottom-line-color_($color) {
&.mdc-text-field--fullwidth:not(.mdc-text-field--textarea) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.mdc-text-field--fullwidth is unnecessarily specific here. Assume the developer is already using a CSS selector that only selects mdc-text-field--fullwidth elements

@@ -17,19 +17,19 @@
//Public

@mixin mdc-text-field-bottom-line-color($color) {
&:not(.mdc-text-field--disabled) {
&:not(.mdc-text-field--disabled):not(.mdc-text-field--outlined):not(.mdc-text-field--textarea) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we say in our README to never use a mdc-text-field__bottom-line element within a mdc-text-field--outlined element? or mdc-text-field--textarea?

Copy link
Contributor Author

@williamernest williamernest Jan 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. They share the mdc-text-field__input, the bottom line color is automatically set, resulting in some weird behavior on outline and textfield if we don't stop it here. This mixin applies border-bottom-color, and outline applies border-color, resulting in a weird line

Without :not(.mdc-text-field--outlined):not(.mdc-text-field--textarea)
screenshot from 2018-01-19 17-25-43

With
screenshot from 2018-01-19 17-26-45

The mdc-text-field-border-bottom-line-color mixin is applied to the border-bottom-color of the input field for idle and hover. The actual bottom line element is a separate element that only gets activated on focus.

@lynnmercier lynnmercier self-assigned this Jan 20, 2018
@lynnmercier
Copy link
Contributor

Oh and...this PR is not a breaking change anymore, now that you moved the CSS only stuff to the other PR

Copy link
Contributor

@lynnmercier lynnmercier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

// Private mixins

@mixin mdc-text-field-invalid-label-shake-keyframes_($modifier, $positionY, $scale: .75) {
@mixin mdc-text-field-invalid-label-shake-keyframes_($modifier, $positionY, $positionX: 0%, $scale: .75) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this change something that should be in this PR? Or unrelated to this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated. This was my merge with master.

@@ -324,13 +312,18 @@
.mdc-text-field__label--float-above ~ .mdc-text-field__outline {
opacity: 1;
}

&.mdc-text-field--invalid {
@include mdc-text-field-outlined-invalid_;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this call to mdc-text-field.scss

.mdc-text-field--focused.mdc-text-field--invalid {
  @include mdc-text-field-outlined-invalue_;
}

padding: 8px 16px;
margin-top: 2px;
margin-left: 8px;
padding: 8px;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a new change? Or did you move existing logic into here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated. This was my merge with master.

}

&.mdc-text-field--invalid {
@include mdc-text-field-textarea-invalid_;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this call to mdc-text-field.scss

&.mdc-text-field--focused:not(.mdc-text-field--invalid) {
@include mdc-text-field-focused-textarea-stroke-color(primary);
&.mdc-text-field--disabled {
@include mdc-text-field-textarea-disabled_;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this call to mdc-text-field.scss

&.mdc-text-field--disabled {
@include mdc-text-field-textarea-disabled_;
&.mdc-text-field--focused {
@include mdc-text-field-textarea-stroke-color(primary);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this call to mdc-text-field.scss

.mdc-text-field--textarea.mdc-text-field--focused {
  @include mdc-text-field-textarea-stroke-color(primary);
}

@williamernest williamernest merged commit 989c516 into master Jan 22, 2018
@williamernest williamernest deleted the feat/text-field/color-mixins-final branch January 22, 2018 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Textarea has two different border colors when the field is invalid Add Sass color mixin to text field
3 participants