Skip to content

Conversation

@tintin1343
Copy link
Contributor

  • PR has tests / docs demo, and is linted.
  • Commit and PR titles begin with [ComponentName], and are in imperative form: "[Component] Fix leaky abstraction".
  • Description explains the issue / use-case resolved, and auto-closes the related issue(s) (http://tr.im/vFqem).

Resolves: #4144

color prop of icon was not being passed to the icon used within a flat-button

Replaced color: mergedRootStyles.color, with color: icon.props.color, and that fixed it.

    <FlatButton
      backgroundColor="#a4c639"
      hoverColor="#8AA62F"
      icon={<ActionAndroid color={fullWhite} />}
      style={style}
    />

screen shot 2016-05-04 at 2 22 38 pm

if (icon) {
iconCloned = React.cloneElement(icon, {
color: mergedRootStyles.color,
color: icon.props.color,
Copy link
Member

Choose a reason for hiding this comment

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

icon.props.color || mergedRootStyles.color ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh yeah..shoot. I missed the case when there is not color prop passed.

Thanks @mbrookes for pointing it out.

@oliviertassinari
Copy link
Member

@tintin1343 That looks good. Do you want to write a test for this specific case?

@tintin1343
Copy link
Contributor Author

tintin1343 commented May 5, 2016

@oliviertassinari : Yeah sure. Let me give it a try.

@tintin1343
Copy link
Contributor Author

@oliviertassinari : Done.

/>
);
const icon = wrapper.children().at(0);
assert.equal(icon.prop('color'), 'white', 'icon should have same color as that of color prop');
Copy link
Member

Choose a reason for hiding this comment

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

strictEqual

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

<FlatButton
backgroundColor="#a4c639"
hoverColor="#8AA62F"
icon={<ActionAndroid color={'white'} />}
Copy link
Member

Choose a reason for hiding this comment

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

I would put 'white' in a variable so the link is explicit in the test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alright. Thats a good idea.

@oliviertassinari
Copy link
Member

@tintin1343 That looks good, nice 👍.

@oliviertassinari oliviertassinari added this to the 0.15.1 Release milestone May 5, 2016
@tintin1343
Copy link
Contributor Author

tintin1343 commented May 5, 2016

Rebase Done.

});

it('colors the icon with the passed color in prop', () => {
let color = 'white';
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't it be const?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right. I changed it to const

@mbrookes mbrookes merged commit 8d68fb9 into mui:master May 6, 2016
@oliviertassinari
Copy link
Member

@tintin1343 Nice!

@zannager zannager added component: Icon The React component. scope: button Changes related to the button. labels Mar 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: Icon The React component. scope: button Changes related to the button.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FlatButton] icon props are not passed through

4 participants