-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
[TextField] Initial implementation of optional underline #2476
Conversation
On a separate note: If we like the idea of using a separate component for the |
@@ -55,6 +55,7 @@ const TextField = React.createClass({ | |||
rowsMax: React.PropTypes.number, | |||
style: React.PropTypes.object, | |||
type: React.PropTypes.string, | |||
underline: React.PropTypes.bool, |
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.
maybe underlineVisible
? underline
feels like you need to pass the "Underline" node through this prop. @oliviertassinari Thoughts?
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.
Yeah that's true, I can see that being confused for a prop that accept a component.
Naming things is hard 😸
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.
Naming things is hard
Couldn't agree more >.>
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.
what about underlineShow
?
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.
that's good too 😬
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.
Let me know which one you want! I'm fine with either 😄
Now that I think about it, as a general rule, using a "positive-form" adjective might have a slight advantage over a verb/noun because some people specify boolean props as truthy without explicitly specifying the value of the prop as true.
For example some people and use eslint rules for this pattern:
/* CORRECT */
<Component
active
/>
/* WRONG */
<MyComponent
active={true}
/>
/* CORRECT */
<MyComponent
active={false}
/>
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.
go with underlineShow
, easier to spell 😬
@oliviertassinari Do you think the generator can understand stateless functional components? (or whatever the hell facebook finally decides to call them) |
nice 👍 |
Yeah I really like stateless functional components if you haven't realized 😅 I wanted to "test the waters" to see what you two thought, if you'd prefer me to write it |
@newoga I like them too, besides there can be heavily optimized by React, when they actually get around to it. I'm alright with this. @oliviertassinari ?should be migrate the stateless components to take advantage of these things? |
If we go through with this, I'll throw out another style question/suggestion: If we followed Airbnb's style guide, for example, we would define the So we would make this change to the order...: import React from 'react';
const propTypes = {
};
const defaultProps = {
};
const TextFieldUnderline = (props) => {
// impl
}
TextFieldUnderline.propTypes = propTypes;
TextFieldUnderline.defaultProps = defaultProps;
export default TextFieldUnderline; Personally, I think I like this more so that when we add documentation to the props, they remain at the top of the file above the implementation instead of at the bottom... |
I want to enforce |
According to the react doc about the stateless component:
Seems like as soon as we don't need a state, we should use this pattern 👍 |
@oliviertassinari Yeah, this is a great pattern. 👍 👍 |
Yay! 🎆 |
I think I'm pretty much done with this too. Let me know if you need anything else, otherwise I can squash and push. Note: This pull request and #2473 has the same change to |
😱 😱 😱 You did a merge instead of rebase in your branch :D :D You're gonna hate git for the first time in your life when you try to squash this :D I'll review right away P.S. I had this issue before, I can help you if you get clueless. |
@newoga I'm all good @oliviertassinari Take a look too. |
Looks fine so far, I'm gonna test it. |
@newoga @subjectix @oliviertassinari
|
disabled: React.PropTypes.bool, | ||
|
||
/** | ||
* Override the inline-styles of the underline when parent TextField is disabled |
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.
What about considering the descriptions as a phrase and adding a dot at the end?
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.
and use markdown in them too 😁
I think that we should create a
|
@oliviertassinari I agree on the folder/new naming structure. Also, at some point in the future I think it'd be nice if the import matched the component name like mentioned in #1793. Would it make sense to export the component under two names and deprecate the access to the other one?
Maybe we could make a util file like import warning from 'warning';
function deprecatedExport(Component, deprecated, supported) {
warning(false,
`Importing ${Component.displayName} from '${deprecated}' has been deprecated, use '${supported}' instead.`);
return Component;
}
export default deprecatedExport; And then, like you suggested, we can rewrite import TextField from './TextField';
import deprecatedExport from './deprecatedExport';
export default deprecatedExport(TextField, 'material-ui/lib/text-field', 'material-ui/lib/TextField'); |
@newoga I like your idea 👍 👍 |
@oliviertassinari @subjectix If we like this |
@newoga I'm ok with this 👍. |
@newoga Yeah that's a great idea 👍 |
Alright, I changed this set of components to the new PascalCase format in an appropriate I also made some documentation improvements like adding periods and markdown formatting such as code hint @oliviertassinari, you had mentioned previously that you think the descriptions should be phrases with a period at the end. I added a period, but could you please give me an example description for one of the props? 😄 Just want to make sure I understand you correctly, I can fix the others afterwards. |
@newoga The description is fine now. My point was simply to add a dot at the end. |
Oh okay, sounds good. I'll squash now. |
d6d8118
to
9e6b777
Compare
@newoga Thanks a lot. you're a huge help 👍 👍 |
[WIP][TextField] Initial implementation of optional underline
This resolves #2475. Related to and possibly fixes #2448 and #2233.
Done:
text-field-underline.jsx
component that defines its own style defaults, acceptsdisable
,focus
, anderror
state, and disabled, focus, and error style override configuration through propstext-field.jsx
to pass underlineStyle configurations totext-field-underline.jsx
componentTodo:
- Create disabled underline example in docsWill do in a separate pull request since the TextField docs still need to be migrated to the new format.Note:
The new
text-field-underline.jsx
currently takes themuiTheme
through props from its parenttext-field.jsx
component. Stateless components also support context if we wanted to to make it work like the other components. Though for components like this that aren't meant to be alone, maybe we should consider accepting everything through props for simplicity. I'm open to discussing this though.