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

Closed
wants to merge 6 commits into from

Conversation

breehall
Copy link
Contributor

@breehall breehall commented Oct 4, 2023

#7238

Summary

This PR extends the eventColor prop on EuiCommentEvent and applies the color to the entire comment header, not just the panel included inside of the header.

Before
image

After
image

QA

General checklist

  • Browser QA
    • Checked in both light and dark modes
    • Checked in mobile
    • Checked in Chrome, Safari, Edge, and Firefox
    • Checked for accessibility including keyboard-only and screenreader modes
  • Docs site QA
  • Code quality checklist
  • Release checklist
    • A changelog entry exists and is marked appropriately.
    • If applicable, added the breaking change issue label (and filled out the breaking change checklist)
  • Designer checklist
    • Updated the Figma library counterpart

…eader color to the entire comment header, not just the text background color
@breehall breehall changed the title [EuiComment] Create styles header and border for EuiCommentHeader [EuiComment] Create styles header and border for EuiCommentEvent Oct 4, 2023
@breehall breehall changed the title [EuiComment] Create styles header and border for EuiCommentEvent [EuiComment] WIP Create styles header and border for EuiCommentEvent Oct 4, 2023
@breehall
Copy link
Contributor Author

breehall commented Oct 4, 2023

@andreadelrio @1Copenut

Hey Andrea & Trevor, do you all mind taking a look at the the change made to EuiCommentEvent in Storybook. After allowing extending the eventColor prop to set the header to our full range of colors (which is based on EuiPanel colors) I have accessibility concerns for the lighter shades. Do you all have any insight?

You can test this in Storybook by visiting the EuiCommentEvent example and toggling the eventColor prop. These colors match EuiPanel in production for light mode and dark mode, so this could extend a more broad conversation about those colors as well.

@andreadelrio
Copy link
Contributor

@breehall I think we need darker colors for the borders.

@breehall
Copy link
Contributor Author

breehall commented Oct 4, 2023

Here are a few options I'm considering:

image

@1Copenut
Copy link
Contributor

1Copenut commented Oct 4, 2023

@breehall I think I lean toward option 1 for accessibility and visual interest. The higher contrast of the border makes the header more prominent and keeps us on the safe side of WCAG SC 1.4.11: Non-text contrast (AA). I did a thought experiment where I mocked up an alert with each of the brand color tints and full-strength border, then ran them through the axe-core browser plugin. We had zero contrast issues, and the strong borders really gave each their own character.


Screen Shot 2023-10-04 at 1 58 42 PM

@andreadelrio
Copy link
Contributor

Here are a few options I'm considering:

image

Thanks! Can you also give us something like 0.5, 0.75 to see how it feels?

@breehall
Copy link
Contributor Author

breehall commented Oct 4, 2023

@andreadelrio Here are a few more options in .5, .6, and .75

image

@andreadelrio
Copy link
Contributor

@andreadelrio Here are a few more options in .5, .6, and .75

image

Thanks a lot! I'm partial to something between 0.3 and 0.5. I'd have to see all the other color variants to make a final recommendation.

@breehall
Copy link
Contributor Author

breehall commented Oct 4, 2023

@andreadelrio Here's a version of a comment with each color and each transparatize level to assist.

Transparatize @ .3
image

Transparatize @ .4
image

Transparatize @ .5
image

@andreadelrio
Copy link
Contributor

@breehall this is super helpful thank you! My vote would be for 0.5. However, I feel like the warning border is too faint. Do we ever do a different treatment color for a specfic variant? In other words, could we make only the warning one darker? If the answer is "no" we could consider going up in the ratio for all the variants (>0.5). cc-ing @cee-chen in case they have input 🎶 (that last sentence was like a song in my head)

@cee-chen
Copy link
Contributor

cee-chen commented Oct 5, 2023

However, I feel like the warning border is too faint. Do we ever do a different treatment color for a specfic variant?

Yep, we totally do (e.g. success and accent colors for buttons). I think this is a warranted case.

One note - I'm slightly concerned by us using transparentize instead of lightenOrDarken (based on light vs dark mode) for background colors. It isn't possible to correctly calculate contrast ratios for colors with alpha channels. Can we consider tinting or shading instead of transparentizing?

