diff --git a/README.md b/README.md index d6990025..900eccec 100644 --- a/README.md +++ b/README.md @@ -28,9 +28,16 @@ Currently, the following components are supported: - CopyButton - DataTableSkeleton - InlineLoading -- Loading - Link - ListItem +- Loading +- Notification + - ToastNotification + - InlineNotification + - NotificationActionButton + - NotificationButton + - NotificationIcon + - NotificationTextDetails - OrderedList - RadioButton - RadioButtonSkeleton diff --git a/src/components/Notification/InlineNotification.svelte b/src/components/Notification/InlineNotification.svelte new file mode 100644 index 00000000..70c232f2 --- /dev/null +++ b/src/components/Notification/InlineNotification.svelte @@ -0,0 +1,54 @@ + + +{#if open} +
+
+ + + + +
+ + {#if !hideCloseButton} + { + open = false; + }} /> + {/if} +
+{/if} diff --git a/src/components/Notification/Notification.Story.svelte b/src/components/Notification/Notification.Story.svelte new file mode 100644 index 00000000..5891ab73 --- /dev/null +++ b/src/components/Notification/Notification.Story.svelte @@ -0,0 +1,20 @@ + + + + {#if story === 'inline'} + +
+ {$$props.action} +
+
+ {:else if story === 'toast'} + + {/if} +
diff --git a/src/components/Notification/Notification.stories.js b/src/components/Notification/Notification.stories.js new file mode 100644 index 00000000..161cbeb4 --- /dev/null +++ b/src/components/Notification/Notification.stories.js @@ -0,0 +1,42 @@ +import { withKnobs, select, boolean, text } from '@storybook/addon-knobs'; +import Component from './Notification.Story.svelte'; + +export default { title: 'Notification', decorators: [withKnobs] }; + +const kinds = { + 'Error (error)': 'error', + 'Info (info)': 'info', + 'Success (success)': 'success', + 'Warning (warning)': 'warning' +}; + +export const Toast = () => ({ + Component, + props: { + story: 'toast', + 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.'), + caption: text('Caption (caption)', 'Time stamp [00:00:00]'), + iconDescription: text('Icon description (iconDescription)', 'describes the close button'), + hideCloseButton: boolean('Hide close button (hideCloseButton)', false) + } +}); + +export const Inline = () => ({ + Component, + props: { + story: 'inline', + 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.'), + caption: text('Caption (caption)', 'Time stamp [00:00:00]'), + iconDescription: text('Icon description (iconDescription)', 'describes the close button'), + hideCloseButton: boolean('Hide close button (hideCloseButton)', false), + action: text('Action (NotificationActionButton > $$slot#action)', 'Action') + } +}); diff --git a/src/components/Notification/NotificationActionButton.svelte b/src/components/Notification/NotificationActionButton.svelte new file mode 100644 index 00000000..c170f561 --- /dev/null +++ b/src/components/Notification/NotificationActionButton.svelte @@ -0,0 +1,22 @@ + + + diff --git a/src/components/Notification/NotificationButton.svelte b/src/components/Notification/NotificationButton.svelte new file mode 100644 index 00000000..b77ad498 --- /dev/null +++ b/src/components/Notification/NotificationButton.svelte @@ -0,0 +1,36 @@ + + + diff --git a/src/components/Notification/NotificationIcon.svelte b/src/components/Notification/NotificationIcon.svelte new file mode 100644 index 00000000..87161891 --- /dev/null +++ b/src/components/Notification/NotificationIcon.svelte @@ -0,0 +1,21 @@ + + + diff --git a/src/components/Notification/NotificationTextDetails.svelte b/src/components/Notification/NotificationTextDetails.svelte new file mode 100644 index 00000000..42be0626 --- /dev/null +++ b/src/components/Notification/NotificationTextDetails.svelte @@ -0,0 +1,25 @@ + + +{#if notificationType === 'toast'} +
+

{title}

+
{subtitle}
+
{caption}
+ +
+{/if} + +{#if notificationType === 'inline'} +
+

{title}

+
{subtitle}
+ +
+{/if} diff --git a/src/components/Notification/ToastNotification.svelte b/src/components/Notification/ToastNotification.svelte new file mode 100644 index 00000000..1ce9e37c --- /dev/null +++ b/src/components/Notification/ToastNotification.svelte @@ -0,0 +1,60 @@ + + +{#if open} +
+ + + + + {#if !hideCloseButton} + { + open = false; + }} /> + {/if} +
+{/if} diff --git a/src/components/Notification/index.js b/src/components/Notification/index.js new file mode 100644 index 00000000..07b463b9 --- /dev/null +++ b/src/components/Notification/index.js @@ -0,0 +1,6 @@ +export { default as ToastNotification } from './ToastNotification.svelte'; +export { default as InlineNotification } from './InlineNotification.svelte'; +export { default as NotificationActionButton } from './NotificationActionButton.svelte'; +export { default as NotificationButton } from './NotificationButton.svelte'; +export { default as NotificationIcon } from './NotificationIcon.svelte'; +export { default as NotificationTextDetails } from './NotificationTextDetails.svelte'; diff --git a/src/index.js b/src/index.js index 3fa2aa64..90a1b76a 100644 --- a/src/index.js +++ b/src/index.js @@ -8,9 +8,17 @@ import CopyButton from './components/CopyButton'; import CodeSnippet, { CodeSnippetSkeleton } from './components/CodeSnippet'; import DataTableSkeleton from './components/DataTableSkeleton'; import InlineLoading from './components/InlineLoading'; -import Loading from './components/Loading'; import Link from './components/Link'; import ListItem from './components/ListItem'; +import Loading from './components/Loading'; +import { + ToastNotification, + InlineNotification, + NotificationActionButton, + NotificationButton, + NotificationIcon, + NotificationTextDetails +} from './components/Notification'; import OrderedList from './components/OrderedList'; import RadioButton, { RadioButtonSkeleton } from './components/RadioButton'; import Search, { SearchSkeleton } from './components/Search'; @@ -53,9 +61,14 @@ export { DataTableSkeleton, ExpandableTile, InlineLoading, + InlineNotification, Link, ListItem, Loading, + NotificationActionButton, + NotificationButton, + NotificationIcon, + NotificationTextDetails, OrderedList, PasswordInput, RadioButton, @@ -76,6 +89,7 @@ export { TileAboveTheFoldContent, TileBelowTheFoldContent, TileGroup, + ToastNotification, Toggle, ToggleSkeleton, ToggleSmall,