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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
<html>
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="utf-8" />
|
| 5 |
+
<meta name="viewport" content="width=device-width" />
|
| 6 |
+
|
| 7 |
+
<title>Gradio theme gallery</title>
|
| 8 |
+
<meta name="description" content="Discover all gradio themes created by the community." />
|
| 9 |
+
|
| 10 |
+
<meta property="og:url" content="https://freddyaboulton-gradio-themes-gallery.hf.space/" />
|
| 11 |
+
<meta property="og:type" content="website" />
|
| 12 |
+
<meta property="og:title" content="Gradio - Theme Gallery" />
|
| 13 |
+
<meta property="og:description" content="Discover all gradio themes created by the community." />
|
| 14 |
+
<meta property="og:image" content="https://huggingface-projects-diffusers-gallery.hf.space/Fo6vR6JX0AEjbw1.jpeg" />
|
| 15 |
+
|
| 16 |
+
<meta name="twitter:card" content="player" />
|
| 17 |
+
<meta property="twitter:url" content="https://freddyaboulton-gradio-themes-gallery.hf.space/" />
|
| 18 |
+
<meta name="twitter:description" content="Discover all gradio themes created by the community." />
|
| 19 |
+
|
| 20 |
+
<meta name="twitter:site" content="@huggingface" />
|
| 21 |
+
<meta name="twitter:title" content="Gradio - Theme Gallery" />
|
| 22 |
+
|
| 23 |
+
<meta name="twitter:image" content="https://huggingface-projects-diffusers-gallery.hf.space/Fo6vR6JX0AEjbw1.jpeg" />
|
| 24 |
+
<meta name="twitter:player" content="https://freddyaboulton-gradio-themes-gallery.hf.space/index.html" />
|
| 25 |
+
<meta name="twitter:player:width" content="100%" />
|
| 26 |
+
<meta name="twitter:player:height" content="600" />
|
| 27 |
+
|
| 28 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/4.3.1/iframeResizer.contentWindow.min.js"></script>
|
| 29 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 30 |
+
|
| 31 |
+
<style>
|
| 32 |
+
|
| 33 |
+
iframe {
|
| 34 |
+
display: block;
|
| 35 |
+
border: 1px solid transparent;
|
| 36 |
+
width: 100%;
|
| 37 |
+
height: 500px;
|
| 38 |
+
pointer-events: none;
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
.grid-container {
|
| 42 |
+
display: grid;
|
| 43 |
+
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
|
| 44 |
+
grid-gap: 10px;
|
| 45 |
+
margin-top: 3.5rem;
|
| 46 |
+
margin-left: 3.5rem;
|
| 47 |
+
margin-right: 3.5rem;
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
.grid-item {
|
| 51 |
+
position: relative;
|
| 52 |
+
overflow-y: hidden;
|
| 53 |
+
border-radius: 10px;
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
.grid-item a {
|
| 57 |
+
position: absolute;
|
| 58 |
+
top: 0;
|
| 59 |
+
left: 0;
|
| 60 |
+
width: 100%;
|
| 61 |
+
height: 100%;
|
| 62 |
+
display: block;
|
| 63 |
+
z-index: 1;
|
| 64 |
+
}
|
| 65 |
+
</style>
|
| 66 |
+
|
| 67 |
+
<script type="module">
|
| 68 |
+
import Alpine from "https://cdn.skypack.dev/alpinejs";
|
| 69 |
+
import Intersect from "https://cdn.skypack.dev/@alpinejs/intersect";
|
| 70 |
+
Alpine.plugin(Intersect);
|
| 71 |
+
|
| 72 |
+
Alpine.data("themesData", () => ({
|
| 73 |
+
async init() {
|
| 74 |
+
const data = await this.getThemes(this.page, this.sort, this.filter);
|
| 75 |
+
this.themes = data.pageThemes;
|
| 76 |
+
console.log(this.themes);
|
| 77 |
+
this.totalPages = data.totalPages;
|
| 78 |
+
console.log(this.totalPages);
|
| 79 |
+
},
|
| 80 |
+
themes: [],
|
| 81 |
+
filter: "all",
|
| 82 |
+
sort: "likes",
|
| 83 |
+
page: 1,
|
| 84 |
+
totalPages: -1,
|
| 85 |
+
buttonClass(attr, filter) {
|
| 86 |
+
if (this[attr] === filter) {
|
| 87 |
+
return "bg-black dark:bg-white shadow-lg text-white dark:text-black hover:bg-black hover:text-white";
|
| 88 |
+
}
|
| 89 |
+
return "text-gray-600 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-500 hover:text-gray-800";
|
| 90 |
+
},
|
| 91 |
+
async sortModels(sort) {
|
| 92 |
+
// this.sort = sort;
|
| 93 |
+
// this.page = 1;
|
| 94 |
+
// const data = await this.getModels(this.page, this.sort, this.filter);
|
| 95 |
+
// this.models = data.models;
|
| 96 |
+
// this.totalPages = data.totalPages;
|
| 97 |
+
},
|
| 98 |
+
async getThemes(page, sort, style) {
|
| 99 |
+
const res = await fetch(
|
| 100 |
+
'https://huggingface.co/datasets/freddyaboulton/gradio-theme-subdomains/resolve/main/subdomains.json'
|
| 101 |
+
);
|
| 102 |
+
const data = await res.json();
|
| 103 |
+
const themes = Object.entries(data).map(([key, value]) => ({
|
| 104 |
+
id: key,
|
| 105 |
+
subdomain: value,
|
| 106 |
+
}))
|
| 107 |
+
|
| 108 |
+
const pageThemes = themes.slice((page - 1) * 30, page * 30);
|
| 109 |
+
|
| 110 |
+
return {
|
| 111 |
+
pageThemes,
|
| 112 |
+
totalPages: Math.floor(themes.length + 30 - 1, 30)
|
| 113 |
+
};
|
| 114 |
+
},
|
| 115 |
+
async nextPage() {
|
| 116 |
+
if (this.page < this.totalPages) {
|
| 117 |
+
this.page += 1;
|
| 118 |
+
const data = await this.getThemes(this.page, this.sort, this.filter);
|
| 119 |
+
this.themes = this.themes.concat(data.pageThemes);
|
| 120 |
+
// this.totalPages = data.totalPages;
|
| 121 |
+
}
|
| 122 |
+
},
|
| 123 |
+
}));
|
| 124 |
+
Alpine.start();
|
| 125 |
+
</script>
|
| 126 |
+
</head>
|
| 127 |
+
|
| 128 |
+
<body class="pb-10 pt-5 bg-gray-100 dark:bg-gray-900 relative">
|
| 129 |
+
<section
|
| 130 |
+
x-data="themesData"
|
| 131 |
+
>
|
| 132 |
+
<section class="container px-6 grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-14 mx-auto relative">
|
| 133 |
+
<div class="col-span-2 lg:col-span-1 flex flex-col gap-14 row-start">
|
| 134 |
+
<h1 class="text-lg font-semibold dark:text-white whitespace-nowrap">Gradio Themes Gallery</h1>
|
| 135 |
+
</div>
|
| 136 |
+
<div class="col-span-2 md:col-span-3 flex items-center gap-14 flex flex-wrap lg-auto lg:ml-auto text-sm">
|
| 137 |
+
<div class="flex gap-2">
|
| 138 |
+
<span class="md:px-3 py-1 dark:text-white text-gray-400">sort by</span>
|
| 139 |
+
<button
|
| 140 |
+
:class="buttonClass('sort', 'likes')"
|
| 141 |
+
class="text-gray-600 hover:bg-gray-200 dark:hover:bg-gray-500 hover:text-gray-800 px-2 md:px-3 py-1 rounded-full"
|
| 142 |
+
@click="sortModels('likes')"
|
| 143 |
+
>
|
| 144 |
+
Most Likes
|
| 145 |
+
</button>
|
| 146 |
+
<button
|
| 147 |
+
:class="buttonClass('sort', 'recent')"
|
| 148 |
+
class="text-gray-600 hover:bg-gray-200 dark:hover:bg-gray-500 hover:text-gray-800 px-2 md:px-3 py-1 rounded-full"
|
| 149 |
+
@click="sortModels('recent')"
|
| 150 |
+
>
|
| 151 |
+
Recent
|
| 152 |
+
</button>
|
| 153 |
+
</div>
|
| 154 |
+
</div>
|
| 155 |
+
</section>
|
| 156 |
+
<div class="grid-container">
|
| 157 |
+
<template x-for="theme in themes" :key="theme.id">
|
| 158 |
+
<div class="grid-item">
|
| 159 |
+
<iframe :src="theme.subdomain" :alt="theme.id" scrolling="no" frameborder="0"></iframe>
|
| 160 |
+
<a :href="`https://huggingface.co/spaces/${theme.id}`" target="_blank"></a>
|
| 161 |
+
</div>
|
| 162 |
+
</template>
|
| 163 |
+
</div>
|
| 164 |
+
<div class="h-12 relative" x-intersect="nextPage" data-iframe-height></div>
|
| 165 |
+
</section>
|
| 166 |
+
</body>
|
| 167 |
+
</html>
|