-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
/
ArrowButton.tsx
55 lines (54 loc) · 1.54 KB
/
ArrowButton.tsx
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
import * as React from 'react';
import IconButton, { IconButtonProps } from '@mui/material/IconButton';
import KeyboardArrowLeftRounded from '@mui/icons-material/KeyboardArrowLeftRounded';
import KeyboardArrowRightRounded from '@mui/icons-material/KeyboardArrowRightRounded';
export default function ArrowButton({
direction,
...props
}: { direction: 'left' | 'right' } & IconButtonProps) {
const label = {
left: 'Previous',
right: 'Next',
};
return (
<IconButton
size="small"
aria-label={label[direction]}
{...props}
sx={[
{
border: '1px solid',
color: 'primary.main',
borderColor: 'grey.200',
'&:hover': {
borderColor: 'grey.300',
},
'&.Mui-disabled': {
opacity: 0.5,
color: 'grey.700',
borderColor: 'grey.300',
},
'& + .MuiIconButton-root': {
ml: 2,
},
},
(theme) =>
theme.applyDarkStyles({
color: '#fff',
borderColor: 'primaryDark.300',
'&:hover': {
borderColor: 'primaryDark.200',
},
'&.Mui-disabled': {
color: '#fff',
borderColor: 'primary.700',
},
}),
...(Array.isArray(props.sx) ? props.sx : [props.sx]),
]}
>
{direction === 'left' && <KeyboardArrowLeftRounded fontSize="small" />}
{direction === 'right' && <KeyboardArrowRightRounded fontSize="small" />}
</IconButton>
);
}