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] Create styles header and border for EuiCommentEvent #7288

Merged
merged 22 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
e0a2a4e
[EuiCommentEvent] Extended the eventColor prop to apply the desired h…
breehall Oct 4, 2023
f6c139e
Storybook - Create simple storybook for EuiCommentEvent to demonstrat…
breehall Oct 4, 2023
80bdfa0
[EuiComment]
breehall Oct 5, 2023
abb1f55
Update test cases
breehall Oct 5, 2023
e5341a2
[DO NOT MERGE] Added a doc with the different variations of colors fo…
breehall Oct 5, 2023
762ded3
Revert "[DO NOT MERGE] Added a doc with the different variations of c…
breehall Oct 6, 2023
8cb2a47
update examples
andreadelrio Oct 15, 2023
343ef77
update example
andreadelrio Oct 15, 2023
292b43d
clean up
andreadelrio Oct 15, 2023
0edacd3
add cl
andreadelrio Oct 16, 2023
ac1e51d
remove line
andreadelrio Oct 16, 2023
c09a629
Change actions button examples to match `eventColor`
cee-chen Oct 17, 2023
c16b791
[css] DRY out repeated border styles
cee-chen Oct 17, 2023
d02181b
Fix missing padding on `undefined` color `update` type comments
cee-chen Oct 17, 2023
b9dd8b0
Adds docs/storybook testing for `undefined` eventColor value
cee-chen Oct 17, 2023
5e0cb2e
Update snapshots
cee-chen Oct 17, 2023
bb18869
Merge branch 'main' into CommentList-Colors
cee-chen Oct 17, 2023
7831d5a
Merge branch 'main' into CommentList-Colors
cee-chen Oct 18, 2023
5a1fd73
Revert "Change actions button examples to match `eventColor`"
cee-chen Oct 18, 2023
500a178
[storybook] Revert eventColor action as well
cee-chen Oct 18, 2023
5ac2f4b
Restore `plain` color
cee-chen Oct 18, 2023
30e0dc5
Improve Storybook DX further
cee-chen Oct 18, 2023
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
87 changes: 66 additions & 21 deletions src-docs/src/views/comment/comment_flexible.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ import {
EuiFlexItem,
EuiSpacer,
EuiCommentListProps,
EuiSelect,
EuiCode,
} from '../../../../src/components/';

import { EuiCommentEventProps } from '../../../../src/components/comment_list/comment_event';

