Skip to content

Commit

Permalink
move isSelectedCustom declaration to come before the new variable i…
Browse files Browse the repository at this point in the history
…s called
  • Loading branch information
chad1008 committed May 26, 2022
1 parent a3c0e22 commit b37de51
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions packages/components/src/color-palette/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,24 @@ function ColorPalette( {
);
const colors = isGradientSegment ? defaultGradientColors : defaultColors;

const isSelectedCustom = useCallback( () => {
const isWithinColors =
activeColor && mergedColors && mergedColors.includes( activeColor );
if ( enableCustomColor && activeColor ) {
if ( isGradientSegment ) {
return isGradientColor && ! isWithinColors;
}
return ! isGradientColor && ! isWithinColors;
}
return false;
}, [
activeColor,
mergedColors,
enableCustomColor,
isGradientColor,
isGradientSegment,
] );

const customIndicatorColor = isGradientSegment
? activeColor
: customSwatchGradients;
Expand All @@ -94,24 +112,6 @@ function ColorPalette( {
}
}, [ currentSegment, isSelectedCustom ] );

const isSelectedCustom = useCallback( () => {
const isWithinColors =
activeColor && mergedColors && mergedColors.includes( activeColor );
if ( enableCustomColor && activeColor ) {
if ( isGradientSegment ) {
return isGradientColor && ! isWithinColors;
}
return ! isGradientColor && ! isWithinColors;
}
return false;
}, [
activeColor,
mergedColors,
enableCustomColor,
isGradientColor,
isGradientSegment,
] );

function isSelected( color ) {
return ! isSelectedCustom() && activeColor === color;
}
Expand Down

0 comments on commit b37de51

Please sign in to comment.