prakashnayak commited on
Commit
6d14eef
·
verified ·
1 Parent(s): 57bf96a

Update gradioIf.py

Browse files
Files changed (1) hide show
  1. gradioIf.py +55 -29
gradioIf.py CHANGED
@@ -115,21 +115,41 @@ button[aria-label="Clear"] { display: none !important; }
115
  footer { display: none !important; }
116
  .gr-chatbot { max-height: 500px; overflow-y: auto; }
117
 
 
 
 
 
 
 
 
 
 
 
 
 
 
118
  #landing-hero img {
119
  display: block;
120
- margin-left: auto; /* align right edge in its column */
121
  margin-right: 0;
122
  max-width: 100%;
 
 
123
  height: auto;
124
  border-radius: 12px;
125
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
126
  }
127
 
128
- /* Markdown intro text styling */
129
- .mq-intro-text {
130
- font-size: 1.2em;
131
- line-height: 1.6;
132
  font-family: sans-serif;
 
 
 
 
 
133
  }
134
  """
135
 
@@ -154,7 +174,7 @@ with gr.Blocks(css=css, title="Orange Labs") as chatbotDisplay:
154
  <label for="volume-control">Volume</label>
155
  <input type="range" id="volume-control" min="0" max="1" step="0.01" value="1" style="width:140px;">
156
  </div>
157
- <div style="height: 56px;"></div>
158
 
159
  <script>
160
  (function() {
@@ -212,8 +232,8 @@ with gr.Blocks(css=css, title="Orange Labs") as chatbotDisplay:
212
  with gr.Tab("Main Menu", id=0):
213
  # Heading banner at top
214
  gr.HTML("""
215
- <div style="font-family: sans-serif; line-height: 1.6;">
216
- <h3 style="font-size: 1.8em; margin: 0.2em 0;">Welcome to CalmQuest</h3>
217
  </div>
218
  """)
219
 
@@ -233,27 +253,33 @@ with gr.Blocks(css=css, title="Orange Labs") as chatbotDisplay:
233
  if not GAME_PATHS:
234
  gr.Markdown("### No games found in `pathways/`. Add a folder with a JSON to get started.")
235
  else:
236
- # Create a vertical layout for each game with its description
237
- for folder_name, json_path in GAME_PATHS.items():
238
- meta_path = os.path.join("pathways", folder_name, "meta.txt")
239
- display_name = folder_name
240
- description = "Description not available."
241
-
242
- if os.path.isfile(meta_path):
243
- with open(meta_path, "r", encoding="utf-8") as meta_file:
244
- lines = [line.strip() for line in meta_file if line.strip()]
245
- if lines:
246
- display_name = lines[0]
247
- if len(lines) > 1:
248
- description = " ".join(lines[1:])
249
-
250
  with gr.Row():
251
- # Button to start the game
252
- btn = gr.Button(display_name)
253
- btn.click(open_game, [gr.State(folder_name)], [tabs])
254
-
255
- # Game description (larger font)
256
- gr.HTML(f"<div style='font-size: 1.2em; font-family: sans-serif;'><em>{description}</em></div>")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
257
 
258
  # -------- Game Tab --------
259
  with gr.Tab("Game", id=1) as game_tab:
@@ -284,7 +310,7 @@ with gr.Blocks(css=css, title="Orange Labs") as chatbotDisplay:
284
 
285
  input.submit(next_turn, [input, chatBot], [input, chatBot, stage_image, stage_video, submit_btn, back_to_main_btn])
286
  submit_btn.click(next_turn, [input, chatBot], [input, chatBot, stage_image, stage_video, submit_btn, back_to_main_btn])
287
- back_to_main_btn.click(lambda: gr.update(selected=0), None, tabs)
288
 
289
  # Close & launch
290
  chatbotDisplay.close(close_session)
 
115
  footer { display: none !important; }
116
  .gr-chatbot { max-height: 500px; overflow-y: auto; }
117
 
118
+ /* Tighten banner and intro text */
119
+ .mq-intro-text {
120
+ font-size: 1.1em; /* was 1.2em */
121
+ line-height: 1.45; /* was 1.6 */
122
+ font-family: sans-serif;
123
+ }
124
+
125
+ /* Smaller banner margins */
126
+ .mq-welcome h3 {
127
+ margin: 0.15em 0 0.35em 0;
128
+ }
129
+
130
+ /* Hero image */
131
  #landing-hero img {
132
  display: block;
133
+ margin-left: auto;
134
  margin-right: 0;
135
  max-width: 100%;
136
+ max-height: 240px; /* cap height to reduce whitespace */
137
+ object-fit: cover;
138
  height: auto;
139
  border-radius: 12px;
140
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
141
  }
142
 
143
+ /* Game card controls */
144
+ .game-btn { width: 100%; }
145
+ .game-desc {
146
+ font-size: 1.05em;
147
  font-family: sans-serif;
148
+ opacity: 0.9;
149
+ display: -webkit-box;
150
+ -webkit-line-clamp: 3; /* clamp to ~3 lines */
151
+ -webkit-box-orient: vertical;
152
+ overflow: hidden;
153
  }
154
  """
