-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit cdfcb72
Showing
19 changed files
with
9,197 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"presets": [ | ||
["env", { | ||
"targets": { | ||
"browsers": ["last 2 versions", "safari >= 7"] | ||
}, | ||
"modules": "umd" | ||
}] | ||
], | ||
"plugins": [ | ||
"transform-object-rest-spread", | ||
["transform-runtime", { | ||
"polyfill": false, | ||
"regenerator": true | ||
}] | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/dist | ||
node_modules | ||
npm-debug.log | ||
yarn.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) Matthew Dixon | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# Vue Media Library | ||
A vue component for the `mdixon18/media-library` package. | ||
|
||
Laravel package can be found [here](https://github.com/mdixon18/media-library). | ||
|
||
## Screenshots | ||
**Manager** | ||
|
||
 | ||
|
||
**Field** | ||
|
||
 | ||
 | ||
|
||
## Installation | ||
``` | ||
npm install --save vue-medialibrary | ||
``` | ||
|
||
### Usage | ||
#### Vue | ||
``` | ||
import MediaLibrary from 'vue-medialibrary'; | ||
Vue.use(MediaLibrary, { | ||
API_URL: 'http://urltoapp.tld' | ||
}); | ||
``` | ||
The API_URL is helpful if the application you are using the component in isn't the same application that the Laravel package is installed on. E.g. an SPA. | ||
|
||
#### HTML Template | ||
|
||
**Manager** | ||
``` | ||
<vue-medialibrary-manager v-if="show" /> | ||
``` | ||
|
||
**Field** | ||
``` | ||
<vue-medialibrary-field v-model="file" /> | ||
``` | ||
|
||
## Manager API | ||
### Events | ||
- `@close` - this is used when the user has selected the close button in the manager, this should toggle off your original `v-if`. Naturally without a `v-if` this component will display at all times. | ||
- `@select` - this is primarily used within the field component so shouldn't be required, but it is triggered when the insert button has been selected on a media item. Only works if the `selectable` prop is set to `true`. | ||
- `@fail-to-find` - again primarily used within the field component so shouldn't be required. This will when a value is already set on the field component go and find that file so when the manager is opened that file is shown in the window on the right. Only works if the `selectable` prop is set to `true`. | ||
|
||
### Props | ||
| Prop | Type | Default | Description | ||
|--|--|--|--| | ||
| `types` | `Object` | `{ images: true, files: true }` | Property controls whether both images and files can be toggled. Useful if you want to only use images or files. | | ||
| `filetypes` | `Array` | `[]` | To limit the media to only certain file types. E.g. `[ 'png', 'jpg' ]`. | | ||
| `selectable` | `Boolean` | `false` | Used by the field component but allows the media to be selectable, which also allows you to use the `@select` event. | | ||
| `selected` | `String` | `null` | Used by the field component but allows you to pass in a filename which will then be automatically opened on the right window e.g. `test.jpg`. This will also cause the `@fail-to-find` event to be in operation.| | ||
|
||
|
||
## Field API | ||
### Events | ||
- `@close` - this is used when the user has selected the close button in the manager, this should toggle off your original `v-if`. Naturally without a `v-if` this component will display at all times. | ||
- `@select` - this is primarily used within the field component so shouldn't be required, but it is triggered when the insert button has been selected on a media item. Only works if the `selectable` prop is set to `true`. | ||
- `@fail-to-find` - again primarily used within the field component so shouldn't be required. This will when a value is already set on the field component go and find that file so when the manager is opened that file is shown in the window on the right. Only works if the `selectable` prop is set to `true`. | ||
|
||
### Props | ||
| Prop | Type | Default | Description | ||
|--|--|--|--| | ||
| `types` | `Object` | `{ images: true, files: true }` | Property controls whether both images and files can be toggled within the manager. Useful if you want to only use images or files. | | ||
| `filetypes` | `Array` | `[]` | To limit the media to only certain file types. E.g. `[ 'png', 'jpg' ]` in the manager. | | ||
| `helper` | `String` | `null` | This allows you to put helpful message/text into the field. E.g. 'Maximum image width: 100px'. | | ||
|
||
## Future features | ||
Just some ideas in the making... | ||
|
||
- Drag & Drop, this currently doens't work - you have to use the button currently. | ||
- Support multiple image variations. e.g. Responsive images. | ||
- Ability to multi select, or create a repeatable field for multiple images. |
Oops, something went wrong.