You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
632 B
31 lines
632 B
import React, {useLayoutEffect} from "react";
|
|
import iro from '@jaames/iro';
|
|
import {randId} from "../../Helpers/random";
|
|
|
|
function ColorPicker({color, onChange}) {
|
|
const random = randId();
|
|
|
|
useLayoutEffect(() => {
|
|
const colorPicker = new iro.ColorPicker("#color-picker-" + random, {
|
|
color: `#${color}`,
|
|
layout: [
|
|
{
|
|
component: iro.ui.Wheel,
|
|
options: {}
|
|
}
|
|
],
|
|
});
|
|
|
|
colorPicker.on("input:end", color => {
|
|
onChange(color.hexString.substr(1));
|
|
})
|
|
}, []);
|
|
|
|
return (
|
|
<div id={`color-picker-${random}`}>
|
|
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export default ColorPicker;
|