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

fix(material/form-field): align fill, outline, and standard appearance on hover behavior with spec #15618

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
4412e83
form-field hovering style fixes
NicholasCobbFromGoogle Mar 26, 2019
bfc5b38
More small fixes
NicholasCobbFromGoogle Mar 26, 2019
93d0b88
fixes formfield hovering color scheme for night mode
NicholasCobbFromGoogle Mar 28, 2019
e7b0930
Merge branch 'master' of https://github.com/angular/material2
NicholasCobbFromGoogle Mar 28, 2019
2eedfbd
Merge branch 'master' of https://github.com/angular/material2
NicholasCobbFromGoogle Apr 1, 2019
92cbc3d
Adds a ripple mixin for the standard/fill appearances
NicholasCobbFromGoogle Apr 1, 2019
ecfa6e3
Merge branch 'master' of https://github.com/angular/material2
NicholasCobbFromGoogle Apr 2, 2019
cfa1fea
Merge branch 'master' of https://github.com/angular/material2
NicholasCobbFromGoogle Apr 5, 2019
bb0653e
Further changes to the fill appearance opacities and standard appeara…
NicholasCobbFromGoogle Apr 5, 2019
5107df7
Merge branch 'master' of https://github.com/angular/material2
NicholasCobbFromGoogle Apr 11, 2019
e3f4e5b
Merge branch 'master' of https://github.com/angular/material2
NicholasCobbFromGoogle Apr 22, 2019
98358d9
Merge branch 'master' of https://github.com/angular/material2
NicholasCobbFromGoogle Apr 24, 2019
bbd39b1
Further changes to outline style and bg color of fill style.
NicholasCobbFromGoogle Apr 24, 2019
536b4c9
Merge branch 'master' of https://github.com/angular/material2
NicholasCobbFromGoogle Apr 25, 2019
27750c2
Change fill appearance background back to 10/14/16% opacity
NicholasCobbFromGoogle Apr 25, 2019
082809b
Merge branch 'master' of https://github.com/angular/material2
NicholasCobbFromGoogle Apr 27, 2019
425dae8
Moves some of the fil styles away from the theme file.
NicholasCobbFromGoogle Apr 27, 2019
bd335a0
Merge branch 'master' of https://github.com/angular/material2
NicholasCobbFromGoogle May 1, 2019
2feb193
More migration of CSS away from theme files
NicholasCobbFromGoogle May 1, 2019
f85b055
Merge branch 'master' of https://github.com/angular/material2
NicholasCobbFromGoogle May 2, 2019
c8a758e
Removes -hover-height from _form-outline-theme.
NicholasCobbFromGoogle May 2, 2019
567d869
update gitignore to match upstream
NicholasCobbFromGoogle May 23, 2019
ae7ded0
pull/merge from master
NicholasCobbFromGoogle May 23, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/material/core/style/_form-common.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@import '../theming/palette';
@import '../theming/theming';

// Renders a gradient for showing the dashed line when the input is disabled.
Expand Down
26 changes: 18 additions & 8 deletions src/material/form-field/_form-field-fill-theme.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
@import '../core/theming/palette';
@import '../core/theming/theming';
@import '../core/style/form-common';
@import '../core/typography/typography-utils';


