Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development #16

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"presets": ["env", "react", "stage-1"]
"presets": ["@babel/preset-env", ["@babel/preset-react", {"runtime": "automatic"}]]
}
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,10 @@ typings/
.env

# demo
demo/
demo/
/package-lock.json
/.idea/.gitignore
/.idea/modules.xml
/.idea/vcs.xml
/.idea/react-image-picker.iml
/.idea/workspace.xml
7 changes: 7 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
src
.babelrc
webpack.*
.idea
demo
test
node_modules
74 changes: 51 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,31 @@
[![npm](https://img.shields.io/npm/l/react-image-picker.svg)](http://opensource.org/licenses/MIT)

# React Image Picker
The image picker is used for selecting single or multiple images from gallery.
The image picker is used for selecting single or multiple images from the list.

[Live Demo](https://bagongkia.github.io/react-image-picker/)
[Live Demo](https://vashkevichsj16.github.io/node-image-picker-demo/)

## Features
- jQuery Free
- Single or multiple images selection
- Styling (...in progress)
- Size selection
- PreSelected images
- ...

## Installation
```
npm install react-image-picker
npm install simple-react-image-picker - will install source, not current proyect
```

### Examples
![React Image Picker Demo](https://raw.githubusercontent.com/bagongkia/react-image-picker/master/docs/img/react-image-picker-demo.jpg)
![How its looks](https://raw.githubusercontent.com/bagongkia/react-image-picker/master/docs/img/react-image-picker-demo.jpg)


#### Component style
```javascript
//ES6
import React, { Component } from 'react'
import ImagePicker from 'react-image-picker'
import 'react-image-picker/dist/index.css'
import ImagePicker from 'simple-react-image-picker'

//import images from local
import img1 from './images/kitten/200.jpg'
Expand All @@ -36,35 +38,61 @@ import img4 from './images/kitten/203.jpg'

const imageList = [img1, img2, img3, img4]

class App extends Component {
constructor(props) {
super(props)
this.state = {
image: null
}
this.onPick = this.onPick.bind(this)
}

onPick(image) {
this.setState({image})
}
const App = () => {
const [image, setImage] = useState();
const [images, setImages] = useState([]);
const [imagesPreselect, setImagesPreselect] = useState([]);
const [imagesSize, setImagesSize] = useState([]);

render() {
const onPickImage = (newImage) => {
setImage(newImage);
}
const onPickImages = (newImages) => {
setImages(newImages);
}
const onPickImagesPreselect = (newImages) => {
setImagesPreselect(newImages);
}
const onPickImagesChangedSize = (newImages) => {
setImagesSize(newImages);
}
return (
<div>
<ImagePicker
images={imageList.map((image, i) => ({src: image, value: i}))}
onPick={this.onPick}
images={
imageList.map(
(image, i) => (
{
src: image,
value: i,
isSelected: i % 2 === 0,
size: {height: 200, width: 200}
})
)
}
pickHandler={onPickImage}
/>
<button type="button" onClick={() => console.log(this.state.image)}>OK</button>
</div>
)
}
}

export default App
```

### How to build lib
building
```
npm run build-lib
```
publishing
```
npm publish
```

##
Current project is fork of [source](https://github.com/bagongkia/react-image-picker)

## License

React-Image-Picker is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)
16 changes: 2 additions & 14 deletions dist/app.js

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions dist/app.js.LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
object-assign
(c) Sindre Sorhus
@license MIT
*/

/** @license React v17.0.1
* react-jsx-runtime.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
File renamed without changes
41 changes: 0 additions & 41 deletions dist/index.css

This file was deleted.

Loading