mrkeyiano commited on
Commit
ff30aae
·
1 Parent(s): c6378ba

ui changes

Browse files
Files changed (1) hide show
  1. app.py +88 -96
app.py CHANGED
@@ -74,95 +74,99 @@ def validate_license_key(license_key):
74
  content_html = """
75
  <div style="text-align: center; margin-top: 30px;">
76
  <h2 style="font-size: 24px; margin-bottom: 20px;">Slidegen Examples</h2>
77
- <div style="display: flex; justify-content: space-between; align-items: flex-start; margin: 20px auto; max-width: 90%;">
78
- <!-- Portrait video on the left -->
79
- <div style="width: 30%; padding-right: 20px;">
80
- <video controls style="width: 100%; border-radius: 8px; box-shadow: 0 4px 8px rgba(0,0,0,0.2);">
81
- <source src="https://cdn-uploads.huggingface.co/production/uploads/644252f59a5bbb07ab7a987a/IxuuqPhmIX3Jggqkeiseb.mp4" type="video/mp4">
82
- Your browser does not support the video tag.
83
- </video>
84
- <p style="margin-top: 10px; font-size: 14px; color: #666;">Mobile Portrait Layout</p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
  </div>
86
 
87
- <!-- Grid of images on the right -->
88
- <div style="width: 65%; display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px;">
89
- <!-- Actual images -->
90
- <div style="width: 100%;">
91
- <img src="https://cdn-uploads.huggingface.co/production/uploads/644252f59a5bbb07ab7a987a/f4xH6ZNx1rVbKzr8jAHmt.png" alt="Square Layout" style="width: 100%; border-radius: 8px; box-shadow: 0 4px 8px rgba(0,0,0,0.2);">
92
- <p style="margin-top: 5px; font-size: 14px; color: #666;">Square Layout</p>
 
 
93
  </div>
94
 
95
- <div style="width: 100%;">
96
- <img src="https://cdn-uploads.huggingface.co/production/uploads/644252f59a5bbb07ab7a987a/A9BoWW2ulZycv0OQaihKO.png" alt="Mobile Landscape" style="width: 100%; border-radius: 8px; box-shadow: 0 4px 8px rgba(0,0,0,0.2);">
97
- <p style="margin-top: 5px; font-size: 14px; color: #666;">Mobile Landscape</p>
 
 
 
98
  </div>
99
 
100
- <!-- Placeholder for Screenshot layout -->
101
- <div style="width: 100%;">
102
- <div style="width: 100%; height: 0; padding-bottom: 62.5%; background-color: #f0f0f0; border-radius: 8px; position: relative; box-shadow: 0 4px 8px rgba(0,0,0,0.1);">
103
- <div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); text-align: center;">
104
- <div style="width: 50px; height: 50px; margin: 0 auto 10px; border-radius: 50%; background-color: #ddd; display: flex; align-items: center; justify-content: center;">
105
- <span style="font-size: 24px; color: #888;">+</span>
106
- </div>
107
- <p style="margin: 0; font-size: 14px; color: #888;">Screenshot Layout</p>
108
- </div>
109
  </div>
110
- <p style="margin-top: 5px; font-size: 14px; color: #666;">Screenshots (1280x800)</p>
111
  </div>
112
 
113
- <!-- Placeholder for Custom layout -->
114
- <div style="width: 100%;">
115
- <div style="width: 100%; height: 0; padding-bottom: 62.5%; background-color: #f0f0f0; border-radius: 8px; position: relative; box-shadow: 0 4px 8px rgba(0,0,0,0.1);">
116
- <div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); text-align: center;">
117
- <div style="width: 50px; height: 50px; margin: 0 auto 10px; border-radius: 50%; background-color: #ddd; display: flex; align-items: center; justify-content: center;">
118
- <span style="font-size: 24px; color: #888;">+</span>
119
- </div>
120
- <p style="margin: 0; font-size: 14px; color: #888;">Custom Layout</p>
121
- </div>
122
  </div>
123
- <p style="margin-top: 5px; font-size: 14px; color: #666;">Custom Size</p>
124
  </div>
125
 
126
- <!-- Placeholder for Instagram layout -->
127
- <div style="width: 100%;">
128
- <div style="width: 100%; height: 0; padding-bottom: 62.5%; background-color: #f0f0f0; border-radius: 8px; position: relative; box-shadow: 0 4px 8px rgba(0,0,0,0.1);">
129
- <div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); text-align: center;">
130
- <div style="width: 50px; height: 50px; margin: 0 auto 10px; border-radius: 50%; background-color: #ddd; display: flex; align-items: center; justify-content: center;">
131
- <span style="font-size: 24px; color: #888;">+</span>
132
- </div>
133
- <p style="margin: 0; font-size: 14px; color: #888;">Instagram</p>
134
- </div>
135
  </div>
136
- <p style="margin-top: 5px; font-size: 14px; color: #666;">Instagram Story (1080x1920)</p>
137
  </div>
138
 
139
- <!-- Placeholder for Twitter layout -->
140
- <div style="width: 100%;">
141
- <div style="width: 100%; height: 0; padding-bottom: 62.5%; background-color: #f0f0f0; border-radius: 8px; position: relative; box-shadow: 0 4px 8px rgba(0,0,0,0.1);">
142
- <div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); text-align: center;">
143
- <div style="width: 50px; height: 50px; margin: 0 auto 10px; border-radius: 50%; background-color: #ddd; display: flex; align-items: center; justify-content: center;">
144
- <span style="font-size: 24px; color: #888;">+</span>
145
- </div>
146
- <p style="margin: 0; font-size: 14px; color: #888;">Twitter</p>
147
- </div>
148
  </div>
149
- <p style="margin-top: 5px; font-size: 14px; color: #666;">Twitter Post (1200x675)</p>
150
  </div>
151
 
152
- <!-- Placeholder for Tablet layout -->
153
- <div style="width: 100%;">
154
- <div style="width: 100%; height: 0; padding-bottom: 70%; background-color: #f0f0f0; border-radius: 8px; position: relative; box-shadow: 0 4px 8px rgba(0,0,0,0.1);">
155
- <div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); text-align: center;">
156
- <div style="width: 50px; height: 50px; margin: 0 auto 10px; border-radius: 50%; background-color: #ddd; display: flex; align-items: center; justify-content: center;">
157
- <span style="font-size: 24px; color: #888;">+</span>
158
- </div>
159
- <p style="margin: 0; font-size: 14px; color: #888;">Tablet</p>
160
- </div>
161
  </div>
162
- <p style="margin-top: 5px; font-size: 14px; color: #666;">Tablet (2280x1600)</p>
163
  </div>
164
  </div>
165
  </div>
 
166
  <p style="margin-top: 20px; font-size: 16px; color: #666;">Choose a layout that suits your needs from the examples above</p>
167
  </div>
168
  """
