GithubHelp home page GithubHelp logo

uiwjs / react-color Goto Github PK

View Code? Open in Web Editor NEW
248.0 4.0 87.0 69.29 MB

🎨 Is a tiny color picker widget component for React apps.

Home Page: https://uiwjs.github.io/react-color

License: MIT License

TypeScript 98.27% HTML 1.03% CSS 0.66% Less 0.04%
react react-components color-picker color hex typescript react-color react-colorpicker sketch colorful

react-color's People

Contributors

cjjordan avatar dangreaves avatar dereklowlind avatar farshad-vgr avatar jaywcjlove avatar marcosfreitas avatar nosferatu31 avatar renovate-bot avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

react-color's Issues

Typo in Github picker placement enum: "Botton" instead of "Bottom"

In the GithubPlacement enum there is a typo the word "Bottom" in several combinations.

export enum GithubPlacement {
  Left = 'L',
  LeftTop = 'LT',
  LeftBotton = 'LB',
  Right = 'R',
  RightTop = 'RT',
  RightBotton = 'RB',
  Top = 'T',
  TopRight = 'TR',
  TopLeft = 'TL',
  Botton = 'B',
  BottonLeft = 'BL',
  BottonRight = 'BR',
}

Not sure if you want to change this as it would mean a API breaking change. You could add the correctly spelled keys mapping to the same string values though.

Wheel shape width/height adaption

Hey everyone!

First of all, I love the library. Is there a way to change the width/height of the Wheel variant but not use a square?
I am able to change it with the props but the draggable picker still always seems to rotate in a circle?

I'd appreciate any help here!

Screenshot 2023-03-31 at 19 05 42

Disable Alpha for Sketch picker

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

Color wheel gets stuck at V = 0

When you pass HSVA into the color wheel if you set the V to 0, the dragging of the color wheel cursor becomes stuck and brings S to 0 as well. The H value will change while dragging the cursor, but the cursor never moves from the center of the color wheel.

Cursor Stuck At Center

[color-convert] Circular dependencies error

Hi,

I'm trying to bundle a project using @uiw/color-convert package, but I get the Circular dependencies error.

(!) Circular dependencies
node_modules/@uiw/color-convert/esm/index.js -> node_modules/@uiw/color-convert/esm/utils.js -> node_modules/@uiw/color-convert/esm/index.js
node_modules/@uiw/color-convert/esm/index.js -> node_modules/@uiw/color-convert/esm/getContrastingColor.js -> node_modules/@uiw/color-convert/esm/index.js

Anyone had any issue like that? Trying to find out if it's a bug or am I doing something wrong.
Thanks

Color picking dark color results in jumpy behavior

Issue is reproducible both in code and on the live demo site: https://uiwjs.github.io/react-color/#/colorful

  • use the second picker on the page, under Usage section
  • Drag the color picker to the lower dark range - it jumps around and is unusable
  • For some reason, this does not occur in the "example" pickers that are not accompanied by a code snippet

This occurs for several other demo pickers on the site, making this unusable in my projects. This is occurring in Chrome.

Wheel using HEX instead of HSVA

I see Colorful can use hex; is there a way we can implement hex with the Wheel component instead of hsva? Really great tools! Thanks.

Uncaught TypeError: Cannot redefine property: render

