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

Update useColorPicker.ts to use current selected value from picker #110

Merged
merged 1 commit into from
Nov 8, 2024

Conversation

khoshrou
Copy link
Contributor

@khoshrou khoshrou commented Nov 6, 2024

I like to create a component that contains ColorPicker and I like to pass the gradient object to the upper component.
getGradientObject not returning the correct object coz color not updated with value yet. this happens for value to hex too.
like this

const [color, setColor] = useState('rgba(70,70,142,1)');
const { getGradientObject, valueToHex } = useColorPicker(color, setColor);

function onChange(value: string) {
  setColor(value);
  
  if (props.onChange) {
	  const g = getGradientObject();
	  props.onChange(value, g.isGradient ? g : undefined);
  }
}
<ColorPicker value={color} onChange={onChange} width={290} />

@hxf31891
Copy link
Owner

hxf31891 commented Nov 8, 2024

@khoshrou thanks for putting this PR together, going to merge now. Hope it resolves your issue.

@hxf31891 hxf31891 merged commit b2a5867 into hxf31891:main Nov 8, 2024
0 of 2 checks passed
@khoshrou
Copy link
Contributor Author

khoshrou commented Nov 8, 2024

Thanks, seems we need more changes. I will other pr's when I finished debugging.

@hxf31891
Copy link
Owner

hxf31891 commented Nov 8, 2024

@khoshrou whats going on with it? Are you getting any bugs or just looking for different functionality?

@khoshrou
Copy link
Contributor Author

please check the new pull request and seems npm not updated with the latest changes

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

Successfully merging this pull request may close these issues.

2 participants