RectFormFields.jsx 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import React from "react";
  2. import { useTranslation } from "react-i18next";
  3. import { Field } from "react-final-form";
  4. import Label from "../../../ui/formUtils/Label";
  5. import ColorPicker from "../../../ui/formUtils/ColorPicker";
  6. const Form = ({ initialValues }) => {
  7. const { t } = useTranslation();
  8. return (
  9. <>
  10. <Label>
  11. {t("Label")}
  12. <Field
  13. name="text"
  14. component="input"
  15. initialValue={initialValues.text}
  16. />
  17. </Label>
  18. <Label>
  19. {t("Width")}
  20. <Field
  21. name="width"
  22. component="input"
  23. initialValue={initialValues.width}
  24. >
  25. {(props) => <input {...props.input} type="number" />}
  26. </Field>
  27. </Label>
  28. <Label>
  29. {t("Height")}
  30. <Field
  31. name="height"
  32. component="input"
  33. initialValue={initialValues.height}
  34. >
  35. {(props) => <input {...props.input} type="number" />}
  36. </Field>
  37. </Label>
  38. <Label>
  39. {t("Color")}
  40. <Field
  41. name="color"
  42. component="input"
  43. initialValue={initialValues.color}
  44. >
  45. {({ input: { onChange, value } }) => (
  46. <ColorPicker value={value} onChange={onChange} />
  47. )}
  48. </Field>
  49. </Label>
  50. </>
  51. );
  52. };
  53. export default Form;