TokenFormFields.jsx 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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("Size")}
  12. <Field name="size" component="input" initialValue={initialValues.size}>
  13. {(props) => <input {...props.input} type="number" />}
  14. </Field>
  15. </Label>
  16. <Label>
  17. {t("Color")}
  18. <Field
  19. name="color"
  20. component="input"
  21. initialValue={initialValues.color}
  22. >
  23. {({ input: { onChange, value } }) => (
  24. <ColorPicker value={value} onChange={onChange} />
  25. )}
  26. </Field>
  27. </Label>
  28. <Label>
  29. {t("Label")}
  30. <Field
  31. name="text"
  32. component="input"
  33. initialValue={initialValues.text}
  34. />
  35. </Label>
  36. <Label>
  37. {t("Text Color")}
  38. <Field
  39. name="textColor"
  40. component="input"
  41. initialValue={initialValues.textColor}
  42. >
  43. {({ input: { onChange, value } }) => (
  44. <ColorPicker value={value} onChange={onChange} />
  45. )}
  46. </Field>
  47. </Label>
  48. <Label>
  49. {t("Font size")}
  50. <Field
  51. name="fontSize"
  52. component="input"
  53. initialValue={initialValues.fontSize}
  54. >
  55. {(props) => <input {...props.input} type="number" />}
  56. </Field>
  57. </Label>
  58. </>
  59. );
  60. };
  61. export default Form;