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 1 commit
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
57 changes: 36 additions & 21 deletions src-docs/src/views/comment/comment_example.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React from 'react';
andreadelrio marked this conversation as resolved.
Show resolved Hide resolved

import { Link } from 'react-router';

import { renderToHtml } from '../../services';

import { GuideSectionTypes } from '../../components';
Expand Down Expand Up @@ -49,6 +51,7 @@ const commentTimelineIconsSnippet = [
`<EuiComment timelineIcon={
<EuiAvatar
name="Jane D"
size="l"
/>
} username="janed">
{body}
Expand Down Expand Up @@ -77,14 +80,14 @@ export const CommentExample = {
text: (
<div>
<p>
Use <strong>EuiComment</strong> for displaying comment threads with{' '}
<strong>EuiCommentList</strong>. Each <strong>EuiComment</strong>{' '}
has two parts: a <EuiCode>timelineIcon</EuiCode> on the left and
content on the right. The <EuiCode>timelineIcon</EuiCode> provides a
visual indication of the <EuiCode>type</EuiCode> of comment it is.
For example, it can be an icon that represents what action was
performed or it can be a user avatar. The content has a header with
all the relevant metadata and a body.
Use <strong>EuiComment</strong> to display comments. Each{' '}
<strong>EuiComment</strong> has two parts: a{' '}
<EuiCode>timelineIcon</EuiCode> on the left and content on the
right. The <EuiCode>timelineIcon</EuiCode> provides a visual
indication of the <EuiCode>type</EuiCode> of comment it is. For
example, it can be an icon that represents what action was performed
or it can be a user avatar. The content has a header with all the
relevant metadata and a body.
</p>
</div>
),
Expand All @@ -107,12 +110,12 @@ export const CommentExample = {
text: (
<div>
<p>
Use the default <EuiCode>type</EuiCode> of comment,{' '}
<EuiCode>regular</EuiCode> to display comments that a user has
The default <EuiCode>type</EuiCode> of comment is
<EuiCode>regular</EuiCode> and displays a comment that a user has
written.
</p>
<p>
Use comments of type <EuiCode>update</EuiCode> to display comments
Change the type to <EuiCode>update</EuiCode> to display comments
that generally do not have a body and are logging actions that
either the user or the system has performed (e.g. &ldquo;jsmith
edited a case&rdquo; or &ldquo;kibanamachine added the review
Expand All @@ -125,7 +128,7 @@ export const CommentExample = {
demo: <CommentTypes />,
},
{
title: 'Custom timelineIcon',
title: 'Custom timeline icon',
source: [
{
type: GuideSectionTypes.JS,
Expand All @@ -143,19 +146,21 @@ export const CommentExample = {
</p>
<ol>
<li>
Use the defaults a) a user icon inside a 40x40 container for
comments of type
<EuiCode>regular</EuiCode> and b) a dot icon inside a 24x24
container for comments of type <EuiCode>update</EuiCode>.
Use the defaults; a user icon inside a large container for
<EuiCode>regular</EuiCode> comments; or a dot icon inside a small
container for <EuiCode>update</EuiCode> comments.
</li>
<li>
Pass a string with any of the icon types that{' '}
<strong>EuiIcon</strong> supports and it will receive the default
styling.
</li>
<li>
Pass any other element (e.g. <strong>EuiAvatar</strong>). It is
recommended not to use an element larger that 40x40.
Pass any other element (e.g.{' '}
<Link to="/display/avatar">
<strong>EuiAvatar</strong>
</Link>
). It is recommended not to use an element larger that 40x40.
andreadelrio marked this conversation as resolved.
Show resolved Hide resolved
</li>
</ol>
</div>
Expand Down Expand Up @@ -187,9 +192,19 @@ export const CommentExample = {
prop. These will be placed to the right of the metadata in the
comment&apos;s header. You can use any element to display{' '}
<EuiCode>actions</EuiCode>. For example, for something simple you
can use <strong>EuiButtonIcon</strong> and for something more
complex you can combine that with <strong>EuiPopover</strong> and{' '}
<strong>EuiContextMenu</strong>.
can use{' '}
<Link to="/navigation/button">
<strong>EuiButtonIcon</strong>
</Link>{' '}
and for something more complex you can combine that with{' '}
<Link to="/layout/popover">
<strong>EuiPopover</strong>
</Link>{' '}
and{' '}
<Link to="/navigation/context-menu">
<strong>EuiContextMenu</strong>
</Link>
.
</p>
</div>
),
Expand Down
2 changes: 1 addition & 1 deletion src-docs/src/views/comment/comment_timelineIcons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const defaultBody = (
<EuiText size="s">
<p>
This comment and the one below are using the default{' '}
<EuiCode>timelineIcon</EuiCode>s.
<EuiCode>timelineIcon</EuiCode>.
</p>
</EuiText>
);
Expand Down
11 changes: 0 additions & 11 deletions src-docs/src/views/comment/comment_types.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import { EuiComment } from '../../../../src/components/comment';
import { EuiButtonIcon } from '../../../../src/components/button';
import { EuiText } from '../../../../src/components/text';
import { EuiCode } from '../../../../src/components/code';

Expand All @@ -20,21 +19,11 @@ const bodyUpdate = (
</EuiText>
);

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

export default () => (
<div>
<EuiComment
username="andred"
event="added a comment"
actions={copyAction}
timestamp="Jan 1, 2020">
{body}
</EuiComment>
Expand Down
30 changes: 6 additions & 24 deletions src/components/comment/__snapshots__/comment.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ exports[`EuiComment is rendered 1`] = `
class="euiCommentTimeline__content"
>
<div
class="euiCommentTimeline__default euiCommentTimeline--regular"
class="euiCommentTimeline__icon--default euiCommentTimeline__icon--regular"
>
<div
data-euiicon-type="user"
Expand All @@ -39,9 +39,6 @@ exports[`EuiComment is rendered 1`] = `
class="euiCommentEvent__headerEvent"
/>
</div>
<div
class="euiCommentEvent__headerActions"
/>
</div>
</div>
</div>
Expand All @@ -58,7 +55,7 @@ exports[`EuiComment props event is rendered 1`] = `
class="euiCommentTimeline__content"
>
<div
class="euiCommentTimeline__default euiCommentTimeline--regular"
class="euiCommentTimeline__icon--default euiCommentTimeline__icon--regular"
>
<div
data-euiicon-type="user"
Expand Down Expand Up @@ -86,9 +83,6 @@ exports[`EuiComment props event is rendered 1`] = `
commented
</div>
</div>
<div
class="euiCommentEvent__headerActions"
/>
</div>
</div>
</div>
Expand All @@ -105,7 +99,7 @@ exports[`EuiComment props timelineIcon is rendered 1`] = `
class="euiCommentTimeline__content"
>
<div
class="euiCommentTimeline--regular"
class="euiCommentTimeline__icon--regular"
>
<div
aria-label="Mario"
Expand Down Expand Up @@ -140,9 +134,6 @@ exports[`EuiComment props timelineIcon is rendered 1`] = `
class="euiCommentEvent__headerEvent"
/>
</div>
<div
class="euiCommentEvent__headerActions"
/>
</div>
</div>
</div>
Expand All @@ -159,7 +150,7 @@ exports[`EuiComment props timestamp is rendered 1`] = `
class="euiCommentTimeline__content"
>
<div
class="euiCommentTimeline__default euiCommentTimeline--regular"
class="euiCommentTimeline__icon--default euiCommentTimeline__icon--regular"
>
<div
data-euiicon-type="user"
Expand Down Expand Up @@ -193,9 +184,6 @@ exports[`EuiComment props timestamp is rendered 1`] = `
</time>
</div>
</div>
<div
class="euiCommentEvent__headerActions"
/>
</div>
</div>
</div>
Expand All @@ -212,7 +200,7 @@ exports[`EuiComment props type is rendered 1`] = `
class="euiCommentTimeline__content"
>
<div
class="euiCommentTimeline__default euiCommentTimeline--update"
class="euiCommentTimeline__icon--default euiCommentTimeline__icon--update"
>
<div
data-euiicon-type="dot"
Expand All @@ -238,9 +226,6 @@ exports[`EuiComment props type is rendered 1`] = `
class="euiCommentEvent__headerEvent"
/>
</div>
<div
class="euiCommentEvent__headerActions"
/>
</div>
</div>
</div>
Expand All @@ -257,7 +242,7 @@ exports[`EuiComment renders a body 1`] = `
class="euiCommentTimeline__content"
>
<div
class="euiCommentTimeline__default euiCommentTimeline--regular"
class="euiCommentTimeline__icon--default euiCommentTimeline__icon--regular"
>
<div
data-euiicon-type="user"
Expand All @@ -283,9 +268,6 @@ exports[`EuiComment renders a body 1`] = `
class="euiCommentEvent__headerEvent"
/>
</div>
<div
class="euiCommentEvent__headerActions"
/>
</div>
<div
class="euiCommentEvent__body"
Expand Down
26 changes: 26 additions & 0 deletions src/components/comment/__snapshots__/comment_event.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`EuiCommentEvent is rendered 1`] = `
<div
aria-label="aria-label"
class="euiCommentEvent euiCommentEvent--regular testClass1 testClass2"
data-test-subj="test subject string"
>
<div
class="euiCommentEvent__header"
>
<div
class="euiCommentEvent__headerData"
>
<div
class="euiCommentEvent__headerUsername"
>
someuser
</div>
<div
class="euiCommentEvent__headerEvent"
/>
</div>
</div>
</div>
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`EuiCommentTimeline is rendered 1`] = `
<div
aria-label="aria-label"
class="euiCommentTimeline testClass1 testClass2"
data-test-subj="test subject string"
>
<div
class="euiCommentTimeline__content"
>
<div
class="euiCommentTimeline__icon--default euiCommentTimeline__icon--regular"
>
<div
data-euiicon-type="user"
/>
</div>
</div>
</div>
`;
1 change: 1 addition & 0 deletions src/components/comment/_comment_event.scss
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
}