155
 
 
174
  <label for="volume-control">Volume</label>
175
  <input type="range" id="volume-control" min="0" max="1" step="0.01" value="1" style="width:140px;">
176
  </div>
177
+ <div style="height: 24px;"></div>
178
 
179
  <script>
180
  (function() {
 
232
  with gr.Tab("Main Menu", id=0):
233
  # Heading banner at top
234
  gr.HTML("""
235
+ <div class="mq-welcome" style="font-family: sans-serif; line-height: 1.6;">
236
+ <h3 style="font-size: 1.8em;">Welcome to CalmQuest</h3>
237
  </div>
238
  """)
239
 
 
253
  if not GAME_PATHS:
254
  gr.Markdown("### No games found in `pathways/`. Add a folder with a JSON to get started.")
255
  else:
256
+ # Two-column card layout (title button on top, description under)
257
+ items = list(GAME_PATHS.items()) # [(folder_name, json_path), ...]
258
+ for i in range(0, len(items), 2):
 
 
 
 
 
 
 
 
 
 
 
259
  with gr.Row():
260
+ for j in (i, i + 1):
261
+ if j >= len(items):
262
+ break
263
+ folder_name, _ = items[j]
264
+ meta_path = os.path.join("pathways", folder_name, "meta.txt")
265
+ display_name = folder_name
266
+ description = "Description not available."
267
+
268
+ if os.path.isfile(meta_path):
269
+ with open(meta_path, "r", encoding="utf-8") as meta_file:
270
+ lines = [line.strip() for line in meta_file if line.strip()]
271
+ if lines:
272
+ display_name = lines[0]
273
+ if len(lines) > 1:
274
+ description = " ".join(lines[1:])
275
+
276
+ with gr.Column():
277
+ # Title button on top
278
+ btn = gr.Button(display_name, elem_classes=["game-btn"])
279
+ btn.click(open_game, [gr.State(folder_name)], [tabs])
280
+
281
+ # Description under the title
282
+ gr.HTML(f"<div class='game-desc'><em>{description}</em></div>")
283
 
284
  # -------- Game Tab --------
285
  with gr.Tab("Game", id=1) as game_tab:
 
310
 
311
  input.submit(next_turn, [input, chatBot], [input, chatBot, stage_image, stage_video, submit_btn, back_to_main_btn])
312
  submit_btn.click(next_turn, [input, chatBot], [input, chatBot, stage_image, stage_video, submit_btn, back_to_main_btn])
313
+ back_to_main_btn.click(lambda: gr.update(selected=0), None, [tabs])
314
 
315
  # Close & launch
316
  chatbotDisplay.close(close_session)