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

[EuiComment] Add "custom" option to EuiComment.type and more enhancements #5692

Closed
Show file tree
Hide file tree
Changes from 46 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
239bfe2
[EuiComment] Add type `"custom"`
elizabetdev Mar 4, 2022
662e8c6
Adding error state
elizabetdev Mar 4, 2022
ba11471
Adding CL
elizabetdev Mar 4, 2022
fa92dae
CL number
elizabetdev Mar 4, 2022
8da2022
Adding missing array key
elizabetdev Mar 4, 2022
b7a37c8
All children using `EuiMarkdownFormat` to render
elizabetdev Mar 7, 2022
36189ad
Fixing codesandbox issue with height
elizabetdev Mar 7, 2022
770d299
Changed `.euiMarkdownEditor` display to `flex`
elizabetdev Mar 7, 2022
b794788
Adding unit tests for `type`
elizabetdev Mar 7, 2022
bad52f5
Removing error text
elizabetdev Mar 9, 2022
b877e80
Adding new props
elizabetdev Mar 15, 2022
136d073
Adding docs
elizabetdev Mar 15, 2022
6491fd2
Text examples
elizabetdev Mar 16, 2022
d3d756b
Merge remote-tracking branch 'upstream/main' into docs-comment-list-w…
elizabetdev Mar 16, 2022
8073f6f
Actions a `ReactNode[]`
elizabetdev Mar 16, 2022
3bdfe60
Better variable naming
elizabetdev Mar 16, 2022
adaccf8
Adding new line in CL
elizabetdev Mar 16, 2022
371e152
Adding CL entry
elizabetdev Mar 16, 2022
00cd73f
Removing unnecessary prop
elizabetdev Mar 16, 2022
e17e9d1
Section title
elizabetdev Mar 16, 2022
de5e729
CL again
elizabetdev Mar 16, 2022
d9ec9fd
Merge remote-tracking branch 'upstream/main' into docs-comment-list-w…
elizabetdev Apr 26, 2022
e5000cb
Adding `EuiTimeline` and converting to emotion.
elizabetdev Apr 26, 2022
796707f
WIP
elizabetdev Apr 26, 2022
010e593
Adding `gap`, `padding-block` and `padding-inline`
elizabetdev Apr 27, 2022
08eb192
Wrapping all `EuiComment`s in a `EuiCommentList`
elizabetdev Apr 27, 2022
a7abb35
Adding intro text
elizabetdev Apr 27, 2022
a3336a9
Merge remote-tracking branch 'upstream/main' into docs-comment-list-w…
elizabetdev Apr 27, 2022
e1df245
Avoiding nesting divs in `EuiText`
elizabetdev Apr 27, 2022
08a9d09
Fixing icon issue
elizabetdev Apr 27, 2022
fa8a3d2
CL. Tags without colors.
elizabetdev Apr 27, 2022
18f5a55
Adding header actions margin
elizabetdev Apr 28, 2022
dcb1920
CL
elizabetdev Apr 28, 2022
ab42297
Merge remote-tracking branch 'upstream/main' into docs-comment-list-w…
elizabetdev Apr 28, 2022
0cfad84
Added `component` prop to `EuiComment`
elizabetdev Apr 28, 2022
14e907b
Adding `className`s
elizabetdev Apr 28, 2022
4bd0907
Minor style change
elizabetdev Apr 28, 2022
2f260ef
Merge remote-tracking branch 'upstream/main' into docs-comment-list-w…
elizabetdev May 3, 2022
0401881
`euiCommentEvent` putting overflow hidden back
elizabetdev May 3, 2022
0447029
Fixing a11y issue in copy to clipboard example with EuiComment
elizabetdev May 3, 2022
2618205
Fixing `updateIcon` a11y issues
elizabetdev May 3, 2022
d00143c
Better emotion styles grouping
elizabetdev May 3, 2022
bb28072
Snippets
elizabetdev May 4, 2022
d2e4779
Snippets
elizabetdev May 4, 2022
d25ed5c
Extend shouldRenderCustomStyles class name regex to allow zero or mor…
chandlerprall May 4, 2022
3b4d601
Merge remote-tracking branch 'upstream/main' into docs-comment-list-w…
elizabetdev May 6, 2022
a7a0ee2
No more comment types
elizabetdev May 11, 2022
ba8de79
Removed `EuiComment.type` and more changes
elizabetdev May 12, 2022
33993d5
Adding `logicalCSS`
elizabetdev May 12, 2022
629db79
Prettier
elizabetdev May 16, 2022
3b93f5b
Adding flexibe component section
elizabetdev May 18, 2022
252ce33
Merge remote-tracking branch 'upstream/main' into docs-comment-list-w…
elizabetdev May 18, 2022
c953a18
simplifying avatar line vertical alignment logic
elizabetdev May 24, 2022
9737423
Merge remote-tracking branch 'upstream/main' into docs-comment-list-w…
elizabetdev May 24, 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
19 changes: 9 additions & 10 deletions src-docs/src/views/comment/comment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@ const copyAction = (
);