min-height: $euiSizeXXL;
height: $euiSize; // vertical centering stops working in IE when there's a min-height and not a height.
cchaos marked this conversation as resolved.
Show resolved Hide resolved
background-color: $euiColorLightestShade;
border-bottom: $euiBorderThin;
padding: 0 $euiSizeS;
Expand Down
6 changes: 3 additions & 3 deletions src/components/comment/_comment_timeline.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
position: relative;
}

.euiCommentTimeline__default {
.euiCommentTimeline__icon--default {
flex-shrink: 0;
display: flex;
justify-content: center;
Expand All @@ -15,12 +15,12 @@
border-radius: 50%;
background-color: $euiColorLightestShade;

&.euiCommentTimeline--regular {
&.euiCommentTimeline__icon--regular {
width: $euiSizeXXL;
height: $euiSizeXXL;
}

&.euiCommentTimeline--update {
&.euiCommentTimeline__icon--update {
width: $euiSizeL;
height: $euiSizeL;
}
Expand Down
15 changes: 15 additions & 0 deletions src/components/comment/comment_event.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react';
import { render } from 'enzyme';
import { requiredProps } from '../../test/required_props';

import { EuiCommentEvent } from './comment_event';

describe('EuiCommentEvent', () => {
test('is rendered', () => {
andreadelrio marked this conversation as resolved.
Show resolved Hide resolved
const component = render(
<EuiCommentEvent username="someuser" {...requiredProps} />
);

expect(component).toMatchSnapshot();
});
});
6 changes: 5 additions & 1 deletion src/components/comment/comment_event.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ export const EuiCommentEvent: FunctionComponent<EuiCommentEventProps> = ({
undefined
)}
</div>
<div className="euiCommentEvent__headerActions">{actions}</div>
{actions ? (
<div className="euiCommentEvent__headerActions">{actions}</div>
) : (
undefined
)}
</div>
{children ? (
<div className="euiCommentEvent__body">{children}</div>
Expand Down
13 changes: 13 additions & 0 deletions src/components/comment/comment_timeline.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from 'react';
import { render } from 'enzyme';
import { requiredProps } from '../../test/required_props';

import { EuiCommentTimeline } from './comment_timeline';

describe('EuiCommentTimeline', () => {
test('is rendered', () => {
andreadelrio marked this conversation as resolved.
Show resolved Hide resolved
const component = render(<EuiCommentTimeline {...requiredProps} />);

expect(component).toMatchSnapshot();
});
});
Loading