ScreenFormFields.jsx 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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("Background color")}
  40. <Field
  41. name="backgroundColor"
  42. component="input"
  43. initialValue={initialValues.backgroundColor || "#CCCCCC"}
  44. >
  45. {({ input: { onChange, value } }) => (
  46. <ColorPicker value={value} onChange={onChange} />
  47. )}
  48. </Field>
  49. </Label>
  50. <Label>
  51. {t("Border color")}
  52. <Field
  53. name="borderColor"
  54. component="input"
  55. initialValue={initialValues.borderColor || "#CCCCCC33"}
  56. >
  57. {({ input: { onChange, value } }) => (
  58. <ColorPicker
  59. value={value}
  60. onChange={onChange}
  61. disableAlpha={false}
  62. />
  63. )}
  64. </Field>
  65. </Label>
  66. <Label>
  67. {t("Border style")}
  68. <Field
  69. name="borderStyle"
  70. component="select"
  71. initialValue={initialValues.borderStyle || "dotted"}
  72. style={{ width: "10em" }}
  73. >
  74. <option value="dotted">{t("Dotted")}</option>
  75. <option value="Solid">{t("solid")}</option>
  76. <option value="dashed">{t("Dashed")}</option>
  77. </Field>
  78. </Label>
  79. </>
  80. );
  81. };
  82. export default Form;