-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
8905 notification refactor inline toast (#9004)
* 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
1 parent
2c76d18
commit 0ccb047
Showing
9 changed files
with
743 additions
and
1 deletion.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
packages/carbon-react/src/components/Notification/Notification.stories.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
12
packages/carbon-react/src/components/Notification/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; |
27 changes: 27 additions & 0 deletions
27
packages/styles/scss/components/__tests__/inline-notification-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); |
27 changes: 27 additions & 0 deletions
27
packages/styles/scss/components/__tests__/toast-notification-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.