Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

toolbar.tsx 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. import state, { useSelector } from "state"
  2. import styled from "styles"
  3. import { Menu } from "react-feather"
  4. export default function Toolbar() {
  5. const activeTool = useSelector((state) =>
  6. state.whenIn({
  7. selecting: "select",
  8. dot: "dot",
  9. circle: "circle",
  10. ellipse: "ellipse",
  11. ray: "ray",
  12. line: "line",
  13. polyline: "polyline",
  14. rectangle: "rectangle",
  15. draw: "draw",
  16. })
  17. )
  18. return (
  19. <ToolbarContainer>
  20. <Section>
  21. <Button>
  22. <Menu />
  23. </Button>
  24. <Button
  25. isSelected={activeTool === "select"}
  26. onClick={() => state.send("SELECTED_SELECT_TOOL")}
  27. >
  28. Select
  29. </Button>
  30. <Button
  31. isSelected={activeTool === "draw"}
  32. onClick={() => state.send("SELECTED_DRAW_TOOL")}
  33. >
  34. Draw
  35. </Button>
  36. <Button
  37. isSelected={activeTool === "dot"}
  38. onClick={() => state.send("SELECTED_DOT_TOOL")}
  39. >
  40. Dot
  41. </Button>
  42. <Button
  43. isSelected={activeTool === "circle"}
  44. onClick={() => state.send("SELECTED_CIRCLE_TOOL")}
  45. >
  46. Circle
  47. </Button>
  48. <Button
  49. isSelected={activeTool === "ellipse"}
  50. onClick={() => state.send("SELECTED_ELLIPSE_TOOL")}
  51. >
  52. Ellipse
  53. </Button>
  54. <Button
  55. isSelected={activeTool === "ray"}
  56. onClick={() => state.send("SELECTED_RAY_TOOL")}
  57. >
  58. Ray
  59. </Button>
  60. <Button
  61. isSelected={activeTool === "line"}
  62. onClick={() => state.send("SELECTED_LINE_TOOL")}
  63. >
  64. Line
  65. </Button>
  66. <Button
  67. isSelected={activeTool === "polyline"}
  68. onClick={() => state.send("SELECTED_POLYLINE_TOOL")}
  69. >
  70. Polyline
  71. </Button>
  72. <Button
  73. isSelected={activeTool === "rectangle"}
  74. onClick={() => state.send("SELECTED_RECTANGLE_TOOL")}
  75. >
  76. Rectangle
  77. </Button>
  78. <Button onClick={() => state.send("RESET_CAMERA")}>Reset Camera</Button>
  79. </Section>
  80. <Section>
  81. <Button onClick={() => state.send("UNDO")}>Undo</Button>
  82. <Button onClick={() => state.send("REDO")}>Redo</Button>
  83. </Section>
  84. </ToolbarContainer>
  85. )
  86. }
  87. const ToolbarContainer = styled("div", {
  88. gridArea: "toolbar",
  89. userSelect: "none",
  90. borderBottom: "1px solid black",
  91. display: "flex",
  92. alignItems: "center",
  93. justifyContent: "space-between",
  94. backgroundColor: "$panel",
  95. gap: 8,
  96. fontSize: "$1",
  97. zIndex: 200,
  98. })
  99. const Section = styled("div", {
  100. whiteSpace: "nowrap",
  101. overflow: "hidden",
  102. display: "flex",
  103. })
  104. const Button = styled("button", {
  105. display: "flex",
  106. alignItems: "center",
  107. cursor: "pointer",
  108. font: "$ui",
  109. fontSize: "$ui",
  110. height: "40px",
  111. outline: "none",
  112. borderRadius: 0,
  113. border: "none",
  114. padding: "0 12px",
  115. background: "none",
  116. "&:hover": {
  117. backgroundColor: "$hint",
  118. },
  119. "& svg": {
  120. height: 16,
  121. width: 16,
  122. },
  123. variants: {
  124. isSelected: {
  125. true: {
  126. color: "$selected",
  127. },
  128. false: {},
  129. },
  130. },
  131. })