Skip to content

Commit 963d6f4

Browse files
committed
version 1.0.0
1 parent e1398ab commit 963d6f4

12 files changed

+6853
-2
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

README.md

+68-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,68 @@
1-
# vue-image-browser
2-
A VueJS Image Browser Component with options to upload, browse, delete and select images
1+
# An Image Browser Component Built with VueJs
2+
3+
![](images/example-image-1.png)
4+
5+
6+
## Usage
7+
8+
```
9+
npm install @akashmitra/vue-image-browser
10+
```
11+
To use this inside another Vue component, you must `import` this as a component.
12+
13+
```
14+
<template>
15+
<VueImageBrowser
16+
source="api/images"
17+
selectable
18+
deletable
19+
@selected="onSelect"></VueImageBrowser>
20+
21+
</template>
22+
<script>
23+
import VueImageBrowser from '@akashmitra/vue-image-browser'
24+
25+
export default {
26+
components: {
27+
VueImageBrowser,
28+
},
29+
methods: {
30+
onSelect() {
31+
32+
}
33+
}
34+
}
35+
</script>
36+
37+
```
38+
39+
## Image Object
40+
41+
The browser assumes that the `source` URL returns an array of `image` objects of following format.
42+
43+
```
44+
{
45+
data: [
46+
{
47+
id: 1,
48+
name: 'image-name.jpg',
49+
type: 'jpeg',
50+
size: 10,
51+
url: 'www.example.com/image-name.jpg',
52+
storage: 'public',
53+
user_id: 1,
54+
created_ago: '2 days ago'
55+
},
56+
{...},
57+
{...}
58+
]
59+
}
60+
61+
62+
```
63+
64+
## Options
65+
`source` - Specify the URL that returns an array of the `image` objects
66+
`selectable` - If this is true, you can select an image from the browser and a `selected` event will be generated and the corresponding `image` object will be passed to the event handler.
67+
`deletable` - If this is true, the browser will show a Delete button. Clicking the Delete button will generate a `deleted` event and the corresponding `image` object will be passed to the event handler.
68+
`lazyload` - When this is true, only the images that are within the viewport will be actually downloaded. By default it is true.

build/rollup.config.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import commonjs from '@rollup/plugin-commonjs'; // Convert CommonJS modules to ES6
2+
import vue from 'rollup-plugin-vue'; // Handle .vue SFC files
3+
import buble from '@rollup/plugin-buble'; // Transpile/polyfill with reasonable browser support
4+
5+
export default {
6+
input: 'src/wrapper.js', // Path relative to package.json
7+
output: {
8+
name: 'VueImageBrowser',
9+
exports: 'named',
10+
},
11+
external: [],
12+
plugins: [
13+
commonjs(),
14+
vue({
15+
css: true, // Dynamically inject css as a <style> tag
16+
compileTemplate: true, // Explicitly convert template to render function
17+
}),
18+
buble(), // Transpile to ES5
19+
],
20+
};

0 commit comments

Comments
 (0)