-
Notifications
You must be signed in to change notification settings - Fork 2.1k
chore(text-field): Split out label into subelement #1693
Changes from 17 commits
63c5885
473a446
878f28d
a7a182c
7ee923c
7d8f68f
8d90707
f490e7a
61b4e48
81886dc
76eeea4
85416af
56728c6
8f2fa6f
b47759e
cd71ffd
0b01723
4b1e731
c7e9af9
a4e0020
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<!--docs: | ||
title: "Text Field Label" | ||
layout: detail | ||
section: components | ||
excerpt: "The label is a text caption or description for the text field." | ||
iconId: text_field | ||
path: /catalog/input-controls/text-fields/label/ | ||
--> | ||
|
||
# Text Field Label | ||
|
||
The label is a text caption or description for the text field. | ||
|
||
## Design & API Documentation | ||
|
||
<ul class="icon-list"> | ||
<li class="icon-list-item icon-list-item--spec"> | ||
<a href="https://material.io/guidelines/components/text-fields.html#text-fields-layout">Material Design guidelines: Text Fields Layout</a> | ||
</li> | ||
</ul> | ||
|
||
|
||
## Usage | ||
|
||
#### MDCTextFieldLabel API | ||
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. These heading levels don't make sense to me... Usage is h2, this is h4, foundation is h5, but then "using the foundation class" is h3? Now that I look, the same applies to #1697. Maybe we should have a task to iron out the subcomponents' readme formats once they all exist. 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. Filed #1707. |
||
|
||
##### MDCTextFieldLabel.foundation | ||
|
||
MDCTextFieldLabelFoundation. This allows the parent MDCTextField component to access the public methods on the MDCTextFieldLabelFoundation class. | ||
|
||
### Using the foundation class | ||
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. Same comment as on #1697 - this is documenting the adapter, so we should re-word the heading or add a sentence. |
||
|
||
Method Signature | Description | ||
--- | --- | ||
addClass(className: string) => void | Adds a class to the label element | ||
removeClass(className: string) => void | Removes a class from the label element | ||
|
||
#### The full foundation API | ||
|
||
##### MDCTextFieldLabelFoundation.floatAbove() | ||
|
||
Makes the label float above the text field. | ||
|
||
##### MDCTextFieldLabelFoundation.deactivateFocus(shouldRemoveLabelFloat: boolean) | ||
|
||
Deactivates the label's focus state. | ||
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. We should still explain what the parameter does here, e.g. " 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. Done! |
||
|
||
##### MDCTextFieldLabelFoundation.setValidity(isValid: boolean) | ||
|
||
Updates the label's valid state based on the supplied validity. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 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 Text Field Label. | ||
* | ||
* Defines the shape of the adapter expected by the foundation. Implement this | ||
* adapter to integrate the Text Field label into your framework. See | ||
* https://github.com/material-components/material-components-web/blob/master/docs/authoring-components.md | ||
* for more information. | ||
* | ||
* @record | ||
*/ | ||
class MDCTextFieldLabelAdapter { | ||
/** | ||
* Adds a class to the label element. | ||
* @param {string} className | ||
*/ | ||
addClass(className) {} | ||
|
||
/** | ||
* Removes a class from the label element. | ||
* @param {string} className | ||
*/ | ||
removeClass(className) {} | ||
} | ||
|
||
export default MDCTextFieldLabelAdapter; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** | ||
* @license | ||
* Copyright 2016 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. | ||
*/ | ||
|
||
/** @enum {string} */ | ||
const cssClasses = { | ||
LABEL_FLOAT_ABOVE: 'mdc-text-field__label--float-above', | ||
LABEL_SHAKE: 'mdc-text-field__label--shake', | ||
}; | ||
|
||
export {cssClasses}; |
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.
Didn't catch this when I looked at earlier PRs, but I'm wondering whether it really makes sense to have this heading in the subcomponents' readmes.