CheckerBoardFormFields.jsx 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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="label"
  14. component="input"
  15. initialValue={initialValues.label}
  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 1")}
  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. <Label>
  51. {t("Color 2")}
  52. <Field
  53. name="alternateColor"
  54. component="input"
  55. initialValue={initialValues.alternateColor}
  56. >
  57. {({ input: { onChange, value } }) => (
  58. <ColorPicker value={value} onChange={onChange} />
  59. )}
  60. </Field>
  61. </Label>
  62. <Label>
  63. {t("Column count")}
  64. <Field
  65. name="colCount"
  66. component="input"
  67. initialValue={initialValues.colCount}
  68. >
  69. {(props) => <input {...props.input} type="number" />}
  70. </Field>
  71. </Label>
  72. <Label>
  73. {t("Row count")}
  74. <Field
  75. name="rowCount"
  76. component="input"
  77. initialValue={initialValues.rowCount}
  78. >
  79. {(props) => <input {...props.input} type="number" />}
  80. </Field>
  81. </Label>
  82. </>
  83. );
  84. };
  85. export default Form;