New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-videos-uploading

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-videos-uploading

The simple videos uploader applied Render Props pattern. This approach allows you to fully control UI component and behaviours.

  • 1.0.1
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

react-videos-uploading

The simple videos uploader applied Render Props pattern. (You can read more about this pattern here).

This approach allows you to fully control UI component and behaviours.

This is a modified version of react-images-uploading for videos uploading.

tested with jest Github_Actions NPM NPM License: MIT PRs Welcome Package Quality code style: prettier

All Contributors

Package Quality

Installation

npm

npm install --save react-videos-uploading

yarn

yarn add react-videos-uploading

Basic

import React from 'react';
import VideoUploading from 'react-videos-uploading';

export function App() {
  const [videos, setVideos] = React.useState<File[]>([]);

  const onChange = (videoList: File[]) => {
    setVideos(videoList);
  };

  return (
    <div id="app">
      <VideoUploading value={videos} onChange={onChange} {...props}>
        {({
          videoList,
          errors,
          isDragging,
          onVideoUpload,
          onVideoRemoveAll,
          onVideoUpdate,
          onVideoRemove,
          dragProps,
        }) => {
          return (
            <div className="upload__video-wrapper">
              {errors && errors.maxNumber && (
                <span>Number of selected videos exceed maxNumber</span>
              )}

              <button
                id="btn-upload"
                type="button"
                style={isDragging ? { color: 'red' } : undefined}
                onClick={onVideoUpload}
                {...dragProps}
              >
                Click or Drop here
              </button>

              <button id="btn-remove" type="button" onClick={onVideoRemoveAll}>
                Remove all videos
              </button>

              <div id="list-videos">
                {videoList.map((video, index) => (
                  <div key={`video-${index}`} className="video-item">
                    <p data-testid={`video-${index}`} id={`video-${index}`}>
                      {video.name}
                    </p>
                    <div className="video-item__btn-wrapper">
                      <button
                        id={`update_${index}`}
                        type="button"
                        onClick={() => onVideoUpdate(index)}
                      >
                        {`Update ${index}`}
                      </button>
                      <button
                        id={`remove_${index}`}
                        type="button"
                        onClick={() => onVideoRemove(index)}
                      >
                        {`Remove ${index}`}
                      </button>
                    </div>
                  </div>
                ))}
              </div>
            </div>
          );
        }}
      </VideoUploading>
    </div>
  );
}

Validation

...
  {({ videoList, onVideoUpload, onVideoRemoveAll, errors }) => (
    errors && <div>
      {errors.maxNumber && <span>Number of selected videos exceed maxNumber</span>}
      {errors.acceptType && <span>Your selected file type is not allow</span>}
      {errors.maxFileSize && <span>Selected file size exceed maxFileSize</span>}
    </div>
  )}
...

Drag and Drop

...
  {({ videoList, dragProps, isDragging }) => (
    <div {...dragProps}>
      {isDragging ? "Drop here please" : "Upload space"}
      {videoList.map((file, index) => (
        <p>{file.name}</p>
      ))}
    </div>
  )}
...

Props

parametertypeoptionsdefaultdescription
valuearray[]List of videos
onChangefunction(videoList, addUpdateIndex) => voidCalled when add, update or delete action is called
multiplebooleanfalseSet true for multiple chooses
maxNumbernumber1000Number of videos user can select if mode = multiple
onErrorfunction(errors, files) => voidCalled when it has errors
acceptTypearray['mp4', 'webm', 'vob'][]The file extension(s) to upload
maxFileSizenumberMax video size (Byte) and it is used in validation
inputPropsReact.HTMLProps<HTMLInputElement>

Exported options

parametertypedescription
videoListarrayList of videos to render.
onVideoUploadfunctionCalled when an element is clicks and triggers to open a file dialog
onVideoRemoveAllfunctionCalled when removing all videos
onVideoUpdate(updateIndex: number) => voidCalled when updating an video at updateIndex.
onVideoRemove(deleteIndex: number | number[]) => voidCalled when removing one or list video.
errorsobjectExported object of validation
dragPropsobjectNative element props for drag and drop feature
isDraggingboolean"true" if an video is being dragged

Contributors ✨

Thanks goes to these wonderful people (emoji key):


vutoan266

💻 🤔 📖 🚧 ⚠️ 👀

David Nguyen

💻 🤔 📖 👀

DK

💻 🚇 🤔 👀 📖

Isaac Maseruka

💻

Vu Nguyen

💻

This project follows the all-contributors specification. Contributions of any kind welcome!

Keywords

FAQs

Package last updated on 24 Jun 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc