Skip to content

Commit 2e3cd4f

Browse files
author
Ibrahim Cesar
committed
✨ feat: do not exporting css directly
1 parent d14805d commit 2e3cd4f

File tree

8 files changed

+43727
-19639
lines changed

8 files changed

+43727
-19639
lines changed

β€ŽREADME.mdβ€Ž

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,104 @@ Port of Paul Irish's [Lite YouTube Embed](https://github.com/paulirish/lite-yout
66

77
![iFrame example](https://react-lite-youtube-embed.s3-sa-east-1.amazonaws.com/lite.gif)
88

9+
## Version 2.0 - BREAKNG CHANGE
10+
11+
To play nice with new frameworks like [NextJS](https://nextjs.org/), we now don't import the `.css` necessary. Instead in order to use now you have three options:
12+
13+
### Option 1
14+
15+
Manual import our file in your React application this way:
16+
17+
### Option 2
18+
19+
Place the necessary CSS in your Global CSS file
20+
21+
```css
22+
.yt-lite {
23+
background-color: #000;
24+
position: relative;
25+
display: block;
26+
contain: content;
27+
background-position: center center;
28+
background-size: cover;
29+
cursor: pointer;
30+
}
31+
32+
/* gradient */
33+
.yt-lite::before {
34+
content: '';
35+
display: block;
36+
position: absolute;
37+
top: 0;
38+
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAADGCAYAAAAT+OqFAAAAdklEQVQoz42QQQ7AIAgEF/T/D+kbq/RWAlnQyyazA4aoAB4FsBSA/bFjuF1EOL7VbrIrBuusmrt4ZZORfb6ehbWdnRHEIiITaEUKa5EJqUakRSaEYBJSCY2dEstQY7AuxahwXFrvZmWl2rh4JZ07z9dLtesfNj5q0FU3A5ObbwAAAABJRU5ErkJggg==);
39+
background-position: top;
40+
background-repeat: repeat-x;
41+
height: 60px;
42+
padding-bottom: 50px;
43+
width: 100%;
44+
transition: all 0.2s cubic-bezier(0, 0, 0.2, 1);
45+
}
46+
47+
/* responsive iframe with a 16:9 aspect ratio
48+
thanks https://css-tricks.com/responsive-iframes/
49+
*/
50+
.yt-lite::after {
51+
content: "";
52+
display: block;
53+
padding-bottom: calc(100% / (16 / 9));
54+
}
55+
.yt-lite > iframe {
56+
width: 100%;
57+
height: 100%;
58+
position: absolute;
59+
top: 0;
60+
left: 0;
61+
}
62+
63+
/* play button */
64+
.yt-lite > .lty-playbtn {
65+
width: 70px;
66+
height: 46px;
67+
background-color: #212121;
68+
z-index: 1;
69+
opacity: 0.8;
70+
border-radius: 14%; /* TODO: Consider replacing this with YT's actual svg. Eh. */
71+
transition: all 0.2s cubic-bezier(0, 0, 0.2, 1);
72+
}
73+
.yt-lite:hover > .lty-playbtn {
74+
background-color: #f00;
75+
opacity: 1;
76+
}
77+
/* play button triangle */
78+
.yt-lite > .lty-playbtn:before {
79+
content: '';
80+
border-style: solid;
81+
border-width: 11px 0 11px 19px;
82+
border-color: transparent transparent transparent #fff;
83+
}
84+
85+
.yt-lite > .lty-playbtn,
86+
.yt-lite > .lty-playbtn:before {
87+
position: absolute;
88+
top: 50%;
89+
left: 50%;
90+
transform: translate3d(-50%, -50%, 0);
91+
}
92+
93+
/* Post-click styles */
94+
.yt-lite.lyt-activated {
95+
cursor: unset;
96+
}
97+
.yt-lite.lyt-activated::before,
98+
.yt-lite.lyt-activated > .lty-playbtn {
99+
opacity: 0;
100+
pointer-events: none;
101+
}
102+
```
103+
### Option 3
104+
105+
Using your CSS-In-JS tool of choice encapsulate this component and use the css provided as a guide.
106+
9107
## Installation
10108

11109
Use your favorite package manager:

β€Ždist/LiteYouTubeEmbed.cssβ€Ž

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
2-
31
.yt-lite {
42
background-color: #000;
53
position: relative;
@@ -12,17 +10,17 @@
1210

1311
/* gradient */
1412
.yt-lite::before {
15-
content: '';
16-
display: block;
17-
position: absolute;
18-
top: 0;
19-
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAADGCAYAAAAT+OqFAAAAdklEQVQoz42QQQ7AIAgEF/T/D+kbq/RWAlnQyyazA4aoAB4FsBSA/bFjuF1EOL7VbrIrBuusmrt4ZZORfb6ehbWdnRHEIiITaEUKa5EJqUakRSaEYBJSCY2dEstQY7AuxahwXFrvZmWl2rh4JZ07z9dLtesfNj5q0FU3A5ObbwAAAABJRU5ErkJggg==);
20-
background-position: top;
21-
background-repeat: repeat-x;
22-
height: 60px;
23-
padding-bottom: 50px;
24-
width: 100%;
25-
transition: all 0.2s cubic-bezier(0, 0, 0.2, 1);
13+
content: '';
14+
display: block;
15+
position: absolute;
16+
top: 0;
17+
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAADGCAYAAAAT+OqFAAAAdklEQVQoz42QQQ7AIAgEF/T/D+kbq/RWAlnQyyazA4aoAB4FsBSA/bFjuF1EOL7VbrIrBuusmrt4ZZORfb6ehbWdnRHEIiITaEUKa5EJqUakRSaEYBJSCY2dEstQY7AuxahwXFrvZmWl2rh4JZ07z9dLtesfNj5q0FU3A5ObbwAAAABJRU5ErkJggg==);
18+
background-position: top;
19+
background-repeat: repeat-x;
20+
height: 60px;
21+
padding-bottom: 50px;
22+
width: 100%;
23+
transition: all 0.2s cubic-bezier(0, 0, 0.2, 1);
2624
}
2725

2826
/* responsive iframe with a 16:9 aspect ratio

β€Ždist/LiteYouTubeEmbed.jsβ€Ž

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
22
import React, { Fragment, useState } from "react";
3-
import "./LiteYouTubeEmbed.css";
43

54
var LiteYouTubeEmbed = function LiteYouTubeEmbed(_ref) {
65
var adNetwork = _ref.adNetwork,

0 commit comments

Comments
Β (0)