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.2KB

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