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

Add EuiTimeline #5730

Merged
merged 67 commits into from
Apr 13, 2022
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
4ad1377
Adding new component
miukimiu Mar 17, 2022
cd601f7
WIP
miukimiu Mar 17, 2022
28e5452
WIP
miukimiu Mar 17, 2022
8ef5d79
WIP
miukimiu Mar 18, 2022
3e8b794
WIP event props
miukimiu Mar 18, 2022
42890a4
`isFigure`
miukimiu Mar 21, 2022
b9a059e
Simplifying props structure to avoid objects
miukimiu Mar 21, 2022
c3fd70e
Updated `textSize` in markdown editor example
miukimiu Mar 21, 2022
74217da
Small fixes
miukimiu Mar 21, 2022
f0a0927
`panelProps` as object
miukimiu Mar 21, 2022
4133d83
Better text
miukimiu Mar 22, 2022
6867384
Fixing rest props
miukimiu Mar 22, 2022
d8347d1
Updating shade color to subdued in EuiAvatar
miukimiu Mar 22, 2022
29982a1
No more `panelProps`
miukimiu Mar 22, 2022
c666cd4
Adding `isCenterAligned` prop
miukimiu Mar 22, 2022
a6a1fc3
Snippets
miukimiu Mar 22, 2022
e1ebaef
Adding `verticalAlign` prop
miukimiu Mar 23, 2022
19672ef
Adding tests
miukimiu Mar 23, 2022
30a71c0
Merge remote-tracking branch 'upstream/main' into add-timeline-component
miukimiu Mar 23, 2022
1f6efa7
Adding CL
miukimiu Mar 23, 2022
30d412d
Updating avatar example to use color `"subdued"`
miukimiu Mar 23, 2022
814eaee
Avatar names
miukimiu Mar 23, 2022
91abc7c
Using `euiPaletteColorBlindBehindText` to ensure better contrast
miukimiu Mar 28, 2022
1303ac0
Merge remote-tracking branch 'upstream/main' into add-timeline-component
miukimiu Mar 28, 2022
00f8beb
refactor
thompsongl Mar 31, 2022
efc6686
clean up
thompsongl Mar 31, 2022
cb10c9a
Merge remote-tracking branch 'upstream/main' into add-timeline-component
miukimiu Apr 1, 2022
e5f8633
Addressing PR review
miukimiu Apr 1, 2022
4d0c823
Converting styles to emotion
miukimiu Apr 1, 2022
d04d03d
Merge pull request #28 from thompsongl/add-timeline-component
miukimiu Apr 1, 2022
f0d4c5c
Merge branch 'add-timeline-component' of https://github.com/miukimiu/…
miukimiu Apr 1, 2022
2ccabed
Better complex example
miukimiu Apr 1, 2022
83176c6
Adding playground
miukimiu Apr 1, 2022
728b1bb
Linking `steps` and `comments` components
miukimiu Apr 1, 2022
7b7fbb6
Updating tests
miukimiu Apr 1, 2022
acb1d09
Adding design consideration text
miukimiu Apr 5, 2022
9299b47
More design considerations
miukimiu Apr 5, 2022
a128f3a
Merge remote-tracking branch 'upstream/main' into add-timeline-component
miukimiu Apr 5, 2022
7c3644c
Merge remote-tracking branch 'upstream/main' into add-timeline-component
miukimiu Apr 5, 2022
f6bf949
Better `::before` styles
miukimiu Apr 5, 2022
d1b6acf
Emotion styles
miukimiu Apr 6, 2022
b4fa0b9
Fixing prop description
miukimiu Apr 6, 2022
049e8aa
Merge remote-tracking branch 'upstream/main' into add-timeline-component
miukimiu Apr 6, 2022
c17cf4d
WIP
miukimiu Apr 7, 2022
f9067ee
Tests
miukimiu Apr 7, 2022
940b175
Fixing `min-height` issue
miukimiu Apr 7, 2022
caf07dd
Update src-docs/src/views/timeline/timeline_item.tsx
miukimiu Apr 7, 2022
06c9fcc
Update src-docs/src/views/timeline/timeline.tsx
miukimiu Apr 7, 2022
d62ceab
Update src-docs/src/views/timeline/timeline.tsx
miukimiu Apr 7, 2022
2de0a93
Update src-docs/src/views/timeline/timeline.tsx
miukimiu Apr 7, 2022
b25ab3b
Update src-docs/src/views/timeline/timeline_example.js
miukimiu Apr 7, 2022
3bb564f
Update src-docs/src/views/timeline/timeline_example.js
miukimiu Apr 7, 2022
525b98d
Update src-docs/src/views/timeline/timeline_example.js
miukimiu Apr 7, 2022
19aa16a
Update src-docs/src/views/timeline/timeline_example.js
miukimiu Apr 7, 2022
7d472b6
Update src-docs/src/views/timeline/timeline_example.js
miukimiu Apr 7, 2022
cf1dc53
Update src-docs/src/views/timeline/timeline_example.js
miukimiu Apr 7, 2022
5f3eada
Update src-docs/src/views/timeline/timeline_example.js
miukimiu Apr 7, 2022
a50eebf
Update src-docs/src/views/timeline/timeline_example.js
miukimiu Apr 7, 2022
b75a931
Prettier 🤩
miukimiu Apr 7, 2022
181da63
Adjusting the timeline icon line
miukimiu Apr 7, 2022
391b5b5
Removing `verticalAlign="center"` from examples
miukimiu Apr 7, 2022
8c91017
Fixing path to type
miukimiu Apr 7, 2022
28496cb
Recommendation for icon size
miukimiu Apr 7, 2022
2c9c667
Adding `iconAriaLabel` to EuiTimelineItem
miukimiu Apr 12, 2022
16a506e
Fixing issue with center vertical alignment
miukimiu Apr 12, 2022
9172994
Adding dot into prop description.
miukimiu Apr 12, 2022
c25b3d4
Update src-docs/src/views/timeline/timeline_example.js
miukimiu Apr 13, 2022
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
3 changes: 3 additions & 0 deletions src-docs/src/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ import { TextDiffExample } from './views/text_diff/text_diff_example';

