Skip to content
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
2243a51
Notification events
elizabetdev Feb 16, 2021
d651459
Looping through EuiNotificationEvent
elizabetdev Feb 17, 2021
a424dab
Adding props table and more methods
elizabetdev Feb 17, 2021
772012c
wip
elizabetdev Feb 18, 2021
aed40dc
Renaming event notifications to event messages
elizabetdev Feb 19, 2021
cbd4c0a
onClickNoNewsTitles
elizabetdev Feb 19, 2021
49630c1
Toggle mark as read/unread
elizabetdev Feb 19, 2021
6c0efac
Initial documentation
elizabetdev Feb 19, 2021
7a2e13e
Improving examples
elizabetdev Feb 20, 2021
afee6bb
Fixing TS error
elizabetdev Feb 20, 2021
6daed5b
Refactored EuiEventNotification context menu item creation
chandlerprall Feb 20, 2021
cdad6f8
improving data
elizabetdev Feb 22, 2021
6f57571
Notifications data
elizabetdev Feb 22, 2021
e142a1a
Primary example buttons
elizabetdev Feb 22, 2021
09868a3
Reset data
elizabetdev Feb 22, 2021
89c7f79
More docs
elizabetdev Feb 23, 2021
8cb9958
snippets
elizabetdev Feb 23, 2021
7ea4356
Merge branch 'notification-events-content-context-menu-items' of http…
elizabetdev Feb 24, 2021
0e94d78
Merge pull request #15 from miukimiu/chandlerprall-notification-event…
elizabetdev Feb 24, 2021
6470f60
Adding tests
elizabetdev Feb 25, 2021
a5d2408
Better messages explanation
elizabetdev Feb 25, 2021
ce0a6cf
Better snippets
elizabetdev Feb 25, 2021
d83b6ea
Small fixes
elizabetdev Feb 25, 2021
ee2c76f
Missing prop explanation
elizabetdev Feb 25, 2021
a62b626
Adding heading level
elizabetdev Mar 1, 2021
3f15f22
Adding flexible comp section
elizabetdev Mar 2, 2021
499c6bb
More a11y
elizabetdev Mar 2, 2021
b933716
Update src/components/notification/notification_event_messages.tsx
elizabetdev Mar 2, 2021
66a1bf9
Button messages ay11
elizabetdev Mar 2, 2021
f08e9c6
test
elizabetdev Mar 2, 2021
397cf0c
Better descriptions
elizabetdev Mar 2, 2021
c552bc8
Tests
elizabetdev Mar 2, 2021
911651e
Adding icon arial label into notifications feed example
elizabetdev Mar 2, 2021
86f0fac
i18n token
elizabetdev Mar 2, 2021
afd3c97
i18n token
elizabetdev Mar 2, 2021
953190a
i18 token again
elizabetdev Mar 2, 2021
44f5b1e
primaryAction description
elizabetdev Mar 2, 2021
c986923
More description
elizabetdev Mar 2, 2021
bc46770
Update src/components/notification/notification_event_messages.tsx
elizabetdev Mar 3, 2021
63e6144
Update src/components/notification/notification_event_messages.tsx
elizabetdev Mar 3, 2021
9ed044f
Update src-docs/src/views/notification_event/notification_event_examp…
elizabetdev Mar 3, 2021
d847ce7
Update src-docs/src/views/notification_event/notification_event_examp…
elizabetdev Mar 3, 2021
ab552ec
Update src-docs/src/views/notification_event/notification_event_examp…
elizabetdev Mar 3, 2021
2bc96f7
Update src-docs/src/views/notification_event/notification_event_examp…
elizabetdev Mar 3, 2021
32bcec2
Update src-docs/src/views/notification_event/notification_event_examp…
elizabetdev Mar 3, 2021
9b76651
Addressing PR review
elizabetdev Mar 3, 2021
4dafc61
More improvements
elizabetdev Mar 3, 2021
dff649a
Adding comment
elizabetdev Mar 3, 2021
ed1351e
Excluding `eventName` at top level and changing title vs aria-label o…
Mar 3, 2021
d0a56fa
Fix title
Mar 3, 2021
583f47e
Merge pull request #16 from cchaos/notification-events-content
elizabetdev Mar 4, 2021
b7c1dc0
Fixing tests and removing evenName from docs usage
elizabetdev Mar 4, 2021
4b3a095
Fixing icon margin
elizabetdev Mar 4, 2021
f73f685
More tests and small fixes
elizabetdev Mar 4, 2021
62e2a31
Moving read button from event meta comp to event comp
elizabetdev Mar 4, 2021
17f8c60
Split primaryAction and primaryActionProps
elizabetdev Mar 4, 2021
aa19641
Exposing EuiPrimaryActionProps in props table
elizabetdev Mar 4, 2021
355131b
Update src-docs/src/views/notification_event/notification_event_examp…
elizabetdev Mar 5, 2021
b6ee7e2
Update src-docs/src/views/notification_event/notification_event_examp…
elizabetdev Mar 5, 2021
79576d6
Update src-docs/src/views/notification_event/notification_event_examp…
elizabetdev Mar 5, 2021
23d2d7f
Update src-docs/src/views/notification_event/notification_event_examp…
elizabetdev Mar 5, 2021
06b56bf
Update src-docs/src/views/notification_event/notification_event_examp…
elizabetdev Mar 5, 2021
d876039
Update src-docs/src/views/notification_event/notification_event_examp…
elizabetdev Mar 5, 2021
190ab23
Update src-docs/src/views/notification_event/notification_event_examp…
elizabetdev Mar 5, 2021
9bcb214
Messages length and more
elizabetdev Mar 5, 2021
6a1732e
Fixing data test subj
elizabetdev Mar 5, 2021
890f8c4
Renaming tsx examples to js
elizabetdev Mar 5, 2021
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
67 changes: 67 additions & 0 deletions src-docs/src/components/guide_components.scss
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,72 @@ $guideZLevelHighest: $euiZLevel9 + 1000;
top: 0;
}

