Skip to content

Conversation

@Andrewpk
Copy link

This PR loosens the requirements on children and allows any number of elements nested inside a button as long as they're either a string, or valid react elements.

The button textStyle property is optional and only applied to bare strings. If you specify child elements that are of <Text> type, you'll want to specify your own style on that <Text> element. This keeps the original functionality but expands upon it for further customization.

@alvaromb
Copy link
Collaborator

Thanks @Andrewpk!

Will review and test tomorrow. Can you squash your commits??

@Andrewpk
Copy link
Author

@alvaromb sure!

@Andrewpk Andrewpk closed this May 12, 2016
@Andrewpk Andrewpk force-pushed the fix-renderable-children branch from 6ff23eb to 3abb743 Compare May 12, 2016 02:34
@Andrewpk Andrewpk reopened this May 12, 2016
@Andrewpk
Copy link
Author

@alvaromb Also, I think you can have merges default squashed as a repository owner now as well:
https://github.com/blog/2141-squash-your-commits

@alvaromb alvaromb added this to the 3.0 milestone May 20, 2016
@alvaromb alvaromb self-assigned this May 20, 2016
@alvaromb
Copy link
Collaborator

Sorry for the delay @Andrewpk, too much work happening here right now. Would this close #15, right?

@Andrewpk
Copy link
Author

No worries. I hope all is well. I've been using my PR branch in my project for about a week now. You are correct, it would fix and close #15 as well.

-Andrew

On May 20, 2016, at 9:54 AM, Álvaro Medina Ballester notifications@github.com wrote:

Sorry for the delay @Andrewpk, too much work happening here right now. Would this close #15, right?


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub

@Andrewpk Andrewpk force-pushed the fix-renderable-children branch from 5c5ea40 to 3fb8fa0 Compare June 6, 2016 03:35
@Andrewpk
Copy link
Author

Andrewpk commented Jun 6, 2016

Sorry for wiping out some history here but I'm trying to keep my commits to one as you requested. I recently merged in master.

@alvaromb
Copy link
Collaborator

Hello @Andrewpk!

I've just tested the code, could you please update your PR with the latest changes on master? I can merge today this.

Thanks!

@Andrewpk Andrewpk force-pushed the fix-renderable-children branch from 3fb8fa0 to b0256fe Compare June 27, 2016 04:51
@Andrewpk
Copy link
Author

@alvaromb sorry for the delay - merged in, rebased and pushed!

@alvaromb
Copy link
Collaborator

@Andrewpk the PR looks good, I'm testing it right now.

However the example throws a warning because in the iterator you should define some key to the elements:

screen shot 2016-06-27 at 10 35 46

Can you update this and check that all tabs are set to two spaces? Squash your commits if you can, too 😊

@alvaromb
Copy link
Collaborator

Just one more thing, can you document these changes into the README.md?

@Andrewpk
Copy link
Author

Sure. I forgot I made that change locally and never pushed 😓

@Andrewpk Andrewpk force-pushed the fix-renderable-children branch 2 times, most recently from c880ebb to 0e9bf49 Compare June 27, 2016 17:56
@Andrewpk
Copy link
Author

Andrewpk commented Jun 27, 2016

I updated the README.md and changed the children requirements a bit. Hopefully my documentation is descriptive enough to be useful.
I changed the looseness of allowing a child to be of type PropTypes.node due to potential issues with a javascript array containing numbers or strings being passed as a child. In the current implementation, you can have a var someNum = 3; and pass {someNum} as a child and it will be properly wrapped in a <Text> element, but if you were to pass var someNums = [3, 4, 5] as {someNums} for a <Button>'s child, it would not render them. This could be an area for future enhancement if someone needs this functionality, but for now I felt that the current implementation worked well.
So as a summary, the current requirements for children are that a <Button> can now have any number of:

  • string
  • number
  • React.PropTypes.Element

… allowed. Multiple children can be nested in a single Button element. Added information to Readme.

Changed PropTypes.node allowance to PropTypes.number. This way we don't have to check if an array of numbers or strings was passed via variable.
Had to change required child to be of type PropTypes.node otherwise numbers passed in jsx variables would be denied.
@Andrewpk Andrewpk force-pushed the fix-renderable-children branch from 0e9bf49 to a8d93c5 Compare June 27, 2016 20:42
@Andrewpk
Copy link
Author

Had to make one more change, going back to allowing the react type of children to be of type React.PropTypes.node otherwise numbers passed to <Button> via JSX variables were denied.

@alvaromb
Copy link
Collaborator

Thanks @Andrewpk! Will check and test the code now.

Do you have any cool example that I can insert into the Example project and display it in the screenshots?

@Andrewpk
Copy link
Author

@alvaromb The best example I have is using buttons with icons from a vector icon library that uses font awesome. Do you have any issues with me adding an external dependency to the example project in order to bring the icons in?

@Andrewpk
Copy link
Author

@alvaromb as an alternative to pulling in a dependency, I could make a examples with nested <Image>s.

@alvaromb alvaromb mentioned this pull request Jul 15, 2016
@alvaromb
Copy link
Collaborator

Closing by #45.

@alvaromb alvaromb closed this Jul 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants