Coder Social home page Coder Social logo

richard1320 / react-media-library Goto Github PK

View Code? Open in Web Editor NEW
48.0 3.0 22.0 3.47 MB

React Media Library is a UI package similar to the WordPress' media library, but for React. It features file drag-and-drop as well as a library to select previously uploaded files.

Home Page: https://richard1320.github.io/React-Media-Library/

TypeScript 72.23% MDX 3.72% JavaScript 8.46% SCSS 15.59%
react reactjs drag-and-drop file-manager filemanager-ui filemanager react-dom

react-media-library's Introduction

React Media Library

Have you ever worked with WordPress? If not, count your blessings. :)

But seriously, using a CMS like WordPress does provide a lot of useful features. The feature I miss most as a MERN developer is the media library browser. All image fields are edited using a modal where you can select something previously uploaded or drag-and-drop new images from your file browser. Well, now you can have something similar for your React app.

Note: this only includes the UI; everybody's app is different, so I can't write your API connections for you.

Installation

Install it via npm in your project.

npm install react-media-library --save

Documentation / Examples

See Storybook.

react-media-library's People

Contributors

dependabot[bot] avatar ramonmalcolm10 avatar richard1320 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

react-media-library's Issues

Manually sorting order of multiple images

I like to request a feature if possible

The only feature this package is missing is something like the wordpress or wix media library, after selecting multiple images you are able to drag and drop the images in an order of choice.

wix-gallery
wp-gallery

Custom Card Example

I didn't find an example of the custom card to precisely follow. If you could put a working example, that would be really great.
Thank you for your time to create this package.

Enable Unselection of Selected Files

Users are unable to unselect a file if it's the only one selected, once the sole selected file is unselected, the "Select file" button disappears. A possible solution is to track whether any file was selected before the media library open and base on that flag and if all selection was removed then display a "Remove file" button that trigger the filesSelectCallback function with an empty array.

Support for defaultProps will be removed from function components in a future major release.

ReactMediaLibrary.tsx component use defaultProps which is deprecated, can I make the change to use default parameters instead?

Warning: er: Support for defaultProps will be removed from function components in a future major release. Use JavaScript default parameters instead.
    at er (webpack-internal:///(ssr)/./node_modules/react-media-library/dist/esm/index.js:2154:60)

No way to clear selection i.e selected files

Media library selection is not cleared even if 'defaultSelectedItemIds' is set to an empty array.

I suggest adding an else block with setSelectedItems([]); in ReactMediaLibrary.tsx line no 17.
So, the updated useEffect hook will be

useEffect(() => {
		// Asset loads are sometimes async.
		// Need to check the default and reselect if either the file library list or default select list is updated.
		if (props.defaultSelectedItemIds?.length) {
			const filterDefaultSelected = props.fileLibraryList.filter((item) => props.defaultSelectedItemIds?.includes(item._id));
			setSelectedItems(filterDefaultSelected);
		} else {
			setSelectedItems([]);
		}
	}, [props.fileLibraryList, props.defaultSelectedItemIds]);

Please update it so selected items in ReactMediaLibrary can be cleared.

P.S. Nice component

Thanks

Buttons Cause Form Submissions

The buttons in the library components inadvertently trigger form submissions due to the absence of the "type" attribute set to "button", when integrated into forms.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.