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 EuiComment #3179

Merged
merged 27 commits into from
Apr 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
f83761b
playing with css and layouts
andreadelrio Mar 5, 2020
cb9a8d5
more experimentation with styles
andreadelrio Mar 9, 2020
e8c77e6
before adding an extra style to commentEvent
andreadelrio Mar 11, 2020
61dad2f
some things I stashed, not sure why
andreadelrio Mar 16, 2020
508211e
will try a different way for separator
andreadelrio Mar 20, 2020
193a22b
rename one prop and improve handling of large timelineIcon
andreadelrio Mar 23, 2020
40f046b
props descriptions not showing up
andreadelrio Mar 24, 2020
0f088f9
improve demo
andreadelrio Mar 25, 2020
4776ea4
clean and more tests
andreadelrio Mar 25, 2020
9e2a095
mobile small improvement
andreadelrio Mar 26, 2020
58fc8f9
add snippet
andreadelrio Mar 26, 2020
1fa8a6e
Merge branch 'master' into comment
thompsongl Mar 26, 2020
e5b1d1c
add cl
andreadelrio Mar 26, 2020
c691624
feedback part 1
andreadelrio Mar 31, 2020
89f1fef
feedback part 2
andreadelrio Apr 2, 2020
c4fbca4
remove commentList for now
andreadelrio Apr 2, 2020
ea74210
header in regular has min-height and fixed separator in mobile
andreadelrio Apr 2, 2020
56855b3
documentation feedback
andreadelrio Apr 3, 2020
91eb5fb
more feedback and new tests
andreadelrio Apr 6, 2020
6cb33b1
more tests and more IE fixes
andreadelrio Apr 6, 2020
0e831b0
Tidying CSS a bit and fixing IE and responsiveness
Apr 6, 2020
12eb136
Merge pull request #8 from cchaos/andreadelrio-comment
andreadelrio Apr 6, 2020
c96b3cc
greg's feedback
andreadelrio Apr 7, 2020
da73824
small a11y change
andreadelrio Apr 7, 2020
c986405
figure; better type inheritance
thompsongl Apr 8, 2020
a2be805
Merge remote-tracking branch 'upstream/master' into comment
andreadelrio Apr 8, 2020
d6cf389
update cl
andreadelrio Apr 8, 2020
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- Added support for `href`, `onClick`, and related props in `EuiBasicTable` default actions ([#3115](https://github.com/elastic/eui/pull/3115))
- Added support for `EuiCodeEditor` to set `readonly` and `id` on `<textarea />` ([#3212](https://github.com/elastic/eui/pull/3212))
- Added `EuiComment` component ([#3179](https://github.com/elastic/eui/pull/3179))

**Deprecation**

Expand Down
3 changes: 3 additions & 0 deletions src-docs/src/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ import { ColorPickerExample } from './views/color_picker/color_picker_example';

import { ComboBoxExample } from './views/combo_box/combo_box_example';

import { CommentExample } from './views/comment/comment_example';

import { ContextMenuExample } from './views/context_menu/context_menu_example';

import { ControlBarExample } from './views/control_bar/control_bar_example';
Expand Down Expand Up @@ -364,6 +366,7 @@ const navigation = [
CallOutExample,
CardExample,
CodeExample,
CommentExample,
DescriptionListExample,
DragAndDropExample,
EmptyPromptExample,
Expand Down
103 changes: 103 additions & 0 deletions src-docs/src/views/comment/comment.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
import React from 'react';
import { EuiComment } from '../../../../src/components/comment';
import { EuiAvatar } from '../../../../src/components/avatar';
import { EuiBadge } from '../../../../src/components/badge';
import { EuiFlexGroup, EuiFlexItem } from '../../../../src/components/flex';
import { EuiButtonIcon } from '../../../../src/components/button';
import { EuiText } from '../../../../src/components/text';

const body = (
<EuiText size="s">
<p>
Far out in the uncharted backwaters of the unfashionable end of the
western spiral arm of the Galaxy lies a small unregarded yellow sun.
</p>
</EuiText>
);

const longBody = (
<EuiText size="s">
<p>
This planet has - or rather had - a problem, which was this: most of the
people living on it were unhappy for pretty much of the time. Many
solutions were suggested for this problem, but most of these were largely
concerned with the movements of small green pieces of paper, which is odd
because on the whole it was not the small green pieces of paper that were
unhappy.
</p>
</EuiText>
);

const copyAction = (
<EuiButtonIcon
title="Custom action"
aria-label="Custom action"
color="subdued"
iconType="copy"
/>
);

export default () => (
<div>
<EuiComment
username="janed"
event="added a comment"
actions={copyAction}
timestamp="on Jan 1, 2020">
andreadelrio marked this conversation as resolved.
Show resolved Hide resolved
{body}
</EuiComment>
<EuiComment
username="juanab"
type="update"
actions={copyAction}
event="pushed incident X0Z235"
timestamp="on Jan 3, 2020"
timelineIcon={
<EuiAvatar
imageUrl="https://source.unsplash.com/64x64/?woman"
size="l"
name="Juana"
/>
}
/>
<EuiComment
username="pancho1"
type="update"
event="edited case"
timestamp="on Jan 9, 2020"
/>
<EuiComment
actions={copyAction}
username={
<EuiFlexGroup responsive={false} alignItems="center" gutterSize="s">
<EuiFlexItem grow={false}>
<EuiAvatar size="s" type="space" name="Pedro" />
</EuiFlexItem>
<EuiFlexItem grow={false}>pedror</EuiFlexItem>
</EuiFlexGroup>
}
type="update"
event={
<EuiFlexGroup responsive={false} alignItems="center" gutterSize="s">
<EuiFlexItem grow={false}>added tags</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiBadge color="primary">sample</EuiBadge>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiBadge color="secondary">review</EuiBadge>
</EuiFlexItem>
</EuiFlexGroup>
}
timestamp="on Jan 11, 2020"
timelineIcon="tag"
/>
<EuiComment
username="elohar"
event="added a comment"
actions={copyAction}
timestamp="on Jan 14, 2020"
timelineIcon={<EuiAvatar size="l" name="Eloha" />}>
{longBody}
</EuiComment>
</div>
);
103 changes: 103 additions & 0 deletions src-docs/src/views/comment/comment_actions.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
import React, { Component, HTMLAttributes } from 'react';
import { EuiComment } from '../../../../src/components/comment';
import { EuiButtonIcon } from '../../../../src/components/button';
import { EuiText } from '../../../../src/components/text';
import { EuiPopover } from '../../../../src/components/popover';
import {
EuiContextMenuPanel,
EuiContextMenuItem,
} from '../../../../src/components/context_menu';
import { CommonProps } from '../../../../src/components/common';

const body = (
<EuiText size="s">
<p>
This comment has custom actions available. See the upper right corner.
</p>
</EuiText>
);

export type CustomActionsProps = HTMLAttributes<HTMLDivElement> &
CommonProps & {};

interface CustomActionsState {
isPopoverOpen: boolean;
}

export default class extends Component<CustomActionsProps, CustomActionsState> {
state = {
isPopoverOpen: false,
};

togglePopover = () => {
this.setState(prevState => ({
isPopoverOpen: !prevState.isPopoverOpen,
}));
};

closePopover = () => {
this.setState({
isPopoverOpen: false,
});
};

render() {
const { isPopoverOpen } = this.state;
const customActions = (
<EuiPopover
button={
<EuiButtonIcon
aria-label="Actions"
iconType="gear"
size="s"
color="text"
onClick={() => this.togglePopover()}
/>
}
isOpen={isPopoverOpen}
closePopover={() => this.closePopover()}
panelPaddingSize="none"
anchorPosition="leftCenter">
<EuiContextMenuPanel
items={[
<EuiContextMenuItem
key="A"
icon="pencil"
onClick={() => {
this.closePopover();
}}>
Edit
</EuiContextMenuItem>,
<EuiContextMenuItem
key="B"
icon="share"
onClick={() => {
this.closePopover();
}}>
Share
</EuiContextMenuItem>,
<EuiContextMenuItem
key="C"
icon="copy"
onClick={() => {
this.closePopover();
}}>
Copy
</EuiContextMenuItem>,
]}
/>
</EuiPopover>
);
return (
<div>
<EuiComment
username="janed"
event="added a comment"
actions={customActions}
timestamp="Jan 1, 2020">
{body}
</EuiComment>
</div>
);
}
}
Loading