MarkupEditorFooter.jsx 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. import React from "react"
  2. import Button from "../button"
  3. const MarkupEditorFooter = ({
  4. canProtect,
  5. disabled,
  6. empty,
  7. preview,
  8. isProtected,
  9. submitText,
  10. showPreview,
  11. closePreview,
  12. enableProtection,
  13. disableProtection,
  14. }) => (
  15. <div className="markup-editor-footer">
  16. {!!canProtect && (
  17. <Button
  18. className="btn-default btn-icon hidden-sm hidden-md hidden-lg"
  19. title={
  20. isProtected
  21. ? pgettext("markup editor", "Protected")
  22. : pgettext("markup editor", "Protect")
  23. }
  24. type="button"
  25. disabled={disabled}
  26. onClick={() => {
  27. if (isProtected) {
  28. disableProtection()
  29. } else {
  30. enableProtection()
  31. }
  32. }}
  33. >
  34. <span className="material-icon">
  35. {isProtected ? "lock" : "lock_open"}
  36. </span>
  37. </Button>
  38. )}
  39. {!!canProtect && (
  40. <div>
  41. <Button
  42. className="btn-default hidden-xs"
  43. type="button"
  44. disabled={disabled}
  45. onClick={() => {
  46. if (isProtected) {
  47. disableProtection()
  48. } else {
  49. enableProtection()
  50. }
  51. }}
  52. >
  53. <span className="material-icon">
  54. {isProtected ? "lock" : "lock_open"}
  55. </span>
  56. {isProtected
  57. ? pgettext("markup editor", "Protected")
  58. : pgettext("markup editor", "Protect")}
  59. </Button>
  60. </div>
  61. )}
  62. <div className="markup-editor-spacer" />
  63. {preview ? (
  64. <Button
  65. className="btn-default btn-auto"
  66. type="button"
  67. onClick={closePreview}
  68. >
  69. {pgettext("markup editor", "Edit")}
  70. </Button>
  71. ) : (
  72. <Button
  73. className="btn-default btn-auto"
  74. disabled={disabled || empty}
  75. type="button"
  76. onClick={showPreview}
  77. >
  78. {pgettext("markup editor", "Preview")}
  79. </Button>
  80. )}
  81. <Button className="btn-primary btn-auto" disabled={disabled || empty}>
  82. {submitText || gettext("Post")}
  83. </Button>
  84. </div>
  85. )
  86. export default MarkupEditorFooter