-
Notifications
You must be signed in to change notification settings - Fork 2.1k
chore(select): Remove default variant #3476
Changes from 9 commits
d615253
01cacc1
31bfd09
0e46865
fc5c80c
45e4af7
0520b9a
fa8f06c
7e01f0e
bbd721b
2cbfa4f
30f9a13
0600e0c
538c84d
3bc2183
8f9ca3c
9f69005
b78805f
225a0c9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,21 +83,6 @@ See [Importing the JS component](../../docs/importing-js.md) for more informatio | |
|
||
## Variants | ||
|
||
### Select Box | ||
|
||
The Select Box variant uses the same markup as the standard variant, with the addition of the `mdc-select--box` | ||
modifier class on the root element. | ||
|
||
```html | ||
<div class="mdc-select mdc-select--box"> | ||
<select class="mdc-select__native-control"> | ||
... | ||
</select> | ||
<label class="mdc-floating-label">Pick a Food Group</label> | ||
<div class="mdc-line-ripple"></div> | ||
</div> | ||
``` | ||
|
||
### Outlined Select | ||
|
||
The Select Outlined variant uses the `mdc-notched-outline` in place of the `mdc-line-ripple` element and adds the | ||
|
@@ -198,7 +183,6 @@ Since MDC Select uses native `<select>` and `<option>` elements, simply add the | |
| Class | Description | | ||
| --- | --- | | ||
| `mdc-select` | Mandatory. | | ||
| `mdc-select--box` | Optional. Styles the select as a box select. | | ||
| `mdc-select--disabled` | Optional. Styles the select as disabled. This class should be applied to the root element when the `disabled` attribute is applied to the `<select>` element. | | ||
| `mdc-select--outlined` | Optional. Styles the select as outlined select. | | ||
| `mdc-select__native-control` | Mandatory. The native `<select>` element. | | ||
|
@@ -215,7 +199,7 @@ Mixin | Description | |
`mdc-select-focused-label-color($color)` | Customizes the label color of the select when focused. | ||
`mdc-select-bottom-line-color($color)` | Customizes the color of the default bottom line of the select. | ||
`mdc-select-focused-bottom-line-color($color)` | Customizes the color of the bottom line of the select when focused. | ||
`mdc-select-corner-radius($radius)` | Customizes the corner radius of the box variant of the select. | ||
`mdc-select-corner-radius($radius)` | Customizes the corner radius of the select. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we say "of the filled select variant" or something? Since there's a separate mixin for outlined... |
||
`mdc-select-hover-bottom-line-color($color)` | Customizes the color of the bottom line when the select is hovered. | ||
`mdc-select-outline-color($color)` | Customizes the color of the notched outline. | ||
`mdc-select-outline-corner-radius($radius)` | Sets the border radius of of the outlined select variant. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -176,3 +176,12 @@ | |
@include mdc-notched-outline-color($color); | ||
} | ||
} | ||
|
||
@mixin mdc-select-floating-label_ { | ||
.mdc-floating-label { | ||
@include mdc-rtl-reflexive-position(left, 16px); | ||
|
||
bottom: 12px; | ||
line-height: 1.75rem; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this related to any of our typography variables or mixins? Or just a component-specific value? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is required to get the notched outline to float to the correct position. This will be refactored in a follow up PR so that the notched outline requires no changes in the default version of text field and the select. |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -145,7 +145,7 @@ class MDCSelect extends MDCComponent { | |
this.outline_ = outlineFactory(outlineElement); | ||
} | ||
|
||
if (this.root_.classList.contains(cssClasses.BOX)) { | ||
if (!this.root_.classList.contains(cssClasses.OUTLINED)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems like a change of behavior. Did outlined previously not have ripples? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Never mind... I missed the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The outlined variant does not have ripples. This code used to single out the box variant to add ripples, but since there is no longer a default variant this needs to exclude the outlined variant. |
||
this.ripple = this.initRipple_(); | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,7 +34,13 @@ | |
|
||
// postcss-bem-linter: define select | ||
.mdc-select { | ||
@include mdc-select-container-fill-color(transparent); | ||
@include mdc-select-container-fill-color($mdc-select-box-fill-color); | ||
@include mdc-ripple-surface; | ||
@include mdc-ripple-radius-bounded; | ||
// Select intentionally omits press ripple, so each state needs to be specified individually. | ||
@include mdc-states-base-color($mdc-select-ink-color); | ||
@include mdc-states-hover-opacity(mdc-states-opacity($mdc-select-ink-color, hover)); | ||
@include mdc-states-focus-opacity(mdc-states-opacity($mdc-select-ink-color, focus)); | ||
@include mdc-select-dd-arrow-svg-bg_; | ||
@include mdc-select-ink-color($mdc-select-ink-color); | ||
@include mdc-select-label-color($mdc-select-label-color); | ||
|
@@ -46,20 +52,30 @@ | |
|
||
// Hover state colors | ||
@include mdc-select-hover-bottom-line-color($mdc-select-bottom-line-hover-color); | ||
@include mdc-floating-label-float-position($mdc-select-label-position-y); | ||
@include mdc-select-floating-label_; | ||
|
||
display: inline-flex; | ||
position: relative; | ||
box-sizing: border-box; | ||
height: 52px; | ||
height: 56px; | ||
border-radius: 4px 4px 0 0; | ||
background-repeat: no-repeat; | ||
background-position: right 8px bottom 12px; | ||
background-position: right 10px center; | ||
overflow: hidden; | ||
will-change: opacity, transform, color; | ||
|
||
// stylelint-disable-next-line plugin/selector-bem-pattern | ||
.mdc-floating-label { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be moved to the floating-label_ mixin you created? (Though that mixin is only seemingly invoked in one place) |
||
pointer-events: none; | ||
} | ||
|
||
@include mdc-rtl { | ||
background-position: left 8px bottom 12px; | ||
background-position: left 10px center; | ||
} | ||
|
||
&__native-control { | ||
@include mdc-rtl-reflexive-property(padding, 0, $mdc-select-arrow-padding); | ||
@include mdc-rtl-reflexive-property(padding, $mdc-select-label-padding, $mdc-select-arrow-padding); | ||
@include mdc-typography(subtitle1); | ||
|
||
&::-ms-expand { | ||
|
@@ -72,23 +88,19 @@ | |
} | ||
|
||
width: 100%; | ||
height: 56px; | ||
padding-top: 20px; | ||
padding-bottom: 4px; | ||
border: none; | ||
border-bottom: 1px solid; | ||
border-radius: 0; | ||
border-radius: 4px 4px 0 0; | ||
outline: none; | ||
background-color: transparent; | ||
white-space: nowrap; | ||
cursor: pointer; | ||
appearance: none; | ||
} | ||
|
||
// stylelint-disable-next-line plugin/selector-bem-pattern | ||
.mdc-floating-label { | ||
pointer-events: none; | ||
} | ||
|
||
@include mdc-select-focused-line-ripple_ { | ||
&::after { | ||
transform: scale(1, 2); | ||
|
@@ -97,60 +109,19 @@ | |
} | ||
} | ||
|
||
.mdc-select--box { | ||
@include mdc-select-container-fill-color($mdc-select-box-fill-color); | ||
@include mdc-ripple-surface; | ||
@include mdc-ripple-radius-bounded; | ||
// Select Box intentionally omits press ripple, so each state needs to be specified individually | ||
@include mdc-states-base-color($mdc-select-ink-color); | ||
@include mdc-states-hover-opacity(mdc-states-opacity($mdc-select-ink-color, hover)); | ||
@include mdc-states-focus-opacity(mdc-states-opacity($mdc-select-ink-color, focus)); | ||
|
||
height: 56px; | ||
border-radius: 4px 4px 0 0; | ||
background-position: right 10px center; | ||
overflow: hidden; | ||
|
||
@include mdc-rtl { | ||
background-position: left 10px center; | ||
} | ||
|
||
.mdc-select__native-control { | ||
@include mdc-rtl-reflexive-property(padding, $mdc-select-label-padding, $mdc-select-arrow-padding); | ||
|
||
height: 56px; | ||
border-radius: 4px 4px 0 0; | ||
} | ||
|
||
// stylelint-disable plugin/selector-bem-pattern | ||
.mdc-floating-label { | ||
@include mdc-rtl-reflexive-position(left, 16px); | ||
|
||
bottom: 12px; | ||
line-height: 1.75rem; | ||
|
||
&--float-above { | ||
transform: translateY(-40%) scale(.75, .75); | ||
} | ||
} | ||
// stylelint-enable plugin/selector-bem-pattern | ||
} | ||
|
||
.mdc-select--outlined { | ||
@include mdc-select-container-fill-color(transparent); | ||
@include mdc-select-outline-color($mdc-select-outlined-idle-border); | ||
@include mdc-select-hover-outline-color($mdc-select-outlined-hover-border); | ||
@include mdc-select-focused-outline-color(primary); | ||
@include mdc-floating-label-float-position($mdc-select-outlined-label-position-y); | ||
@include mdc-floating-label-shake-animation(text-field-outlined); | ||
@include mdc-select-outline-corner-radius($mdc-select-border-radius); | ||
@include mdc-states-base-color(transparent); | ||
@include mdc-select-container-fill-color(transparent); | ||
|
||
height: 56px; | ||
border: none; | ||
background-position: right 10px center; | ||
|
||
@include mdc-rtl { | ||
background-position: left 10px center; | ||
} | ||
overflow: visible; | ||
|
||
.mdc-select__native-control { | ||
@include mdc-rtl-reflexive-property(padding, $mdc-select-label-padding, $mdc-select-arrow-padding); | ||
|
@@ -165,35 +136,32 @@ | |
|
||
// stylelint-disable-next-line plugin/selector-bem-pattern | ||
.mdc-floating-label { | ||
@include mdc-rtl-reflexive-position(left, 16px); | ||
|
||
position: absolute; | ||
bottom: 20px; | ||
line-height: 1.15rem; | ||
} | ||
} | ||
|
||
.mdc-select--disabled { | ||
@include mdc-select-dd-arrow-svg-bg_($mdc-select-disabled-arrow-color); | ||
@include mdc-select-container-fill-color_($mdc-select-box-disabled-fill-color); | ||
|
||
.mdc-floating-label { | ||
@include mdc-floating-label-ink-color($mdc-select-disabled-label-color); | ||
} | ||
|
||
// stylelint-disable plugin/selector-bem-pattern | ||
// stylelint-disable-next-line plugin/selector-bem-pattern | ||
.mdc-line-ripple { | ||
display: none; | ||
} | ||
|
||
// stylelint-disable-next-line plugin/selector-bem-pattern | ||
.mdc-select__native-control { | ||
border-bottom-style: dotted; | ||
} | ||
// stylelint-enable plugin/selector-bem-pattern | ||
|
||
&.mdc-select--box { | ||
@include mdc-select-container-fill-color_($mdc-select-box-disabled-fill-color); | ||
} | ||
|
||
&.mdc-select--outlined { | ||
@include mdc-select-container-fill-color_(transparent); | ||
|
||
// stylelint-disable-next-line plugin/selector-bem-pattern | ||
.mdc-select__native-control { | ||
border-bottom-style: none; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also remove the default style deprecation notice?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should leave the deprecation notice in so people see it if they come looking for why their default variant changes.