Skip to content

[RaisedButton] Respect theme fontSize#3988

Merged
mbrookes merged 1 commit intomui:masterfrom
echenley:bugfix/raised-button-font-size
May 12, 2016
Merged

[RaisedButton] Respect theme fontSize#3988
mbrookes merged 1 commit intomui:masterfrom
echenley:bugfix/raised-button-font-size

Conversation

@echenley
Copy link
Copy Markdown
Contributor

@echenley echenley commented Apr 14, 2016

RaisedButton label fontSize is hard coded as 14px. This PR allows the theme to override it.

Quick question: Is this the way you guys are doing it? There are styles all over that don't inherit from the theme, and this seems like a pretty heavy-handed way of dealing with it. I do see why it's complicated with multiple nested elements inheriting from a single config object. Just wondering what the idea is for this. Thanks!

@oliviertassinari
Copy link
Copy Markdown
Member

Quick question: Is this the way you guys are doing it?

I'm using the labelStyle property.

Comment thread src/RaisedButton/RaisedButton.js Outdated
verticalAlign: 'middle',
opacity: 1,
fontSize: '14px',
fontSize: raisedButton.fontSize || button.fontSize || '14px',
Copy link
Copy Markdown
Member

@oliviertassinari oliviertassinari Apr 18, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that we should follow the FlatButton implementation.
What about applying the fontSize at the root of the component and adding raisedButton.fontSize: typography.fontStyleButtonFontSize into getMuiTheme.js?
Then using this using this value here instead of the hard coded 14px?

@mbrookes
Copy link
Copy Markdown
Member

mbrookes commented May 7, 2016

@echenley are you still working on this?

@echenley
Copy link
Copy Markdown
Contributor Author

echenley commented May 7, 2016

@mbrookes Ah sorry, I forgot about this. I'll take a look today.

@echenley
Copy link
Copy Markdown
Contributor Author

echenley commented May 7, 2016

@mbrookes This should work. Do you think it's worth adding a test for it?

@echenley echenley force-pushed the bugfix/raised-button-font-size branch from 8381bb3 to 2292790 Compare May 7, 2016 18:39
@mbrookes
Copy link
Copy Markdown
Member

mbrookes commented May 7, 2016

Thanks @echenley tests are always welcome, so if you wouldn't mind, that would be great!

@mbrookes
Copy link
Copy Markdown
Member

mbrookes commented May 7, 2016

Also, since the commit history is most just rebases etc, you can go ahead and squash these, and the test when it's ready.

@echenley echenley force-pushed the bugfix/raised-button-font-size branch from 2292790 to 5590584 Compare May 7, 2016 18:46
Comment thread src/RaisedButton/RaisedButton.js Outdated
position: 'relative',
opacity: 1,
fontSize: '14px',
fontSize: raisedButton.fontSize || button.fontSize,
Copy link
Copy Markdown
Contributor Author

@echenley echenley May 7, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mbrookes Now that I look at it, there's no point in keeping || button.fontSize, since raisedButton.fontSize will always be defined, right? Unless someone purposefully sets it to something falsy.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True. 👍

@echenley echenley force-pushed the bugfix/raised-button-font-size branch from 5590584 to ea30623 Compare May 7, 2016 19:24
@echenley
Copy link
Copy Markdown
Contributor Author

echenley commented May 7, 2016

Should be good to go!

Comment thread docs/package.json Outdated
"eslint-plugin-react": "^5.0.1",
"highlight.js": "^9.0.0",
"history": "^2.0.0",
"html-webpack-plugin": "^2.16.1",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@echenley it isn't missing - we removed it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, actually, that's my mistake. I need to update the webpack dev-server config to match the production one.

Copy link
Copy Markdown
Contributor Author

@echenley echenley May 7, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha, I removed the commit!

@echenley echenley force-pushed the bugfix/raised-button-font-size branch from ea30623 to 844f56a Compare May 7, 2016 20:53
@mbrookes
Copy link
Copy Markdown
Member

mbrookes commented May 7, 2016

Looks good. Thanks @echenley 👍

Comment thread src/RaisedButton/RaisedButton.spec.js Outdated
});

it('inherits fontSize from theme', () => {
const wrapper = mountWithContext(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we use the shallow rendering instead? I don't think that we need to mount the component to test this behavior.

Copy link
Copy Markdown
Contributor Author

@echenley echenley May 8, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately not. Shallow rendering doesn't go deep enough to render the label. Edit: actually, I may be wrong.

Copy link
Copy Markdown
Member

@oliviertassinari oliviertassinari May 8, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reading at the source code. I think that we can.
Even if we were using an internal RaisedButtonLabel, we could just make sure the right style props is applied.

@echenley echenley force-pushed the bugfix/raised-button-font-size branch 2 times, most recently from ea52377 to 884c36d Compare May 8, 2016 19:35
<RaisedButton label="test" />
);

assert.strictEqual(wrapper.contains('test'), true);
Copy link
Copy Markdown
Contributor Author

@echenley echenley May 8, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about this? wrapper.text() doesn't work since there are non-primitive components in the way (it just returns '<Paper />'). The alternative is something like wrapper.find('EnhancedButton').childAt(0).text().

@oliviertassinari
Copy link
Copy Markdown
Member

@echenley The commit message isn't following the PR title. Aside from this minor issue. That looks great 👍.

@echenley echenley force-pushed the bugfix/raised-button-font-size branch from 884c36d to 54d8223 Compare May 9, 2016 19:43
@echenley echenley changed the title [RaisedButton] Respect theme fontSize in <RaisedButton> [RaisedButton] Respect theme fontSize May 9, 2016
@echenley
Copy link
Copy Markdown
Contributor Author

echenley commented May 9, 2016

@oliviertassinari Oops, updated and removed the redundancy!

@mbrookes mbrookes merged commit 8c0ec6f into mui:master May 12, 2016
@mbrookes
Copy link
Copy Markdown
Member

@echenley Thanks! 👍

@zannager zannager added scope: button Changes related to the button. customization: theme Higher level theming customizability. labels Mar 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

customization: theme Higher level theming customizability. scope: button Changes related to the button.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants