GitHub - vinayakkulkarni/v-image: ๐ท Tiny little component for input type=file (css free! style it as you want!) (original) (raw)
v-image ๐ท
โ ๏ธ Docs are for Vue 3, for Vue 2 docs, check this tree
Demo
Features
- ๐ช Built with TypeScript
- ๐ Built with Vue 3
- โก Zero dependencies.
Table of Contents
Installation
Build Setup
install dependencies
$ npm install
package lib
$ npm run build
Usage
Global component:
// main.ts import { VImage } from 'v-image'; import { createApp } from 'vue';
const app = createApp({}); app.component('VImage', VImage);
Or use locally
// component.vue
For Nuxt 3, create a file in plugins/v-image.ts
import { VImage } from 'v-image';
export default defineNuxtPlugin((nuxtApp) => { nuxtApp.vueApp.component('VImage', VImage); });
then import the file in nuxt.config.{j|t}s:
export default { // ... plugins: [ // ... { src: '~/plugins/v-image', mode: 'client' }, // ... ], // ... };
Example
API
Props
| Name | Type | Required? | Default | Description |
|---|---|---|---|---|
| wrapper | String | No | '' | The wrapper classes for the top level |
| placeholder | Object | No | - | The placeholder image & input related code |
| placeholder.wrapper | String | No | '' | Any wrapper classes for the placeholder |
| placeholder.image | String | No | 'https://picsum.photos/200x200' | The placeholder image |
| placeholder.alt | String | No | 'Placeholder Image' | The placeholder image alt attribute |
| placeholder.imgClass | String | No | '' | Any placeholder image classes |
| placeholder.btnClass | String | No | '' | Select Image button classes |
| form | Object | No | - | The placeholder input form |
| form.name | String | No | 'v-image' | Enable the label to interact with the |
| form.label | String | No | 'Select Image' | The label/button text |
| form.accept | String | No | 'image/*' | Abilty to accept file types |
| uploaded | Object | No | - | The user uploaded image related Object |
| uploaded.wrapper | String | No | '' | Any wrapper classes for the uploaded image |
| uploaded.alt | String | No | 'Very Interesting Image' | The actual uploaded image alt attribute |
| uploaded.imgClass | String | No | '' | Uploaded image classes |
| uploaded.btnClass | String | No | '' | Remove Image button classes |
| uploaded.removeBtnText | String | No | 'Remove Image' | Remove Image button text |
Events
| Name | Returns | Description |
|---|---|---|
| @image-loaded | String | Sends the image in base64 format |
| @image-removed | Boolean | Emits true if image is removed |
Contributing
- Fork it (https://github.com/vinayakkulkarni/v-image/fork)
- Create your feature branch (
git checkout -b feat/new-feature) - Commit your changes (
git commit -Sam 'feat: add feature') - Push to the branch (
git push origin feat/new-feature) - Create a new Pull Request
Note:
- Please contribute using GitHub Flow
- Commits & PRs will be allowed only if the commit messages & PR titles follow the conventional commit standard, read more about it here
- PS. Ensure your commits are signed. Read why
Author
v-image ยฉ Vinayak, Released under the MIT License.
Authored and maintained by Vinayak Kulkarni with help from contributors (list).
vinayakkulkarni.dev ยท GitHub @vinayakkulkarni ยท Twitter @_vinayak_k