Skip to content

Commit

Permalink
small a11y change
Browse files Browse the repository at this point in the history
  • Loading branch information
andreadelrio committed Apr 7, 2020
1 parent c96b3cc commit 51f1dfb
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 36 deletions.
40 changes: 20 additions & 20 deletions src/components/comment/__snapshots__/comment.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ exports[`EuiComment is rendered 1`] = `
</div>
</div>
</div>
<div
<figure
class="euiCommentEvent euiCommentEvent--regular"
>
<div
<figcaption
class="euiCommentEvent__header"
>
<div
Expand All @@ -39,8 +39,8 @@ exports[`EuiComment is rendered 1`] = `
class="euiCommentEvent__headerEvent"
/>
</div>
</div>
</div>
</figcaption>
</figure>
</div>
`;

Expand All @@ -63,10 +63,10 @@ exports[`EuiComment props event is rendered 1`] = `
</div>
</div>
</div>
<div
<figure
class="euiCommentEvent euiCommentEvent--regular"
>
<div
<figcaption
class="euiCommentEvent__header"
>
<div
Expand All @@ -83,8 +83,8 @@ exports[`EuiComment props event is rendered 1`] = `
commented
</div>
</div>
</div>
</div>
</figcaption>
</figure>
</div>
`;

Expand Down Expand Up @@ -116,10 +116,10 @@ exports[`EuiComment props timelineIcon is rendered 1`] = `
</div>
</div>
</div>
<div
<figure
class="euiCommentEvent euiCommentEvent--regular"
>
<div
<figcaption
class="euiCommentEvent__header"
>
<div
Expand All @@ -134,8 +134,8 @@ exports[`EuiComment props timelineIcon is rendered 1`] = `
class="euiCommentEvent__headerEvent"
/>
</div>
</div>
</div>
</figcaption>
</figure>
</div>
`;

Expand All @@ -158,10 +158,10 @@ exports[`EuiComment props timestamp is rendered 1`] = `
</div>
</div>
</div>
<div
<figure
class="euiCommentEvent euiCommentEvent--regular"
>
<div
<figcaption
class="euiCommentEvent__header"
>
<div
Expand All @@ -183,8 +183,8 @@ exports[`EuiComment props timestamp is rendered 1`] = `
</time>
</div>
</div>
</div>
</div>
</figcaption>
</figure>
</div>
`;

Expand Down Expand Up @@ -249,10 +249,10 @@ exports[`EuiComment renders a body 1`] = `
</div>
</div>
</div>
<div
<figure
class="euiCommentEvent euiCommentEvent--regular"
>
<div
<figcaption
class="euiCommentEvent__header"
>
<div
Expand All @@ -267,14 +267,14 @@ exports[`EuiComment renders a body 1`] = `
class="euiCommentEvent__headerEvent"
/>
</div>
</div>
</figcaption>
<div
class="euiCommentEvent__body"
>
<p>
This is the body.
</p>
</div>
</div>
</figure>
</div>
`;
24 changes: 12 additions & 12 deletions src/components/comment/__snapshots__/comment_event.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`EuiCommentEvent is rendered 1`] = `
<div
<figure
aria-label="aria-label"
class="euiCommentEvent euiCommentEvent--regular testClass1 testClass2"
data-test-subj="test subject string"
>
<div
<figcaption
class="euiCommentEvent__header"
>
<div
Expand All @@ -21,15 +21,15 @@ exports[`EuiCommentEvent is rendered 1`] = `
class="euiCommentEvent__headerEvent"
/>
</div>
</div>
</div>
</figcaption>
</figure>
`;

exports[`EuiCommentEvent props event is rendered 1`] = `
<div
<figure
class="euiCommentEvent euiCommentEvent--regular"
>
<div
<figcaption
class="euiCommentEvent__header"
>
<div
Expand All @@ -46,15 +46,15 @@ exports[`EuiCommentEvent props event is rendered 1`] = `
commented
</div>
</div>
</div>
</div>
</figcaption>
</figure>
`;

exports[`EuiCommentEvent props timestamp is rendered 1`] = `
<div
<figure
class="euiCommentEvent euiCommentEvent--regular"
>
<div
<figcaption
class="euiCommentEvent__header"
>
<div
Expand All @@ -76,8 +76,8 @@ exports[`EuiCommentEvent props timestamp is rendered 1`] = `
</time>
</div>
</div>
</div>
</div>
</figcaption>
</figure>
`;

exports[`EuiCommentEvent props type is rendered 1`] = `
Expand Down
16 changes: 12 additions & 4 deletions src/components/comment/comment_event.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,17 @@ export const EuiCommentEvent: FunctionComponent<EuiCommentEventProps> = ({
className
);

const Element =
type === 'regular' || (type === 'update' && children) ? 'figure' : 'div';

const HeaderElement =
type === 'regular' || (type === 'update' && children)
? 'figcaption'
: 'div';

return (
<div className={classes} {...rest}>
<div className="euiCommentEvent__header">
<Element className={classes} {...rest}>
<HeaderElement className="euiCommentEvent__header">
<div className="euiCommentEvent__headerData">
<div className="euiCommentEvent__headerUsername">{username}</div>
<div className="euiCommentEvent__headerEvent">{event}</div>
Expand All @@ -69,12 +77,12 @@ export const EuiCommentEvent: FunctionComponent<EuiCommentEventProps> = ({
) : (
undefined
)}
</div>
</HeaderElement>
{children ? (
<div className="euiCommentEvent__body">{children}</div>
) : (
undefined
)}
</div>
</Element>
);
};

0 comments on commit 51f1dfb

Please sign in to comment.