-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
fix(code-snippet): add light styles for all variations and update storybook knobs #4342
Conversation
Deploy preview for the-carbon-components ready! Built with commit b21ea99 https://deploy-preview-4342--the-carbon-components.netlify.com |
Deploy preview for carbon-elements ready! Built with commit b21ea99 |
Deploy preview for carbon-components-react failed. Built with commit b21ea99 https://app.netlify.com/sites/carbon-components-react/deploys/5da6199dc05f250007807620 |
Deploy preview for carbon-components-react ready! Built with commit b21ea99 https://deploy-preview-4342--carbon-components-react.netlify.com |
Deploy preview for carbon-elements ready! Built with commit baf682e |
Deploy preview for the-carbon-components ready! Built with commit baf682e https://deploy-preview-4342--the-carbon-components.netlify.com |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍 - Thanks @jendowns!
There was a problem hiding this 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
There was a problem hiding this 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.
@dakahn could you describe which parts of the |
@jendowns The interface element's background color must meet a 3:1 contrast ratio against adjacent colors. |
@dakahn 🤔 So do you mean that a "light" |
@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. |
@dakahn Are we definitely sure we should consider all variations of the I can definitely see it for the |
There was a problem hiding this 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. 👍
@dakahn Per our Slack convo, I added a conditional wrapper class & a |
@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. |
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 '} |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
.
There was a problem hiding this 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.
Thanks @aagonzales & @jillianhowarth! I have updated that copy & you should see it reflected in the netlify preview soon. Here's g90 for example (I'm hovering over the "copy" button in the upper right of the multi line snippet): |
Hmm I wonder if the new color updates made them too similar. Or maybe its time to add an These are the options |
@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? |
@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% |
Thank you @aagonzales! That makes sense. And for the |
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. |
@jendowns sorry about all the changes here! Let me know if you need anything else from us 👀 |
packages/components/src/components/code-snippet/_code-snippet.scss
Outdated
Show resolved
Hide resolved
Co-Authored-By: Josh Black <josh@josh.black>
…tion Co-Authored-By: Josh Black <josh@josh.black>
Closes #4341
Proposal to add light styles to all variations of the
CodeSnippet
, since thelight
prop is available to use for the component but currently only applies styles for theinline
variation.Changelog
Changed
.bx--snippet--light
styles to apply to all variations of theCodeSnippet
(and also update button hover colors to accurately reflect these changes) -- NOTE: I realize the originalinline
+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.light
prop knobs for all variations ofCodeSnippet
Testing / Reviewing
Check out the
carbon-components-react
Netlify deployment for this PR & use the knobs to toggle thelight
state for eachCodeSnippet
variation.