.guideDemo__notificationEventCircleIndicator {
display: inline-block;
width: 16px;
height: 16px;
Comment thread
elizabetdev marked this conversation as resolved.
Outdated
background: $euiColorPrimary;
color: $euiColorEmptyShade;
font-size: 12px;
line-height: 16px;
text-align: center;
border-radius: 50%;
}

.guideDemo__notificationEventHighlight {
background: transparentize($euiColorPrimary, .9);
border-radius: $euiBorderRadiusSmall;
padding: $euiSizeXS;
}

.guideDemo__notificationEvent {
@include euiFontSizeS;
display: flex;
flex-direction: column;

> * {
display: flex;
}

.guideDemo__notificationEventCircleIndicator {
margin-right: $euiSizeXS;
}
}

.guideDemo__notificationEventTopRow {
display: flex;

> * {
position: relative;
}

.guideDemo__notificationEventCircleIndicator {
position: absolute;
top: -$euiSizeS;
left: 0;
}
}

.guideDemo__notificationEventMeta {
display: flex;
width: 100%;
margin: 0 $euiSizeS;

.euiNotificationEventMeta {
width: 100%;
}
}

.guideDemo__notificationEventSections {
margin-left: $euiSizeXXL;
display: flex;
flex-direction: column;

> * {
margin-top: $euiSizeS;
}
}

.euiDataGridRowCell--favoriteFranchise {
background: transparentize($color: #800080, $amount: .95) !important;
}
Expand All @@ -259,6 +325,7 @@ $guideZLevelHighest: $euiZLevel9 + 1000;
color: $euiColorAccentText;
}


@import '../views/guidelines/index';
@import 'guide_section/index';
@import 'guide_rule/index';
Expand Down
4 changes: 2 additions & 2 deletions src-docs/src/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ import { ModalExample } from './views/modal/modal_example';

import { MutationObserverExample } from './views/mutation_observer/mutation_observer_example';

import { NotificationEventsExample } from './views/notification_events/notification_events_example';
import { NotificationEventExample } from './views/notification_event/notification_event_example';

import { OutsideClickDetectorExample } from './views/outside_click_detector/outside_click_detector_example';