Expand All @@ -9,19 +8,17 @@
@mixin mat-form-field-fill-theme($theme) {
$foreground: map-get($theme, foreground);
$is-dark-theme: map-get($theme, is-dark);

$fill-background: mat-color($foreground, base, if($is-dark-theme, 0.1, 0.04));
$fill-disabled-background: mat-color($foreground, base, if($is-dark-theme, 0.05, 0.02));
$fill-background: mat-color($foreground, base);
$underline-color: mat-color($foreground, divider, if($is-dark-theme, 0.5, 0.42));
$label-disabled-color: mat-color($foreground, disabled-text);

.mat-form-field-appearance-fill {
.mat-form-field-flex {
background-color: $fill-background;
.mat-form-field-flex::before {
background: $fill-background;
}

&.mat-form-field-disabled .mat-form-field-flex {
background-color: $fill-disabled-background;
&.mat-form-field-disabled .mat-form-field-flex::before {
opacity: if($is-dark-theme, 0.05, 0.02);
}

.mat-form-field-underline::before {
Expand Down Expand Up @@ -68,8 +65,21 @@ $mat-form-field-fill-dedupe: 0;
$infix-margin-top: 1em * $line-height * $subscript-font-scale;
// The amount we offset the label from the input text in the fill appearance.
$fill-appearance-label-offset: -0.5em;
// The space between the bottom of the .mat-form-field-flex area and the subscript wrapper.
// Mocks show half of the text size, but this margin is applied to an element with the subscript
// text font size, so we need to divide by the scale factor to make it half of the original text
// size.
$subscript-margin-top: 0.5em / $subscript-font-scale;
// The padding applied to the form-field-wrapper to reserve space for the subscript, since it's
// absolutely positioned. This is a combination of the subscript's margin and line-height, but we
// need to multiply by the subscript font scale factor since the wrapper has a larger font size.
$wrapper-padding-bottom: ($subscript-margin-top + $line-height) * $subscript-font-scale;

.mat-form-field-appearance-fill {
.mat-form-field-flex::before {
NicholasCobbFromGoogle marked this conversation as resolved.
Show resolved Hide resolved
bottom: $wrapper-padding-bottom;
}

.mat-form-field-infix {
padding: $infix-padding-top 0 $infix-padding-bottom 0;
}
Expand Down
5 changes: 3 additions & 2 deletions src/material/form-field/_form-field-outline-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@

$label-disabled-color: mat-color($foreground, disabled-text);
$outline-color: mat-color($foreground, divider, if($is-dark-theme, 0.3, 0.12));
$outline-color-hover: mat-color($foreground, divider, if($is-dark-theme, 1, 0.87));
$outline-color-hover-dark: mat-color($foreground, divider, 0.7);
$outline-color-hover: map-get($mat-grey, 900);
$outline-color-primary: mat-color($primary);
$outline-color-accent: mat-color($accent);
$outline-color-warn: mat-color($warn);
Expand All @@ -27,7 +28,7 @@
}

.mat-form-field-outline-thick {
color: $outline-color-hover;
color: if($is-dark-theme, $outline-color-hover-dark, $outline-color-hover);
}

&.mat-focused {
Expand Down
9 changes: 8 additions & 1 deletion src/material/form-field/_form-field-standard-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,17 @@
@mixin mat-form-field-standard-theme($theme) {
$foreground: map-get($theme, foreground);
$is-dark-theme: map-get($theme, is-dark);

$ripple-hover-color: map-get($mat-grey, 700);
$ripple-dark-theme-hover-color: mat-color($foreground, divider, 0.7);
$underline-color: mat-color($foreground, divider, if($is-dark-theme, 0.7, 0.42));

.mat-form-field-appearance-standard {
&:not(.mat-form-field-invalid):not(.mat-focused) {
.mat-form-field-ripple {
background-color: if($is-dark-theme, $ripple-dark-theme-hover-color, $ripple-hover-color);
}
}

.mat-form-field-underline {
background-color: $underline-color;
}
Expand Down
24 changes: 24 additions & 0 deletions src/material/form-field/form-field-fill.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ $mat-form-field-fill-subscript-font-scale: 0.75 !default;
$mat-form-field-fill-subscript-padding:
$mat-form-field-fill-side-padding / $mat-form-field-fill-subscript-font-scale;

$mat-form-field-fill-ripple-hover-height: 1px !default;

.mat-form-field-appearance-fill {
.mat-form-field-flex {
Expand All @@ -33,6 +34,25 @@ $mat-form-field-fill-subscript-padding:
}
}

.mat-form-field-flex::before {
content: '';
border-radius: $mat-form-field-fill-border-radius $mat-form-field-fill-border-radius 0 0;
left: 0;
opacity: 0.1;
position: absolute;
right: 0;
top: 0;
transition: opacity 400ms $swift-ease-out-timing-function;
}

&:hover .mat-form-field-flex::before {
opacity: 0.14;
}

&.mat-focused .mat-form-field-flex::before {
opacity: 0.16;
}

.mat-form-field-underline::before {
content: '';
display: block;
Expand All @@ -52,6 +72,10 @@ $mat-form-field-fill-subscript-padding:
}
}

&:not(.mat-form-field-invalid):not(.mat-focused) .mat-form-field-ripple {
height: $mat-form-field-fill-ripple-hover-height;
}

// Note that we need this specific of a selector because we don't want
// the hover effect to show when the user hovers over the hints.
&:not(.mat-form-field-disabled) .mat-form-field-flex:hover ~ .mat-form-field-underline {
Expand Down
19 changes: 12 additions & 7 deletions src/material/form-field/form-field-outline.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ $mat-form-field-outline-label-overlap: 0.25em;
$mat-form-field-outline-border-radius: 5px;
// The width of the outline.
$mat-form-field-outline-width: 1px;
// The width of the thick outline (used for focus, hover, and error state).
// The width of the thick outline (used for focus and error state).
$mat-form-field-outline-thick-width: 2px;
// The horizontal padding between the edge of the subscript box and the start of the subscript text.
$mat-form-field-outline-subscript-padding:
Expand Down Expand Up @@ -98,13 +98,10 @@ $mat-form-field-outline-subscript-padding:

.mat-form-field-outline-thick {
opacity: 0;
}

.mat-form-field-outline-start,
.mat-form-field-outline-end,
.mat-form-field-outline-gap {
border-width: $mat-form-field-outline-thick-width;
transition: border-color 300ms $swift-ease-out-timing-function;
}
&.mat-focused .mat-form-field-outline-thick {
border-width: $mat-form-field-outline-width;
}

&.mat-focused,
Expand All @@ -113,9 +110,17 @@ $mat-form-field-outline-subscript-padding:
opacity: 0;
transition: opacity 100ms $swift-ease-out-timing-function;
}

.mat-form-field-outline-thick {
opacity: 1;
}

.mat-form-field-outline-start,
.mat-form-field-outline-end,
.mat-form-field-outline-gap {
border-width: $mat-form-field-outline-thick-width;
transition: border-color 300ms $swift-ease-out-timing-function;
}
}

&:not(.mat-form-field-disabled) .mat-form-field-flex:hover {
Expand Down
5 changes: 5 additions & 0 deletions src/material/form-field/form-field-standard.scss
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ $mat-form-field-standard-padding-top: 0.75em !default;
}
}

&:not(.mat-form-field-invalid):not(.mat-focused) {
.mat-form-field-ripple {
height: $mat-form-field-standard-underline-height;
}
}
// Note that we need this specific of a selector because we don't want
// the hover effect to show when the user hovers over the hints.
&:not(.mat-form-field-disabled) .mat-form-field-flex:hover ~ .mat-form-field-underline {
Expand Down