Skip to content
This repository has been archived by the owner on Oct 19, 2021. It is now read-only.

Commit

Permalink
feat(Notification): remove for v10 (#1978)
Browse files Browse the repository at this point in the history
Superseded by `<InlineNotification>` and `<ToastNotification>`.

Fixes #1958.
  • Loading branch information
asudoh authored and joshblack committed Mar 8, 2019
1 parent fbedcae commit b7e8075
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 16 deletions.
26 changes: 15 additions & 11 deletions src/components/Notification/Notification-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Notification, {
ToastNotification,
InlineNotification,
} from '../Notification';
import { breakingChangesX } from '../../internal/FeatureFlags';

const kinds = {
'Error (error)': 'error',
Expand All @@ -33,9 +34,19 @@ const notificationProps = () => ({
onCloseButtonClick: action('onCloseButtonClick'),
});

storiesOf('Notifications', module)
const stories = storiesOf('Notifications', module)
.addDecorator(withKnobs)
.add(
.add('Toast', () => (
<ToastNotification
{...notificationProps()}
caption={text('Caption (caption)', 'Time stamp [00:00:00]')}
style={{ minWidth: '30rem', marginBottom: '.5rem' }}
/>
))
.add('inline', () => <InlineNotification {...notificationProps()} />);

if (!breakingChangesX) {
stories.add(
'Deprecated: <Notfication />',
() => (
<Notification
Expand All @@ -51,12 +62,5 @@ storiesOf('Notifications', module)
`,
},
}
)
.add('Toast', () => (
<ToastNotification
{...notificationProps()}
caption={text('Caption (caption)', 'Time stamp [00:00:00]')}
style={{ minWidth: '30rem', marginBottom: '.5rem' }}
/>
))
.add('inline', () => <InlineNotification {...notificationProps()} />);
);
}
22 changes: 17 additions & 5 deletions src/components/Notification/Notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { breakingChangesX, componentsX } from '../../internal/FeatureFlags';

const { prefix } = settings;

let didWarnAboutDeprecation = false;
let didWarnAboutDeprecationButtonIcon = false;

export class NotificationButton extends Component {
static propTypes = {
Expand Down Expand Up @@ -105,11 +105,11 @@ export class NotificationButton extends Component {

if (__DEV__ && breakingChangesX && (icon || name)) {
warning(
didWarnAboutDeprecation,
didWarnAboutDeprecationButtonIcon,
'The `icon`/`name` properties in the `NotificationButton` component is being removed in the next release of ' +
'`carbon-components-react`. Please use `renderIcon` instead.'
);
didWarnAboutDeprecation = true;
didWarnAboutDeprecationButtonIcon = true;
}

const buttonClasses = classNames(
Expand Down Expand Up @@ -529,9 +529,10 @@ export class InlineNotification extends Component {
}
}

// Deprecated
let didWarnAboutDeprecationNotification = false;

export default class Notification extends Component {
// Deprecated
class Notification extends Component {
static propTypes = {
children: PropTypes.node,

Expand Down Expand Up @@ -602,6 +603,15 @@ export default class Notification extends Component {
}[kindProp]);

render() {
if (__DEV__) {
warning(
didWarnAboutDeprecationNotification,
'The `Notification` component is being removed in the next release of ' +
'`carbon-components-react`. Please use `InlineNotification` or `ToastNotification` instead.'
);
didWarnAboutDeprecationNotification = true;
}

if (!this.state.open) {
return null;
}
Expand Down Expand Up @@ -689,3 +699,5 @@ export default class Notification extends Component {
return caption ? toastHTML : inlineHTML;
}
}

export default (!breakingChangesX ? Notification : null);

0 comments on commit b7e8075

Please sign in to comment.