-
Notifications
You must be signed in to change notification settings - Fork 842
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
[EuiComment] Add "custom"
option to EuiComment.type
and more enhancements
#5692
Conversation
Preview documentation changes for this PR: https://eui.elastic.co/pr_5692/ |
"custom"
and comment system example "custom"
option to EuiComment.type
and comment system docs example
Preview documentation changes for this PR: https://eui.elastic.co/pr_5692/ |
Preview documentation changes for this PR: https://eui.elastic.co/pr_5692/ |
Hey @miukimiu. Thanks for working on this. I've actually been working on a slight rework of cases in the Security app and one thing @dimadavid and I had trouble with is why the avatar icon pattern flip flops. In Github flows this can make sense because of the indents and "child" representation of things, but the way we use it (with a linear line) makes it a little difficult to grok. Part of me wonders if we should just keep avatars on one side, and actions on the other. There are generally going to be three styles of feed items coming in the stream:
Another state that we needed to cover was:
^^ we don't have a good pattern for this, and I was likely going to do it through custom css. In any case, this screen shows a bit of the trouble: |
Let's also not forget to do any updates to the Figma Library if we change component configurations. |
Here are a few ideas to solve the issues @snide mentioned:
@snide it would be really helpful if you could give me an example of a real timeline. Just the text examples. The Figma prototype can be found here. Let me know what you think. |
Thanks @miukimiu ! I added comments to the FIgma. |
@snide @cchaos and @dimadavid just to keep the API conversation here and after going through the Figma comments here are my proposed changes: 1 - In the current implementation, the avatar with the user is the default. I propose to change it to avatar initials. The 2 - When the 3 - Be able to pass a 4 - Custom actions should be aligned on the right side. New icons (probably not needed)1 - I noticed that in Observability -> Cases an arrow right is being used to show the alert details (opens in a flyout). What should be the right icon for this scenario? I created a new one called for now 2 - If we change to avatars for the initials we won't require to show the icon These new designs are in the prototype (pages 3 and 4). You can add your design comments there. |
Preview documentation changes for this PR: https://eui.elastic.co/pr_5692/ |
Preview documentation changes for this PR: https://eui.elastic.co/pr_5692/ |
Preview documentation changes for this PR: https://eui.elastic.co/pr_5692/ |
Preview documentation changes for this PR: https://eui.elastic.co/pr_5692/ |
…e additional qualifiers
I re-enabled the |
Preview documentation changes for this PR: https://eui.elastic.co/pr_5692/ |
…ith-markdown-editor
Preview documentation changes for this PR: https://eui.elastic.co/pr_5692/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love the final output of this. Very uniform and easy to scan. Here is some early feedback just looking at the component code and output for now. I'm also happy to pair on any of these that aren't particularly clear.
Mobile
I would see if you can get the event details items to all wrap in some fashion otherwise they'll need sort of overflow scroll on them or something.
@@ -45,7 +45,6 @@ export const EuiTimelineItem: FunctionComponent<EuiTimelineItemProps> = ({ | |||
verticalAlign = 'center', | |||
icon, | |||
iconAriaLabel, | |||
className, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Nice catch
@@ -31,6 +31,7 @@ export const euiTimelineItemStyles = ({ euiTheme }: UseEuiTheme) => ({ | |||
} | |||
|
|||
&:not(:only-child) > [class*='euiTimelineItemIcon-center']::before { | |||
display: flex; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you'll find that you'll be fighting with this override quite a bit if you ever change the default display
of EuiTimelineItemIcon. You may want to mvoe this set of styles to outside of :last-of-type
.
let iconRender; | ||
if (typeof timelineIcon === 'string') { | ||
iconRender = ( | ||
<EuiIcon size={type === 'update' ? 'm' : 'l'} type={timelineIcon} /> | ||
<EuiAvatar | ||
className="euiCommentTimeline" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just looking at the rendered DOM output, this classname no longer seems appropriate. Since there's already a breaking change on this component, I'd suggest changing this to be EuiCommentIcon
or EuiCommentTimelineIcon
or even avatar
instead of icon
. But leaving it at simply timeline
I think mis-represents what and where it renders.
username="someuser" | ||
timelineIcon={<EuiAvatar size="l" name="Mario" />} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm, do we think this is duplicative? Mostly meaning, if username
is required, but they want to pass a custom Avatar, they're most likely duplicating username
on both but the timeline icon doesn't actually render / use the username
anymore in the custom case.
*/ | ||
comments?: EuiCommentProps[]; | ||
}; | ||
export type EuiCommentListProps = EuiTimelineProps & { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Preview documentation changes for this PR: https://eui.elastic.co/pr_5692/ |
I'm pushing this PR off to Stack 8.4 as it's a major breaking change for all consumers of this component. |
Preview documentation changes for this PR: https://eui.elastic.co/pr_5692/ |
Preview documentation changes for this PR: https://eui.elastic.co/pr_5692/ |
Closing in favor of #6030 |
Summary
The idea of this PR was to add a docs example/demo of a comment system similar to the one from Security -> Cases.
But when I tried to build the demo I struggled to add a EuiMarkdownEditor inside a comment list. So I inspected the code of the Security -> Cases and noticed that they styled the comment list to make it work:
https://github.com/elastic/kibana/blob/513a08ea390156327a8fbeed4d6d6254315e02cd/x-pack/plugins/cases/public/components/user_actions/index.tsx#L43-L56
This research leads to introducing a new component called EuiTimeline #5730 and some enhancements in
EuiCommentList
andEuiComment
components to better suit Security and Observability use cases. Thanks, @snide, and @cchaos for showing me pain points in the current usages.Using the EuiTimeline
The EuiCommentList and EuiComment are now using the new EuiTimeline and EuiTimelineItem components respectively.
New props
I added a
"custom"
option toEuiComment.type
. With this option, consumers can pass any custom element in the timeline.In the past, the timeline was reflecting the type of event. The type
update
had a smaller avatar and it was defaulting to adot
. Now the timeline always defaults to the avatar with the username initial letter:For this reason, I needed to introduce a new prop
updateIcon
to allow the events typeupdate
to have a custom icon. Also added a prop calledupdateColor
that changes de panel color of an event typeupdate
.The
EuiComment.actions
prop was updated to also accept aReactNode[]
. This way we ensure better spacing when multiple actions are added.Breaking changes
I changed the
EuiCommentEvent.username
type fromReactNode
tostring
. The reason for that is that now the timeline icon defaults to an avatar with an initial username letter. So we need to make sure the username is a string to pass to theEuiAvatar.name
.Another breaking change is that EuiCommentList (
<ol/>
) is now required to wrap the EuiComment whenEuiComment.component
defaults toli
.Note: Not having any of these new requirements doesn't break the code but throws TS errors and without the wrapper, it breaks the a11y.
Docs
The docs were updated to reflect the changes and two new sections were added:
Checklist
[ ] Checked in mobile[ ] Checked for breaking changes and labeled appropriately[ ] Checked for accessibility including keyboard-only and screenreader modesThings to look out for when moving styles
[ ] Convert global Sass vars to JS version like sizing[ ] Convert component-specific Sass vars to exported JS versions-inline
and-block
(Logical properties)gap
property to add margin between items if using flex[ ] Can any still existing.js
files be converted to TS?[ ] All animations or transitions are wrapped ineuiCanAnimate
QA