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
Colors - adjust palette to steps of 9 when addDarkestTint is true #2855
Conversation
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.
PLEASE try to refactor in separate commits 🙏
I think it would have been much easier to look at.
src/style/__tests__/colors.spec.js
Outdated
const palette = uut.generateColorPalette('#FFE5FF'); | ||
expect(palette).toEqual(['#661A66', '#8F248F', '#B82EB7', '#D148D1', '#DB71DB', '#E699E6', '#F0C2F0', '#FFE5FF']); | ||
it('should generateColorPalette with adjustLightness option true (default)', () => { | ||
const palette = uut.generateColorPalette(baseColor, {adjustLightness: true}); |
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 is a little odd IMO, you send the default value and test it, shouldn't the test above be enough for it?
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.
Right, I wanted to explicitlly test it but it is redundent
src/style/__tests__/colors.spec.js
Outdated
const tints = ['#193852', '#255379', '#316EA1', '#3F88C5', '#66A0D1', '#8DB9DD', '#B5D1E9', '#DCE9F4']; | ||
const baseColorLight = '#DCE9F4'; | ||
const tintsLight = ['#1A3851', '#265278', '#326D9F', '#4187C3', '#68A0CF', '#8EB8DC', '#B5D1E8', '#DCE9F4']; | ||
const tintsAdjustedLightness = ['#193852', '#255379', '#316EA1', '#3F88C5', '#66A0D1', '#8DB9DD', '#B5D1E9', '#DCE9F4']; |
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 looks like there is duplication of consts, why do we need them?
tintsAdjustedLightness
= tints
tintsAdjustedSaturation
= tintsLight
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.
Yes, I see... That's because I tested default options... I removed the tests
src/style/colors.ts
Outdated
@@ -323,7 +337,31 @@ function colorStringValue(color: string | object) { | |||
return color?.toString(); | |||
} | |||
|
|||
function adjustSaturation(colors: string[], color: string) { | |||
function adjustAllSaturations(colors: string[], color: string, levels: 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.
is color: string
actually selectedColor
`currentColor`?
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.
Yes... changed to 'baseColor' to be extra clear
src/style/colors.ts
Outdated
const hsl = Color(c).hsl(); | ||
const saturation = hsl.color[1]; | ||
const level = levels[index]; | ||
if (level) { |
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 will ignore 0
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.
That's fine... Changed to be more explicit?
src/style/colors.ts
Outdated
if (level) { | ||
const saturationLevel = saturation + level; | ||
const clampedLevel = _.clamp(saturationLevel, 0, 100); | ||
const adjusted = addSaturation(c, clampedLevel); |
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.
Maybe it's out of scope but I think addSaturation
is actually setSaturation
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.
Agree
render() { | ||
return ( | ||
<> | ||
{this.renderSearch()} | ||
<ScrollView ref={this.scrollViewRef}> | ||
{/* {this.renderColorPaletteExample()} */} |
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.
Not sure why it's hidden, wouldn't UX will want to test it?
BTW, I did not test it.
We can go over it together if you like
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.
Moved to the bottom of the screen
Description
Colors - adjust palette to steps of 9 when addDarkestTint is true
Changelog
Colors - adjust palette to steps of 9 when addDarkestTint is true
Additional info
WOAUILIB-3830