Skip to content

Commit

Permalink
📝 added example of how to use the 'getPreviewIcon' prop
Browse files Browse the repository at this point in the history
  • Loading branch information
max-carroll committed May 4, 2020
1 parent f98cb58 commit 561572c
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/components/DropzoneArea.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,41 @@ import { DropzoneArea } from 'material-ui-dropzone';
onChange={(files) => console.log('Files:', files)}
/>
```

### Custom Preview Icon

Demonstration of how to customize the preview icon for:
* PDF files
* Video
* Audio
* Word Documents


```jsx
import react from 'react'
import { AttachFile, AudioTrack, Description, PictureAsPdf, Theaters } from '@material-ui/icons';

const handlePreviewIcon=(fileObject, classes) => {
const {type} = fileObject.file
const iconProps = { className : classes.smallPreviewImg}

if (type.startsWith("video/")) return <Theaters {...iconProps} />
if (type.startsWith("audio/")) return <AudioTrack {...iconProps} />

let component
switch (type) {
case "application/msword":
case "application/vnd.openxmlformats-officedocument.wordprocessingml.document":
return <Description {...iconProps} />
case "application/pdf":
return <PictureAsPdf {...iconProps} />
default:
return <AttachFile {...iconProps} />
}

}

<DropzoneArea
getPreviewIcon={handlePreviewIcon}
/>
```

0 comments on commit 561572c

Please sign in to comment.