DiceFormFields.jsx 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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("Side count")}
  20. <Field
  21. name="side"
  22. component="input"
  23. initialValue={initialValues.side || 6}
  24. >
  25. {(props) => <input {...props.input} type="number" />}
  26. </Field>
  27. </Label>
  28. <Label>
  29. {t("Color")}
  30. <Field
  31. name="color"
  32. component="input"
  33. initialValue={initialValues.color || "#ccc"}
  34. >
  35. {({ input: { onChange, value } }) => (
  36. <ColorPicker value={value} onChange={onChange} />
  37. )}
  38. </Field>
  39. </Label>
  40. <Label>
  41. {t("Font size")}
  42. <Field
  43. name="fontSize"
  44. component="input"
  45. initialValue={initialValues.fontSize || 35}
  46. >
  47. {(props) => <input {...props.input} type="number" />}
  48. </Field>
  49. </Label>
  50. <Label>
  51. {t("Text color")}
  52. <Field
  53. name="textColor"
  54. component="input"
  55. initialValue={initialValues.textColor || "#fff"}
  56. >
  57. {({ input: { onChange, value } }) => (
  58. <ColorPicker
  59. value={value}
  60. onChange={onChange}
  61. disableAlpha={true}
  62. />
  63. )}
  64. </Field>
  65. </Label>
  66. </>
  67. );
  68. };
  69. export default Form;