prettier + remove lazy on img
Browse files- index.html +103 -85
index.html
CHANGED
@@ -1,96 +1,114 @@
|
|
1 |
<!DOCTYPE html>
|
2 |
<html>
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
-
<
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
<script src="https://cdn.tailwindcss.com"></script>
|
9 |
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/4.3.1/iframeResizer.contentWindow.min.js"></script>
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
|
|
|
|
|
|
|
|
15 |
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
getModels(page) {
|
32 |
-
// return fetch(`http://localhost:8000/api/models?page=${page}`)
|
33 |
-
return fetch(`https://huggingface-projects-diffusers-gallery-bot.hf.space/api/models?page=${page}`)
|
34 |
-
.then((res) => res.json())
|
35 |
-
},
|
36 |
-
nextPage() {
|
37 |
-
if (this.page < this.totalPages) {
|
38 |
-
this.page += 1
|
39 |
-
this.getModels(this.page).then((data) => {
|
40 |
-
const models = data.models.map(model => ({
|
41 |
-
id: model.id,
|
42 |
-
likes: model.likes,
|
43 |
-
images: model.images.filter(image => image && image.endsWith('.jpg'))
|
44 |
-
}))
|
45 |
-
this.models = this.models.concat(models)
|
46 |
-
})
|
47 |
-
}
|
48 |
-
},
|
49 |
-
}))
|
50 |
-
Alpine.start()
|
51 |
-
</script>
|
52 |
-
</head>
|
53 |
-
|
54 |
-
<body class="py-10 bg-gray-100">
|
55 |
-
<section class="container px-6 grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4 mx-auto" x-data="modelsData">
|
56 |
-
<div class="col-span-2 md:col-span-3 lg:col-span-4 flex items-center gap-2">
|
57 |
-
<h1 class="mr-auto text-lg font-semibold">Diffusers Models Gallery</h1>
|
58 |
-
<button class="bg-black shadow-lg px-4 py-1 rounded-full text-white">All</button>
|
59 |
-
<!-- <button class="text-gray-600 px-4 py-1 rounded-full hover:bg-gray-200 hover:text-gray-800">Anime</button>
|
60 |
<button class="text-gray-600 px-4 py-1 rounded-full hover:bg-gray-200 hover:text-gray-800">3D</button>
|
61 |
<button class="text-gray-600 px-4 py-1 rounded-full hover:bg-gray-200 hover:text-gray-800">Realistic</button> -->
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
</div>
|
79 |
-
<div
|
80 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
</div>
|
82 |
-
</
|
83 |
-
|
84 |
-
<template x-if="model.images[0]">
|
85 |
-
<img :src="()=> ASSETS_URL + model.images[model.images.length * Math.random() | 0]" :alt="model.id" alt=""
|
86 |
-
loading="lazy" class="w-full h-full object-cover group-hover:scale-[1.01] transition" />
|
87 |
-
</template>
|
88 |
-
</div>
|
89 |
-
</a>
|
90 |
</template>
|
91 |
-
|
92 |
-
|
93 |
-
</
|
94 |
-
</
|
95 |
-
|
96 |
-
</html>
|
|
|
1 |
<!DOCTYPE html>
|
2 |
<html>
|
3 |
+
<head>
|
4 |
+
<meta charset="utf-8" />
|
5 |
+
<meta name="viewport" content="width=device-width" />
|
6 |
+
<title>Diffusers gallery</title>
|
7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
8 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/4.3.1/iframeResizer.contentWindow.min.js"></script>
|
9 |
|
10 |
+
<script type="module">
|
11 |
+
import Alpine from "https://cdn.skypack.dev/alpinejs";
|
12 |
+
import Intersect from "https://cdn.skypack.dev/@alpinejs/intersect";
|
13 |
+
Alpine.plugin(Intersect);
|
|
|
|
|
14 |
|
15 |
+
Alpine.data("modelsData", () => ({
|
16 |
+
async init() {
|
17 |
+
const data = await this.getModels(this.page);
|
18 |
+
this.models = data.models.map((model) => ({
|
19 |
+
id: model.id,
|
20 |
+
likes: model.likes,
|
21 |
+
images: model.images.filter((image) => image && image.endsWith(".jpg")),
|
22 |
+
}));
|
23 |
|
24 |
+
this.totalPages = data.totalPages;
|
25 |
+
},
|
26 |
+
ASSETS_URL: "https://d26smi9133w0oo.cloudfront.net/diffusers-gallery/",
|
27 |
+
models: [],
|
28 |
+
page: 1,
|
29 |
+
totalPages: -1,
|
30 |
+
getModels(page) {
|
31 |
+
// return fetch(`http://localhost:8000/api/models?page=${page}`)
|
32 |
+
return fetch(`https://huggingface-projects-diffusers-gallery-bot.hf.space/api/models?page=${page}`).then(
|
33 |
+
(res) => res.json()
|
34 |
+
);
|
35 |
+
},
|
36 |
+
nextPage() {
|
37 |
+
if (this.page < this.totalPages) {
|
38 |
+
this.page += 1;
|
39 |
+
this.getModels(this.page).then((data) => {
|
40 |
+
const models = data.models.map((model) => ({
|
41 |
+
id: model.id,
|
42 |
+
likes: model.likes,
|
43 |
+
images: model.images.filter((image) => image && image.endsWith(".jpg")),
|
44 |
+
}));
|
45 |
+
this.models = this.models.concat(models);
|
46 |
+
});
|
47 |
+
}
|
48 |
+
},
|
49 |
+
}));
|
50 |
+
Alpine.start();
|
51 |
+
</script>
|
52 |
+
</head>
|
53 |
|
54 |
+
<body class="pb-10 pt-5 bg-gray-100">
|
55 |
+
<section class="container px-6 grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4 mx-auto" x-data="modelsData">
|
56 |
+
<div class="col-span-2 md:col-span-3 lg:col-span-4 flex items-center gap-2">
|
57 |
+
<h1 class="mr-auto text-lg font-semibold">Diffusers Models Gallery</h1>
|
58 |
+
<button class="bg-black shadow-lg px-4 py-1 rounded-full text-white">All</button>
|
59 |
+
<!-- <button class="text-gray-600 px-4 py-1 rounded-full hover:bg-gray-200 hover:text-gray-800">Anime</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
<button class="text-gray-600 px-4 py-1 rounded-full hover:bg-gray-200 hover:text-gray-800">3D</button>
|
61 |
<button class="text-gray-600 px-4 py-1 rounded-full hover:bg-gray-200 hover:text-gray-800">Realistic</button> -->
|
62 |
+
</div>
|
63 |
+
<template x-for="model in models" :key="model.id">
|
64 |
+
<template x-if="model.images.length > 0">
|
65 |
+
<a
|
66 |
+
:href="`https://huggingface.co/${model.id}`"
|
67 |
+
class="block bg-gray-900 rounded-xl overflow-hidden relative group aspect-square text-white"
|
68 |
+
target="_blank"
|
69 |
+
>
|
70 |
+
<div
|
71 |
+
class="absolute bottom-0 p-4 bg-gradient-to-t text-white pt-10 from-black/90 via-black/70 to-transparent w-full z-10"
|
72 |
+
>
|
73 |
+
<div class="text-sm flex items-center group-hover:translate-x-0.5 transition">
|
74 |
+
<svg
|
75 |
+
class="mr-1.5 text-white/70"
|
76 |
+
xmlns="http://www.w3.org/2000/svg"
|
77 |
+
xmlns:xlink="http://www.w3.org/1999/xlink"
|
78 |
+
aria-hidden="true"
|
79 |
+
focusable="false"
|
80 |
+
role="img"
|
81 |
+
width="1em"
|
82 |
+
height="1em"
|
83 |
+
preserveAspectRatio="xMidYMid meet"
|
84 |
+
viewBox="0 0 32 32"
|
85 |
+
fill="currentColor"
|
86 |
+
>
|
87 |
+
<path
|
88 |
+
d="M22.5,4c-2,0-3.9,0.8-5.3,2.2L16,7.4l-1.1-1.1C12,3.3,7.2,3.3,4.3,6.2c0,0-0.1,0.1-0.1,0.1c-3,3-3,7.8,0,10.8L16,29l11.8-11.9c3-3,3-7.8,0-10.8C26.4,4.8,24.5,4,22.5,4z"
|
89 |
+
></path>
|
90 |
+
</svg>
|
91 |
+
<span x-text="model.likes"></span>
|
92 |
+
</div>
|
93 |
+
<div
|
94 |
+
x-text="model.id"
|
95 |
+
class="text-base md:text-lg lg:text-xl font-semibold group-hover:translate-x-0.5 transition"
|
96 |
+
></div>
|
97 |
</div>
|
98 |
+
<div class="group-hover:brightness-90 h-full">
|
99 |
+
<template x-if="model.images[0]">
|
100 |
+
<img
|
101 |
+
:src="()=> ASSETS_URL + model.images[model.images.length * Math.random() | 0]"
|
102 |
+
:alt="model.id"
|
103 |
+
alt=""
|
104 |
+
class="w-full h-full object-cover group-hover:scale-[1.01] transition"
|
105 |
+
/>
|
106 |
+
</template>
|
107 |
</div>
|
108 |
+
</a>
|
109 |
+
</template>
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
</template>
|
111 |
+
<div class="h-12" x-intersect="nextPage"></div>
|
112 |
+
</section>
|
113 |
+
</body>
|
114 |
+
</html>
|
|
|
|