import { TextExample } from './views/text/text_example';

import { TimelineExample } from './views/timeline/timeline_example';

import { TitleExample } from './views/title/title_example';

import { ToastExample } from './views/toast/toast_example';
Expand Down Expand Up @@ -496,6 +498,7 @@ const navigation = [
ProgressExample,
StatExample,
TextExample,
TimelineExample,
TitleExample,
ToastExample,
ToolTipExample,
Expand Down
7 changes: 6 additions & 1 deletion src-docs/src/views/avatar/avatar_icon.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ export default () => {
 
<EuiAvatar size="m" name="Medium size" iconType="managementApp" />
&emsp;
<EuiAvatar size="l" name="Large" iconType="managementApp" />
<EuiAvatar
size="l"
color="subdued"
name="Large"
iconType="managementApp"
/>
&emsp;
<EuiAvatar
size="xl"
Expand Down
44 changes: 44 additions & 0 deletions src-docs/src/views/timeline/timeline.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import React, { ReactElement } from 'react';
import {
EuiTimeline,
EuiTimelineProps,
EuiText,
EuiAvatar,
EuiPanel,
} from '../../../../src/components';

const wrapper = (children: ReactElement) => (
<EuiPanel paddingSize="none" color="transparent">
<EuiText size="s">{children}</EuiText>
</EuiPanel>
miukimiu marked this conversation as resolved.
Show resolved Hide resolved
);

const items: EuiTimelineProps['items'] = [
{
icon: <EuiAvatar name="email" iconType="email" color="subdued" />,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For all the names of the avatars, I would suggest using a word that describes the event type/action and not just repeating the icon name. This way when the user gets the tooltip, they're getting information about that's more meaningful to the context.

Screen Shot 2022-03-31 at 12 16 29 PM

Suggested change
icon: <EuiAvatar name="email" iconType="email" color="subdued" />,
icon: <EuiAvatar name="Invitation" iconType="email" color="subdued" />,

verticalAlign: 'center',
children: wrapper(
<p>
<strong>janet@elastic.co</strong> was invited to the project
</p>
),
},
{
icon: <EuiAvatar name="pencil" iconType="pencil" color="subdued" />,
verticalAlign: 'center',
children: wrapper(
<p>
The project was renamed to <strong>Revenue Dashboard</strong>
</p>
),
},
{
icon: (
<EuiAvatar name="folder closed" iconType="folderClosed" color="subdued" />
),
verticalAlign: 'center',
children: wrapper(<p>The project was archived</p>),
},
];

export default () => <EuiTimeline items={items} />;
157 changes: 157 additions & 0 deletions src-docs/src/views/timeline/timeline_complex.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
import React, { useState } from 'react';
import {
EuiTimelineItem,
EuiAvatar,
EuiText,
EuiSwitch,
EuiAccordion,
EuiFlexGroup,
EuiFlexItem,
EuiSpacer,
EuiBadge,
EuiTitle,
EuiSplitPanel,
EuiPanel,
EuiHorizontalRule,
} from '../../../../src/components';

import {
useGeneratedHtmlId,
euiPaletteColorBlind,
} from '../../../../src/services';

export default () => {
const [checked1, setChecked1] = useState(false);
const [checked2, setChecked2] = useState(false);
const [checked3, setChecked3] = useState(false);
const buttonElementAccordionId = useGeneratedHtmlId({
prefix: 'buttonElementAccordion',
});

const onChange1 = (e: {
target: { checked: React.SetStateAction<boolean> };
}) => {
setChecked1(e.target.checked);
};

const onChange2 = (e: {
target: { checked: React.SetStateAction<boolean> };
}) => {
setChecked2(e.target.checked);
};

const onChange3 = (e: {
target: { checked: React.SetStateAction<boolean> };
}) => {
setChecked3(e.target.checked);
};

const phase = (
title: string,
checked: boolean,
onChange: any,
avatarColor: string
) => (
<EuiTimelineItem
icon={
checked ? (
<EuiAvatar
size="m"
name="check icon"
iconType="check"
color={avatarColor}
/>
) : (
<EuiAvatar size="s" name="dot icon" iconType="dot" color="subdued" />
)
}
>
<EuiSplitPanel.Outer color="transparent" hasBorder grow>
<EuiSplitPanel.Inner color={checked ? 'transparent' : 'subdued'}>
<EuiFlexGroup alignItems="center" gutterSize="s">
<EuiFlexItem grow={false}>
<EuiSwitch
showLabel={false}
label={checked ? `${title} is on` : `${title} is off`}
checked={checked}
onChange={onChange}
/>
</EuiFlexItem>
<EuiFlexItem>
<EuiTitle size="s">
<h2>{title}</h2>
</EuiTitle>
</EuiFlexItem>
</EuiFlexGroup>
</EuiSplitPanel.Inner>
<EuiHorizontalRule margin="none" />
<EuiSplitPanel.Inner>
<EuiText size="s" grow={false}>
<p>
Move data to the cold tier when you are searching it less often
and don’t need to update it. The cold tier is optimized for cost
savings over search performance.
</p>
</EuiText>

{checked && (
<>
<EuiSpacer />
<EuiAccordion
id={buttonElementAccordionId}
buttonElement="div"
buttonContent="Advanced settings"
>
<EuiPanel color="transparent">
Any content inside of <strong>EuiAccordion</strong> will
appear here.
</EuiPanel>
</EuiAccordion>
</>
)}
</EuiSplitPanel.Inner>
</EuiSplitPanel.Outer>
</EuiTimelineItem>
);

return (
<div>
<EuiTimelineItem
icon={
<EuiAvatar
size="m"
name="check icon"
iconType="check"
color={euiPaletteColorBlind()[0]}
/>
}
>
<EuiSplitPanel.Outer color="transparent" hasBorder grow>
<EuiSplitPanel.Inner>
<EuiTitle size="s">
<h2>
Hot phase <EuiBadge color="warning">Required</EuiBadge>
</h2>
</EuiTitle>
</EuiSplitPanel.Inner>
<EuiHorizontalRule margin="none" />
<EuiSplitPanel.Inner>
<EuiText grow={false} size="s">
<p>
Store your most recent, most frequently-searched data in the hot
tier. The hot tier provides the best indexing and search
performance by using the most powerful, expensive hardware.
</p>
</EuiText>
</EuiSplitPanel.Inner>
</EuiSplitPanel.Outer>
</EuiTimelineItem>

{phase('Warm phase', checked1, onChange1, euiPaletteColorBlind()[1])}

{phase('Cold phase', checked2, onChange2, euiPaletteColorBlind()[2])}

{phase('Frozen phase', checked3, onChange3, euiPaletteColorBlind()[3])}
</div>
);
};
147 changes: 147 additions & 0 deletions src-docs/src/views/timeline/timeline_example.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
import React from 'react';
import { Link } from 'react-router-dom';
import { GuideSectionTypes } from '../../components';

import {
EuiCode,
EuiTimeline,
EuiTimelineItem,
} from '../../../../src/components';

import Timeline from './timeline';
const timelineSource = require('!!raw-loader!./timeline');
const timelineSnippet = `<EuiTimeline
timelines={[
miukimiu marked this conversation as resolved.
Show resolved Hide resolved
{
icon: icon,
children: content,
},
]}
miukimiu marked this conversation as resolved.
Show resolved Hide resolved
/>`;

import TimelineItem from './timeline_item';
const timelineItemSource = require('!!raw-loader!./timeline_item');
const timelineItemSnippet = `<EuiTimelineItem icon={icon}>
{content}
</EuiTimeline>`;

import TimelineItemEvent from './timeline_item_event';
const timelineItemEventSource = require('!!raw-loader!./timeline_item_event');
const timelineItemEventSnippet = `<EuiTimelineItem icon={icon}>
<EuiPanel paddingSize="none" color="transparent">
<EuiText size="s">
miukimiu marked this conversation as resolved.
Show resolved Hide resolved
<p>
<strong>Janet</strong> edited the dashboard 4 days ago
</p>
</EuiText>
</EuiPanel>
</EuiTimeline>`;

import TimelineComplex from './timeline_complex';
const TimelineComplexSource = require('!!raw-loader!./timeline_complex');

export const TimelineExample = {
title: 'Timeline',
miukimiu marked this conversation as resolved.
Show resolved Hide resolved
sections: [
miukimiu marked this conversation as resolved.
Show resolved Hide resolved
{
source: [
{
type: GuideSectionTypes.JS,
code: timelineSource,
},
],
text: (
<div>
The <strong>EuiTimeline</strong> is a component that standardizes the
miukimiu marked this conversation as resolved.
Show resolved Hide resolved
way a timeline thread is displayed. Pass an array of{' '}
<strong>EuiTimelineItem</strong> objects and{' '}
<strong>EuiTimeline</strong> will generate a timeline thread.
</div>
),
props: { EuiTimeline, EuiTimelineItem },
snippet: timelineSnippet,
demo: <Timeline />,
},
{
title: 'Timeline item',
source: [
{
type: GuideSectionTypes.JS,
code: timelineItemSource,
},
],
text: (
<>
<p>
Use <strong>EuiTimelineItem</strong> to display timeline items. Each{' '}
miukimiu marked this conversation as resolved.
Show resolved Hide resolved
<strong>EuiTimelineItem</strong> has two parts: an icon on the left
side and an event on the right side. To create an item you basically
miukimiu marked this conversation as resolved.
Show resolved Hide resolved
need the following props:
</p>
<ul>
<li>
<EuiCode>icon</EuiCode>: main icon that appears on the left side.
miukimiu marked this conversation as resolved.
Show resolved Hide resolved
</li>
<li>
<EuiCode>children</EuiCode>: event content. You can pass any node.
miukimiu marked this conversation as resolved.
Show resolved Hide resolved
</li>
</ul>
</>
),
props: { EuiTimelineItem },
snippet: timelineItemSnippet,
demo: <TimelineItem />,
},
{
title: 'Customizing an event',
source: [
{
type: GuideSectionTypes.JS,
code: timelineItemEventSource,
},
],
text: (
<>
<p>
Although any node is allowed as a <EuiCode>children</EuiCode> the
recommendation is to use a{' '}
<Link to="/layout/panel">
<strong>EuiPanel</strong>
</Link>{' '}
or a{' '}
<Link to="/layout/panel#split-panels">
<strong>EuiSplitPanel</strong>
</Link>{' '}
when your content is text-based. For other types of components like
editors, the recommendation is to pass the{' '}
<EuiCode>children</EuiCode> without any wrapper.
</p>
</>
),
snippet: timelineItemEventSnippet,
demo: <TimelineItemEvent />,
},
{
title: 'Complex example',
source: [
{
type: GuideSectionTypes.JS,
code: TimelineComplexSource,
},
],
text: (
<div>
<p>
This is an example of how you can customize and display multiple{' '}
<strong>EuiTimelineItem</strong>.
</p>
</div>
),
props: {
EuiTimeline,
EuiTimelineItem,
},
demo: <TimelineComplex />,
},
],
};
Loading