-
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
fix(select): add adapter #3233
Merged
Merged
fix(select): add adapter #3233
Changes from 12 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
63f4696
WIP: closure
e63a2ed
WIP: Closure
974641d
Merge branch 'master' into fix/select/add-adapter
0ee43f8
WIP: update readme
cc624d2
t Merge branch 'fix/select/add-adapter' of github.com:material-compon…
9967eb8
WIP: closure test
9e8c99c
Merge branch 'master' into fix/select/add-adapter
044830e
fix: PR updates
9dc3f0b
Merge branch 'fix/select/add-adapter' of github.com:material-componen…
59d39df
Merge branch 'master' into fix/select/add-adapter
1776e5c
WIP Consistency and typo fixes
3200c8e
Merge branch 'master' into fix/select/add-adapter
e31bc21
Merge branch 'master' into fix/select/add-adapter
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,117 @@ | ||
/** | ||
* @license | ||
* Copyright 2018 Google Inc. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/* eslint no-unused-vars: [2, {"args": "none"}] */ | ||
|
||
/** | ||
* Adapter for MDC Select. Provides an interface for managing | ||
* - classes | ||
* - dom | ||
* - event handlers | ||
* | ||
* Additionally, provides type information for the adapter to the Closure | ||
* compiler. | ||
* | ||
* Implement this adapter for your framework of choice to delegate updates to | ||
* the component in your framework of choice. See architecture documentation | ||
* for more details. | ||
* https://github.com/material-components/material-components-web/blob/master/docs/code/architecture.md | ||
* | ||
* @record | ||
*/ | ||
|
||
class MDCSelectAdapter { | ||
/** | ||
* Adds class to root element. | ||
* @param {string} className | ||
*/ | ||
addClass(className) {} | ||
|
||
/** | ||
* Removes a class from the root element. | ||
* @param {string} className | ||
*/ | ||
removeClass(className) {} | ||
|
||
/** | ||
* Returns true if the root element contains the given class name. | ||
* @param {string} className | ||
* @return {boolean} | ||
*/ | ||
hasClass(className) {} | ||
|
||
/** | ||
* Activates the bottom line, showing a focused state. | ||
*/ | ||
activateBottomLine() {} | ||
|
||
/** | ||
* Deactivates the bottom line. | ||
*/ | ||
deactivateBottomLine() {} | ||
|
||
/** | ||
* Returns the selected value of the select element. | ||
* @return {string} | ||
*/ | ||
getValue() {} | ||
|
||
/** | ||
* Returns true if the direction of the root element is set to RTL. | ||
* @return {boolean} | ||
*/ | ||
isRtl() {} | ||
|
||
/** | ||
* Returns true if label element exists, false if it doesn't. | ||
* @return {boolean} | ||
*/ | ||
hasLabel() {} | ||
|
||
/** | ||
* Floats label determined based off of the shouldFloat argument. | ||
* @param {boolean} shouldFloat | ||
*/ | ||
floatLabel(shouldFloat) {} | ||
|
||
/** | ||
* Returns width of label in pixels, if the label exists. | ||
* @return {number} | ||
*/ | ||
getLabelWidth() {} | ||
|
||
/** | ||
* Returns true if outline element exists, false if it doesn't. | ||
* @return {boolean} | ||
*/ | ||
hasOutline() {} | ||
|
||
/** | ||
* Updates SVG Path and outline element based on the | ||
* label element width and RTL context, if the outline exists. | ||
* @param {number} labelWidth | ||
* @param {boolean=} isRtl | ||
*/ | ||
notchOutline(labelWidth, isRtl) {} | ||
|
||
/** | ||
* Closes notch in outline element, if the outline exists. | ||
*/ | ||
closeOutline() {} | ||
} | ||
|
||
export default MDCSelectAdapter; |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 have typically kept correlated APIs together, so can we move removeClass and hasClass back here, and put APIs for the label / outline each together, etc?
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.
gotcha - i alpha sorted