Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change Value for Wheel #135

Closed
spl1nt3r99 opened this issue Nov 28, 2023 · 7 comments
Closed

Change Value for Wheel #135

spl1nt3r99 opened this issue Nov 28, 2023 · 7 comments

Comments

@spl1nt3r99
Copy link

Is there any slider I can use to change v for hsva wheel?

@jaywcjlove
Copy link
Member

@spl1nt3r99 Like this ?

import React, { useState } from 'react';
import Slider from '@uiw/react-color-slider';
import Wheel from '@uiw/react-color-wheel';

export default function Demo() {
  const [hsva, setHsva] = useState({ h: 0, s: 0, v: 68, a: 1 });
  return (
    <>
      <Slider
        color={hsva}
        style={{ paddingBottom: 10 }}
        onChange={(color) => {
          setHsva({ ...hsva, ...color.hsv });
        }}
      />
      <Wheel
        color={hsva}
        onChange={(color) => setHsva({ ...hsva, ...color.hsva })}
      />
    </>
  );
}

jaywcjlove added a commit that referenced this issue Nov 28, 2023
@spl1nt3r99
Copy link
Author

@jaywcjlove I mean like ShadeSlider. Can I reuse it for Value?

@jaywcjlove
Copy link
Member

@spl1nt3r99 You can use it in combination, I don't understand what you need to do

@spl1nt3r99
Copy link
Author

@jaywcjlove For example, pre-default state of wheel is {h: 214, s: 43, v: 90, a: 1}. Any changes at wheel will modified only h and s properties. I want to add slider like this to change v property too.
Снимок экрана 2023-11-29 в 14 23 12

jaywcjlove added a commit that referenced this issue Nov 29, 2023
@jaywcjlove
Copy link
Member

image

@spl1nt3r99

@jaywcjlove
Copy link
Member

import React, { useState, Fragment } from 'react';
import Wheel from '@uiw/react-color-wheel';
import ShadeSlider from '@uiw/react-color-shade-slider';
import { hsvaToHex } from '@uiw/color-convert';

function Demo() {
  const [hsva, setHsva] = useState({ h: 214, s: 43, v: 90, a: 1 });
  return (
    <Fragment>
      <Wheel color={hsva} onChange={(color) => setHsva({ ...hsva, ...color.hsva })} />
      <ShadeSlider
        hsva={hsva}
        style={{ width: 210, marginTop: 20 }}
        onChange={(newShade) => {
          setHsva({ ...hsva, ...newShade });
        }}
      />
      <div style={{ width: '100%', height: 34, marginTop: 20, background: hsvaToHex(hsva) }}></div>
    </Fragment>
  );
}

export default Demo;

@spl1nt3r99
Copy link
Author

@jaywcjlove Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants