Skip to content

Commit e577681

Browse files
first commit
0 parents  commit e577681

12 files changed

+9044
-0
lines changed

Diff for: .babelrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["@babel/preset-env"]
3+
}

Diff for: .gitignore

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

Diff for: .npmignore

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

Diff for: LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Andrew Vasilchuk
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Diff for: README.md

+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# vue-lazy-youtube-video
2+
3+
![Vue.js logo plus YouTube logo](./assets/img.jpg)
4+
5+
## Features
6+
7+
- a11y included
8+
- `.webp` preview img format for modern browsers that support it, with `.jpg` fallback for browsers that don't
9+
- reduced initial load size by ~1.1MB per video
10+
11+
## 💿 Installation
12+
13+
### Via NPM
14+
15+
```bash
16+
$ npm install vue-lazy-youtube-video --save
17+
```
18+
19+
### Via Yarn
20+
21+
```bash
22+
$ yarn add vue-lazy-youtube-video
23+
```
24+
25+
## Initialization
26+
27+
### As a global component
28+
29+
> ⚠️ It must be called before `new Vue()`.
30+
31+
```js
32+
import Vue from "vue";
33+
import LazyYoutubeVideo from "vue-lazy-youtube-video";
34+
35+
Vue.component("LazyYoutubeVideo", LazyYoutubeVideo);
36+
```
37+
38+
### As a local component
39+
40+
```js
41+
import LazyYoutubeVideo from "vue-lazy-youtube-video";
42+
43+
export default {
44+
name: "YourAwesomeComponent",
45+
components: {
46+
LazyYoutubeVideo
47+
}
48+
};
49+
```
50+
51+
## 🚀 Usage
52+
53+
```vue
54+
<template>
55+
<LazyYoutubeVideo url="https://www.youtube.com/watch?v=[VIDEO_ID]" />
56+
</template>
57+
```
58+
59+
## ⚙️ Properties
60+
61+
| Property | Required | Type | Default | Description |
62+
| ----------- | -------- | ------ | --------------------------- | ------------------------------------------------------------------------------------------ |
63+
| url | `true` | String | | Video `URL` in https://www.youtube.com/watch?v=VIDEO_ID format |
64+
| alt | `false` | String | `"Video alternative image"` | Value of the `alt` attribute of the thumbnail `<img />` element |
65+
| buttonLabel | `false` | String | `"Play video"` | Value of the `aria-label` attribute of the play `<button></button>` element. Improves a11y |
66+
| aspectRatio | `false` | String | `"16:9"` | Aspect ratio. It helps to save proportions of the video on different container sizes |
67+
68+
## ⚙️ Events
69+
70+
| Name | Type | Usage |
71+
| ----------- | ------------ | --------------------------------------------------------------------- |
72+
| videoLoaded | `() => void` | The event that is triggered when the iframe is inserted into the DOM. |
73+
74+
## 💉 Tests
75+
76+
Jest is used for unit-tests.
77+
78+
You can run tests by typing this command in your console:
79+
80+
```bash
81+
npm run test
82+
```
83+
84+
## Powered by
85+
86+
- Babel
87+
- Webpack 4
88+
- Vue
89+
- SASS
90+
91+
## Inspiration
92+
93+
Inspired by [Vadim Makeev](https://pepelsbey.net). Vadim created a comprehensive tutorial in which he shows how to lazyload YouTube videos properly.
94+
95+
## 🔒 License
96+
97+
[MIT](http://opensource.org/licenses/MIT)

Diff for: assets/img.jpg

42.4 KB
Loading

0 commit comments

Comments
 (0)