Skip to content

Commit

Permalink
fix: hide square behind 'mixed' icon
Browse files Browse the repository at this point in the history
  • Loading branch information
mxmou committed Aug 30, 2022
1 parent c68adc2 commit 98237f4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/components/color-button/color-button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ import styles from './color-button.css';
import GradientTypes from '../../lib/gradient-types';
import log from '../../log/log';

const isMixed = (color, color2, gradientType) => {
return color === MIXED || (gradientType !== GradientTypes.SOLID && color2 === MIXED);
}

const colorToBackground = (color, color2, gradientType) => {
if (color === MIXED || (gradientType !== GradientTypes.SOLID && color2 === MIXED)) return 'white';
if (isMixed(color, color2, gradientType)) return 'white';
if (color === null) color = 'white';
if (color2 === null) color2 = 'white';
switch (gradientType) {
Expand All @@ -30,7 +34,7 @@ const ColorButtonComponent = props => (
>
<div
className={classNames(styles.colorButtonSwatch, {
[styles.outlineSwatch]: props.outline && !(props.color === MIXED)
[styles.outlineSwatch]: props.outline && !isMixed(props.color, props.color2, props.gradientType)
})}
style={{
background: colorToBackground(props.color, props.color2, props.gradientType)
Expand All @@ -42,7 +46,7 @@ const ColorButtonComponent = props => (
draggable={false}
src={noFillIcon}
/>
) : ((props.color === MIXED || (props.gradientType !== GradientTypes.SOLID && props.color2 === MIXED) ? (
) : ((isMixed(props.color, props.color2, props.gradientType) ? (
<img
className={styles.swatchIcon}
draggable={false}
Expand Down

0 comments on commit 98237f4

Please sign in to comment.