Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for child controls #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions MessageBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class MessageBar extends Component {
/* Cusomisation of the alert: Title, Message, Icon URL, Alert alertType (error, success, warning, info), Duration for Alert keep shown */
title: props.title,
message: props.message,
children: props.children,
avatar: props.avatar,
alertType: props.alertType || 'info',
duration: props.duration || 3000,
Expand Down Expand Up @@ -116,7 +117,7 @@ class MessageBar extends Component {
*/
showMessageBarAlert() {
// If an alert is already shonw or doesn't have a title or a message, do nothing
if (this.alertShown || (this.state.title == null && this.state.message == null)) {
if (this.alertShown || (this.state.title == null && this.state.message == null && this.state.children == null)) {
return;
}

Expand Down Expand Up @@ -404,13 +405,20 @@ class MessageBar extends Component {
}

renderMessage() {
var controls = [];
if (this.state.message != null) {
return (
<Text numberOfLines={this.state.messageNumberOfLines} style={this.state.messageStyle}>
controls.push(
<Text key="message" numberOfLines={this.state.messageNumberOfLines} style={this.state.messageStyle}>
{ this.state.message }
</Text>
);
}
if (this.state.children != null) {
controls.push(
this.state.children
);
}
return controls;
}

}
Expand Down