You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

toolbar.tsx 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. import state, { useSelector } from 'state'
  2. import styled from 'styles'
  3. import { Lock, Menu, RotateCcw, RotateCw, Unlock } from 'react-feather'
  4. import { IconButton } from './shared'
  5. export default function Toolbar() {
  6. const activeTool = useSelector((state) =>
  7. state.whenIn({
  8. selecting: 'select',
  9. dot: 'dot',
  10. circle: 'circle',
  11. ellipse: 'ellipse',
  12. ray: 'ray',
  13. line: 'line',
  14. polyline: 'polyline',
  15. rectangle: 'rectangle',
  16. draw: 'draw',
  17. })
  18. )
  19. const isToolLocked = useSelector((s) => s.data.settings.isToolLocked)
  20. return (
  21. <ToolbarContainer>
  22. <Section>
  23. <Button>
  24. <Menu />
  25. </Button>
  26. <Button onClick={() => state.send('RESET_CAMERA')}>Reset Camera</Button>
  27. </Section>
  28. <Section>
  29. <Button title="Undo" onClick={() => state.send('UNDO')}>
  30. <RotateCcw />
  31. </Button>
  32. <Button title="Redo" onClick={() => state.send('REDO')}>
  33. <RotateCw />
  34. </Button>
  35. </Section>
  36. </ToolbarContainer>
  37. )
  38. }
  39. const ToolbarContainer = styled('div', {
  40. gridArea: 'toolbar',
  41. userSelect: 'none',
  42. borderBottom: '1px solid black',
  43. display: 'flex',
  44. alignItems: 'center',
  45. justifyContent: 'space-between',
  46. backgroundColor: '$panel',
  47. gap: 8,
  48. fontSize: '$1',
  49. zIndex: 200,
  50. })
  51. const Section = styled('div', {
  52. whiteSpace: 'nowrap',
  53. overflowY: 'hidden',
  54. overflowX: 'auto',
  55. display: 'flex',
  56. scrollbarWidth: 'none',
  57. '&::-webkit-scrollbar': {
  58. '-webkit-appearance': 'none',
  59. width: 0,
  60. height: 0,
  61. },
  62. })
  63. const Button = styled('button', {
  64. display: 'flex',
  65. alignItems: 'center',
  66. cursor: 'pointer',
  67. font: '$ui',
  68. fontSize: '$ui',
  69. height: '40px',
  70. outline: 'none',
  71. borderRadius: 0,
  72. border: 'none',
  73. padding: '0 12px',
  74. background: 'none',
  75. '&:hover': {
  76. backgroundColor: '$hint',
  77. },
  78. '& svg': {
  79. height: 16,
  80. width: 16,
  81. },
  82. variants: {
  83. isSelected: {
  84. true: {
  85. color: '$selected',
  86. },
  87. false: {},
  88. },
  89. },
  90. })