Skip to content

Commit

Permalink
Fixed #1761 - Change the type of content property in ToastMessage
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Jan 27, 2021
1 parent 1e1e03c commit aa55ff3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/components/toast/Toast.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import * as React from 'react';

export interface ToastMessage {
severity?: 'success' | 'info' | 'warn' | 'error',
summary?: React.ReactNode;
detail?: React.ReactNode;
summary?: any;
detail?: any;
content?: any;
closable?: boolean;
sticky?: boolean;
life?: number;
Expand Down
4 changes: 3 additions & 1 deletion src/components/toast/ToastMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { classNames } from '../utils/ClassNames';
import DomHandler from '../utils/DomHandler';
import ObjectUtils from '../utils/ObjectUtils';
import { Ripple } from '../ripple/Ripple';

export class ToastMessage extends Component {
Expand Down Expand Up @@ -71,14 +72,15 @@ export class ToastMessage extends Component {
renderMessage() {
if (this.props.message) {
const { severity, content, summary, detail } = this.props.message;
const contentEl = ObjectUtils.getJSXElement(content, this.props);
let iconClassName = classNames('p-toast-message-icon pi', {
'pi-info-circle': severity === 'info',
'pi-exclamation-triangle': severity === 'warn',
'pi-times': severity === 'error',
'pi-check': severity === 'success'
});

return content || (
return contentEl || (
<>
<span className={iconClassName}></span>
<div className="p-toast-message-text">
Expand Down
10 changes: 8 additions & 2 deletions src/showcase/toast/ToastDoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -439,16 +439,22 @@ toast.current.show({severity: 'success', summary: 'Success Message', detail: 'Or
</tr>
<tr>
<td>summary</td>
<td>element</td>
<td>element/string</td>
<td>null</td>
<td>Summary content of the message.</td>
</tr>
<tr>
<td>detail</td>
<td>element</td>
<td>element/string</td>
<td>null</td>
<td>Detail content of the message.</td>
</tr>
<tr>
<td>content</td>
<td>any</td>
<td>null</td>
<td>Custom content of the message. If enabled, summary and details properties are ignored.</td>
</tr>
<tr>
<td>closable</td>
<td>boolean</td>
Expand Down

0 comments on commit aa55ff3

Please sign in to comment.