export default () => (
<div>
<EuiComment
username="janed"
event="added a comment"
actions={copyAction}
timestamp="on Jan 1, 2020"
>
{body}
</EuiComment>
</div>
<EuiComment
username="janed"
event="added a comment"
actions={copyAction}
timestamp="on Jan 1, 2020"
component="div"
>
{body}
</EuiComment>
);
210 changes: 123 additions & 87 deletions src-docs/src/views/comment/comment_actions.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import React, { Component, HTMLAttributes } from 'react';
import { EuiComment } from '../../../../src/components/comment_list';
import { EuiButtonIcon } from '../../../../src/components/button';
import { EuiText } from '../../../../src/components/text';
import { EuiPopover } from '../../../../src/components/popover';
import React, { useState } from 'react';
import {
EuiCommentList,
EuiComment,
EuiButtonIcon,
EuiText,
EuiPopover,
EuiContextMenuPanel,
EuiContextMenuItem,
} from '../../../../src/components/context_menu';
import { CommonProps } from '../../../../src/components/common';
EuiLink,
EuiFlyout,
EuiFlyoutHeader,
EuiFlyoutBody,
EuiTitle,
} from '../../../../src/components/';
import { useGeneratedHtmlId } from '../../../../src/services/';

const body = (
<EuiText size="s">
Expand All @@ -17,92 +23,122 @@ const body = (
</EuiText>
);

export type CustomActionsProps = HTMLAttributes<HTMLDivElement> &
CommonProps & {};
export default () => {
const [isPopoverOpen, setIsPopoverOpen] = useState(false);
const [isFlyoutVisible, setIsFlyoutVisible] = useState(false);

interface CustomActionsState {
isPopoverOpen: boolean;
}
const flyoutTitleId = useGeneratedHtmlId({
prefix: 'flyoutTitleId',
});

export default class extends Component<CustomActionsProps, CustomActionsState> {
state = {
isPopoverOpen: false,
const togglePopover = () => {
setIsPopoverOpen(!isPopoverOpen);
};

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

closePopover = () => {
this.setState({
isPopoverOpen: false,
});
const toggleFlyout = () => {
setIsFlyoutVisible(!isFlyoutVisible);
};

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>,
]}
const flyout = isFlyoutVisible && (
<EuiFlyout
ownFocus
onClose={() => setIsFlyoutVisible(false)}
aria-labelledby={flyoutTitleId}
>
<EuiFlyoutHeader hasBorder>
<EuiTitle size="m">
<h2 id={flyoutTitleId}>Malware detection alert</h2>
</EuiTitle>
</EuiFlyoutHeader>
<EuiFlyoutBody>
<EuiText>
<p>
Use a flyout to show more details related to your comment event.
</p>
</EuiText>
</EuiFlyoutBody>
</EuiFlyout>
);

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

const updateActions = [
<EuiButtonIcon
key="copy-alert"
title="Copy alert link"
aria-label="Copy alert link"
iconType="link"
size="xs"
color="text"
/>,
<EuiButtonIcon
key="show-details"
title="Show the alert details in a flyout"
aria-label="Show details"
iconType="popout"
size="xs"
color="text"
onClick={toggleFlyout}
/>,
];

return (
<EuiCommentList aria-label="Actions">
<EuiComment
username="janed"
event="added a comment"
actions={customActions}
timestamp="Jan 1, 2020"
>
{body}
</EuiComment>
<EuiComment
type="update"
username="system"
event={
<>
added an alert from <EuiLink>malware detection</EuiLink>
</>
}
actions={updateActions}
timestamp="Jan 2, 2020"
timelineIcon="dot"
/>
{flyout}
</EuiCommentList>
);
};
Loading