-
-
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
Use 'em' to size TextField elements relatively to fontSize #2039
Conversation
@thomasguillory Interesting approach, could you add an example of this in the documentation? |
@oliviertassinari The advantage of computed values over Also, don't you think that such a modification should be done for every material-ui components and not only |
IMO the
I would say no. Do you have a specific component in mind? |
fc39c5f
to
4665e74
Compare
@oliviertassinari I did the missing changes. There is however one gotcha: We would have the same problem if we decided to compute everything using |
I would say that right now, people are not using the @shaurya947 Are you ok to use |
@thomasguillory @oliviertassinari if I understand correctly, what we're proposing is that the user would need to pass in a If that is the case, I'm good with that. I think most people are already using |
@@ -414,6 +414,10 @@ const TextField = React.createClass({ | |||
} | |||
}, | |||
|
|||
_getFontSize() { | |||
return this.props.style && this.props.style.fontSize ? this.props.style.fontSize : 16; |
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.
Could we add a warning in the dev environment if the fontSize is not a number?
We could use some things like babel-plugin-dev-expression
with warning
.
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.
Would you mind showing a more explicit example?
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.
@celiao We already have an example. IMO it's fine. What's missing?
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.
@oliviertassinari warning added, but without babel-plugin-dev-expression
, as you have seen here #2107
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.
@thomasguillory Awesome. I will test it as soon as I have some time.
Currently TextField is using fixed pixel values to size the different elements composing the component. However, if one wants to change the size of the component to fit a given design, it's hard to achieve as there is many sizings to manually set. This commit is a proposal to size the inner parts of the component relatively to the fontSize property of its root element, so it's the only property the user needs to touch.
4665e74
to
d60cd20
Compare
d60cd20
to
580feaa
Compare
@@ -416,6 +417,17 @@ const TextField = React.createClass({ | |||
} | |||
}, | |||
|
|||
_getFontSize() { | |||
if (this.props.style && this.props.style.fontSize) { | |||
if (process.env.NODE_ENV !== 'production') { |
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.
if (process.env.NODE_ENV !== 'production') {
is not needed anymore. It will be automaticaly added by the babel plugin. Could you remove it?
I have just tried your PR. It seems that the height of the HintText changed and that the Floating Label is too high on the example you added. I feel like using |
An interesting approach. But given the subsequent and planned changes around styling, I'm closing for now. We can reopen if there's still merit. |
Currently TextField is using fixed pixel values to size the different
elements composing the component. However, if one wants to change the
size of the component to fit a given design, it's hard to achieve as
there is many sizings to manually set.
This commit is a proposal to size the inner parts of the component
relatively to the fontSize property of its root element, so it's the
only property the user needs to touch.