mirror of
https://github.com/iib0011/omni-tools.git
synced 2025-12-29 16:16:02 +00:00
feat: change colors in png init
This commit is contained in:
59
src/components/result/ToolFileResult.tsx
Normal file
59
src/components/result/ToolFileResult.tsx
Normal file
@@ -0,0 +1,59 @@
|
||||
import { Box } from '@mui/material';
|
||||
import React from 'react';
|
||||
import InputHeader from '../InputHeader';
|
||||
import greyPattern from '@assets/grey-pattern.png';
|
||||
|
||||
export default function ToolFileResult({
|
||||
title = 'Result',
|
||||
value
|
||||
}: {
|
||||
title?: string;
|
||||
value: File | null;
|
||||
}) {
|
||||
const [preview, setPreview] = React.useState<string | null>(null);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (value) {
|
||||
const objectUrl = URL.createObjectURL(value);
|
||||
setPreview(objectUrl);
|
||||
|
||||
return () => URL.revokeObjectURL(objectUrl);
|
||||
} else {
|
||||
setPreview(null);
|
||||
}
|
||||
}, [value]);
|
||||
|
||||
return (
|
||||
<Box>
|
||||
<InputHeader title={title} />
|
||||
<Box
|
||||
sx={{
|
||||
width: '100%',
|
||||
height: 250,
|
||||
border: preview ? 0 : 1,
|
||||
borderRadius: 2,
|
||||
boxShadow: '5'
|
||||
}}
|
||||
>
|
||||
{preview && (
|
||||
<Box
|
||||
width={'100%'}
|
||||
height={'100%'}
|
||||
sx={{
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
backgroundImage: `url(${greyPattern})`
|
||||
}}
|
||||
>
|
||||
<img
|
||||
src={preview}
|
||||
alt="Result"
|
||||
style={{ maxWidth: '100%', maxHeight: 250 }}
|
||||
/>
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import DownloadIcon from '@mui/icons-material/Download';
|
||||
import ContentPasteIcon from '@mui/icons-material/ContentPaste';
|
||||
import React, { useContext } from 'react';
|
||||
import { CustomSnackBarContext } from '../../contexts/CustomSnackBarContext';
|
||||
import InputHeader from '../InputHeader';
|
||||
|
||||
export default function ToolTextResult({
|
||||
title = 'Result',
|
||||
@@ -37,9 +38,7 @@ export default function ToolTextResult({
|
||||
};
|
||||
return (
|
||||
<Box>
|
||||
<Typography fontSize={30} color={'primary'}>
|
||||
{title}
|
||||
</Typography>
|
||||
<InputHeader title={title} />
|
||||
<TextField value={value} fullWidth multiline rows={10} />
|
||||
<Stack mt={1} direction={'row'} spacing={2}>
|
||||
<Button onClick={handleDownload} startIcon={<DownloadIcon />}>
|
||||
|
||||
Reference in New Issue
Block a user