@@ -224,25 +228,6 @@ Feature Image Background Color (Optional): i.e #008000
224
  """
225
 
226
 
227
- # Escape default_value for JavaScript
228
- escaped_default_value = default_value.replace('\n', '\\n').replace('\'', '\\\'')
229
- js = f'''
230
-
231
- function js() {{
232
-
233
- // let default_value = '{escaped_default_value}';
234
- window.set_cookie = function(key, value) {{
235
- // if (!key || !value || value.length < 20) {{
236
- // console.log("Cannot set cookie, key or value is undefined or null", key, value);
237
- // console.log("default value set to: ", default_value);
238
- // return [default_value];
239
- // }}
240
- // document.cookie = key + '=' + value + '; Path=/; SameSite=Strict';
241
- // return [value];
242
- }}
243
- }}
244
- '''
245
-
246
  # Custom CSS for dark background
247
  css = """
248
  body {
@@ -280,6 +265,12 @@ body {
280
  margin-top: 16px;
281
  margin-bottom: 3px;
282
  }
 
 
 
 
 
 
283
  """
284
 
285
 
@@ -306,7 +297,7 @@ def get_config(request: Request):
306
  return config['campaign_details']
307
 
308
 
309
- with gr.Blocks(analytics_enabled=False, js=js, css=css, title="Slidegen AI - Image generator") as iface:
310
  gr.Markdown("# Slidegen AI - Image generator")
311
  gr.Markdown("Generate social media creatives from a few prompts")
312
 
@@ -318,12 +309,12 @@ with gr.Blocks(analytics_enabled=False, js=js, css=css, title="Slidegen AI - Ima
318
  label="Campaign Details",
319
  value=default_value
320
  )
321
-
 
322
  campaign_details_input.change(
323
- fn=None,
324
  inputs=campaign_details_input,
325
- outputs=[],
326
- js="(value) => { console.log('Setting cookie:', value); set_cookie('campaign_details', value); }"
327
  )
328
 
329
  submit_btn = gr.Button("Generate Image")
@@ -335,23 +326,24 @@ with gr.Blocks(analytics_enabled=False, js=js, css=css, title="Slidegen AI - Ima
335
  # Center-aligned license key section with bottom margin
336
  with gr.Group(elem_classes=["license-section"]):
337
  license_key_input = gr.Textbox(
338
- placeholder="Enter your license key (email address used for payment)",
339
  label="License Key (optional for first 5 images)"
340
  )
341
 
342
  # Center the button using Row and Columns
343
  with gr.Row(elem_classes=["license-button-row"]):
344
- with gr.Column(scale=1):
345
  # Empty column for spacing
346
  pass
347
- with gr.Column(scale=1):
348
  validate_btn = gr.Button("Validate")
349
- with gr.Column(scale=1):
350
  # Empty column for spacing
351
  pass
352
 
353
  license_key_status = gr.Markdown("You can generate 5 free images without a license key.", elem_classes=["license-status", "center-text"])
354
  gr.Markdown(f"Need more images? [Purchase a license key]({STRIPE_PAYMENT_LINK}) for 50 images.", elem_classes=["center-text", "license-bottom"])
 
355
 
356
  # Set up the validation button click event
357
  validate_btn.click(
@@ -370,7 +362,7 @@ with gr.Blocks(analytics_enabled=False, js=js, css=css, title="Slidegen AI - Ima
370
  # Add examples section
371
  gr.HTML(content_html)
372
 
373
- #iface.load(fn=get_config, outputs=campaign_details_input, js=js)
374
 
375
 
376
  iface.launch(show_error=True)
 
74
  content_html = """
75
  <div style="text-align: center; margin-top: 30px;">
76
  <h2 style="font-size: 24px; margin-bottom: 20px;">Slidegen Examples</h2>
77
+
78
+ <!-- Wrapper with responsive styles -->
79
+ <style>
80
+ @media (max-width: 768px) {
81
+ .slidegen-container {
82
+ flex-direction: column-reverse !important;
83
+ }
84
+ .video-container {
85
+ margin-right: 0 !important;
86
+ margin-top: 25px !important;
87
+ width: 100% !important;
88
+ max-width: 300px !important;
89
+ margin-left: auto !important;
90
+ margin-right: auto !important;
91
+ }
92
+ .carousel-container {
93
+ width: 100% !important;
94
+ }
95
+ }
96
+ </style>
97
+
98
+ <div style="margin: 20px auto; max-width: 95%; position: relative; display: flex; align-items: flex-start;" class="slidegen-container">
99
+ <!-- Stationary Tutorial Video on the left (on desktop) or bottom (on mobile) -->
100
+ <div style="flex: 0 0 180px; margin-right: 25px;" class="video-container">
101
+ <div style="height: 220px; display: flex; align-items: center; justify-content: center; margin-bottom: 5px;">
102
+ <video controls controlsList="nodownload" playsinline style="max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; box-shadow: 0 2px 4px rgba(0,0,0,0.1);">
103
+ <source src="https://cdn-uploads.huggingface.co/production/uploads/644252f59a5bbb07ab7a987a/IxuuqPhmIX3Jggqkeiseb.mp4" type="video/mp4">
104
+ Your browser does not support the video tag.
105
+ </video>
106
+ </div>
107
+ <p style="margin-top: 5px; font-size: 14px; color: #666; text-align: center;">Tutorial Video</p>
108
  </div>
109
 
110
+ <!-- Scrollable carousel container for other items -->
111
+ <div style="flex: 1; overflow-x: auto; white-space: nowrap; padding: 0; scrollbar-width: thin; scrollbar-color: #4a5568 #1a2438;" class="carousel-container">
112
+ <!-- Screenshots (1280x800) -->
113
+ <div style="display: inline-block; vertical-align: top; margin-right: 25px; width: 280px;">
114
+ <div style="height: 220px; display: flex; align-items: center; justify-content: center; margin-bottom: 5px;">
115
+ <img src="https://res.cloudinary.com/dol2onsxl/image/upload/v1745556423/Slidegen/bgpt-faveimage_20241230061609_nbrjb5.png" alt="Screenshot Layout" style="max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; box-shadow: 0 2px 4px rgba(0,0,0,0.1);">
116
+ </div>
117
+ <p style="margin-top: 5px; font-size: 14px; color: #666; text-align: center;">Screenshots (1280x800)</p>
118
  </div>
119
 
120
+ <!-- Square Layout -->
121
+ <div style="display: inline-block; vertical-align: top; margin-right: 25px; width: 220px;">
122
+ <div style="height: 220px; display: flex; align-items: center; justify-content: center; margin-bottom: 5px;">
123
+ <img src="https://cdn-uploads.huggingface.co/production/uploads/644252f59a5bbb07ab7a987a/f4xH6ZNx1rVbKzr8jAHmt.png" alt="Square Layout" style="max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; box-shadow: 0 2px 4px rgba(0,0,0,0.1);">
124
+ </div>
125
+ <p style="margin-top: 5px; font-size: 14px; color: #666; text-align: center;">Square Layout</p>
126
  </div>
127
 
128
+ <!-- Custom Size -->
129
+ <div style="display: inline-block; vertical-align: top; margin-right: 25px; width: 280px;">
130
+ <div style="height: 220px; display: flex; align-items: center; justify-content: center; margin-bottom: 5px;">
131
+ <img src="https://res.cloudinary.com/dol2onsxl/image/upload/v1745556411/Slidegen/exploring-host-cities_lp6dy8.png" alt="Custom Layout" style="max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; box-shadow: 0 2px 4px rgba(0,0,0,0.1);">
 
 
 
 
 
132
  </div>
133
+ <p style="margin-top: 5px; font-size: 14px; color: #666; text-align: center;">Custom Size</p>
134
  </div>
135
 
136
+ <!-- Mobile Landscape -->
137
+ <div style="display: inline-block; vertical-align: top; margin-right: 25px; width: 280px;">
138
+ <div style="height: 220px; display: flex; align-items: center; justify-content: center; margin-bottom: 5px;">
139
+ <img src="https://cdn-uploads.huggingface.co/production/uploads/644252f59a5bbb07ab7a987a/A9BoWW2ulZycv0OQaihKO.png" alt="Mobile Landscape" style="max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; box-shadow: 0 2px 4px rgba(0,0,0,0.1);">
 
 
 
 
 
140
  </div>
141
+ <p style="margin-top: 5px; font-size: 14px; color: #666; text-align: center;">Mobile Landscape</p>
142
  </div>
143
 
144
+ <!-- Twitter Post -->
145
+ <div style="display: inline-block; vertical-align: top; margin-right: 25px; width: 220px;">
146
+ <div style="height: 220px; display: flex; align-items: center; justify-content: center; margin-bottom: 5px;">
147
+ <img src="https://res.cloudinary.com/dol2onsxl/image/upload/v1745556418/Slidegen/browsergpt-cartoon-ad_xodysb.png" alt="Twitter Layout" style="max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; box-shadow: 0 2px 4px rgba(0,0,0,0.1);">
 
 
 
 
 
148
  </div>
149
+ <p style="margin-top: 5px; font-size: 14px; color: #666; text-align: center;">Twitter Post (1200x675)</p>
150
  </div>
151
 
152
+ <!-- Landscape Article Image -->
153
+ <div style="display: inline-block; vertical-align: top; margin-right: 25px; width: 280px;">
154
+ <div style="height: 220px; display: flex; align-items: center; justify-content: center; margin-bottom: 5px;">
155
+ <img src="https://res.cloudinary.com/dol2onsxl/image/upload/v1745558123/Slidegen/article_image_1745215220129_32yqnq_ldeyft.png" alt="Landscape Layout" style="max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; box-shadow: 0 2px 4px rgba(0,0,0,0.1);">
 
 
 
 
 
156
  </div>
157
+ <p style="margin-top: 5px; font-size: 14px; color: #666; text-align: center;">Landscape Article Image</p>
158
  </div>
159
 
160
+ <!-- Landscape Layout -->
161
+ <div style="display: inline-block; vertical-align: top; margin-right: 25px; width: 280px;">
162
+ <div style="height: 220px; display: flex; align-items: center; justify-content: center; margin-bottom: 5px;">
163
+ <img src="https://res.cloudinary.com/dol2onsxl/image/upload/v1745558119/Slidegen/1692111223459-153ucd_hibeys.png" alt="Landscape Layout" style="max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; box-shadow: 0 2px 4px rgba(0,0,0,0.1);">
 
 
 
 
 
164
  </div>
165
+ <p style="margin-top: 5px; font-size: 14px; color: #666; text-align: center;">Landscape Layout</p>
166
  </div>
167
  </div>
168
  </div>
169
+ <p style="margin-top: 15px; font-size: 14px; color: #888; text-align: center;">← Scroll horizontally to see more layouts →</p>
170
  <p style="margin-top: 20px; font-size: 16px; color: #666;">Choose a layout that suits your needs from the examples above</p>
171
  </div>
172
  """
 
228
  """
229
 
230
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
231
  # Custom CSS for dark background
232
  css = """
233
  body {
 
265
  margin-top: 16px;
266
  margin-bottom: 3px;
267
  }
268
+
269
+ /* Custom button width */
270
+ .license-button-row button {
271
+ width: 40% !important;
272
+ margin: 0 auto !important;
273
+ }
274
  """
275
 
276
 
 
297
  return config['campaign_details']
298
 
299
 
300
+ with gr.Blocks(css=css, title="Slidegen AI - Image generator") as iface:
301
  gr.Markdown("# Slidegen AI - Image generator")
302
  gr.Markdown("Generate social media creatives from a few prompts")
303
 
 
309
  label="Campaign Details",
310
  value=default_value
311
  )
312
+
313
+ # This JS approach doesn't work in Gradio 3.x, so we're using a simpler approach
314
  campaign_details_input.change(
315
+ fn=lambda x: x, # Just a simple identity function
316
  inputs=campaign_details_input,
317
+ outputs=campaign_details_input
 
318
  )
319
 
320
  submit_btn = gr.Button("Generate Image")
 
326
  # Center-aligned license key section with bottom margin
327
  with gr.Group(elem_classes=["license-section"]):
328
  license_key_input = gr.Textbox(
329
+ placeholder="Enter your license key",
330
  label="License Key (optional for first 5 images)"
331
  )
332
 
333
  # Center the button using Row and Columns
334
  with gr.Row(elem_classes=["license-button-row"]):
335
+ with gr.Column(scale=3):
336
  # Empty column for spacing
337
  pass
338
+ with gr.Column(scale=4):
339
  validate_btn = gr.Button("Validate")
340
+ with gr.Column(scale=3):
341
  # Empty column for spacing
342
  pass
343
 
344
  license_key_status = gr.Markdown("You can generate 5 free images without a license key.", elem_classes=["license-status", "center-text"])
345
  gr.Markdown(f"Need more images? [Purchase a license key]({STRIPE_PAYMENT_LINK}) for 50 images.", elem_classes=["center-text", "license-bottom"])
346
+ gr.Markdown("Each image generation uses 1 credit. Free tier gives 5 credits, license key provides 100 credits.", elem_classes=["center-text", "license-bottom"])
347
 
348
  # Set up the validation button click event
349
  validate_btn.click(
 
362
  # Add examples section
363
  gr.HTML(content_html)
364
 
365
+ #iface.load(fn=get_config, outputs=campaign_details_input)
366
 
367
 
368
  iface.launch(show_error=True)