-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
232 lines (231 loc) · 8.27 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Lightbox-js</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="./style/index.css" />
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/default.min.css"
/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
</head>
<script>
hljs.highlightAll();
</script>
<body class="bg-gray-200">
<div class="bg-black text-center text-white py-5">
<h3 class="text-5xl font-bold">Lightbox-js</h3>
<p class="mt-3">
The fast and simple lightbox package, support multiple type of file,
with no dependency.
</p>
<a
class="bg-gray-300 px-3 py-2 rounded-md text-black flex flex-row mx-auto mt-3 w-32 justify-center"
href="https://github.com/duccanhole/lightbox-js"
target="_blank"
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="25"
height="25"
viewBox="0 0 25 25"
>
<path
d="M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z"
/>
</svg>
<span class="font-bold mx-2">Github</span>
</a>
</div>
<div class="p-3 xl:w-[1024px] mx-auto">
<a href="#example" class="text-3xl font-bold my-3">EXAMPLES</a>
<div class="text-lg uppercase mt-2">With single file</div>
<div class="mb-2">
<label for="type">Type</label>
<select
id="lightbox-type"
name="type"
class="border-2 border-black/90 rounded-md"
>
<option value="image" selected>Image</option>
<option value="video">Video</option>
<option value="audio">Audio</option>
<option value="iframe">Iframe</option>
<option value="custom">Custom</option>
</select>
</div>
<button
class="bg-black/90 text-white px-2 rounded-md"
onclick="openLightbox()"
>
Open
</button>
<div class="text-lg uppercase mt-2">With gallery</div>
<button
class="bg-black/90 text-white px-2 rounded-md"
onclick="openLightbox('gallery')"
>
Open
</button>
<div class="border-[1px] border-black/90 w-full my-3"></div>
<a href="#install" class="text-3xl font-bold">Installation</a>
<ul class="mt-2 list-disc list-inside">
<li>NPM</li>
<pre>
<code class="language-bash">npm install @duccanhole/lightbox</code>
</pre>
<li>Yarn</li>
<pre>
<code class="language-bash">yarn add @duccanhole/lightbox</code>
</pre>
<li>PNPM</li>
<pre>
<code class="language-bash">pnpm install @duccanhole/lightbox</code>
</pre>
<li>Includes</li>
<p>
Copy or download javascript file from <code>index.js</code> and css
file from <code>style/index.css</code> to your project
</p>
<pre>
<code class="language-html">
<head>
<link type="text/css" rel="stylesheet" href="/** link your css file here */" />
</head>
<body>
<script type="module">
import Lightbox from "/** link your js file here */"
const lightbox = new Lightbox()
lightbox.open({
type: 'image',
src: 'https://picsum.photos/800/800',
downloadUrl: 'https://picsum.photos/200/300'
})
</script>
</body>
</code>
</pre>
</ul>
</div>
</body>
<script type="module">
import Lightbox from "./index.js";
const lightbox = new Lightbox();
function openLightbox(defaultType) {
const selectEl = document.getElementById("lightbox-type");
const type = defaultType ?? selectEl.value;
let item = null;
switch (type) {
case "image":
item = {
type: "image",
src: "https://picsum.photos/800/800",
downloadUrl: "https://picsum.photos/800/800",
};
break;
case "video":
item = {
type: "video",
downloadUrl:
"https://www.taxmann.com/emailer/images/CompaniesAct.mp4",
sources: [
{
src: "https://www.taxmann.com/emailer/images/CompaniesAct.mp4",
type: "video/mp4",
},
],
};
break;
case "audio":
item = {
type: "audio",
downloadUrl:
"https://commondatastorage.googleapis.com/codeskulptor-demos/DDR_assets/Kangaroo_MusiQue_-_The_Neverwritten_Role_Playing_Game.mp3",
sources: [
{
src: "https://commondatastorage.googleapis.com/codeskulptor-demos/DDR_assets/Kangaroo_MusiQue_-_The_Neverwritten_Role_Playing_Game.mp3",
type: "audio/mpeg",
},
],
};
break;
case "iframe":
item = {
type: "iframe",
thumbnail: "",
downloadUrl:
"https://www.antennahouse.com/hubfs/xsl-fo-sample/pdf/basic-link-1.pdf",
src: "https://www.antennahouse.com/hubfs/xsl-fo-sample/pdf/basic-link-1.pdf",
};
break;
case "custom":
item = {
type: "custom",
thumbnail: "",
template: `
<div class="w-full h-full text-center bg-white text-black flex flex-col justify-center text-xl">
<b>This is custom html</b>
<p>Hello, world !</p>
</div>
`,
};
break;
}
if (type === "gallery") {
const list = [
{
type: "image",
src: "https://picsum.photos/id/1/800/800",
thumbnail: "https://picsum.photos/id/1/800/800",
downloadUrl: "https://picsum.photos/id/1/800/800",
},
{
type: "image",
src: "https://picsum.photos/id/2/500/600",
thumbnail: "https://picsum.photos/id/2/500/600",
downloadUrl: "https://picsum.photos/id/2/500/600",
},
{
type: "video",
downloadUrl:
"http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4",
sources: [
{
src: "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4",
type: "video/mp4",
},
],
thumbnail: "https://picsum.photos/id/3/500/500",
},
{
type: "audio",
downloadUrl:
"https://github.com/rafaelreis-hotmart/Audio-Sample-files/raw/master/sample.mp3",
sources: [
{
src: "https://github.com/rafaelreis-hotmart/Audio-Sample-files/raw/master/sample.mp3",
type: "audio/mpeg",
},
],
thumbnail: "https://picsum.photos/id/4/500/500",
},
{
type: "image",
src: "https://picsum.photos/id/5/400/700",
thumbnail: "https://picsum.photos/id/5/400/700",
downloadUrl: "https://picsum.photos/id/5/400/700",
},
];
lightbox.setGallery(list);
lightbox.openGalleryItem(0);
} else {
lightbox.setGallery([]);
lightbox.open(item);
}
}
window.openLightbox = openLightbox;
</script>
</html>