Skip to content

Commit bbf5b19

Browse files
lukefanningmastermoo
authored andcommitted
Added numberOfLines prop for text truncation (#312)
feat: add numberOfLines prop to ActionButtonItem for text truncation
1 parent 5f25552 commit bbf5b19

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

ActionButtonItem.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ export default class ActionButtonItem extends Component {
3434
useNativeFeedback: true,
3535
activeOpacity: DEFAULT_ACTIVE_OPACITY,
3636
fixNativeFeedbackRadius: false,
37-
nativeFeedbackRippleColor: "rgba(255,255,255,0.75)"
37+
nativeFeedbackRippleColor: "rgba(255,255,255,0.75)",
38+
numberOfLines: 1,
3839
};
3940
}
4041

@@ -44,7 +45,8 @@ export default class ActionButtonItem extends Component {
4445
useNativeFeedback: PropTypes.bool,
4546
fixNativeFeedbackRadius: PropTypes.bool,
4647
nativeFeedbackRippleColor: PropTypes.string,
47-
activeOpacity: PropTypes.number
48+
activeOpacity: PropTypes.number,
49+
numberOfLines: PropTypes.number,
4850
};
4951
}
5052

@@ -140,7 +142,8 @@ export default class ActionButtonItem extends Component {
140142
parentSize,
141143
size,
142144
position,
143-
spaceBetween
145+
spaceBetween,
146+
numberOfLines,
144147
} = this.props;
145148
const offsetTop = Math.max(size / 2 - TEXT_HEIGHT / 2, 0);
146149
const positionStyles = { top: offsetTop };
@@ -169,6 +172,7 @@ export default class ActionButtonItem extends Component {
169172
<Text
170173
allowFontScaling={false}
171174
style={[styles.text, this.props.textStyle]}
175+
numberOfLines={numberOfLines}
172176
>
173177
{this.props.title}
174178
</Text>

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ Take a look at [this gist](https://gist.github.com/mmazzarolo/cfd467436f9d110e94
143143
| textContainerStyle | style | null | use this to set the textstyle of the button's item text container
144144
| textStyle | style | null | use this to set the textstyle of the button's item text
145145
| spaceBetween | number | 15 | use this to set the space between the Button and the text container
146+
| numberOfLines | number | 1 | use this to set the number of lines on the button's item text
146147
| activeOpacity | number | 0.85 | activeOpacity props of TouchableOpacity
147148
| hideLabelShadow | boolean | same as hideShadow | use this to hide the button's label default elevation and boxShadow
148149
| shadowStyle | style | null | The custom shadow style you want to pass in the action button item

0 commit comments

Comments
 (0)