blob: 62f82f299ab5720303de20e768ffa668765d2ba6 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
import { observer } from 'mobx-react-lite';
import React from 'react';
import { makeStyles } from '@material-ui/core/styles';
import Button from '@material-ui/core/Button';
import ButtonGroup from '@material-ui/core/ButtonGroup';
import Divider from '@material-ui/core/Divider';
import FormatListNumberedIcon from '@material-ui/icons/FormatListNumbered';
import RedoIcon from '@material-ui/icons/Redo';
import UndoIcon from '@material-ui/icons/Undo';
import ToggleButton from '@material-ui/lab/ToggleButton';
import { useRootStore } from '../RootStore';
const useStyles = makeStyles(theme => ({
iconButton: {
padding: 8,
minWidth: 36,
'&.MuiButtonGroup-groupedTextHorizontal': {
borderRight: 0,
},
},
flatToggleButton: {
padding: 8,
border: 0,
color: theme.palette.text.primary,
},
divider: {
margin: theme.spacing(0.5),
}
}));
export default observer(() => {
const editorStore = useRootStore().editorStore;
const classes = useStyles();
return (
<>
<ButtonGroup
variant='text'
>
<Button
disabled={!editorStore.canUndo}
onClick={() => editorStore.undo()}
className={classes.iconButton}
>
<UndoIcon fontSize='small'/>
</Button>
<Button
disabled={!editorStore.canRedo}
onClick={() => editorStore.redo()}
className={classes.iconButton}
>
<RedoIcon fontSize='small'/>
</Button>
</ButtonGroup>
<Divider
flexItem
orientation='vertical'
className={classes.divider}
/>
<ToggleButton
value='Show line numbers'
selected={editorStore.showLineNumbers}
onChange={() => editorStore.toggleLineNumbers()}
size='small'
className={classes.flatToggleButton}
>
<FormatListNumberedIcon fontSize='small'/>
</ToggleButton>
</>
);
});
|