tldraw/components/tools-panel/undo-redo.tsx

65 lines
1.4 KiB
TypeScript
Raw Normal View History

2021-05-29 14:06:23 +00:00
import { IconButton } from 'components/shared'
import { RotateCcw, RotateCw, Trash2 } from 'react-feather'
2021-06-21 21:35:28 +00:00
import state from 'state'
2021-05-29 14:06:23 +00:00
import styled from 'styles'
2021-06-02 21:17:38 +00:00
import Tooltip from '../tooltip'
2021-05-29 14:06:23 +00:00
const undo = () => state.send('UNDO')
const redo = () => state.send('REDO')
const clear = () => state.send('CLEARED_PAGE')
2021-06-21 21:35:28 +00:00
export default function UndoRedo(): JSX.Element {
2021-05-29 14:06:23 +00:00
return (
<Container size={{ '@sm': 'small' }}>
2021-06-02 21:17:38 +00:00
<Tooltip label="Undo">
<IconButton onClick={undo}>
<RotateCcw />
</IconButton>
</Tooltip>
<Tooltip label="Redo">
<IconButton onClick={redo}>
<RotateCw />
</IconButton>
</Tooltip>
<Tooltip label="Clear Canvas">
<IconButton onClick={clear}>
<Trash2 />
</IconButton>
</Tooltip>
2021-05-29 14:06:23 +00:00
</Container>
)
}
const Container = styled('div', {
position: 'absolute',
bottom: 64,
2021-05-29 14:06:23 +00:00
right: 12,
backgroundColor: '$panel',
borderRadius: '4px',
overflow: 'hidden',
alignSelf: 'flex-end',
pointerEvents: 'all',
userSelect: 'none',
zIndex: 200,
2021-05-30 13:49:33 +00:00
border: '1px solid $panel',
boxShadow: '0px 2px 4px rgba(0,0,0,.12)',
2021-05-29 14:06:23 +00:00
display: 'flex',
padding: 4,
2021-06-02 16:11:42 +00:00
flexDirection: 'column',
2021-05-29 14:06:23 +00:00
'& svg': {
height: 13,
width: 13,
},
variants: {
size: {
small: {
bottom: 12,
2021-06-02 16:11:42 +00:00
flexDirection: 'row',
alignItems: 'center',
},
},
},
2021-05-29 14:06:23 +00:00
})