Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(sass): notification refactor inline toast #9004

Merged
merged 13 commits into from
Jun 30, 2021
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/**
* 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';
import { action } from '@storybook/addon-actions';

import { boolean, number, select, text } from '@storybook/addon-knobs';
andreancardona marked this conversation as resolved.
Show resolved Hide resolved

const kinds = {
'Error (error)': 'error',
'Info (info)': 'info',
'Info square (info-square)': 'info-square',
'Success (success)': 'success',
'Warning (warning)': 'warning',
'Warning (warning-alt)': 'warning-alt',
};
const notificationProps = () => ({
kind: select('The notification kind (kind)', kinds, 'info'),
lowContrast: boolean('Use low contrast variant (lowContrast)', false),
role: text('ARIA role (role)', 'alert'),
title: text('Title (title)', 'Notification title'),
subtitle: text('Subtitle (subtitle)', 'Subtitle text goes here.'),
iconDescription: text(
'Icon description (iconDescription)',
'describes the close button'
),
statusIconDescription: text(
'Status icon description (statusIconDescription)',
'describes the status icon'
),
hideCloseButton: boolean('Hide close button (hideCloseButton)', false),
onClose: action('onClose'),
onCloseButtonClick: action('onCloseButtonClick'),
});

const toastNotificationProps = () => ({
...notificationProps(),
timeout: number(
'Duration in milliseconds to display notification (timeout)',
0
),
});
andreancardona marked this conversation as resolved.
Show resolved Hide resolved

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

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

export const Inline = () => (
<InlineNotification
{...notificationProps()}
actions={
<NotificationActionButton
onClick={action('NotificationActionButton onClick')}>
{text('Action (NotificationActionButton > children)', '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 @@ -18,6 +18,7 @@
@use 'loading';
@use 'menu';
@use 'modal';
@use 'notification';
@use 'data-table';
@use 'data-table/action';
@use 'data-table/expandable';
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