-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(select): update select as per MDCWeb 0.37.0
Also add support for outlined select
- Loading branch information
Showing
6 changed files
with
258 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<template> | ||
<label | ||
:class="labelClasses" | ||
class="mdc-floating-label"> | ||
<slot /> | ||
</label> | ||
</template> | ||
|
||
<script> | ||
import MDCFloatingLabelFoundation from '@material/floating-label/foundation' | ||
export default { | ||
name: 'mdc-select-label', | ||
data() { | ||
return { | ||
labelClasses: {} | ||
} | ||
}, | ||
mounted() { | ||
this.foundation = new MDCFloatingLabelFoundation({ | ||
addClass: className => { | ||
this.$set(this.labelClasses, className, true) | ||
}, | ||
removeClass: className => { | ||
this.$delete(this.labelClasses, className) | ||
}, | ||
getWidth: () => this.$el.offsetWidth, | ||
registerInteractionHandler: (evtType, handler) => { | ||
this.$el.addEventListener(evtType, handler) | ||
}, | ||
deregisterInteractionHandler: (evtType, handler) => { | ||
this.$el.removeEventListener(evtType, handler) | ||
} | ||
}) | ||
this.foundation.init() | ||
}, | ||
beforeDestroy() { | ||
let foundation = this.foundation | ||
this.foundation = null | ||
foundation.destroy() | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<template> | ||
<div | ||
:class="lineClasses" | ||
:style="lineStyles" | ||
class="mdc-line-ripple"/> | ||
</template> | ||
|
||
<script> | ||
import MDCLineRippleFoundation from '@material/line-ripple/foundation' | ||
export default { | ||
name: 'mdc-select-line-ripple', | ||
data() { | ||
return { | ||
lineClasses: {}, | ||
lineStyles: {} | ||
} | ||
}, | ||
mounted() { | ||
this.foundation = new MDCLineRippleFoundation({ | ||
addClass: className => { | ||
this.$set(this.lineClasses, className, true) | ||
}, | ||
removeClass: className => { | ||
this.$delete(this.lineClasses, className) | ||
}, | ||
hasClass: className => { | ||
this.$el.classList.contains(className) | ||
}, | ||
setStyle: (name, value) => { | ||
this.$set(this.lineStyles, name, value) | ||
}, | ||
registerEventHandler: (evtType, handler) => { | ||
this.$el.addEventListener(evtType, handler) | ||
}, | ||
deregisterEventHandler: (evtType, handler) => { | ||
this.$el.removeEventListener(evtType, handler) | ||
} | ||
}) | ||
this.foundation.init() | ||
}, | ||
beforeDestroy() { | ||
let foundation = this.foundation | ||
this.foundation = null | ||
foundation.destroy() | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<template> | ||
<div> | ||
<div | ||
ref="outlined" | ||
:class="outlinedClasses" | ||
class="mdc-notched-outline"> | ||
<svg> | ||
<path | ||
ref="outlinedPath" | ||
class="mdc-notched-outline__path"/> | ||
</svg> | ||
</div> | ||
<div | ||
ref="outlinedIdle" | ||
class="mdc-notched-outline__idle"/> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import MDCnotchedOutlineFoundationFoundation from '@material/notched-outline/foundation' | ||
export default { | ||
name: 'mdc-select-notched-outline', | ||
data() { | ||
return { | ||
outlinedClasses: {} | ||
} | ||
}, | ||
mounted() { | ||
this.foundation = new MDCnotchedOutlineFoundationFoundation({ | ||
getWidth: () => this.$refs.outlined.offsetWidth, | ||
getHeight: () => this.$refs.outlined.offsetHeight, | ||
addClass: className => { | ||
this.$set(this.outlinedClasses, className, true) | ||
}, | ||
removeClass: className => { | ||
this.$delete(this.outlinedClasses, className) | ||
}, | ||
setOutlinePathAttr: value => { | ||
const path = this.$refs.outlinedPath | ||
path.setAttribute('d', value) | ||
}, | ||
getIdleOutlineStyleValue: propertyName => { | ||
return window | ||
.getComputedStyle(this.$refs.outlinedIdle) | ||
.getPropertyValue(propertyName) | ||
} | ||
}) | ||
this.foundation.init() | ||
}, | ||
beforeDestroy() { | ||
let foundation = this.foundation | ||
this.foundation = null | ||
foundation.destroy() | ||
} | ||
} | ||
</script> |
Oops, something went wrong.