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

feat(text-field): Move color for default text-field to mixins. #1885

Merged

Conversation

williamernest
Copy link
Contributor

@williamernest williamernest commented Jan 5, 2018

references: #1526

Moves colors for the default text-field into mixins. Separated private/public mixins to prevent users from modifying disabled state colors.

@williamernest williamernest force-pushed the feat/text-field/sass_color_mixins_for_default_component branch from 45c9ae3 to 07205bd Compare January 5, 2018 22:53
}
}

@mixin mdc-text-field-bottom-line-hover-color($color) {
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-hover-bottom-line-color is better I think. Since you hover on the text field, not the bottom line.

}
}

@mixin mdc-text-field-bottom-line-focused-color($color) {
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-focused-bottom-line-color is better I think. Since you focus on the text field, not the bottom line.

}
}

@mixin mdc-text-field-input-ink-color($color) {
Copy link
Contributor

Choose a reason for hiding this comment

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

just use mdc-text-field-ink-color. <input> is an implementation detail

@@ -38,14 +38,21 @@
// postcss-bem-linter: define text-field

.mdc-text-field {
@include mdc-text-field-bottom-line-color($mdc-text-field-underline-on-light-idle);
@include mdc-text-field-bottom-line-hover-color($mdc-text-field-underline-on-light);
@include mdc-text-field-bottom-line-focused-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.

Love these bottom line mixins

@include mdc-text-field-bottom-line-focused-color(primary);
@include mdc-text-field-label-ink-color($mdc-text-field-light-label);
@include mdc-text-field-input-ink-color(text-primary-on-light);
@include mdc-text-field-input-placeholder-ink-color(text-hint-on-light);
Copy link
Contributor

Choose a reason for hiding this comment

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

combine the label-color, input-placeholder-ink-color (one is CSS only and one is JS)

@include mdc-text-field-label-ink-color($mdc-text-field-light-label);
@include mdc-text-field-input-ink-color(text-primary-on-light);
@include mdc-text-field-input-placeholder-ink-color(text-hint-on-light);
@include mdc-text-field-input-placeholder-hover-ink-color($mdc-text-field-light-placeholder);
Copy link
Contributor

Choose a reason for hiding this comment

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

drop this "change label color on hover" feature from the CSS only version of text field

}
}

@mixin mdc-text-field-label-ink-color($color) {
Copy link
Contributor

Choose a reason for hiding this comment

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

you can just say label-color there is only one way to color the label

Copy link
Contributor Author

Choose a reason for hiding this comment

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

.mdc-text-field--textarea .mdc-text-field__label has a background-color attribute.

@codecov-io
Copy link

codecov-io commented Jan 5, 2018

Codecov Report

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

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1885   +/-   ##
=======================================
  Coverage   99.43%   99.43%           
=======================================
  Files          84       84           
  Lines        3721     3721           
  Branches      484      484           
=======================================
  Hits         3700     3700           
  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 10ca23e...8392863. Read the comment docs.

@williamernest williamernest force-pushed the feat/text-field/sass_color_mixins_for_default_component branch 2 times, most recently from 08b875d to 8abecc7 Compare January 6, 2018 00:21
@@ -198,6 +198,12 @@ Mixin | Description
--- | ---
`mdc-text-field-box-corner-radius($radius)` | Customizes the border radius for a box text field
`mdc-text-field-textarea-corner-radius($radius)` | Customizes the border radius for a `<textarea>` text field
`mdc-text-field-bottom-line-color($color)` | Customizes the color of the default bottom line of the text-field.
`mdc-text-field-hover-bottom-line-color($color)` | Customizes the hover color of the bottom line of the text-field.
`mdc-text-field-focused-bottom-line-color($color)` | Customizes the bottom-line ripple color when the text-field is selected.
Copy link
Contributor

Choose a reason for hiding this comment

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

when the text field is focused, not selected


@mixin mdc-text-field-bottom-line-color_($color) {
.mdc-text-field__input,
.mdc-text-field__input::placeholder {
Copy link
Contributor

Choose a reason for hiding this comment

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

why do you need the ::placeholder? Maybe add a comment explaining this, since it is not obvious

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I definitely don't need it there. I need it on the label color mixin for the css only version uses a placeholder instead of a label.

@@ -194,10 +194,21 @@ CSS Class | Description

### Sass Mixins

To customize the colors of any part of the text-field, use the following mixins. We recommend you apply
these mixins within CSS selectors like .foo-text-field:not(.mdc-text-field--focused) to select your inactive text-fields,
Copy link
Contributor

Choose a reason for hiding this comment

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

to select your unfocused text fields

(no dashes in text field, it is two words)

To customize the colors of any part of the text-field, use the following mixins. We recommend you apply
these mixins within CSS selectors like .foo-text-field:not(.mdc-text-field--focused) to select your inactive text-fields,
and .foo-tab.mdc-text-field--focused to select your active text-fields (Note: the `mdc-text-field-focused-bottom-line-color`
mixin should be applied from the not focused class `foo-text-field:not(.mdc-tab--focused)`).
Copy link
Contributor

Choose a reason for hiding this comment

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

put this note in an '> NOTE: ' comment. You can see examples though-out this README

&:not(.mdc-text-field--disabled) {
@include mdc-text-field-bottom-line-color_($color);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

move all the bottom-line mixins to bottom-line/_mixins.scss (and then export them through this file)

&:not(.mdc-text-field--disabled) {
@include mdc-text-field-label-color_($color);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

move all the label mixins to label/_mixins.scss (and then export them through this file)


// Private Color Mixins

@mixin mdc-text-field-bottom-line-color_($color) {
Copy link
Contributor

Choose a reason for hiding this comment

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

move the private ones too

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

and .foo-tab.mdc-text-field--focused to select your active text-fields (Note: the `mdc-text-field-focused-bottom-line-color`
mixin should be applied from the not focused class `foo-text-field:not(.mdc-tab--focused)`).
these mixins within CSS selectors like .foo-text-field:not(.mdc-text-field--focused) to select your unfocused text fields,
and .foo-tab.mdc-text-field--focused to select your active text-fields.
Copy link
Contributor

Choose a reason for hiding this comment

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

your focused text fields. Fix this too!!

And add a mention about the invalid state.

@williamernest williamernest force-pushed the feat/text-field/sass_color_mixins_for_default_component branch from f60c4df to c54ebf4 Compare January 8, 2018 18:21
@williamernest williamernest merged commit ca1eadc into master Jan 8, 2018
@williamernest williamernest deleted the feat/text-field/sass_color_mixins_for_default_component branch January 11, 2018 18:18
copybara-service bot pushed a commit that referenced this pull request Jul 23, 2021
Upcoming work:

* implement theme
* add component tests

fixes #1885
fixes #2109
fixes #2108
fixes #523
fixes #1028
fixes #1671

PiperOrigin-RevId: 367260030
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants