-
Notifications
You must be signed in to change notification settings - Fork 97
feat(colorpickers): adds light/dark mode colors #1862
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
Conversation
const thumbHoverBorderColor = thumbHoverBackgroundColor; | ||
|
||
return ` | ||
border-color: ${props.isOpaque && getColorV8('background', 600 /* default shade */, props.theme)}; |
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.
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.
If this ends up having no issues with the final interaction/element then sounds good 👍
$green: number; | ||
$blue: number; | ||
$alpha?: number; | ||
} |
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.
🔥
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.
Looking good!
style: { | ||
backgroundSize: 'auto', | ||
background: background(props) | ||
}, |
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.
Out of curiosity, why can't this live in the style block below?
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.
I think this approach avoids dynamically creating a new class every time the color props change. styled-component
will warn you when that happens.
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.
...and performance drops through the floor
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.
💀
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.
[nit] should the data for the ColorSwatch
demos be updated to show all 12 colors from the primary (blue, green, red, yellow) palette?
} | ||
${props => | ||
!props.$isOpaque && | ||
css` |
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.
Is css
necessary here?
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 provides proper placement for the sliders when isOpaque
is false
.
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.
yep, I get that. More wondering whether this can be a simple template literal rather than invoking the css
function?
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.
I tried the template literal first but it didn't parse correctly. I'll give it another shot.
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.
...as I understand it, styled
already handles this, making css
redundant...
during flattening, styled-components ignores interpolations that evaluate to undefined, null, false, or an empty string ("")
https://styled-components.com/docs/advanced#tagged-template-literals
const colorStyles = (props: IStyledRangeProps & ThemeProps<DefaultTheme>) => { | ||
const thumbBackgroundColor = getColorV8('neutralHue', 100, props.theme); | ||
const colorStyles = ({ theme }: ThemeProps<DefaultTheme>) => { | ||
const thumbBackgroundColor = getColor({ theme, variable: 'background.default' }); |
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.
@lucijanblagonic maybe just me, but I'm finding these dark mode thumbs very difficult to see. Somehow I don't have the same problem with shadowed white over white background.
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.
+1, feels like an accessibility concern for sure.
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.
@steue @lucijanblagonic For clarity, we're referring to this:
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.
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.
curious about your thoughts of bumping up the contrast by setting the thumbs to bg/raised with a -100 offset? (looks brighter)
@steue for me, that color tweak works great 🙌
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.
export interface IRGBColorProps { | ||
$red: number; | ||
$green: number; | ||
$blue: number; | ||
$alpha?: number; | ||
} |
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.
Can this move to a types.ts
file within the styled
directory? We just wouldn't want to mistake the fact that this interface should never be publicly exported.
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.
sans the thumb
treatment, everything looks good to me! great work!
} | ||
|
||
const sizeStyles = (props: IStyledSlidersProps & ThemeProps<DefaultTheme>) => { | ||
if (props.$isOpaque) return undefined; |
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.
if (props.$isOpaque) return undefined; | |
if (props.$isOpaque) { | |
return undefined; | |
} |
Conditions in Garden should always be blocks. We used to lint for this, but the rule was deprecated. Probably need to bring it back with a plugin since prettier doesn't cover us.
The changes here look good, thanks @steue for jumping in. The only thing that seems off is the hover behavior of the handle. I would expect the hover to lighten on hover (in dark mode), to be in line with other interactive controls. What do you think? |
agreed! |
Great! In dark mode, the slider's thumb is using |
Not sure the best place to put this so I'll throw it here. 😅 I'm going off of the updated designs: ![]() ![]() I'm still worried about this contrast. Even with the box shadow, the thumb blends in with the background especially at the ends of the range (which is the default state). I'm not sure what the best approach is (border, or maybe flipping the thumb to be white for dark mode and dark grey for light mode). Maybe this isn't a problem we can solve in this PR, which is also fair. But wanted to at least put it our there for posterity. I also asked Jen over in accessibility and she agreed, FWIW. She shared the criterion, which specifies:
|
i would imagine following our default on hover, so another -100 (effectively -200)? |
@geotrev valid concern! color pickers have interesting a11y considerations as colors themselves pose inherent issues. we can get into the nitty gritty of it, but where is the contrast compared against? is it against the colors in the slider itself or the BG? you're right, though the the thumb might not always achieve the 3:1 contrast ratio. that said, the overall design does incorporate alternative methods for controlling color that are accessible. (i.e. thumbs / sliders controllable via keyboard and input fields to control HSL/RGB etc) i do think we could explore treatment as another treatment |
Following @lucijanblagonic 's comment:
@steue If the default state is |
@steue The contrast is with everything behind it, but primarily the dark grey background. Currently the background and the thumb have less than a 2:1 contrast ratio, which is concerning in the cases I mentioned. Especially since we can't depend on the thumb being positioned inside the slider at all times. The issue of the contrast not always being perfect could be a good reason to use a border. A single solid color will present persistence issues like you mention.
That is true. There are input fields as well. I bring it up as a medium-high concern mainly because the bulk of the picker UI contains visual/color-based controls. |
I don't think there is a difference in light or dark mode when it comes to accessibility in this case. Having a
|
That makes sense and would definitely remediate the concerns. Not a blocker for this PR of course, we can set aside time to do it after if preferred |
@lucijanblagonic @steue The latest preview increases the thumbs contrast based on the last suggestion. The border treatment of the range thumbs matches with the inputs' below. I think this looks good. Hope this works for all too! 🤞 |
const thumbBorderColor = getColor({ | ||
theme, | ||
variable: 'border.default', | ||
dark: { offset: -100 }, | ||
light: { offset: 100 } | ||
}); |
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.
[nit] now that the thumbs have a visible border, can we check that the transition
animation is updated to include the border?
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.
Transition animations appear to be inherited from Range
:
react-components/packages/forms/src/styled/range/StyledRangeInput.ts
Lines 142 to 144 in e1bac19
transition: | |
border-color .25s ease-in-out, | |
background-color .25s ease-in-out; |
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.
Ok, my bad. I wasn't viewing the :hover
state.
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.
Tested and looks good, feel free to merge after resolving @jzempel 's comment for transition.
Description
Adds dark / light mode support to
@zendeskgarden/react-colorpickers
Detail
ColorPicker
,ColorPickerDialog
,ColorSwatch
, andColorSwatchDialog
isOpaque
optionChecklist
npm start
)🤘 renders as expected with Bedrock CSS (?bedrock
)