-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: extensible file upload input
- Loading branch information
Showing
2 changed files
with
81 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
packages/console/src/components/common/DraggableFileUpload/FileItem.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { makeStyles, Theme } from '@material-ui/core'; | ||
import { Clear, Done } from '@material-ui/icons'; | ||
import React from 'react'; | ||
|
||
const useStyles = makeStyles((theme: Theme) => ({ | ||
container: { | ||
background: theme.palette.grey[100], | ||
display: 'flex', | ||
flexDirection: 'row', | ||
justifyContent: 'space-between', | ||
gap: '8px', | ||
alignItems: 'center', | ||
width: '100%', | ||
padding: theme.spacing(1, 0.5), | ||
fontSize: 12, | ||
}, | ||
icon: { | ||
color: theme.palette.success.main, | ||
}, | ||
fileName: { | ||
flex: 1, | ||
textAlign: 'left', | ||
}, | ||
})); | ||
|
||
interface Props { | ||
file: File; | ||
remove: () => void; | ||
} | ||
|
||
function FileItem({ file, remove }: Props) { | ||
const styles = useStyles(); | ||
|
||
return ( | ||
<div className={styles.container}> | ||
<Done className={styles.icon} /> | ||
<div className={styles.fileName}>{file.name}</div> | ||
<Clear | ||
onClick={e => { | ||
e.preventDefault(); | ||
e.stopPropagation(); | ||
|
||
remove(); | ||
}} | ||
/> | ||
</div> | ||
); | ||
} | ||
|
||
export default FileItem; |