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

fix(code-snippet): add light styles for all variations and update storybook knobs #4342

Merged
merged 19 commits into from
Oct 25, 2019
Merged

Conversation

jendowns
Copy link
Contributor

Closes #4341

Proposal to add light styles to all variations of the CodeSnippet, since the light prop is available to use for the component but currently only applies styles for the inline variation.

Changelog

Changed

  • update .bx--snippet--light styles to apply to all variations of the CodeSnippet (and also update button hover colors to accurately reflect these changes) -- NOTE: I realize the original inline + light variation used $field-01 props, however the $ui-* tokens I picked out are the same and are good foils for the non-light $ui-* tokens used.
  • update story to include light prop knobs for all variations of CodeSnippet

Testing / Reviewing

Check out the carbon-components-react Netlify deployment for this PR & use the knobs to toggle the light state for each CodeSnippet variation.

@jendowns jendowns requested a review from a team as a code owner October 15, 2019 19:10
@ghost ghost requested review from aledavila and asudoh October 15, 2019 19:10
@netlify
Copy link

netlify bot commented Oct 15, 2019

Deploy preview for the-carbon-components ready!

Built with commit b21ea99

https://deploy-preview-4342--the-carbon-components.netlify.com

@jendowns jendowns changed the title Code snippet light fix(code-snippet): add light styles for all variations and update storybook knobs Oct 15, 2019
@netlify
Copy link

netlify bot commented Oct 15, 2019

Deploy preview for carbon-elements ready!

Built with commit b21ea99

https://deploy-preview-4342--carbon-elements.netlify.com

@netlify
Copy link

netlify bot commented Oct 15, 2019

Deploy preview for carbon-components-react failed.

Built with commit b21ea99

https://app.netlify.com/sites/carbon-components-react/deploys/5da6199dc05f250007807620

@netlify
Copy link

netlify bot commented Oct 15, 2019

Deploy preview for carbon-components-react ready!

Built with commit b21ea99

https://deploy-preview-4342--carbon-components-react.netlify.com

@netlify
Copy link

netlify bot commented Oct 15, 2019

Deploy preview for carbon-elements ready!

Built with commit baf682e

https://deploy-preview-4342--carbon-elements.netlify.com

@netlify
Copy link

netlify bot commented Oct 15, 2019

Deploy preview for the-carbon-components ready!

Built with commit baf682e

https://deploy-preview-4342--the-carbon-components.netlify.com

Copy link
Contributor

@asudoh asudoh left a comment

Choose a reason for hiding this comment

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

LGTM 👍 - Thanks @jendowns!

Copy link
Member

@emyarod emyarod left a comment

Choose a reason for hiding this comment

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

looks good to me, pending design review

@emyarod emyarod requested a review from a team October 16, 2019 13:30
@ghost ghost requested review from jillianhowarth and removed request for a team October 16, 2019 13:31
Copy link
Contributor

@dakahn dakahn left a comment

Choose a reason for hiding this comment

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

WCAG 1.4.11 requires a 3:1 contrast ratio for non-text interface elements and their adjacent colors. Common ways of meeting this requirement are 3:1 ratio contrast borders or improving the contrast between the interface element and it's adjacent colors (page background, parent background etc).

Currently our code snippet does not meet these requirements. While most code-snippets are not considered "interface components" ours are since they are interactable.

This situation is made worse in lighter themes by allowing an even lower contrast variant background color for these interface components.

@jendowns
Copy link
Contributor Author

@dakahn could you describe which parts of the light variation of the CodeSnippet you are referring to?

@dakahn
Copy link
Contributor

dakahn commented Oct 16, 2019

@jendowns The interface element's background color must meet a 3:1 contrast ratio against adjacent colors.

@jendowns
Copy link
Contributor Author

@dakahn 🤔 So do you mean that a "light" CodeSnippet technically can't really exist, because that background would be too close to the $ui-background?

@dakahn
Copy link
Contributor

dakahn commented Oct 16, 2019

@dakahn precisely. Since it's interactable it must meet 1.4.11 contrast requirements (3:1) for non-text interface elements. Worth noting -- it currently doesn't meet this requirement today.

@jendowns
Copy link
Contributor Author

@dakahn Are we definitely sure we should consider all variations of the CodeSnippet interactive?

I can definitely see it for the inline one because you click it to copy etc.
But what about the single and multi-line versions? Technically they have interactive buttons, but the body of the components (where code is) isn't interactive? 🤔

@jendowns
Copy link
Contributor Author