const body = (
<EuiText size="s">
<p>
Expand Down Expand Up @@ -64,14 +68,6 @@ const commentsData: EuiCommentListProps['comments'] = [
eventIconAriaLabel: 'tag',
actions: copyAction,
},
{
username: 'system',
timelineAvatarAriaLabel: 'System',
timelineAvatar: 'dot',
event: 'pushed a new incident',
timestamp: '20 hours ago',
eventColor: 'danger',
},
{
username: 'pancho1',
timelineAvatarAriaLabel: 'Pancho Pérez',
Expand All @@ -95,18 +91,29 @@ const toggleButtons = [
id: 'update',
label: 'Update',
},
{
id: 'updateDanger',
label: 'Update danger',
},
{
id: 'custom',
label: 'Custom',
},
];

export default () => {
const colors: Array<{
value: EuiCommentEventProps['eventColor'];
text: string;
}> = [
{ value: 'subdued', text: 'subdued' },
{ value: 'transparent', text: 'transparent' },
{ value: 'plain', text: 'plain' },
{ value: 'danger', text: 'danger' },
{ value: 'warning', text: 'warning' },
{ value: 'accent', text: 'accent' },
{ value: 'primary', text: 'primary' },
{ value: 'success', text: 'success' },
{ value: undefined, text: 'undefined' },
];
const [toggleIdSelected, setToggleIdSelected] = useState('regular');
const [color, setColor] = useState(colors[0].value);
const [comment, setComment] = useState(commentsData[0]);

const onChangeButtonGroup = (optionId: any) => {
Expand All @@ -119,19 +126,57 @@ export default () => {
setComment(commentsData[selectedCommentIndex]);
};

const onChangeSize = (e: React.ChangeEvent<HTMLSelectElement>) => {
const color = e.target.value;
setColor(
color && color !== 'undefined'
? (color as EuiCommentEventProps['eventColor'])
: undefined
);
};

return (
<>
<EuiButtonGroup
legend="Pick an example"
options={toggleButtons}
onChange={onChangeButtonGroup}
idSelected={toggleIdSelected}
type="single"
color="primary"
/>
<EuiFlexGroup alignItems="center">
<EuiFlexItem grow={false}>
<EuiButtonGroup
legend="Pick an example"
options={toggleButtons}
onChange={onChangeButtonGroup}
idSelected={toggleIdSelected}
type="single"
color="primary"
/>
</EuiFlexItem>
{toggleIdSelected !== 'custom' ? (
<EuiFlexItem grow={false}>
<EuiSelect
prepend="eventColor"
options={colors}
value={color}
onChange={(e) => onChangeSize(e)}
compressed
/>
</EuiFlexItem>
) : undefined}
<EuiFlexItem>
{toggleIdSelected === 'regular' && color === 'subdued' && (
<span>
subdued is the default <EuiCode>eventColor</EuiCode> for regular{' '}
<strong>EuiComment</strong>
</span>
)}
{toggleIdSelected === 'update' && color === 'transparent' && (
<span>
transparent is the default <EuiCode>eventColor</EuiCode> for
update <strong>EuiComment</strong>
</span>
)}
</EuiFlexItem>
</EuiFlexGroup>
<EuiSpacer />
<EuiCommentList>
<EuiComment {...comment} />
<EuiComment {...comment} eventColor={color} />
</EuiCommentList>
</>
);
Expand Down
23 changes: 5 additions & 18 deletions src-docs/src/views/comment/comment_list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,6 @@ const complexEvent = (
</EuiFlexGroup>
);

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 comments: EuiCommentProps[] = [
{
username: 'janed',
Expand Down Expand Up @@ -88,12 +75,12 @@ const comments: EuiCommentProps[] = [
eventIconAriaLabel: 'tag',
},
{
username: 'elohar',
timelineAvatarAriaLabel: 'Elohar Jackson',
event: 'added a comment',
timestamp: 'on Jan 14, 2020',
children: longBody,
username: 'Assistant',
timelineAvatarAriaLabel: 'Assistant',
timestamp: 'on Jan 14, 2020, 1:39:04 PM',
children: <p>An error ocurred sending your message.</p>,
actions: copyAction,
eventColor: 'danger',
},
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ exports[`EuiComment is rendered 1`] = `
class="emotion-euiTimelineItemEvent-center"
>
<div
class="euiCommentEvent emotion-euiCommentEvent-custom"
class="euiCommentEvent emotion-euiCommentEvent"
data-type="custom"
/>
</div>
Expand Down Expand Up @@ -63,14 +63,14 @@ exports[`EuiComment props event is rendered 1`] = `
class="emotion-euiTimelineItemEvent-center"
>
<div
class="euiCommentEvent emotion-euiCommentEvent-update"
class="euiCommentEvent emotion-euiCommentEvent"
data-type="update"
>
<div
class="euiCommentEvent__header emotion-euiCommentEvent__header"
>
<div
class="euiPanel euiPanel--transparent emotion-euiPanel-grow-m-transparent"
class="euiPanel euiPanel--transparent euiPanel--paddingSmall emotion-euiPanel-grow-m-s-transparent"
>
<div
class="euiCommentEvent__headerMain emotion-euiCommentEvent__headerMain"
Expand Down Expand Up @@ -124,14 +124,14 @@ exports[`EuiComment props timestamp is rendered 1`] = `
class="emotion-euiTimelineItemEvent-center"
>
<div
class="euiCommentEvent emotion-euiCommentEvent-update"
class="euiCommentEvent emotion-euiCommentEvent"
data-type="update"
>
<div
class="euiCommentEvent__header emotion-euiCommentEvent__header"
>
<div
class="euiPanel euiPanel--transparent emotion-euiPanel-grow-m-transparent"
class="euiPanel euiPanel--transparent euiPanel--paddingSmall emotion-euiPanel-grow-m-s-transparent"
>
<div
class="euiCommentEvent__headerMain emotion-euiCommentEvent__headerMain"
Expand Down Expand Up @@ -187,7 +187,7 @@ exports[`EuiComment renders a body 1`] = `
class="emotion-euiTimelineItemEvent-top"
>
<div
class="euiCommentEvent emotion-euiCommentEvent-custom"
class="euiCommentEvent emotion-euiCommentEvent"
data-type="custom"
>
<div
Expand Down Expand Up @@ -229,7 +229,7 @@ exports[`EuiComment renders a timeline icon 1`] = `
class="emotion-euiTimelineItemEvent-top"
>
<div
class="euiCommentEvent emotion-euiCommentEvent-custom"
class="euiCommentEvent emotion-euiCommentEvent"
data-type="custom"
>
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

exports[`EuiCommentEvent is rendered with custom content 1`] = `
<div
class="euiCommentEvent testClass1 testClass2 emotion-euiCommentEvent-custom-euiTestCss"
class="euiCommentEvent testClass1 testClass2 emotion-euiCommentEvent-euiTestCss"
data-type="custom"
>
<div
Expand All @@ -17,14 +17,14 @@ exports[`EuiCommentEvent is rendered with custom content 1`] = `

exports[`EuiCommentEvent props event is rendered 1`] = `
<div
class="euiCommentEvent emotion-euiCommentEvent-update"
class="euiCommentEvent emotion-euiCommentEvent"
data-type="update"
>
<div
class="euiCommentEvent__header emotion-euiCommentEvent__header"
>
<div
class="euiPanel euiPanel--transparent emotion-euiPanel-grow-m-transparent"
class="euiPanel euiPanel--transparent euiPanel--paddingSmall emotion-euiPanel-grow-m-s-transparent"
>
<div
class="euiCommentEvent__headerMain emotion-euiCommentEvent__headerMain"
Expand All @@ -51,21 +51,21 @@ exports[`EuiCommentEvent props event is rendered 1`] = `

exports[`EuiCommentEvent props eventColor is rendered 1`] = `
<div
class="euiCommentEvent emotion-euiCommentEvent-custom"
class="euiCommentEvent emotion-euiCommentEvent"
data-type="custom"
/>
`;

exports[`EuiCommentEvent props eventIcon and eventIconAriaLabel are rendered 1`] = `
<div
class="euiCommentEvent emotion-euiCommentEvent-update"
class="euiCommentEvent emotion-euiCommentEvent"
data-type="update"
>
<div
class="euiCommentEvent__header emotion-euiCommentEvent__header"
>
<div
class="euiPanel euiPanel--transparent emotion-euiPanel-grow-m-transparent"
class="euiPanel euiPanel--transparent euiPanel--paddingSmall emotion-euiPanel-grow-m-s-transparent"
>
<div
class="euiCommentEvent__headerMain emotion-euiCommentEvent__headerMain"
Expand Down Expand Up @@ -99,14 +99,14 @@ exports[`EuiCommentEvent props eventIcon and eventIconAriaLabel are rendered 1`]

exports[`EuiCommentEvent props timestamp is rendered 1`] = `
<div
class="euiCommentEvent emotion-euiCommentEvent-update"
class="euiCommentEvent emotion-euiCommentEvent"
data-type="update"
>
<div
class="euiCommentEvent__header emotion-euiCommentEvent__header"
>
<div
class="euiPanel euiPanel--transparent emotion-euiPanel-grow-m-transparent"
class="euiPanel euiPanel--transparent euiPanel--paddingSmall emotion-euiPanel-grow-m-s-transparent"
>
<div
class="euiCommentEvent__headerMain emotion-euiCommentEvent__headerMain"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ exports[`EuiCommentList is rendered 1`] = `
class="emotion-euiTimelineItemEvent-center"
>
<div
class="euiCommentEvent emotion-euiCommentEvent-custom"
class="euiCommentEvent emotion-euiCommentEvent"
data-type="custom"
/>
</div>
Expand Down Expand Up @@ -72,7 +72,7 @@ exports[`EuiCommentList props gutterSize l is rendered 1`] = `
class="emotion-euiTimelineItemEvent-center"
>
<div
class="euiCommentEvent emotion-euiCommentEvent-custom"
class="euiCommentEvent emotion-euiCommentEvent"
data-type="custom"
/>
</div>
Expand Down Expand Up @@ -111,7 +111,7 @@ exports[`EuiCommentList props gutterSize m is rendered 1`] = `
class="emotion-euiTimelineItemEvent-center"
>
<div
class="euiCommentEvent emotion-euiCommentEvent-custom"
class="euiCommentEvent emotion-euiCommentEvent"
data-type="custom"
/>
</div>
Expand Down Expand Up @@ -150,7 +150,7 @@ exports[`EuiCommentList props gutterSize xl is rendered 1`] = `
class="emotion-euiTimelineItemEvent-center"
>
<div
class="euiCommentEvent emotion-euiCommentEvent-custom"
class="euiCommentEvent emotion-euiCommentEvent"
data-type="custom"
/>
</div>
Expand Down
Loading
Loading