Expand Down Expand Up @@ -393,7 +393,7 @@ const navigation = [
ImageExample,
ListGroupExample,
LoadingExample,
NotificationEventsExample,
NotificationEventExample,
ProgressExample,
StatExample,
TextExample,
Expand Down
55 changes: 55 additions & 0 deletions src-docs/src/views/notification_event/notification_event.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import React, { useState } from 'react';
import { EuiPanel } from '../../../../src/components/panel';
import { EuiContextMenuItem } from '../../../../src/components/context_menu';
import { EuiNotificationEvent } from '../../../../src/components/notification/notification_event';

export default () => {
const [isRead, setIsRead] = useState(false);

const onRead = (id: string, isRead: boolean) => {
setIsRead(!isRead);
};

const onOpenContextMenu = (id: string) => {
return [
<EuiContextMenuItem
key="contextMenuItemA"
onClick={() => onRead(id, isRead)}>
{isRead ? 'Mark as unread' : 'Mark as read'}
</EuiContextMenuItem>,

<EuiContextMenuItem key="contextMenuItemB" onClick={() => {}}>
View messages like this
</EuiContextMenuItem>,

<EuiContextMenuItem key="contextMenuItemC" onClick={() => {}}>
Don’t notify me about this
</EuiContextMenuItem>,
];
};

return (
<EuiPanel paddingSize="none" hasShadow={true} style={{ maxWidth: '540px' }}>
<EuiNotificationEvent
id="report"
meta={{
type: 'Report',
iconType: 'logoKibana',
iconAriaLabel: 'Kibana',
time: '1 min ago',
}}
title="[Error Monitoring Report] is generated"
primaryAction={{
iconType: 'download',
label: 'Download',
}}
messages={['The reported was generated at 17:12:16 GMT+4']}
isRead={isRead}
onRead={onRead}
onOpenContextMenu={onOpenContextMenu}
onClickPrimaryAction={() => {}}
onClickTitle={() => {}}
/>
</EuiPanel>
);
};
241 changes: 241 additions & 0 deletions src-docs/src/views/notification_event/notification_event_example.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,241 @@
import React, { Fragment } from 'react';
import { renderToHtml } from '../../services';
import { GuideSectionTypes } from '../../components';
import { Link } from 'react-router-dom';
import { EuiNotificationEventMeta } from '../../../../src/components/notification/notification_event_meta';
import {
EuiNotificationEvent,
EuiText,
EuiContextMenuItem,
EuiSpacer,
EuiCode,
EuiAccordion,
EuiCodeBlock,
} from '../../../../src/components';
import { notificationEventReadButtonConfig } from './playground';
import { EuiNotificationEventPrimaryAction } from './props';
import NotificationEventPropsMethods from './notification_event_props_methods';

import NotificationEvent from './notification_event';
const notificationEventSource = require('!!raw-loader!./notification_event');
const notificationEventHtml = renderToHtml(NotificationEvent);

import NotificationEventFlexible from './notification_event_flexible';
const notificationEventFlexibleSource = require('!!raw-loader!./notification_event_flexible');
const notificationEventFlexibleHtml = renderToHtml(NotificationEventFlexible);

import NotificationsFeed from './notifications_feed';
const notificationsFeedSource = require('!!raw-loader!./notifications_feed');
const notificationsFeedHtml = renderToHtml(NotificationsFeed);

const notificationEventSnippet = `<EuiNotificationEvent
id={id}
meta={{
type: 'Alert',
iconType: 'logoMaps',
iconAriaLabel: 'Maps',
time: '1 min ago',
}}
title={title}
isRead={isRead}
primaryAction={primaryAction}
messages={messages}
onRead={onRead}
onOpenContextMenu={onOpenContextMenu}
onClickPrimaryAction={onClickPrimaryAction}
onClickTitle={onClickTitle}
/>`;

const notificationEventFeedSnippet = `// we're looping through an array of objects to render multiple EuiNotificationEvent
const notificationEvents = events.map((event) => (
<EuiNotificationEvent
key={event.id}
id={event.id}
meta={event.meta}
title={event.title}
isRead={event.isRead}
primaryAction={event.primaryAction}
messages={event.messages}
onRead={onRead}
onOpenContextMenu={onOpenContextMenu}
onClickPrimaryAction={onClickPrimaryAction}
onClickTitle={onClickTitle}
/>
));

// the multiple EuiNotificationEvent should live inside the same container
<div>
{notificationEvents}
</div>
`;

export const NotificationEventExample = {
title: 'Notification event',
beta: true,
isNew: true,
intro: (
<EuiText>
<p>
Use <strong>EuiNotificationEvent</strong> to display notifications about
new events in your product like alerts, support, or news. This component
is meant to live inside a{' '}
<strong>
<Link to="/layout/flyout/">EuiFlyout</Link>
</strong>{' '}
so that users can quickly be informed or take action.
</p>
</EuiText>
),
sections: [
{
source: [
{
type: GuideSectionTypes.JS,
code: notificationEventSource,
},
{
type: GuideSectionTypes.HTML,
code: notificationEventHtml,
},
],
props: {
EuiNotificationEvent,
EuiNotificationEventMeta,
EuiNotificationEventPrimaryAction,
EuiContextMenuItem,
},
snippet: notificationEventSnippet,
demo: <NotificationEvent />,
},
{
source: [
{
type: GuideSectionTypes.JS,
code: notificationEventFlexibleSource,
},
{
type: GuideSectionTypes.HTML,
code: notificationEventFlexibleHtml,
},
],
title: 'A flexible component',
text: (
<>
<EuiText>
<p>
The <strong>EuiNotificationEvent</strong> takes into account that
an event can be purely informative or actionable. It&apos;s
Comment thread
elizabetdev marked this conversation as resolved.
Outdated
flexible enough and adapts the design according to the props
Comment thread
elizabetdev marked this conversation as resolved.
Outdated
passed.
</p>
</EuiText>
<EuiSpacer />
<NotificationEventPropsMethods />
<EuiSpacer size="xs" />
<EuiAccordion
id="propsSnippet"
buttonContent={<small>Code snippet</small>}>
<EuiSpacer size="xs" />
<EuiCodeBlock language="ts" isCopyable paddingSize="s">
{notificationEventSnippet}
</EuiCodeBlock>
</EuiAccordion>
<EuiSpacer />
<EuiText>
<ul style={{ listStyleType: 'upper-alpha' }}>
<li>
<EuiCode>isRead</EuiCode>: Use this prop to show a button that
indicates the current <EuiCode>isRead</EuiCode> state of the
event. Use the <EuiCode>onRead</EuiCode> to allow users to
Comment thread
elizabetdev marked this conversation as resolved.
Outdated
toggle between read and unread states.
</li>
<li>
<EuiCode>meta</EuiCode> (required): Provides important
information about the event, like when it was received, the type
Comment thread
elizabetdev marked this conversation as resolved.
Outdated
of event, and its severity. Use the{' '}
<EuiCode>badgeColor</EuiCode> in conjunction with the{' '}
<EuiCode>severity</EuiCode> to better indicate the level of
urgency. You can also pass an icon/logo to help users quickly
Comment thread
elizabetdev marked this conversation as resolved.
Outdated
identify an event.
</li>
<li>
<EuiCode>onContextMenu</EuiCode>: Use this prop when you have
multiple events, and you need to add individual actions to each
Comment thread
elizabetdev marked this conversation as resolved.
Outdated
event. You can add filters based on the event type or a more
descriptive read/unread action as an alternative to the read
Comment thread
elizabetdev marked this conversation as resolved.
Outdated
indicator.
</li>
<li>
<EuiCode>title</EuiCode> (required): The title of the
notification event. It should be descriptive enough so that
users don&apos;t need to navigate away. But use it in
conjunction with an <EuiCode>onClickTitle</EuiCode> to direct
users to the respective app in case they need more information
about the notification.
</li>
<li>
<EuiCode>messages</EuiCode>: Use this prop to provide more
details about the event. You can provide just one message or
multiple messages when the event executes in various steps.
Comment thread
elizabetdev marked this conversation as resolved.
Outdated
</li>
<li>
<EuiCode>primaryAction</EuiCode>: Use this prop to provide a
call to action, like download a report or link to a page where
an action is required. Most of the time, the clickable title is
enough.
</li>
</ul>
</EuiText>
<EuiSpacer />
<EuiText>
<p>
The following demo shows how you can combine different props to
create different types of events like a report, alert, or even
Comment thread
elizabetdev marked this conversation as resolved.
Outdated
news.
</p>
</EuiText>
</>
),
props: {
EuiNotificationEvent,
EuiNotificationEventMeta,
EuiNotificationEventPrimaryAction,
EuiContextMenuItem,
},
snippet: notificationEventSnippet,
demo: <NotificationEventFlexible />,
},
{
source: [
{
type: GuideSectionTypes.JS,
code: notificationsFeedSource,
},
{
type: GuideSectionTypes.HTML,
code: notificationsFeedHtml,
},
],
title: 'Notifications feed',
text: (
<p>
You can create a notifications feed by rendering multiple{' '}
<strong>EuiNotificationEvent</strong>. These components should live
inside a container without other components on the same level. This
way, we ensure that feed styles are applied correctly. Consuming
applications should implement all the logic to filter and save
read/unread states.
</p>
),
props: {
EuiNotificationEvent,
EuiNotificationEventMeta,
EuiNotificationEventPrimaryAction,
EuiContextMenuItem,
},
snippet: notificationEventFeedSnippet,
demo: <NotificationsFeed />,
},
],
playground: notificationEventReadButtonConfig,
};
Loading