ActionBar.jsx 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. import React from "react";
  2. import MessageButton from "../../components/messages/MessageButton";
  3. import EditInfoButton from "../../components/EditInfoButton";
  4. import AddItemButton from "../../components/AddItemButton";
  5. import styled from "styled-components";
  6. import { useTranslation } from "react-i18next";
  7. import Touch from "../../components/ui/Touch";
  8. const StyledActionBar = styled.div`
  9. position: absolute;
  10. bottom: 1em;
  11. right: 0em;
  12. display: flex;
  13. width: 100%;
  14. text-shadow: 1px 1px 2px #222;
  15. font-size: 0.8em;
  16. pointer-events: none;
  17. & > *:not(.spacer) {
  18. padding: 0 1.5em;
  19. pointer-events: all;
  20. }
  21. & .spacer {
  22. flex: 1;
  23. }
  24. @media screen and (max-width: 640px) {
  25. & > *:not(.spacer) {
  26. padding: 0 0.5em;
  27. }
  28. & .spacer {
  29. padding: 0;
  30. }
  31. }
  32. @media screen and (max-width: 420px) {
  33. & > *:not(.spacer) {
  34. padding: 0 0.2em;
  35. }
  36. }
  37. `;
  38. const ActionBar = ({
  39. editMode,
  40. BoardFormComponent,
  41. itemLibraries,
  42. moveFirst,
  43. setMoveFirst,
  44. hideMenu,
  45. setHideMenu,
  46. }) => {
  47. const { t } = useTranslation();
  48. return (
  49. <StyledActionBar>
  50. {!editMode && <MessageButton />}
  51. {editMode && <EditInfoButton BoardFormComponent={BoardFormComponent} />}
  52. <div className="spacer" />
  53. <Touch
  54. onClick={() => setMoveFirst(false)}
  55. alt={t("Select mode")}
  56. label={t("Select")}
  57. title={t("Switch to select mode")}
  58. icon={"mouse-pointer"}
  59. active={!moveFirst}
  60. />
  61. <Touch
  62. onClick={() => setMoveFirst(true)}
  63. alt={t("Move mode")}
  64. label={t("Move")}
  65. title={t("Switch to move mode")}
  66. icon={"hand"}
  67. active={moveFirst}
  68. />
  69. <Touch
  70. onClick={() => setHideMenu((prev) => !prev)}
  71. alt={hideMenu ? t("Show menu") : t("Hide menu")}
  72. label={hideMenu ? t("Show menu") : t("Hide menu")}
  73. title={hideMenu ? t("Show action menu") : t("Hide action menu")}
  74. icon={hideMenu ? "eye-with-line" : "eye"}
  75. />
  76. <div className="spacer" />
  77. <AddItemButton itemLibraries={itemLibraries} />
  78. </StyledActionBar>
  79. );
  80. };
  81. export default ActionBar;