Browse Source

toaster message multi-line render

all-modes
pbca26 8 years ago
parent
commit
9a5f3027d6
  1. 13
      react/src/components/overrides.scss
  2. 26
      react/src/components/toaster/toaster-item.js

13
react/src/components/overrides.scss

@ -753,6 +753,8 @@ select{
#toast-container { #toast-container {
> div { > div {
padding: 15px 15px 15px 60px;
width: 310px;
opacity: 1; opacity: 1;
} }
} }
@ -980,10 +982,11 @@ select{
color: #757575; color: #757575;
background-color: #efefef; background-color: #efefef;
border: 1px solid #e0e0e0; border: 1px solid #e0e0e0;
}
.-btn:hover { &:hover {
color: #fff; color: #fff;
} }
}
.-btn[disabled]:hover { .-btn[disabled]:hover {
color: #757575; color: #757575;
} }
@ -1073,11 +1076,13 @@ select{
table { table {
width: 100%; width: 100%;
td:first-child { td {
&:first-child {
width: 40%; width: 40%;
} }
td:last-child { &:last-child {
width: 60%; width: 60%;
} }
} }
}
} }

26
react/src/components/toaster/toaster-item.js

@ -22,6 +22,7 @@ class ToasterItem extends React.Component {
}; };
this.dismissToast = this.dismissToast.bind(this); this.dismissToast = this.dismissToast.bind(this);
this.renderLB = this.renderLB.bind(this);
this.timeoutHandler = null; this.timeoutHandler = null;
} }
@ -50,6 +51,29 @@ class ToasterItem extends React.Component {
Store.dispatch(dismissToasterMessage(toastId)); Store.dispatch(dismissToasterMessage(toastId));
} }
renderLB() {
if (typeof this.state.message === 'object') {
let _items = [];
const _msg = this.state.message;
for (let i = 0; i < _msg.length; i++) {
if (_msg[i] === '') {
_items.push(
<div className="margin-top-5"></div>
);
} else {
_items.push(
<div key={ `toaster-msg-${i}` }>{ _msg[i] }</div>
);
}
}
return _items;
} else {
return this.state.message;
}
}
renderToast() { renderToast() {
// ensure that setTimeout is called only once for each toast message // ensure that setTimeout is called only once for each toast message
if (this.state.autoClose && if (this.state.autoClose &&
@ -66,7 +90,7 @@ class ToasterItem extends React.Component {
onClick={ () => this.dismissToast(this.state.toastId) }>× onClick={ () => this.dismissToast(this.state.toastId) }>×
</button> </button>
<div className="toast-title">{ this.state.title }</div> <div className="toast-title">{ this.state.title }</div>
<div className="toast-message">{ this.state.message }</div> <div className="toast-message">{ this.renderLB() }</div>
</div> </div>
); );
} }

Loading…
Cancel
Save