Skip to content

Commit

Permalink
8905 notification refactor inline toast (#9004)
Browse files Browse the repository at this point in the history
* wip-testing

* feat(notifications): figure out tests and add storybook

* feat(notification): refactor for toast and inline

* update feature-flag enabled

* Update packages/styles/scss/components/notification/_toast-notification.scss

Co-authored-by: TJ Egan <tw15egan@gmail.com>

* update: remove knobs

* Update packages/styles/scss/components/notification/_toast-notification.scss

Co-authored-by: TJ Egan <tw15egan@gmail.com>

* feat(notification): remove unnecessary props

Co-authored-by: TJ Egan <tw15egan@gmail.com>
  • Loading branch information
andreancardona and tw15egan committed Jun 30, 2021
1 parent 2c76d18 commit 0ccb047
Show file tree
Hide file tree
Showing 9 changed files with 743 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* Copyright IBM Corp. 2016, 2018
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/

import {
ToastNotification,
InlineNotification,
NotificationActionButton,
} from 'carbon-components-react';
import React from 'react';

const notificationProps = () => ({
kind: 'info',
role: 'alert',
title: 'Notification title',
subtitle: 'Subtitle text goes here.',
});

const toastNotificationProps = () => ({
...notificationProps(),
});

export default {
title: 'Components/Notifications',
};

export const Toast = () => (
<ToastNotification
{...toastNotificationProps()}
caption={('Caption (caption)', '00:00:00 AM')}
style={{ marginBottom: '.5rem' }}
/>
);

export const Inline = () => (
<InlineNotification
{...notificationProps()}
actions={<NotificationActionButton>{'Action'}</NotificationActionButton>}
/>
);

Inline.storyName = 'Inline';
12 changes: 12 additions & 0 deletions packages/carbon-react/src/components/Notification/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* Copyright IBM Corp. 2016, 2018
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/

export {
ToastNotification,
InlineNotification,
NotificationActionButton,
} from 'carbon-components-react';
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Copyright IBM Corp. 2018, 2018
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*
* @jest-environment node
*/

'use strict';

const { SassRenderer } = require('@carbon/test-utils/scss');

const { render } = SassRenderer.create(__dirname);

describe('scss/components/notification', () => {
test('Public API', async () => {
const { unwrap } = await render(`
@use 'sass:map';
@use 'sass:meta';
@use '../notification';
$_: get('mixin', meta.mixin-exists('inline-notification', 'notification'));
`);
expect(unwrap('mixin')).toBe(true);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Copyright IBM Corp. 2018, 2018
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*
* @jest-environment node
*/

'use strict';

const { SassRenderer } = require('@carbon/test-utils/scss');

const { render } = SassRenderer.create(__dirname);

describe('scss/components/notification', () => {
test('Public API', async () => {
const { unwrap } = await render(`
@use 'sass:map';
@use 'sass:meta';
@use '../notification';
$_: get('mixin', meta.mixin-exists('toast-notification', 'notification'));
`);
expect(unwrap('mixin')).toBe(true);
});
});
1 change: 1 addition & 0 deletions packages/styles/scss/components/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
@use 'tooltip';
@use 'radio-button';
@use 'modal';
@use 'notification';
@use 'search';
@use 'data-table';
@use 'data-table/action';
Expand Down
10 changes: 9 additions & 1 deletion packages/styles/scss/components/notification/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,12 @@
// LICENSE file in the root directory of this source tree.
//

@forward 'tokens';
@forward './tokens';
@forward 'inline-notification';
@forward 'toast-notification';

@use 'inline-notification';
@use 'toast-notification';

@include inline-notification.inline-notification;
@include toast-notification.toast-notification;
Loading

0 comments on commit 0ccb047

Please sign in to comment.