uiwjs / react-color

🎨 Is a tiny color picker widget component for React apps.
https://uiwjs.github.io/react-color
MIT License
274 stars 92 forks source link

Disable Alpha for Sketch picker #112

Closed DenisKaminsky closed 1 year ago

DenisKaminsky commented 1 year ago

Could you please add an option to disable alpha for Sketch picker? Alpha doesn't make sense if you work with hex codes because it requires an 8 character hex code format instead of 6 character format which is used by default

jaywcjlove commented 1 year ago

@DenisKaminsky Upgrade v1.2.0

import React, { useState } from 'react';
import Sketch from '@uiw/react-color-sketch';

function Demo() {
  const [hex, setHex] = useState("#fff");
  const [disableAlpha, setDisableAlpha] = useState(false);
  return (
    <div>
      <Sketch
        style={{ marginLeft: 20 }}
        color={hex}
        disableAlpha={disableAlpha}
        onChange={(color) => {
          setHex(color.hex);
        }}
      />
      <button onClick={() => setDisableAlpha(!disableAlpha)}>
        disableAlpha={disableAlpha.toString()}
      </button>
    </div>
  );
}

export default Demo;
DenisKaminsky commented 1 year ago

Nice. But it is still visible on the panel image Also it would be nice to center the text in these cells. You can add "text-align: center" for these inputs

DenisKaminsky commented 1 year ago

Thank you