-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
/
Copy pathImageInput.tsx
46 lines (41 loc) · 1.33 KB
/
ImageInput.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
import * as React from 'react';
import { styled } from '@mui/material/styles';
import { FileInput, FileInputProps, FileInputClasses } from './FileInput';
export const ImageInput = (props: ImageInputProps) => (
<StyledFileInput
labelMultiple="ra.input.image.upload_several"
labelSingle="ra.input.image.upload_single"
{...props}
/>
);
export type ImageInputProps = FileInputProps;
const PREFIX = 'RaImageInput';
const StyledFileInput = styled(FileInput, {
name: PREFIX,
overridesResolver: (props, styles) => styles.root,
})(({ theme }) => ({
width: '100%',
[`& .${FileInputClasses.dropZone}`]: {
background: theme.palette.background.default,
borderRadius: theme.shape.borderRadius,
fontFamily: theme.typography.fontFamily,
cursor: 'pointer',
padding: theme.spacing(1),
textAlign: 'center',
color: theme.palette.getContrastText(theme.palette.background.default),
},
[`& .${FileInputClasses.removeButton}`]: {
display: 'inline-block',
position: 'relative',
'& button': {
position: 'absolute',
top: theme.spacing(1),
right: theme.spacing(1),
minWidth: theme.spacing(2),
opacity: 0,
},
'&:hover button': {
opacity: 1,
},
},
}));