react-color icon indicating copy to clipboard operation
react-color copied to clipboard

#FFF circle color picker selected state on white background

Open proevilz opened this issue 6 years ago • 12 comments

If you use a CirclePicker color of #fff (white) and put it on a white background, the box shadow color is white and the 'selected' circle that appears is also... white. This leaves you with basically an invisible color picker.

I would propose that if one of the CirclePicker colors is #fff then make the box shadow color #000 by default and change the 'selected' circle that appears to additionally include a #000 colored border on it.

I know I can override this with CSS but I feel this shouldn't need to be overridden.

I would make a 'pull request' to offer these changes for you but I don't quite understand how pull requests work. I don't get why it's asking me to compare branches when all I wish to do is submit a single file.

Edit With that said, how exactly do I override the default CSS? I attempted to copy react-color/lib/components/circle/circle.js and react-color/lib/components/circle/CircleSwatch but I just get an error any time I click the color...? screenshot 2018-08-24 at 07 06 57

proevilz avatar Aug 24 '18 05:08 proevilz

I also tried copying the ones from this repo out the src folder and get the same error...

proevilz avatar Aug 24 '18 06:08 proevilz

Update: If I remove line 32 & 34 it works as expected.... However, it seems I cannot change the box-shadow since you're using it to set the actual color of the circle.

proevilz avatar Aug 24 '18 06:08 proevilz

Hmm, maybe we need to do something custom for the white swatch. Maybe we should add a slight border to it or something?

casesandberg avatar Jan 23 '19 23:01 casesandberg

@casesandberg Thinking about this issue for Hacktoberfest 2019.

I don't know if there is a solution for this problem—any of the color swatches would disappear on a background which is identical to their own color, just like the white one.

Whatever is done for white would have to be done on all circle swatches to be effective

image image

andrew-pyle avatar Oct 12 '19 21:10 andrew-pyle

I'll submit a pull request which implements the following OPTION for solving the problem of color swatches disappearing on identical background:

  • Swatches always have grey border. Makes color swatch visible on same color background.
  • Add grey ring inside selected color ring. Makes selection visible on same color background.
  • Always use grey shadow shadow on selected, rather than the color of the swatch. Matches grey border.
  • Adds a borderColor prop & default color

andrew-pyle avatar Oct 12 '19 21:10 andrew-pyle

I'll submit a pull request which implements the following OPTION for solving the problem of color swatches disappearing on identical background:

  • Swatches always have grey border. Makes color swatch visible on same color background.
  • Add grey ring inside selected color ring. Makes selection visible on same color background.
  • Always use grey shadow shadow on selected, rather than the color of the swatch. Matches grey border.
  • Adds a borderColor prop & default color

Hey, @andrew-pyle was this issue solved? I'm running into the same problem where I'm using a white swatch and it disappears into the background!

Cvrane avatar Oct 22 '20 21:10 Cvrane

@Cvrane I am not aware of any more progress than stalled PR #649 above.

@casesandberg Any ideas besides adding the grey border?

Maybe we can detect the background color and add a grey border only in the case that they match?

andrew-pyle avatar Oct 23 '20 02:10 andrew-pyle

@Cvrane I am not aware of any more progress than stalled PR #649 above.

@casesandberg Any ideas besides adding the grey border?

Maybe we can detect the background color and add a grey border only in the case that they match?

Thank you so much for replying and offering to help! I looked into adding a black border just to the white swatch but it just seems to not work. Any suggestions are appreciated!

Cvrane avatar Oct 23 '20 22:10 Cvrane

@Cvrane have you looked at the approach used in PR #649?

andrew-pyle avatar Oct 23 '20 23:10 andrew-pyle

A combination of CSS and a dynamic white-selected className is working for us for now:

  .circle-picker {
    div[title="#ffffff"] {
      border: 1px solid #999;
    }
    &.white-selected {
      div[title="#ffffff"] {
        box-shadow: #999 0 0 0 3px inset !important;
        border: none;

        &:focus {
          box-shadow: #999 0 0 0 3px inset, 0 0 5px #999 !important;
        }
      }
    }
  }
<CirclePicker
   className={chosenColor === '#ffffff' ? 'white-selected' : ''}
   color={chosenColor}
/>
image

jeffsheets avatar Sep 29 '21 19:09 jeffsheets

@jeffsheets Thanks! That solved my problem

I just made small changes, since I'm using pure CSS, in case anyone needs:

.circle-picker span div span div[title~="#fff"] {
    border: 1px solid #999;
}

.white-selected span div span div[title~="#fff"] {
    box-shadow: #999 0 0 0 3px inset, 0 0 5px #999 !important;
}

bruno-silva5 avatar Dec 09 '21 12:12 bruno-silva5

@bruno-silva5 that's nice with the CSS title selector! Thanks, I'm going to modify ours to be pure CSS too!

jeffsheets avatar Dec 09 '21 13:12 jeffsheets