refactor(frontend): migrate MultiImageDropzone to MUI sx
This commit is contained in:
parent
4aac9dae4e
commit
494c09e062
|
|
@ -1,53 +1,7 @@
|
||||||
import React, { useCallback } from 'react';
|
import React from 'react';
|
||||||
import { makeStyles } from '@mui/styles';
|
import { Box, Typography } from '@mui/material';
|
||||||
|
|
||||||
const useStyles = makeStyles({
|
|
||||||
dropzone: {
|
|
||||||
border: '2px dashed #cccccc',
|
|
||||||
borderRadius: '8px',
|
|
||||||
padding: '40px 20px',
|
|
||||||
textAlign: 'center',
|
|
||||||
cursor: 'pointer',
|
|
||||||
transition: 'all 0.3s ease',
|
|
||||||
backgroundColor: '#fafafa',
|
|
||||||
minHeight: '200px',
|
|
||||||
display: 'flex',
|
|
||||||
flexDirection: 'column',
|
|
||||||
justifyContent: 'center',
|
|
||||||
alignItems: 'center',
|
|
||||||
'&:hover': {
|
|
||||||
borderColor: '#999999',
|
|
||||||
backgroundColor: '#f0f0f0'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
dropzoneActive: {
|
|
||||||
borderColor: '#4CAF50',
|
|
||||||
backgroundColor: '#e8f5e8'
|
|
||||||
},
|
|
||||||
dropzoneText: {
|
|
||||||
fontSize: '18px',
|
|
||||||
fontFamily: 'roboto',
|
|
||||||
color: '#666666',
|
|
||||||
margin: '10px 0'
|
|
||||||
},
|
|
||||||
dropzoneSubtext: {
|
|
||||||
fontSize: '14px',
|
|
||||||
color: '#999999',
|
|
||||||
fontFamily: 'roboto'
|
|
||||||
},
|
|
||||||
fileCount: {
|
|
||||||
fontSize: '16px',
|
|
||||||
color: '#4CAF50',
|
|
||||||
fontWeight: 'bold',
|
|
||||||
marginTop: '10px'
|
|
||||||
},
|
|
||||||
hiddenInput: {
|
|
||||||
display: 'none'
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
function MultiImageDropzone({ onImagesSelected, selectedImages = [] }) {
|
function MultiImageDropzone({ onImagesSelected, selectedImages = [] }) {
|
||||||
const classes = useStyles();
|
|
||||||
|
|
||||||
const handleFiles = (files) => {
|
const handleFiles = (files) => {
|
||||||
// Filter nur Bilddateien
|
// Filter nur Bilddateien
|
||||||
|
|
@ -102,30 +56,69 @@ function MultiImageDropzone({ onImagesSelected, selectedImages = [] }) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const dropzoneSx = {
|
||||||
|
border: '2px dashed #cccccc',
|
||||||
|
borderRadius: '8px',
|
||||||
|
padding: '40px 20px',
|
||||||
|
textAlign: 'center',
|
||||||
|
cursor: 'pointer',
|
||||||
|
transition: 'all 0.3s ease',
|
||||||
|
backgroundColor: '#fafafa',
|
||||||
|
minHeight: '200px',
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
justifyContent: 'center',
|
||||||
|
alignItems: 'center',
|
||||||
|
'&:hover': {
|
||||||
|
borderColor: '#999999',
|
||||||
|
backgroundColor: '#f0f0f0'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const dropzoneTextSx = {
|
||||||
|
fontSize: '18px',
|
||||||
|
fontFamily: 'roboto',
|
||||||
|
color: '#666666',
|
||||||
|
margin: '10px 0'
|
||||||
|
};
|
||||||
|
|
||||||
|
const dropzoneSubtextSx = {
|
||||||
|
fontSize: '14px',
|
||||||
|
color: '#999999',
|
||||||
|
fontFamily: 'roboto'
|
||||||
|
};
|
||||||
|
|
||||||
|
const fileCountSx = {
|
||||||
|
fontSize: '16px',
|
||||||
|
color: '#4CAF50',
|
||||||
|
fontWeight: 'bold',
|
||||||
|
marginTop: '10px'
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<Box>
|
||||||
<div
|
<Box
|
||||||
className={classes.dropzone}
|
sx={dropzoneSx}
|
||||||
onDragOver={handleDragOver}
|
onDragOver={handleDragOver}
|
||||||
onDragEnter={handleDragEnter}
|
onDragEnter={handleDragEnter}
|
||||||
onDragLeave={handleDragLeave}
|
onDragLeave={handleDragLeave}
|
||||||
onDrop={handleDrop}
|
onDrop={handleDrop}
|
||||||
onClick={handleClick}
|
onClick={handleClick}
|
||||||
>
|
>
|
||||||
<div className={classes.dropzoneText}>
|
<Typography sx={dropzoneTextSx}>
|
||||||
📸 Mehrere Bilder hier hinziehen oder klicken zum Auswählen
|
📸 Mehrere Bilder hier hinziehen oder klicken zum Auswählen
|
||||||
</div>
|
</Typography>
|
||||||
|
|
||||||
<div className={classes.dropzoneSubtext}>
|
<Typography sx={dropzoneSubtextSx}>
|
||||||
Unterstützte Formate: JPG, PNG, GIF, WebP (max. 10MB pro Datei)
|
Unterstützte Formate: JPG, PNG, GIF, WebP (max. 10MB pro Datei)
|
||||||
</div>
|
</Typography>
|
||||||
|
|
||||||
{selectedImages.length > 0 && (
|
{selectedImages.length > 0 && (
|
||||||
<div className={classes.fileCount}>
|
<Typography sx={fileCountSx}>
|
||||||
✅ {selectedImages.length} Bild{selectedImages.length !== 1 ? 'er' : ''} ausgewählt
|
✅ {selectedImages.length} Bild{selectedImages.length !== 1 ? 'er' : ''} ausgewählt
|
||||||
</div>
|
</Typography>
|
||||||
)}
|
)}
|
||||||
</div>
|
</Box>
|
||||||
|
|
||||||
<input
|
<input
|
||||||
id="multi-file-input"
|
id="multi-file-input"
|
||||||
|
|
@ -133,9 +126,9 @@ function MultiImageDropzone({ onImagesSelected, selectedImages = [] }) {
|
||||||
multiple
|
multiple
|
||||||
accept="image/*"
|
accept="image/*"
|
||||||
onChange={handleFileInputChange}
|
onChange={handleFileInputChange}
|
||||||
className={classes.hiddenInput}
|
style={{ display: 'none' }}
|
||||||
/>
|
/>
|
||||||
</div>
|
</Box>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user