Skip to content

Commit d9860d8

Browse files
committed
* Refactoring of components and reducing screen space requirements for improved user experience
* Many tiny design changes to improve UX
1 parent 30d51f0 commit d9860d8

File tree

4 files changed

+154
-151
lines changed

4 files changed

+154
-151
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import React from 'react';
2+
import TextField from '@mui/material/TextField';
3+
import CopyPasteMenu from '../CopyPasteMenu';
4+
5+
const CompareField = ({
6+
copyLabel, pasteLabel, onPaste, compareLabel, value, onChange,
7+
}) => {
8+
/**
9+
* Paste data
10+
*/
11+
const paste = () => {
12+
if (onPaste) {
13+
onPaste();
14+
}
15+
};
16+
17+
/**
18+
* Change the value
19+
* @param e The event argument
20+
*/
21+
const changeValue = (e) => {
22+
if (onChange) {
23+
onChange(e.target.value);
24+
}
25+
};
26+
27+
return (
28+
<CopyPasteMenu
29+
id={1}
30+
copyData={() => navigator.clipboard.writeText(value)}
31+
copy={copyLabel}
32+
paste={pasteLabel}
33+
pasteData={paste}
34+
>
35+
<TextField
36+
fullWidth
37+
value={value}
38+
onChange={changeValue}
39+
label={compareLabel}
40+
/>
41+
</CopyPasteMenu>
42+
);
43+
};
44+
45+
export default CompareField;

src/components/HashList/index.jsx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import React from 'react';
2+
import Typography from '@mui/material/Typography';
3+
import Box from '@mui/material/Box';
4+
import GridList from '../GridList';
5+
import Hash from '../Hash';
6+
7+
const HashList = ({
8+
outputLabel, hashes, marginTop, copyLabel, compareHash,
9+
}) => (
10+
<Box style={{ marginTop }}>
11+
<Typography component="h2" variant="h5" color="primary" gutterBottom>
12+
{outputLabel}
13+
</Typography>
14+
<GridList md={12} lg={12} xs={12} spacing={2}>
15+
{hashes.map((e, i) => (
16+
<Hash
17+
id={i}
18+
key={e.hash}
19+
content={e.hash}
20+
hashType={e.type}
21+
copy={copyLabel}
22+
compareString={compareHash}
23+
/>
24+
))}
25+
</GridList>
26+
</Box>
27+
);
28+
29+
export default HashList;

src/routes/File/index.jsx

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,11 @@ import React, { useEffect, useRef, useContext } from 'react';
22
import Checkbox from '@mui/material/Checkbox';
33
import FormControlLabel from '@mui/material/FormControlLabel';
44
import Container from '@mui/material/Container';
5-
import Typography from '@mui/material/Typography';
65
import Button from '@mui/material/Button';
76
import TextField from '@mui/material/TextField';
87
import Card from '@mui/material/Card';
98
import CardContent from '@mui/material/CardContent';
109
import Grid from '@mui/material/Grid';
11-
import Box from '@mui/material/Box';
12-
import GridList from '../../components/GridList';
13-
import Hash from '../../components/Hash';
1410
import CopyPasteMenu from '../../components/CopyPasteMenu';
1511
import CsvExport from '../../components/CsvExport';
1612
import { setActiveListItem } from '../../reducers/MainReducer/Actions';
@@ -24,6 +20,7 @@ import {
2420
import LoadingBar from '../../components/LoadingBar';
2521
import AlertDialog from '../../components/AlertDialog';
2622
import PageHeader from '../../components/PageHeader';
23+
import HashList from '../../components/HashList';
2724

2825
const { ipcRenderer } = window.require('electron');
2926

@@ -54,23 +51,13 @@ const File = () => {
5451

5552
const output = hashes && hashes.length > 0
5653
? (
57-
<Box style={{ marginTop: 10 }}>
58-
<Typography component="h2" variant="h5" color="primary" gutterBottom>
59-
{language.output}
60-
</Typography>
61-
<GridList md={12} lg={12} xs={12} spacing={2}>
62-
{hashes.map((e, i) => (
63-
<Hash
64-
id={i}
65-
key={e.hash}
66-
content={e.hash}
67-
hashType={e.type}
68-
copy={language.copy}
69-
compareString={compare ? compareHash : null}
70-
/>
71-
))}
72-
</GridList>
73-
</Box>
54+
<HashList
55+
marginTop={10}
56+
compareHash={compare ? compareHash : null}
57+
hashes={hashes}
58+
copyLabel={language.copy}
59+
outputLabel={language.output}
60+
/>
7461
)
7562
: null;
7663

@@ -212,7 +199,6 @@ const File = () => {
212199
checked={compare}
213200
onChange={(e) => d2(setFileHashComparing(e.target.checked))}
214201
value="compare"
215-
color="primary"
216202
/>
217203
)}
218204
label={language.compare}
@@ -226,7 +212,7 @@ const File = () => {
226212
<>
227213
<Button
228214
variant="contained"
229-
onClick={() => clearData()}
215+
onClick={clearData}
230216
style={{ marginTop: 10 }}
231217
>
232218
{language.clear}

0 commit comments

Comments
 (0)