1.0.3 • Published 12 months ago

react-upload-media v1.0.3

Weekly downloads
-
License
ISC
Repository
github
Last release
12 months ago

⬆️ React Upload Media

React Upload Media is a library of React UI which provides component for uploading media.

This library contains two react component UploadMedia and UploadMediaModal

Installation

This module is installed via npm:

npm install react-upload-media

UploadMedia

UploadMedia component is a easy-to-use Ui component ehich allows user to upload file using drag 'n' drop zone which also works on click event.

import React, { useState } from 'react'
import { UploadMedia } from 'react-upload-media';

export const App = (props) => {

    const [files, setFiles] = useState([]);

    const submitHandler = (files) => {
        setFiles(files);
    }

    return (
        <div>
            <UploadMedia height={'300px'} onSubmit={submitHandler} />
            <div>
                <p>Files Uploaded</p>
                <ul>
                    {files.map((file) => <li key={file.path}>{file.name}</li>)}
                </ul>
            </div>
        </div>
    );
} 


export default App;

API

NameTypeRequiredDefaultDescription
primaryColorStringfalse#fffprimary color of the component
secondaryColorStringfalse#99FF33secondary color of the component
buttonColorStringfalse#0073e6button Color of the component
optionsObjectfalse-Options for file input
onSubmitFunctionfalse-Returs uploaded files

UploadMediaModal

UploadMediaModal component is provides user with the feature of uploding files through the modal. This component have two extra prop then the UploadMedia which aloows the component to open and close the modal.

import React, { useState } from 'react'
import { UploadMediaModal } from 'react-upload-media';

export const App = (props) => {

    const [open, setOpen] = useState(false);
    const [files, setFiles] = useState([]);

    const submitHandler = (files) => {
        setFiles(files);
    }

    const handleClose = () => {
        setOpen(false);
    }

    const handleOpen = () => {
        setOpen(true);
    }

    return (
        <div>
        <UploadMediaModal open={open} onClose={handleClose} onSubmit={submitHandler} />
        <button onClick={handleOpen}>Upload Media</button>
            <div>
                <p>Files Uploaded</p>
                <ul>
                    {files.map((file) => <li key={file.path}>{file.name}</li>)}
                </ul>
            </div>
        </div>
    );
} 

API

NameTypeRequiredDefaultDescription
openBooleantruefalseto open the modal
onCloseFunctiontrue-function to close the modal
primaryColorStringfalse#fffprimary color of the component
secondaryColorStringfalse#99FF33secondary color of the component
buttonColorStringfalse#0073e6button Color of the component
optionsObjectfalse-Options for file input
onSubmitFunctionfalse-Returs uploaded files

Author

Satyam Lohiya

1.0.3

12 months ago

1.0.2

1 year ago

0.0.1

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago