Spaces:
Running
Running
Is this the finished script
Browse files- components/history-panel.js +103 -0
- components/media-wizard.js +22 -9
- index.html +10 -2
- style.css +2 -2
components/history-panel.js
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
class HistoryPanel extends HTMLElement {
|
| 2 |
+
constructor() {
|
| 3 |
+
super();
|
| 4 |
+
this.attachShadow({ mode: 'open' });
|
| 5 |
+
this.history = [];
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
connectedCallback() {
|
| 9 |
+
this.render();
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
render() {
|
| 13 |
+
this.shadowRoot.innerHTML = `
|
| 14 |
+
<style>
|
| 15 |
+
:host {
|
| 16 |
+
display: block;
|
| 17 |
+
background: #1e1e2e;
|
| 18 |
+
border-radius: 0.75rem;
|
| 19 |
+
padding: 1rem;
|
| 20 |
+
height: 100%;
|
| 21 |
+
}
|
| 22 |
+
h3 {
|
| 23 |
+
font-size: 1.1rem;
|
| 24 |
+
font-weight: 600;
|
| 25 |
+
margin-bottom: 1rem;
|
| 26 |
+
color: white;
|
| 27 |
+
}
|
| 28 |
+
.history-item {
|
| 29 |
+
display: flex;
|
| 30 |
+
gap: 0.75rem;
|
| 31 |
+
padding: 0.75rem;
|
| 32 |
+
border-radius: 0.5rem;
|
| 33 |
+
margin-bottom: 0.5rem;
|
| 34 |
+
cursor: pointer;
|
| 35 |
+
transition: all 0.2s ease;
|
| 36 |
+
}
|
| 37 |
+
.history-item:hover {
|
| 38 |
+
background: rgba(255, 255, 255, 0.05);
|
| 39 |
+
}
|
| 40 |
+
.history-thumbnail {
|
| 41 |
+
width: 50px;
|
| 42 |
+
height: 50px;
|
| 43 |
+
border-radius: 0.25rem;
|
| 44 |
+
object-fit: cover;
|
| 45 |
+
}
|
| 46 |
+
.history-details {
|
| 47 |
+
flex: 1;
|
| 48 |
+
overflow: hidden;
|
| 49 |
+
}
|
| 50 |
+
.history-title {
|
| 51 |
+
font-size: 0.9rem;
|
| 52 |
+
color: white;
|
| 53 |
+
white-space: nowrap;
|
| 54 |
+
overflow: hidden;
|
| 55 |
+
text-overflow: ellipsis;
|
| 56 |
+
}
|
| 57 |
+
.history-date {
|
| 58 |
+
font-size: 0.7rem;
|
| 59 |
+
color: #a1a1aa;
|
| 60 |
+
}
|
| 61 |
+
.empty-state {
|
| 62 |
+
color: #71717a;
|
| 63 |
+
text-align: center;
|
| 64 |
+
padding: 2rem 0;
|
| 65 |
+
font-size: 0.9rem;
|
| 66 |
+
}
|
| 67 |
+
</style>
|
| 68 |
+
<h3>Recent Creations</h3>
|
| 69 |
+
${this.history.length ? this.renderHistoryItems() : this.renderEmptyState()}
|
| 70 |
+
`;
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
renderHistoryItems() {
|
| 74 |
+
return this.history.map(item => `
|
| 75 |
+
<div class="history-item">
|
| 76 |
+
<img src="${item.thumbnail}" class="history-thumbnail">
|
| 77 |
+
<div class="history-details">
|
| 78 |
+
<div class="history-title">${item.title}</div>
|
| 79 |
+
<div class="history-date">${item.date}</div>
|
| 80 |
+
</div>
|
| 81 |
+
</div>
|
| 82 |
+
`).join('');
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
renderEmptyState() {
|
| 86 |
+
return `
|
| 87 |
+
<div class="empty-state">
|
| 88 |
+
<i data-feather="clock" class="w-8 h-8 mx-auto mb-2"></i>
|
| 89 |
+
<p>Your creations will appear here</p>
|
| 90 |
+
</div>
|
| 91 |
+
`;
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
addToHistory(item) {
|
| 95 |
+
this.history.unshift(item);
|
| 96 |
+
if (this.history.length > 10) {
|
| 97 |
+
this.history.pop();
|
| 98 |
+
}
|
| 99 |
+
this.render();
|
| 100 |
+
}
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
customElements.define('history-panel', HistoryPanel);
|
components/media-wizard.js
CHANGED
|
@@ -169,9 +169,8 @@ ${this.renderTabs()}
|
|
| 169 |
<p class="mt-2">Your transformed media will appear here</p>
|
| 170 |
</div>
|
| 171 |
</div>
|
| 172 |
-
|
| 173 |
<div class="mt-4 ${this.state.outputFile ? '' : 'hidden'}" id="output-actions">
|
| 174 |
-
<div class="flex gap-2">
|
| 175 |
<button class="bg-gray-700 hover:bg-gray-600 text-white py-2 px-4 rounded-lg flex items-center gap-2">
|
| 176 |
<i data-feather="download"></i>
|
| 177 |
<span>Download</span>
|
|
@@ -180,15 +179,18 @@ ${this.renderTabs()}
|
|
| 180 |
<i data-feather="copy"></i>
|
| 181 |
<span>Copy</span>
|
| 182 |
</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 183 |
<button class="bg-gray-700 hover:bg-gray-600 text-white py-2 px-4 rounded-lg flex items-center gap-2 ml-auto">
|
| 184 |
<i data-feather="share-2"></i>
|
| 185 |
<span>Share</span>
|
| 186 |
</button>
|
| 187 |
</div>
|
| 188 |
</div>
|
| 189 |
-
|
| 190 |
}
|
| 191 |
-
|
| 192 |
renderOptionsSection() {
|
| 193 |
let options = '';
|
| 194 |
|
|
@@ -202,10 +204,17 @@ ${this.renderTabs()}
|
|
| 202 |
class="w-full bg-gray-900 border border-gray-700 rounded-lg px-4 py-2 text-white focus:outline-none focus:ring-2 focus:ring-purple-600"
|
| 203 |
placeholder="Describe how you want to transform your media...">${this.state.prompt}</textarea>
|
| 204 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 205 |
`;
|
| 206 |
}
|
| 207 |
-
|
| 208 |
-
if (this.activeTab === 'face-swap-image' || this.activeTab === 'face-swap-video') {
|
| 209 |
options = `
|
| 210 |
<div class="mb-4">
|
| 211 |
<label class="block text-sm font-medium text-gray-400 mb-2">Target Face</label>
|
|
@@ -257,13 +266,17 @@ ${this.renderTabs()}
|
|
| 257 |
</select>
|
| 258 |
</div>
|
| 259 |
</div>
|
| 260 |
-
|
| 261 |
-
<label class="inline-flex items-center">
|
| 262 |
<input type="checkbox" class="rounded bg-gray-900 border-gray-700 text-purple-600 focus:ring-purple-600">
|
| 263 |
<span class="ml-2 text-sm text-gray-400">Smooth transitions between frames</span>
|
| 264 |
</label>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 265 |
</div>
|
| 266 |
-
|
| 267 |
}
|
| 268 |
|
| 269 |
return `
|
|
|
|
| 169 |
<p class="mt-2">Your transformed media will appear here</p>
|
| 170 |
</div>
|
| 171 |
</div>
|
|
|
|
| 172 |
<div class="mt-4 ${this.state.outputFile ? '' : 'hidden'}" id="output-actions">
|
| 173 |
+
<div class="flex flex-wrap gap-2">
|
| 174 |
<button class="bg-gray-700 hover:bg-gray-600 text-white py-2 px-4 rounded-lg flex items-center gap-2">
|
| 175 |
<i data-feather="download"></i>
|
| 176 |
<span>Download</span>
|
|
|
|
| 179 |
<i data-feather="copy"></i>
|
| 180 |
<span>Copy</span>
|
| 181 |
</button>
|
| 182 |
+
<button class="bg-gray-700 hover:bg-gray-600 text-white py-2 px-4 rounded-lg flex items-center gap-2">
|
| 183 |
+
<i data-feather="repeat"></i>
|
| 184 |
+
<span>Remix</span>
|
| 185 |
+
</button>
|
| 186 |
<button class="bg-gray-700 hover:bg-gray-600 text-white py-2 px-4 rounded-lg flex items-center gap-2 ml-auto">
|
| 187 |
<i data-feather="share-2"></i>
|
| 188 |
<span>Share</span>
|
| 189 |
</button>
|
| 190 |
</div>
|
| 191 |
</div>
|
| 192 |
+
`;
|
| 193 |
}
|
|
|
|
| 194 |
renderOptionsSection() {
|
| 195 |
let options = '';
|
| 196 |
|
|
|
|
| 204 |
class="w-full bg-gray-900 border border-gray-700 rounded-lg px-4 py-2 text-white focus:outline-none focus:ring-2 focus:ring-purple-600"
|
| 205 |
placeholder="Describe how you want to transform your media...">${this.state.prompt}</textarea>
|
| 206 |
</div>
|
| 207 |
+
<div class="mb-4">
|
| 208 |
+
<label class="block text-sm font-medium text-gray-400 mb-2">Negative Prompt</label>
|
| 209 |
+
<textarea
|
| 210 |
+
id="negative-prompt"
|
| 211 |
+
rows="2"
|
| 212 |
+
class="w-full bg-gray-900 border border-gray-700 rounded-lg px-4 py-2 text-white focus:outline-none focus:ring-2 focus:ring-purple-600"
|
| 213 |
+
placeholder="What to exclude from the output..."></textarea>
|
| 214 |
+
</div>
|
| 215 |
`;
|
| 216 |
}
|
| 217 |
+
if (this.activeTab === 'face-swap-image' || this.activeTab === 'face-swap-video') {
|
|
|
|
| 218 |
options = `
|
| 219 |
<div class="mb-4">
|
| 220 |
<label class="block text-sm font-medium text-gray-400 mb-2">Target Face</label>
|
|
|
|
| 266 |
</select>
|
| 267 |
</div>
|
| 268 |
</div>
|
| 269 |
+
<div class="mt-2 md:mt-4 grid grid-cols-1 md:grid-cols-2 gap-4">
|
| 270 |
+
<label class="inline-flex items-center">
|
| 271 |
<input type="checkbox" class="rounded bg-gray-900 border-gray-700 text-purple-600 focus:ring-purple-600">
|
| 272 |
<span class="ml-2 text-sm text-gray-400">Smooth transitions between frames</span>
|
| 273 |
</label>
|
| 274 |
+
<label class="inline-flex items-center">
|
| 275 |
+
<input type="checkbox" class="rounded bg-gray-900 border-gray-700 text-purple-600 focus:ring-purple-600">
|
| 276 |
+
<span class="ml-2 text-sm text-gray-400">Preserve original colors</span>
|
| 277 |
+
</label>
|
| 278 |
</div>
|
| 279 |
+
`;
|
| 280 |
}
|
| 281 |
|
| 282 |
return `
|
index.html
CHANGED
|
@@ -16,10 +16,18 @@
|
|
| 16 |
<link rel="stylesheet" href="style.css">
|
| 17 |
</head>
|
| 18 |
<body class="bg-gray-900 text-white min-h-screen">
|
| 19 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
<script src="components/media-wizard.js"></script>
|
| 22 |
-
<script>
|
|
|
|
| 23 |
feather.replace();
|
| 24 |
</script>
|
| 25 |
<script src="https://huggingface.co/deepsite/deepsite-badge.js"></script>
|
|
|
|
| 16 |
<link rel="stylesheet" href="style.css">
|
| 17 |
</head>
|
| 18 |
<body class="bg-gray-900 text-white min-h-screen">
|
| 19 |
+
<div class="container mx-auto px-4 py-8 grid grid-cols-1 lg:grid-cols-4 gap-8">
|
| 20 |
+
<div class="lg:col-span-3">
|
| 21 |
+
<media-wizard></media-wizard>
|
| 22 |
+
</div>
|
| 23 |
+
<div class="lg:col-span-1">
|
| 24 |
+
<history-panel></history-panel>
|
| 25 |
+
</div>
|
| 26 |
+
</div>
|
| 27 |
|
| 28 |
<script src="components/media-wizard.js"></script>
|
| 29 |
+
<script src="components/history-panel.js"></script>
|
| 30 |
+
<script>
|
| 31 |
feather.replace();
|
| 32 |
</script>
|
| 33 |
<script src="https://huggingface.co/deepsite/deepsite-badge.js"></script>
|
style.css
CHANGED
|
@@ -17,12 +17,12 @@ body {
|
|
| 17 |
border: 2px dashed rgba(255, 255, 255, 0.3);
|
| 18 |
transition: all 0.3s ease;
|
| 19 |
}
|
| 20 |
-
|
| 21 |
.dropzone.active {
|
| 22 |
border-color: var(--primary);
|
| 23 |
background-color: rgba(139, 92, 246, 0.1);
|
|
|
|
|
|
|
| 24 |
}
|
| 25 |
-
|
| 26 |
.tooltip {
|
| 27 |
position: relative;
|
| 28 |
}
|
|
|
|
| 17 |
border: 2px dashed rgba(255, 255, 255, 0.3);
|
| 18 |
transition: all 0.3s ease;
|
| 19 |
}
|
|
|
|
| 20 |
.dropzone.active {
|
| 21 |
border-color: var(--primary);
|
| 22 |
background-color: rgba(139, 92, 246, 0.1);
|
| 23 |
+
transform: scale(1.01);
|
| 24 |
+
box-shadow: 0 0 20px rgba(139, 92, 246, 0.2);
|
| 25 |
}
|
|
|
|
| 26 |
.tooltip {
|
| 27 |
position: relative;
|
| 28 |
}
|