i'm trying to get the value of my select, to change the color of my text.
I have and RichText where i can enter text, but i want to change the color of this text with select input.
There is my code :
on edit.js
export default function Edit({ attributes, setAttributes, className, props }) {
const MyRadioControl = () => {
const [ option, setOption ] = useState( 'a' );
return (
<RadioControl
label="User type"
help="The type of the current user"
selected={ option }
options={ [
{ label: 'Author', value: 'a' },
{ label: 'Editor', value: 'e' },
] }
onChange={ ( value ) => setOption( value ) }
/>
);
};
const blockProps = useBlockProps();
return (
<h2 {...blockProps}>
<RichText
tagName="p"
value={attributes.content}
className ={MyRadioControl()}
allowedFormats={["core/italic"]}
onChange={(content) => setAttributes({ content })}
placeholder={__("Veuillez écrire du texte")}
/>
</h2>
);
}
I dont undertand how i can pass the select value , to my className.
Thanks!