- Create DRY style helper for border styles
- Update styling conditions in CommentEvent to add a matching border when eventColor is passed in and the comment is of the *regular* type
@breehall breehall changed the title [EuiComment] WIP Create styles header and border for EuiCommentEvent [EuiComment] 🛑 WIP Create styles header and border for EuiCommentEvent Oct 5, 2023
@breehall
Copy link
Contributor Author

breehall commented Oct 5, 2023

@andreadelrio Do you mind going to the docs staging for EuiComment and let me know what you think about these colors? Feel free to toggle between light and dark as well. I realized the changes look different in images because I've zoomed out in my browser, so the colors in the images don't 100% reflect the code change.

Staging: https://eui.elastic.co/pr_7253/#/display/comment-list#basic-comment-list

@andreadelrio
Copy link
Contributor

@andreadelrio Do you mind going to the docs staging for EuiComment and let me know what you think about these colors? Feel free to toggle between light and dark as well. I realized the changes look different in images because I've zoomed out in my browser, so the colors in the images don't 100% reflect the code change.

Staging: https://eui.elastic.co/pr_7253/#/display/comment-list#basic-comment-list

@breehall I just checked it out, I like it! Question, what are the differences between subdued, plain and transparent? do we need all of them?

@breehall
Copy link
Contributor Author

breehall commented Oct 5, 2023

what are the differences between subdued, plain and transparent? do we need all of them?

@andreadelrio Subdued is barely a shade lighter than the plain/transparent variations (which are the same). I didn't add these colors to the prop, but if I had to guess, I assume these were all added because the prop is passed directly to the EuiPanel inside of EuiCommentEvent.

A quick check in Kibana showed subdued is being used twice, but I don't see usages for plain or transparent. Also nice to note, this prop doesn't have a default.

euiCommentEvent__header: css``,
// types
regular: css`
background: ${euiTheme.colors.lightestShade};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@breehall could we get rid of this and add a default eventColor to this component instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually think this might be better than adding the color as a component default. The reason I say this is because a background is only set on type regular.

The other two types (custom and update) don't have a background color. So we would be setting the default, and then unsetting if the type is custom or update instead of the above approach which is setting the background color only for type regular or applying the eventColor if needed.

@andreadelrio
Copy link
Contributor

EuiComment has changed a ton since I last contributed to it so I'm not clear on all the inner workings of it. Having said that, my take is that we only need one gray color (which could be subdued) and we also need to support transparent for when the type is update.

@breehall
Copy link
Contributor Author

breehall commented Oct 6, 2023

@andreadelrio

my take is that we only need one gray color (which could be subdued) and we also need to support transparent for when the type is update.

Below is the logic we currently have. If an event color is passed view EuiComment props, we pass that directly to the EuiPanel. If plain is passed, we actually default to transparent because plain gives us a shadow that we don't want on the panel.

This means we have subdued as a gray color and transparent appears as a gray color because the comment header background uses euiTheme.colors.lightShade. If we would like to only have one gray, we could change the regular CSS to use the subdued styling instead of euiTheme.colors.lightShade. What do you think of that? @cee-chen do you have any thoughts?

  // The 'plain' color creates a shadow and adds a border radius that we don't want.
  // So for these cases we use the transparent color instead.
  const finalEventColor = eventColor === 'plain' ? 'transparent' : eventColor;

…olors for event borders for testing"

This reverts commit e5341a2.
Comment on lines +22 to +25
return `1px solid ${tintOrShade(
euiTheme.colors.accent,
ratio,
colorMode
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to DRY this out by simply returning (1px solid ${tintOrShade(euiTheme.colors[color], ratio, colorMode) to avoid logic inside of the switch, but that made TypeScript angry.

custom: css``,
});
const _generateEventBorderColor = (
{ euiTheme, colorMode }: UseEuiTheme,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function accepts colorMode on the chance that we need different color ratios for light and dark mode, but if the 0.6 ratio is OK for both, we can get rid of it.

hasEventColor: css`
padding: 0;
`,
border: {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

border doesn't need to be its own object if you'd prefer to leave the colors as a direct child of the main styling object. I felt like it was easier to contain these styles in border{} so we're aware that these only apply to borders.

@kibanamachine
Copy link

Preview staging links for this PR:

@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

History

@cee-chen
Copy link
Contributor

Closing in favor of #7288

@cee-chen cee-chen closed this Oct 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants