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.

undo-redo.tsx 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import { IconButton } from 'components/shared'
  2. import { RotateCcw, RotateCw, Trash2 } from 'react-feather'
  3. import state from 'state'
  4. import styled from 'styles'
  5. import Tooltip from '../tooltip'
  6. const undo = () => state.send('UNDO')
  7. const redo = () => state.send('REDO')
  8. const clear = () => state.send('CLEARED_PAGE')
  9. export default function UndoRedo(): JSX.Element {
  10. return (
  11. <Container size={{ '@sm': 'small' }}>
  12. <Tooltip label="Undo">
  13. <IconButton onClick={undo}>
  14. <RotateCcw />
  15. </IconButton>
  16. </Tooltip>
  17. <Tooltip label="Redo">
  18. <IconButton onClick={redo}>
  19. <RotateCw />
  20. </IconButton>
  21. </Tooltip>
  22. <Tooltip label="Clear Canvas">
  23. <IconButton onClick={clear}>
  24. <Trash2 />
  25. </IconButton>
  26. </Tooltip>
  27. </Container>
  28. )
  29. }
  30. const Container = styled('div', {
  31. position: 'absolute',
  32. bottom: 64,
  33. right: 12,
  34. backgroundColor: '$panel',
  35. borderRadius: '4px',
  36. overflow: 'hidden',
  37. alignSelf: 'flex-end',
  38. pointerEvents: 'all',
  39. userSelect: 'none',
  40. zIndex: 200,
  41. border: '1px solid $panel',
  42. boxShadow: '0px 2px 4px rgba(0,0,0,.12)',
  43. display: 'flex',
  44. padding: 4,
  45. flexDirection: 'column',
  46. '& svg': {
  47. height: 13,
  48. width: 13,
  49. },
  50. variants: {
  51. size: {
  52. small: {
  53. bottom: 12,
  54. flexDirection: 'row',
  55. alignItems: 'center',
  56. },
  57. },
  58. },
  59. })