Uncaught TypeError: Cannot redefine property: render
    at Function.defineProperty (<anonymous>)
    at <unknown> (file:///..../app/node_modules/@uiw/react-color/cjs/index.js:188:10)

NextJS (tried to turn off SSR, checked for window variable etc) - no difference. Do you have any advises here? Thank you in advance

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Other Branches

These updates are pending. To force PRs open, click the checkbox below.

  • chore(deps): update actions/checkout action to v4
  • chore(deps): update actions/setup-node action to v4

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/ci.yml
  • actions/checkout v4
  • actions/setup-node v4
  • peaceiris/actions-gh-pages v4
  • ncipollo/release-action v1
.github/workflows/pr.yml
  • actions/checkout v3
  • actions/setup-node v3
npm
package.json
  • @kkt/less-modules ^7.2.0
  • @kkt/ncc ^1.0.13
  • @testing-library/react ^14.0.0
  • @types/react ~18.2.0
  • @types/react-dom ~18.2.0
  • @types/react-test-renderer ~18.0.0
  • husky ~9.0.0
  • jest ^29.5.0
  • jest-environment-jsdom ^29.5.0
  • jest-watch-typeahead ^2.2.2
  • lerna ^8.0.0
  • lint-staged ^15.1.0
  • prettier ^3.0.0
  • react ~18.2.0
  • react-dom ~18.2.0
  • react-test-renderer ~18.2.0
  • tsbb ^4.1.0
  • node >=16.0.0
packages/color-alpha/package.json
  • @babel/runtime ^7.21.0
  • @babel/runtime >=7.19.0
  • react >=16.9.0
  • react-dom >=16.9.0
packages/color-block/package.json
  • @babel/runtime ^7.21.0
  • @babel/runtime >=7.19.0
  • react >=16.9.0
  • react-dom >=16.9.0
packages/color-chrome/package.json
  • @babel/runtime ^7.21.0
  • @babel/runtime >=7.19.0
  • react >=16.9.0
  • react-dom >=16.9.0
packages/color-circle/package.json
  • @babel/runtime ^7.21.0
  • @babel/runtime >=7.19.0
  • react >=16.9.0
  • react-dom >=16.9.0
packages/color-colorful/package.json
  • @babel/runtime ^7.21.0
  • @babel/runtime >=7.19.0
  • react >=16.9.0
  • react-dom >=16.9.0
packages/color-compact/package.json
  • @babel/runtime ^7.21.0
  • @babel/runtime >=7.19.0
  • react >=16.9.0
  • react-dom >=16.9.0
packages/color-convert/package.json
  • @babel/runtime ^7.21.0
  • @babel/runtime >=7.19.0
packages/color-editable-input-hsla/package.json
  • @babel/runtime ^7.21.0
  • @babel/runtime >=7.19.0
  • react >=16.9.0
  • react-dom >=16.9.0
packages/color-editable-input-rgba/package.json
  • @babel/runtime ^7.21.0
  • @babel/runtime >=7.19.0
  • react >=16.9.0
  • react-dom >=16.9.0
packages/color-editable-input/package.json
  • @babel/runtime ^7.21.0
  • @babel/runtime >=7.19.0
  • react >=16.9.0
  • react-dom >=16.9.0
packages/color-github/package.json
  • @babel/runtime ^7.21.0
  • @babel/runtime >=7.19.0
  • react >=16.9.0
  • react-dom >=16.9.0
packages/color-hue/package.json
  • @babel/runtime ^7.21.0
  • @babel/runtime >=7.19.0
  • react >=16.9.0
  • react-dom >=16.9.0
packages/color-material/package.json
  • @babel/runtime ^7.21.0
  • @babel/runtime >=7.19.0
  • react >=16.9.0
  • react-dom >=16.9.0
packages/color-name/package.json
  • colors-named ^1.0.1
  • colors-named-hex ^1.0.1
  • @babel/runtime ^7.21.0
  • @babel/runtime >=7.19.0
packages/color-saturation/package.json
  • @babel/runtime ^7.21.0
  • @babel/runtime >=7.19.0
  • react >=16.9.0
  • react-dom >=16.9.0
packages/color-shade-slider/package.json
  • @babel/runtime ^7.21.0
  • @babel/runtime >=7.19.0
  • react >=16.9.0
  • react-dom >=16.9.0
packages/color-sketch/package.json
  • @babel/runtime ^7.21.0
  • @babel/runtime >=7.19.0
  • react >=16.9.0
  • react-dom >=16.9.0
packages/color-slider/package.json
  • @babel/runtime ^7.21.0
  • @babel/runtime >=7.19.0
  • react >=16.9.0
  • react-dom >=16.9.0
packages/color-swatch/package.json
  • @babel/runtime ^7.21.0
  • @babel/runtime >=7.19.0
  • react >=16.9.0
  • react-dom >=16.9.0
packages/color-wheel/package.json
  • @babel/runtime ^7.21.0
  • @babel/runtime >=7.19.0
  • react >=16.9.0
  • react-dom >=16.9.0
packages/color/package.json
  • @babel/runtime ^7.21.0
  • @babel/runtime >=7.19.0
  • react >=16.9.0
  • react-dom >=16.9.0
packages/drag-event-interactive/package.json
  • @babel/runtime ^7.21.0
  • @babel/runtime >=7.19.0
  • react >=16.9.0
  • react-dom >=16.9.0
website/package.json
  • @babel/runtime ^7.21.0
  • @uiw/react-github-corners ~1.5.3
  • @uiw/react-loader ^4.22.2
  • @uiw/react-markdown-preview-example ^2.0.0
  • @wcj/dark-mode ^1.0.14
  • react ~18.2.0
  • react-dom ~18.2.0
  • react-router-dom ^6.20.0
  • @kkt/less-modules ^7.2.0
  • @kkt/raw-modules ^7.2.0
  • @types/react ~18.2.0
  • @types/react-dom ~18.2.0
  • kkt ^7.2.0
  • markdown-react-code-preview-loader ^2.1.2

  • Check this box to trigger a request for Renovate to run again on this repository

Feature request: Ability to disable alpha

It would be very nice to be able to pass a prop to the color picker to remove the alpha slider when I want to restrict the possible value selected to RGB, not RGBA. If the ability already exists, I have not managed to find it in the documentation.

I'm thinking it would work something like:

<Colorful disableAlpha='true' />

image

Direction/angle color issue

simplescreenrecorder3-2024-02-07_15.13.11.mp4

Hello. I tried to customize the wheel by setting direction and angle but they just change the visualization of the background, both the Pointer color and onChange ColorResult still use the "original" color (with default direction="anticlockwise" and angle=180).

Am I missing something?

Saturation range mode

How can I use saturation like hue and alpha in range mode?
I need this one
Hue
Saturation
Shade
Alpha

Screen Shot 2021-12-28 at 11 01 04 PM

Shade slider (white color)

In my opinion the shade slider is not working properly. For the color #ffffff, the range is always from red to black. It seems to me that the saturation should not be permanently 100. Correction suggestion:

import { hsvaToHslaString } from '@uiw/color-convert'
import Alpha, { AlphaProps } from '@uiw/react-color-alpha'
import React from 'react'

export interface ShadeSliderProps extends Omit<AlphaProps, 'onChange'> {
  onChange?: (newShade: { v: number }) => void
}

export const ShadeSlider = React.forwardRef<HTMLDivElement, ShadeSliderProps>(
  (props, ref) => {
    const {
      prefixCls = 'w-color-saturation',
      className,
      onChange,
      direction = 'horizontal',
      hsva,
      ...other
    } = props
    const colorFrom = hsvaToHslaString({ ...hsva, a: 1, v: 100 })
    return (
      <Alpha
        ref={ref}
        {...other}
        className={`${prefixCls} ${className || ''}`}
        hsva={{ h: hsva.h, s: hsva.s, v: hsva.v, a: 1 - hsva.v / 100 }}
        direction={direction}
        background={`linear-gradient(to ${
          direction === 'horizontal' ? 'right' : 'bottom'
        }, ${colorFrom}, rgb(0, 0, 0))`}
        onChange={(_, interaction) => {
          onChange &&
            onChange({
              v:
                direction === 'horizontal'
                  ? 100 - interaction.left * 100
                  : 100 - interaction.top * 100,
            })
        }}
      />
    )
  },
)
Zrzut ekranu 2023-05-12 o 10 29 22

Add type for Hex color

add a type for hex-color strings that is a bit stricter than only string.
type HexColor = `#${string}`;

Default Color Value?

Currently, there are parameters to pass the color value, every time that value is changed the color will reset itself to that value.

Can we also have the option to have a default color value? A value that is only present until the user changes the color.

I would appreciate this feature. Thanks!

Sometimes Wheel don't react to onChange

I've used code like this:

const [hsva, setHsva] = useState({ h: 214, s: 43, v: 90, a: 1 })

const onChangeColorPicker = (event: any) => {
    setHsva({ ...hsva, ...event.hsva })
  }
  
return (
 <Wheel className={"wheel"} color={hsva} onChange={(event) => onChangeColorPicker(event)} />
)

At times, when I simply click (not click, hold, and move) on the wheel, the color doesn't update immediately. I find that I have to click on the same spot again to trigger the onChange event.
Do I need to use another approach?

Wheel cursor disabled

What happens:
For the wheel component, if the color is set to '#000000', then the cursor is immovable

What should happen:
The cursor should be able to move round the wheel and maybe capture all essence of black

Circle with margin

Hello there,

Using your library, I see that a margin has slipped around the circles. Is this a normal behavior? Do you know how I can center them? Is there a prop to add CSS classes (or styles) to override the style of the colored circles?

Thank you in advance and have a great day =D

Capture d’écran 2024-02-19 à 16 05 23

Pointer doesn't work on Color wheel

I'm using @uiw/react-color-wheel latest version (1.0.2) on one of my React JS projects. I need to customize the pointer element. So basically pointer props (color, left, right) will be enough for my implementation. But the problem is the pointer doesn't fit within the wheel element and pointer props are always the same when changing.
Tried with the default Pointer as well. But the result remains the same.

Pointer preview

Screenshot-2021-09-12-at-12-39-45

Pointer props

color: ""
left: "0"
prefixCls: "w-color-wheel"
top: "0"

Source code

Screenshot-2021-09-12-at-13-59-18

Support hex input with leading #

It would be great, if values like #121212 could also be pasted into the hex input fields.
When copying a hex value from an arbitrary source it might contain a leading #.
When pasting it into the input field it unfortunately resets to the previous value.

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.