Spaces:
Sleeping
Sleeping
Update client/src/App.jsx
Browse files- client/src/App.jsx +61 -66
client/src/App.jsx
CHANGED
|
@@ -3,15 +3,13 @@ import { createClient } from '@supabase/supabase-js';
|
|
| 3 |
|
| 4 |
// --- CONFIG ---
|
| 5 |
const SUPABASE_URL = "https://whpciwshxecjvalksicw.supabase.co";
|
| 6 |
-
const SUPABASE_ANON_KEY = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6IndocGNpd3NoeGVjanZhbGtzaWN3Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzAxNDQyNjYsImV4cCI6MjA4NTcyMDI2Nn0.TwWAlQCUstvGykPhaDhPAVpTyg2MV7eltG7JFvjZ-zU"; // <---
|
| 7 |
|
| 8 |
const supabase = createClient(SUPABASE_URL, SUPABASE_ANON_KEY);
|
| 9 |
|
| 10 |
-
// Currently supported models via Puter (we default to Flux for images)
|
| 11 |
const AI_MODELS = [
|
| 12 |
-
{ id: 'flux-schnell', name: 'FLUX.1 (
|
| 13 |
-
{ id: 'flux-dev', name: 'FLUX.1 (
|
| 14 |
-
{ id: 'sdxl', name: 'SDXL Turbo', type: 'image' }
|
| 15 |
];
|
| 16 |
|
| 17 |
function App() {
|
|
@@ -35,14 +33,12 @@ function App() {
|
|
| 35 |
const handleGenerate = async () => {
|
| 36 |
if (!prompt) return;
|
| 37 |
setGenerating(true);
|
|
|
|
|
|
|
|
|
|
| 38 |
try {
|
| 39 |
if (!window.puter.auth.isSignedIn()) await window.puter.auth.signIn();
|
| 40 |
-
|
| 41 |
-
// Note: Puter.js currently auto-routes to best model, but passing model params
|
| 42 |
-
// is possible in their lower-level API. For this UI, we just simulate the selection
|
| 43 |
-
// to show you where it would go.
|
| 44 |
const imgElement = await window.puter.ai.txt2img(prompt);
|
| 45 |
-
|
| 46 |
setImageSrc(imgElement.src);
|
| 47 |
} catch (e) {
|
| 48 |
alert("Error: " + e.message);
|
|
@@ -51,109 +47,108 @@ function App() {
|
|
| 51 |
}
|
| 52 |
};
|
| 53 |
|
| 54 |
-
// --- LOGIN SCREEN
|
| 55 |
if (!session) {
|
| 56 |
return (
|
| 57 |
<div style={{
|
| 58 |
height: '100vh', display: 'flex', flexDirection: 'column',
|
| 59 |
alignItems: 'center', justifyContent: 'center',
|
| 60 |
-
background: 'radial-gradient(circle at center, #
|
|
|
|
| 61 |
}}>
|
| 62 |
-
{/* Pixel Art Icon Placeholder */}
|
| 63 |
-
<div style={{fontSize: '60px', marginBottom: '20px'}} className="pixel-avatar">👾</div>
|
| 64 |
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
<p style={{marginBottom: '20px', color: '#aaa'}}>ENTER THE GRID</p>
|
| 69 |
-
<button onClick={handleLogin} style={{padding: '16px 40px', fontSize: '1.2rem'}}>
|
| 70 |
-
START_GAME
|
| 71 |
-
</button>
|
| 72 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
</div>
|
| 74 |
);
|
| 75 |
}
|
| 76 |
|
| 77 |
-
// ---
|
| 78 |
return (
|
| 79 |
<div style={{
|
| 80 |
-
minHeight: '100vh',
|
| 81 |
-
|
| 82 |
-
maxWidth: '100%', margin: '0 auto',
|
| 83 |
-
position: 'relative',
|
| 84 |
-
paddingBottom: '120px' // Space for bottom bar
|
| 85 |
}}>
|
| 86 |
|
| 87 |
{/* HEADER */}
|
| 88 |
<div style={{
|
| 89 |
-
padding: '20px', display: 'flex', justifyContent: 'space-between', alignItems: 'center',
|
| 90 |
-
background: 'rgba(0,0,0,0.
|
| 91 |
-
position: 'sticky', top: 0, zIndex: 10
|
| 92 |
}}>
|
| 93 |
-
<div style={{
|
| 94 |
-
<span style={{
|
| 95 |
-
<span style={{fontWeight: 'bold', fontSize: '1.2rem'}}>FLUX_GEN</span>
|
| 96 |
</div>
|
| 97 |
|
| 98 |
-
{/* Model Dropdown (Glass) */}
|
| 99 |
<select
|
| 100 |
value={selectedModel}
|
| 101 |
onChange={(e) => setSelectedModel(e.target.value)}
|
| 102 |
-
style={{
|
| 103 |
-
padding: '8px 16px', fontSize: '0.8rem',
|
| 104 |
-
background: 'rgba(255,255,255,0.1)', border: '1px solid rgba(255,255,255,0.2)'
|
| 105 |
-
}}
|
| 106 |
>
|
| 107 |
{AI_MODELS.map(m => <option key={m.id} value={m.id} style={{color:'black'}}>{m.name}</option>)}
|
| 108 |
</select>
|
| 109 |
</div>
|
| 110 |
|
| 111 |
-
{/* VIEWPORT (
|
| 112 |
-
<div style={{
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
<div className="glass-panel" style={{padding: '10px', borderRadius: '16px', maxWidth: '100%'}}>
|
| 118 |
<img src={imageSrc} alt="Generated" style={{width: '100%', borderRadius: '8px', display: 'block'}} />
|
| 119 |
</div>
|
| 120 |
) : (
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
<
|
|
|
|
| 124 |
</div>
|
| 125 |
)}
|
| 126 |
</div>
|
| 127 |
|
| 128 |
-
{/* INPUT DOCK
|
| 129 |
<div style={{
|
| 130 |
position: 'fixed', bottom: 0, left: 0, right: 0,
|
| 131 |
-
padding: '15px 20px 30px 20px',
|
| 132 |
-
background: 'linear-gradient(to top, #
|
| 133 |
-
display: 'flex', alignItems: 'flex-end', gap: '10px',
|
| 134 |
-
zIndex: 20
|
| 135 |
}}>
|
| 136 |
<textarea
|
| 137 |
-
value={prompt}
|
| 138 |
-
|
| 139 |
-
placeholder="COMMAND: Generate a pixel art city..."
|
| 140 |
-
rows="1"
|
| 141 |
style={{
|
| 142 |
-
flex: 1, padding: '
|
| 143 |
-
|
| 144 |
-
borderRadius: '25px' // Pill shape input
|
| 145 |
}}
|
| 146 |
/>
|
| 147 |
-
|
| 148 |
<button
|
| 149 |
-
onClick={handleGenerate}
|
| 150 |
-
disabled={generating}
|
| 151 |
style={{
|
| 152 |
-
height: '
|
| 153 |
display: 'flex', alignItems: 'center', justifyContent: 'center',
|
| 154 |
-
background: generating ? '#333' : '#55ff55'
|
| 155 |
-
color: generating ? '#666' : 'black',
|
| 156 |
-
boxShadow: generating ? 'none' : '0 0 20px rgba(85,255,85,0.4)'
|
| 157 |
}}
|
| 158 |
>
|
| 159 |
{generating ? '...' : '▶'}
|
|
|
|
| 3 |
|
| 4 |
// --- CONFIG ---
|
| 5 |
const SUPABASE_URL = "https://whpciwshxecjvalksicw.supabase.co";
|
| 6 |
+
const SUPABASE_ANON_KEY = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6IndocGNpd3NoeGVjanZhbGtzaWN3Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzAxNDQyNjYsImV4cCI6MjA4NTcyMDI2Nn0.TwWAlQCUstvGykPhaDhPAVpTyg2MV7eltG7JFvjZ-zU"; // <--- PASTE KEY HERE
|
| 7 |
|
| 8 |
const supabase = createClient(SUPABASE_URL, SUPABASE_ANON_KEY);
|
| 9 |
|
|
|
|
| 10 |
const AI_MODELS = [
|
| 11 |
+
{ id: 'flux-schnell', name: 'FLUX.1 (Fast)', type: 'image' },
|
| 12 |
+
{ id: 'flux-dev', name: 'FLUX.1 (HD)', type: 'image' },
|
|
|
|
| 13 |
];
|
| 14 |
|
| 15 |
function App() {
|
|
|
|
| 33 |
const handleGenerate = async () => {
|
| 34 |
if (!prompt) return;
|
| 35 |
setGenerating(true);
|
| 36 |
+
// Clear previous image so we can see the bear
|
| 37 |
+
setImageSrc(null);
|
| 38 |
+
|
| 39 |
try {
|
| 40 |
if (!window.puter.auth.isSignedIn()) await window.puter.auth.signIn();
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
const imgElement = await window.puter.ai.txt2img(prompt);
|
|
|
|
| 42 |
setImageSrc(imgElement.src);
|
| 43 |
} catch (e) {
|
| 44 |
alert("Error: " + e.message);
|
|
|
|
| 47 |
}
|
| 48 |
};
|
| 49 |
|
| 50 |
+
// --- LOGIN SCREEN ---
|
| 51 |
if (!session) {
|
| 52 |
return (
|
| 53 |
<div style={{
|
| 54 |
height: '100vh', display: 'flex', flexDirection: 'column',
|
| 55 |
alignItems: 'center', justifyContent: 'center',
|
| 56 |
+
background: 'radial-gradient(circle at center, #1a1a1a 0%, #000 100%)',
|
| 57 |
+
padding: '20px', textAlign: 'center'
|
| 58 |
}}>
|
|
|
|
|
|
|
| 59 |
|
| 60 |
+
{/* BRANDING */}
|
| 61 |
+
<div className="logo-glass">
|
| 62 |
+
<div className="logo-text">TEK IMAGE GEN</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
</div>
|
| 64 |
+
<div className="sub-brand">TEKTREY BUILDs</div>
|
| 65 |
+
|
| 66 |
+
{/* INFO TEXT */}
|
| 67 |
+
<p style={{
|
| 68 |
+
color: '#888', fontSize: '0.85rem', maxWidth: '300px',
|
| 69 |
+
lineHeight: '1.4', marginBottom: '30px', fontFamily: 'monospace'
|
| 70 |
+
}}>
|
| 71 |
+
Generate images unlimitedly but consider 3 every 5mins. Enjoy.
|
| 72 |
+
</p>
|
| 73 |
+
|
| 74 |
+
{/* THE DREAM BUTTON */}
|
| 75 |
+
<button onClick={handleLogin} style={{padding: '18px 50px', fontSize: '1.2rem'}}>
|
| 76 |
+
LET'S DREAM
|
| 77 |
+
</button>
|
| 78 |
</div>
|
| 79 |
);
|
| 80 |
}
|
| 81 |
|
| 82 |
+
// --- GENERATION HUB ---
|
| 83 |
return (
|
| 84 |
<div style={{
|
| 85 |
+
minHeight: '100vh', display: 'flex', flexDirection: 'column',
|
| 86 |
+
maxWidth: '100%', margin: '0 auto', paddingBottom: '120px'
|
|
|
|
|
|
|
|
|
|
| 87 |
}}>
|
| 88 |
|
| 89 |
{/* HEADER */}
|
| 90 |
<div style={{
|
| 91 |
+
padding: '15px 20px', display: 'flex', justifyContent: 'space-between', alignItems: 'center',
|
| 92 |
+
background: 'rgba(0,0,0,0.6)', backdropFilter: 'blur(10px)',
|
| 93 |
+
position: 'sticky', top: 0, zIndex: 10, borderBottom: '1px solid #333'
|
| 94 |
}}>
|
| 95 |
+
<div className="logo-glass" style={{padding: '5px 15px', borderRadius: '8px', marginBottom: 0, animation: 'none'}}>
|
| 96 |
+
<span style={{fontSize: '0.9rem', fontWeight: 'bold', color: 'white'}}>TEK IMAGE GEN</span>
|
|
|
|
| 97 |
</div>
|
| 98 |
|
|
|
|
| 99 |
<select
|
| 100 |
value={selectedModel}
|
| 101 |
onChange={(e) => setSelectedModel(e.target.value)}
|
| 102 |
+
style={{padding: '8px', fontSize: '0.8rem', width: '120px'}}
|
|
|
|
|
|
|
|
|
|
| 103 |
>
|
| 104 |
{AI_MODELS.map(m => <option key={m.id} value={m.id} style={{color:'black'}}>{m.name}</option>)}
|
| 105 |
</select>
|
| 106 |
</div>
|
| 107 |
|
| 108 |
+
{/* VIEWPORT (BEAR vs IMAGE) */}
|
| 109 |
+
<div style={{flex: 1, display: 'flex', alignItems: 'center', justifyContent: 'center', padding: '20px', flexDirection: 'column'}}>
|
| 110 |
+
|
| 111 |
+
{generating ? (
|
| 112 |
+
/* 🐻 THE DANCING BEAR 🐻 */
|
| 113 |
+
<div style={{textAlign: 'center'}}>
|
| 114 |
+
<div className="dancing-bear">🐻</div>
|
| 115 |
+
<p style={{marginTop: '20px', color: '#55ff55', letterSpacing: '2px', animation: 'pulse 1s infinite'}}>DREAMING...</p>
|
| 116 |
+
</div>
|
| 117 |
+
) : imageSrc ? (
|
| 118 |
+
/* THE RESULT */
|
| 119 |
<div className="glass-panel" style={{padding: '10px', borderRadius: '16px', maxWidth: '100%'}}>
|
| 120 |
<img src={imageSrc} alt="Generated" style={{width: '100%', borderRadius: '8px', display: 'block'}} />
|
| 121 |
</div>
|
| 122 |
) : (
|
| 123 |
+
/* EMPTY STATE */
|
| 124 |
+
<div style={{textAlign: 'center', opacity: 0.3}}>
|
| 125 |
+
<div style={{fontSize: '50px', marginBottom: '10px'}}>❖</div>
|
| 126 |
+
<p>READY FOR INPUT</p>
|
| 127 |
</div>
|
| 128 |
)}
|
| 129 |
</div>
|
| 130 |
|
| 131 |
+
{/* INPUT DOCK */}
|
| 132 |
<div style={{
|
| 133 |
position: 'fixed', bottom: 0, left: 0, right: 0,
|
| 134 |
+
padding: '15px 20px 30px 20px',
|
| 135 |
+
background: 'linear-gradient(to top, #000 90%, transparent)',
|
| 136 |
+
display: 'flex', alignItems: 'flex-end', gap: '10px', zIndex: 20
|
|
|
|
| 137 |
}}>
|
| 138 |
<textarea
|
| 139 |
+
value={prompt} onChange={e => setPrompt(e.target.value)}
|
| 140 |
+
placeholder="COMMAND: Cyberpunk street..."
|
|
|
|
|
|
|
| 141 |
style={{
|
| 142 |
+
flex: 1, padding: '15px', fontSize: '16px', height: '50px',
|
| 143 |
+
borderRadius: '25px', resize: 'none'
|
|
|
|
| 144 |
}}
|
| 145 |
/>
|
|
|
|
| 146 |
<button
|
| 147 |
+
onClick={handleGenerate} disabled={generating}
|
|
|
|
| 148 |
style={{
|
| 149 |
+
height: '54px', width: '54px', borderRadius: '50%',
|
| 150 |
display: 'flex', alignItems: 'center', justifyContent: 'center',
|
| 151 |
+
background: generating ? '#333' : '#55ff55'
|
|
|
|
|
|
|
| 152 |
}}
|
| 153 |
>
|
| 154 |
{generating ? '...' : '▶'}
|