Skip to content

Commit

Permalink
Refactor #1917 - For Messages
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Apr 12, 2021
1 parent 822661f commit 4614d05
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/components/messages/Messages.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ interface MessagesProps {
id?: string;
className?: string;
style?: object;
transitionOptions?: object;
onRemove?(message: MessageOptions): void;
onClick?(message: MessageOptions): void;
}
Expand Down
7 changes: 5 additions & 2 deletions src/components/messages/Messages.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { UIMessage } from './UIMessage';
import { CSSTransition, TransitionGroup } from 'react-transition-group';
import { TransitionGroup } from 'react-transition-group';
import { CSSTransition } from '../transition/CSSTransition';

let messageIdx = 0;

Expand All @@ -11,6 +12,7 @@ export class Messages extends Component {
id: null,
className: null,
style: null,
transitionOptions: null,
onRemove: null,
onClick: null
}
Expand All @@ -19,6 +21,7 @@ export class Messages extends Component {
id: PropTypes.string,
className: PropTypes.string,
style: PropTypes.object,
transitionOptions: PropTypes.object,
onRemove: PropTypes.func,
onClick: PropTypes.func
};
Expand Down Expand Up @@ -85,7 +88,7 @@ export class Messages extends Component {
const messageRef = React.createRef();

return (
<CSSTransition nodeRef={messageRef} key={message.id} classNames="p-message" unmountOnExit timeout={{ enter: 300, exit: 300 }}>
<CSSTransition nodeRef={messageRef} key={message.id} classNames="p-message" unmountOnExit timeout={{ enter: 300, exit: 300 }} options={this.props.transitionOptions}>
<UIMessage ref={messageRef} message={message} onClick={this.props.onClick} onClose={this.onClose} />
</CSSTransition>
)
Expand Down
6 changes: 6 additions & 0 deletions src/showcase/messages/MessagesDoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,12 @@ messages.current.show({ life: 5000, severity: 'error', summary: 'Error Message',
<td>null</td>
<td>Inline style of the element.</td>
</tr>
<tr>
<td>transitionOptions</td>
<td>object</td>
<td>null</td>
<td>The properties of <a href="https://reactcommunity.org/react-transition-group/css-transition" rel="noopener noreferrer" target="_blank">CSSTransition</a> can be customized, except for "nodeRef" and "in" properties.</td>
</tr>
</tbody>
</table>
</div>
Expand Down

0 comments on commit 4614d05

Please sign in to comment.