-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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(select): Add outlined variant #2674
Changes from 8 commits
41fa1df
961bf53
f00d2e4
33e3c00
2310855
b4d5c8c
c7aca7a
68d2f36
53be11f
7a92d56
d7fa67f
a9290b6
644a9df
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 |
---|---|---|
|
@@ -18,6 +18,7 @@ | |
|
||
$mdc-select-arrow-padding: 26px; | ||
$mdc-select-label-padding: 16px; | ||
$mdc-select-border-radius: 4px !default; | ||
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. remove this !default in favor of the sass mixin |
||
|
||
$mdc-select-ink-color: rgba(mdc-theme-prop-value(on-surface), .87); | ||
$mdc-select-disabled-ink-color: rgba(mdc-theme-prop-value(on-surface), .37); | ||
|
@@ -32,3 +33,12 @@ $mdc-select-bottom-line-hover-color: rgba(mdc-theme-prop-value(on-surface), .87) | |
|
||
$mdc-select-box-fill-color: mix(mdc-theme-prop-value(on-surface), mdc-theme-prop-value(surface), 4%); | ||
$mdc-select-box-disabled-fill-color: mix(mdc-theme-prop-value(on-surface), mdc-theme-prop-value(surface), 2%); | ||
|
||
$mdc-select-outlined-idle-border: rgba(mdc-theme-prop-value(on-surface), .24); | ||
|
||
// should be .06 after mdc-select opacity is applied | ||
$mdc-select-outlined-disabled-border: rgba(mdc-theme-prop-value(on-surface), .16); | ||
$mdc-select-outlined-hover-border: rgba(mdc-theme-prop-value(on-surface), .87); | ||
|
||
$mdc-select-outlined-label-position-y: 130%; | ||
$mdc-select-outlined-dense-label-position-y: 110%; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,13 +15,17 @@ | |
*/ | ||
|
||
import {MDCFoundation} from '@material/base/index'; | ||
import {cssClasses, strings} from './constants'; | ||
import {cssClasses, strings, numbers} from './constants'; | ||
|
||
export default class MDCSelectFoundation extends MDCFoundation { | ||
static get cssClasses() { | ||
return cssClasses; | ||
} | ||
|
||
static get numbers() { | ||
return numbers; | ||
} | ||
|
||
static get strings() { | ||
return strings; | ||
} | ||
|
@@ -30,6 +34,7 @@ export default class MDCSelectFoundation extends MDCFoundation { | |
return { | ||
addClass: (/* className: string */) => {}, | ||
removeClass: (/* className: string */) => {}, | ||
hasClass: (/* className: string */) => false, | ||
floatLabel: (/* value: boolean */) => {}, | ||
activateBottomLine: () => {}, | ||
deactivateBottomLine: () => {}, | ||
|
@@ -40,6 +45,12 @@ export default class MDCSelectFoundation extends MDCFoundation { | |
setDisabled: (/* disabled: boolean */) => {}, | ||
getValue: () => /* string */ '', | ||
setValue: (/* value: string */) => {}, | ||
isRtl: () => false, | ||
hasLabel: () => {}, | ||
getLabelWidth: () => {}, | ||
hasOutline: () => {}, | ||
notchOutline: () => {}, | ||
closeOutline: () => {}, | ||
}; | ||
} | ||
|
||
|
@@ -86,10 +97,12 @@ export default class MDCSelectFoundation extends MDCFoundation { | |
floatLabelWithValue_() { | ||
const optionHasValue = this.adapter_.getValue().length > 0; | ||
this.adapter_.floatLabel(optionHasValue); | ||
this.notchOutline(optionHasValue); | ||
} | ||
|
||
handleFocus_() { | ||
this.adapter_.floatLabel(true); | ||
this.notchOutline(true); | ||
this.adapter_.activateBottomLine(); | ||
} | ||
|
||
|
@@ -101,4 +114,23 @@ export default class MDCSelectFoundation extends MDCFoundation { | |
handleSelect_() { | ||
this.setSelectedIndex(this.adapter_.getSelectedIndex()); | ||
} | ||
|
||
/** | ||
* Opens/closes the notched outline. | ||
* @param {boolean} openNotch | ||
*/ | ||
notchOutline(openNotch) { | ||
if (!this.adapter_.hasOutline() || !this.adapter_.hasLabel()) { | ||
return; | ||
} | ||
|
||
if (openNotch) { | ||
const labelScale = numbers.LABEL_SCALE; | ||
const labelWidth = this.adapter_.getLabelWidth() * labelScale; | ||
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. I think you want a dense alternative here. See https://github.com/material-components/material-components-web/blob/feat/select/add-outlined-variant/packages/mdc-textfield/foundation.js#L205 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 select doesn't have a |
||
const isRtl = this.adapter_.isRtl(); | ||
this.adapter_.notchOutline(labelWidth, isRtl); | ||
} else { | ||
this.adapter_.closeOutline(); | ||
} | ||
} | ||
} |
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.
This should be public