From ae9cc91fbf320a76dc7972b14a02fd8ec093bc2c Mon Sep 17 00:00:00 2001 From: Rajendran Nadar Date: Mon, 10 Dec 2018 11:23:09 +0000 Subject: [PATCH] feat: ability to change button text case (#674) --- src/components/Button.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/components/Button.js b/src/components/Button.js index 5fbea60..440877d 100644 --- a/src/components/Button.js +++ b/src/components/Button.js @@ -48,6 +48,10 @@ type Props = React.ElementConfig & {| * Label text of the button. */ children: React.Node, + /** + * Make the label text uppercased. Note that this won't work if you pass React elements as children. + */ + uppercase: boolean, /** * Accessibility label for the button. This is read by the screen reader when the user taps the button. */ @@ -102,6 +106,7 @@ type State = { class Button extends React.Component { static defaultProps = { mode: 'text', + uppercase: true, }; state = { @@ -136,6 +141,7 @@ class Button extends React.Component { icon, color: buttonColor, children, + uppercase, accessibilityLabel, onPress, style, @@ -262,7 +268,9 @@ class Button extends React.Component { {React.Children.map( children, child => - typeof child === 'string' ? child.toUpperCase() : child + typeof child === 'string' && uppercase + ? child.toUpperCase() + : child )}