Also something else to consider... in our case, we are using the light prop to distinguish the CodeSnippet from a ui-01 or similar background where it would normally have been the same color as the background color.

Here's an example of a light + inline snippet with some context (in a panel):
Screen Shot 2019-10-16 at 2 30 20 PM

(so maybe what you are seeing in the storybook isn't a good in-product example of how it would be used anyway? 🤔 )

Copy link
Contributor

@dakahn dakahn left a comment

Choose a reason for hiding this comment

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

Okay! If we're only using light on dark themes and we have docs and guidance coming to back that up. I'm cool with this. 👍

@jendowns
Copy link
Contributor Author

@dakahn Per our Slack convo, I added a conditional wrapper class & a light prop message to help people use the prop correctly. So if you look at the CodeSnippet variations in different themes and toggle the light knob, you'll see something like this:

Screen Shot 2019-10-17 at 11 21 45 AM
Screen Shot 2019-10-17 at 11 21 31 AM

@dakahn
Copy link
Contributor

dakahn commented Oct 17, 2019

@joshblack How do you feel about this in-Storybook warning. I thought this would be cool as a stop-gap until we figure out how we're doing guidance in this thing.

@joshblack
Copy link
Contributor

joshblack commented Oct 17, 2019

I'm down if it helps 👍 what do you think @jillianhowarth? Is this okay from the design perspective to help educate devs who might mistakenly use this prop?

@@ -48,12 +50,23 @@ const props = {
}),
};

const lightPropMessage = (
<small style={{ display: 'block', paddingBottom: '1rem' }}>
{'Make sure to use a different background color for the '}

Choose a reason for hiding this comment

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

This copy is unclear - we should clarify that they should be using the prop with certain themes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey @jillianhowarth the prop is currently available regardless of theme. I'm happy to change the copy though -- what should it be?

Copy link
Member

@aagonzales aagonzales Oct 17, 2019

Choose a reason for hiding this comment

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

It's safe to use with all themes actually. It's working correctly in the White and Gray 10 themes as well.

If we want to get more specific/technical we could say something like:

  • The snippet container should never be the same color as the page background.
  • Do not use the light variant on $ui-background or $ui-02.

Copy link
Member

@aagonzales aagonzales left a comment

Choose a reason for hiding this comment

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

The hover of the light snippet should be using hover-ui as well so it doesn't blind in.

@jendowns
Copy link
Contributor Author

Thanks @aagonzales & @jillianhowarth!

I have updated that copy & you should see it reflected in the netlify preview soon.
But as for using $hover-ui for the hover color... currently it looks great for white and g10 themes but it is very hard to see for the dark themes g90 and g100 🤔 Seems to be because $hover-ui is very close to $ui-02 (the "light" variant bg color).

Here's g90 for example (I'm hovering over the "copy" button in the upper right of the multi line snippet):

Screen Shot 2019-10-17 at 1 42 48 PM

@aagonzales
Copy link
Member

aagonzales commented Oct 17, 2019

Hmm I wonder if the new color updates made them too similar. hover-ui is the appropriate token so I'm wondering if we need to update that token value. Let me look at it in relation to some other things.

Or maybe its time to add an hover-ui-light token specifically for the light variants 🤔


These are the options

image

@jendowns
Copy link
Contributor Author

@aagonzales Personally I'm leaning more toward the new token just so it doesn't affect any other components. 😅 Is that okay? If so, I could go ahead and add the new token in this PR if you happen to know what colors it should be per theme?

@aagonzales
Copy link
Member

@jendowns actually I just talked to Josh about this, could we actually do a lighten/darken effect for the hover for these? That's the direction we're trying to go with hovers in v11 so we can get ahead of the game without adding a new token.

White and gray 10: darken by 8%
Gray 90 and 100: lighten by 8%

@jendowns
Copy link
Contributor Author

Thank you @aagonzales! That makes sense. And for the v9 theme, should the color be darkened by 8% as well?

@aagonzales
Copy link
Member

aagonzales commented Oct 21, 2019

Hmm for V9, the icon color darkens not the background. I think its also controlled by a different token in v9 if I'm not mistaken.

@joshblack
Copy link
Contributor

@jendowns sorry about all the changes here! Let me know if you need anything else from us 👀

@joshblack
Copy link
Contributor

Chatted with @jendowns, I think we'll move forward with using the value out of the theme map and lighten/darken that instead of the property while we figure out the issue around CSS Custom Properties with lighten/darken values over in #4426

@joshblack joshblack merged commit d6498e9 into carbon-design-system:master Oct 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CodeSnippet - light prop only works for inline variation
8 participants