Charlie Li commited on
Commit
4440a50
·
1 Parent(s): d7e1767

readability improvement

Browse files
Files changed (2) hide show
  1. app.py +105 -6
  2. style.css +71 -21
app.py CHANGED
@@ -141,6 +141,103 @@ def build_citation_html() -> str:
141
  """
142
 
143
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
144
  def build_motion_summary_html(motion_label: str) -> str:
145
  if not motion_label:
146
  motion_label = DEFAULT_MOTION
@@ -199,7 +296,7 @@ def build_model_card_head(model_key: str) -> str:
199
  """
200
 
201
 
202
- with gr.Blocks(title="MuscleMimic Research Space", css=CUSTOM_CSS) as app:
203
  gr.HTML(build_hero_html())
204
  gr.HTML(build_explorer_intro_html())
205
 
@@ -211,7 +308,6 @@ with gr.Blocks(title="MuscleMimic Research Space", css=CUSTOM_CSS) as app:
211
  info="Filter the KIT / KINESIS set by locomotion subtype.",
212
  elem_classes="mm-select",
213
  scale=1,
214
- min_width=280,
215
  )
216
  motion_dd = gr.Dropdown(
217
  choices=get_motions_by_category("All"),
@@ -220,7 +316,6 @@ with gr.Blocks(title="MuscleMimic Research Space", css=CUSTOM_CSS) as app:
220
  info="Choose a KIT kinesis locomotion trajectory for checkpoint comparison.",
221
  elem_classes="mm-select",
222
  scale=1,
223
- min_width=280,
224
  )
225
 
226
  _card_class_suffix = {
@@ -243,7 +338,7 @@ with gr.Blocks(title="MuscleMimic Research Space", css=CUSTOM_CSS) as app:
243
  card_classes = ["mm-compare-card"]
244
  if suffix:
245
  card_classes.append(suffix)
246
- with gr.Column(elem_classes=card_classes):
247
  gr.HTML(build_model_card_head(model_key))
248
  vids.append(
249
  gr.Video(
@@ -259,7 +354,7 @@ with gr.Blocks(title="MuscleMimic Research Space", css=CUSTOM_CSS) as app:
259
  gr.HTML(build_highlights_html())
260
  with gr.Row(elem_classes="mm-video-grid", equal_height=False):
261
  for item in HIGHLIGHT_VIDEOS:
262
- with gr.Column(elem_classes="mm-video-card", scale=1, min_width=320):
263
  gr.Video(
264
  value=str(BASE_DIR / "videos" / "blog" / item["file"]),
265
  autoplay=True,
@@ -284,4 +379,8 @@ with gr.Blocks(title="MuscleMimic Research Space", css=CUSTOM_CSS) as app:
284
  )
285
 
286
  if __name__ == "__main__":
287
- app.launch(allowed_paths=STATIC_DIRS)
 
 
 
 
 
141
  """
142
 
143
 
144
+ def build_autoplay_js() -> str:
145
+ return """
146
+ (() => {
147
+ const tryPlay = (video) => {
148
+ if (!video) return;
149
+ if (video.readyState === 0) return;
150
+ const playPromise = video.play();
151
+ if (playPromise && typeof playPromise.catch === "function") {
152
+ playPromise.catch(() => {});
153
+ }
154
+ };
155
+
156
+ const primeVideo = (video) => {
157
+ if (!video) return;
158
+ video.muted = true;
159
+ video.defaultMuted = true;
160
+ video.autoplay = true;
161
+ video.loop = true;
162
+ video.playsInline = true;
163
+ video.setAttribute("muted", "");
164
+ video.setAttribute("autoplay", "");
165
+ video.setAttribute("loop", "");
166
+ video.setAttribute("playsinline", "");
167
+ video.setAttribute("webkit-playsinline", "");
168
+
169
+ if (video.dataset.mmAutoplayBound !== "1") {
170
+ video.dataset.mmAutoplayBound = "1";
171
+ const replay = () => tryPlay(video);
172
+ video.addEventListener("loadedmetadata", replay);
173
+ video.addEventListener("loadeddata", replay);
174
+ video.addEventListener("canplay", replay);
175
+ video.addEventListener("emptied", () => {
176
+ requestAnimationFrame(replay);
177
+ });
178
+ }
179
+
180
+ tryPlay(video);
181
+ };
182
+
183
+ const scan = (root = document) => {
184
+ if (root instanceof HTMLVideoElement) {
185
+ primeVideo(root);
186
+ return;
187
+ }
188
+ root.querySelectorAll?.(".gradio-container video").forEach(primeVideo);
189
+ };
190
+
191
+ const boot = () => {
192
+ scan();
193
+
194
+ const observer = new MutationObserver((mutations) => {
195
+ for (const mutation of mutations) {
196
+ if (
197
+ mutation.type === "attributes" &&
198
+ mutation.target instanceof HTMLVideoElement
199
+ ) {
200
+ primeVideo(mutation.target);
201
+ continue;
202
+ }
203
+ mutation.addedNodes.forEach((node) => {
204
+ if (!(node instanceof HTMLElement)) return;
205
+ if (node.tagName === "VIDEO") {
206
+ primeVideo(node);
207
+ } else {
208
+ scan(node);
209
+ }
210
+ });
211
+ }
212
+ });
213
+
214
+ observer.observe(document.body, {
215
+ childList: true,
216
+ subtree: true,
217
+ attributes: true,
218
+ attributeFilter: ["src"],
219
+ });
220
+
221
+ document.addEventListener("visibilitychange", () => {
222
+ if (!document.hidden) {
223
+ scan();
224
+ }
225
+ });
226
+
227
+ window.addEventListener("pageshow", () => {
228
+ scan();
229
+ });
230
+ };
231
+
232
+ if (document.readyState === "loading") {
233
+ document.addEventListener("DOMContentLoaded", boot, { once: true });
234
+ } else {
235
+ boot();
236
+ }
237
+ })();
238
+ """
239
+
240
+
241
  def build_motion_summary_html(motion_label: str) -> str:
242
  if not motion_label:
243
  motion_label = DEFAULT_MOTION
 
296
  """
297
 
298
 
299
+ with gr.Blocks(title="MuscleMimic Research Space") as app:
300
  gr.HTML(build_hero_html())
301
  gr.HTML(build_explorer_intro_html())
302
 
 
308
  info="Filter the KIT / KINESIS set by locomotion subtype.",
309
  elem_classes="mm-select",
310
  scale=1,
 
311
  )
312
  motion_dd = gr.Dropdown(
313
  choices=get_motions_by_category("All"),
 
316
  info="Choose a KIT kinesis locomotion trajectory for checkpoint comparison.",
317
  elem_classes="mm-select",
318
  scale=1,
 
319
  )
320
 
321
  _card_class_suffix = {
 
338
  card_classes = ["mm-compare-card"]
339
  if suffix:
340
  card_classes.append(suffix)
341
+ with gr.Column(elem_classes=card_classes, min_width=0):
342
  gr.HTML(build_model_card_head(model_key))
343
  vids.append(
344
  gr.Video(
 
354
  gr.HTML(build_highlights_html())
355
  with gr.Row(elem_classes="mm-video-grid", equal_height=False):
356
  for item in HIGHLIGHT_VIDEOS:
357
+ with gr.Column(elem_classes="mm-video-card", scale=1, min_width=0):
358
  gr.Video(
359
  value=str(BASE_DIR / "videos" / "blog" / item["file"]),
360
  autoplay=True,
 
379
  )
380
 
381
  if __name__ == "__main__":
382
+ app.launch(
383
+ allowed_paths=STATIC_DIRS,
384
+ css=CUSTOM_CSS,
385
+ js=build_autoplay_js(),
386
+ )
style.css CHANGED
@@ -38,6 +38,7 @@ html,
38
  body {
39
  margin: 0;
40
  background: var(--mm-bg) !important;
 
41
  }
42
 
43
  body {
@@ -49,6 +50,7 @@ body {
49
  max-width: 1180px !important;
50
  margin: 0 auto !important;
51
  padding: 24px 24px 56px !important;
 
52
  background: transparent !important;
53
  color: var(--mm-ink) !important;
54
  font-family: "Manrope", -apple-system, BlinkMacSystemFont, sans-serif !important;
@@ -74,6 +76,22 @@ body {
74
  color: inherit;
75
  }
76
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  .mm-overline {
78
  margin: 0 0 0.45rem;
79
  color: var(--mm-muted);
@@ -92,12 +110,14 @@ body {
92
  border-radius: 16px;
93
  background: var(--mm-surface);
94
  box-shadow: var(--mm-shadow);
 
95
  }
96
 
97
  .mm-brand {
98
  display: flex;
99
  align-items: center;
100
  gap: 0.75rem;
 
101
  }
102
 
103
  .mm-brand img {
@@ -116,6 +136,7 @@ body {
116
  font-weight: 700;
117
  letter-spacing: 0.06em;
118
  text-transform: uppercase;
 
119
  }
120
 
121
  .mm-hero h1 {
@@ -125,6 +146,7 @@ body {
125
  font-size: clamp(2rem, 4vw, 3rem);
126
  font-weight: 800;
127
  line-height: 1.05;
 
128
  }
129
 
130
  .mm-hero-lede {
@@ -133,15 +155,18 @@ body {
133
  color: var(--mm-ink-soft);
134
  font-size: 1rem;
135
  line-height: 1.72;
 
136
  }
137
 
138
  .mm-nav {
139
  display: flex;
140
  flex-wrap: wrap;
141
  gap: 0.75rem;
 
142
  }
143
 
144
  .mm-nav a {
 
145
  padding: 0.5rem 0.8rem;
146
  border: 1px solid var(--mm-line);
147
  border-radius: 999px;
@@ -150,6 +175,8 @@ body {
150
  font-size: 0.88rem;
151
  font-weight: 700;
152
  text-decoration: none;
 
 
153
  transition: border-color 0.18s ease, color 0.18s ease;
154
  }
155
 
@@ -166,6 +193,7 @@ body {
166
  .mm-section-head {
167
  max-width: 780px;
168
  margin-bottom: 1rem;
 
169
  }
170
 
171
  .mm-section-head h2 {
@@ -174,6 +202,7 @@ body {
174
  font-size: clamp(1.6rem, 3vw, 2.25rem);
175
  font-weight: 800;
176
  line-height: 1.12;
 
177
  }
178
 
179
  .mm-section-head p {
@@ -181,17 +210,22 @@ body {
181
  color: var(--mm-ink-soft);
182
  font-size: 1rem;
183
  line-height: 1.75;
 
184
  }
185
 
186
  .mm-video-grid {
187
- display: grid;
188
- grid-template-columns: repeat(2, minmax(0, 1fr));
189
  gap: 1rem;
 
190
  }
191
 
192
  .mm-video-card,
193
  .mm-compare-card,
194
  .mm-link-card {
 
 
 
195
  overflow: hidden;
196
  border: 1px solid var(--mm-line);
197
  border-radius: 14px;
@@ -247,6 +281,7 @@ body {
247
  overflow: visible !important;
248
  position: relative;
249
  z-index: 20;
 
250
  }
251
 
252
  .mm-controls-shell > div,
@@ -307,6 +342,7 @@ body {
307
  border-radius: 14px;
308
  background: var(--mm-surface);
309
  box-shadow: var(--mm-shadow);
 
310
  }
311
 
312
  .mm-panel-head {
@@ -315,6 +351,7 @@ body {
315
  align-items: flex-start;
316
  gap: 1rem;
317
  margin-bottom: 1rem;
 
318
  }
319
 
320
  .mm-panel-head h3 {
@@ -323,12 +360,14 @@ body {
323
  font-size: 1.35rem;
324
  font-weight: 700;
325
  line-height: 1.15;
 
326
  }
327
 
328
  .mm-panel-head p {
329
  margin: 0;
330
  color: var(--mm-ink-soft);
331
  line-height: 1.7;
 
332
  }
333
 
334
  .mm-panel-head strong {
@@ -339,6 +378,7 @@ body {
339
  display: flex;
340
  flex-wrap: wrap;
341
  gap: 0.5rem;
 
342
  }
343
 
344
  .mm-chip {
@@ -351,12 +391,16 @@ body {
351
  color: var(--mm-ink-soft);
352
  font-size: 0.84rem;
353
  font-weight: 700;
 
 
 
354
  }
355
 
356
  .mm-compare-grid {
357
- display: grid;
358
- grid-template-columns: repeat(2, minmax(0, 1fr));
359
  gap: 1rem;
 
360
  }
361
 
362
  .mm-compare-card {
@@ -401,8 +445,10 @@ body {
401
  font-family: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
402
  font-size: 0.85rem;
403
  line-height: 1.6;
404
- overflow-x: auto;
405
- white-space: pre;
 
 
406
  }
407
 
408
  .mm-bibtex code {
@@ -426,13 +472,15 @@ body {
426
  }
427
 
428
  .mm-link-strip {
429
- display: grid;
430
- grid-template-columns: repeat(4, minmax(0, 1fr));
431
  gap: 1rem;
432
  margin-top: 0.75rem;
 
433
  }
434
 
435
  .mm-link-card {
 
436
  display: flex;
437
  flex-direction: column;
438
  gap: 0.32rem;
@@ -451,25 +499,19 @@ body {
451
  color: var(--mm-ink);
452
  font-size: 1rem;
453
  font-weight: 700;
 
454
  }
455
 
456
  .mm-link-note {
457
  color: var(--mm-muted);
458
  font-size: 0.9rem;
459
  line-height: 1.5;
460
- }
461
-
462
- @media (max-width: 1100px) {
463
- .mm-video-grid,
464
- .mm-compare-grid,
465
- .mm-link-strip {
466
- grid-template-columns: repeat(2, minmax(0, 1fr));
467
- }
468
  }
469
 
470
  @media (max-width: 820px) {
471
  .gradio-container {
472
- padding: 18px 16px 48px !important;
473
  }
474
 
475
  .mm-hero,
@@ -483,13 +525,21 @@ body {
483
  font-size: clamp(2rem, 9vw, 2.7rem);
484
  }
485
 
 
 
 
 
 
 
 
 
 
486
  .mm-panel-head {
487
  flex-direction: column;
488
  }
489
 
490
- .mm-video-grid,
491
- .mm-compare-grid,
492
- .mm-link-strip {
493
- grid-template-columns: 1fr;
494
  }
495
  }
 
38
  body {
39
  margin: 0;
40
  background: var(--mm-bg) !important;
41
+ width: 100%;
42
  }
43
 
44
  body {
 
50
  max-width: 1180px !important;
51
  margin: 0 auto !important;
52
  padding: 24px 24px 56px !important;
53
+ box-sizing: border-box;
54
  background: transparent !important;
55
  color: var(--mm-ink) !important;
56
  font-family: "Manrope", -apple-system, BlinkMacSystemFont, sans-serif !important;
 
76
  color: inherit;
77
  }
78
 
79
+ .gradio-container *,
80
+ .gradio-container *::before,
81
+ .gradio-container *::after {
82
+ box-sizing: border-box;
83
+ }
84
+
85
+ .gradio-container > *,
86
+ .gradio-container .gr-block,
87
+ .gradio-container .gr-group,
88
+ .gradio-container .gr-form,
89
+ .gradio-container .gr-column,
90
+ .gradio-container .gr-row {
91
+ min-width: 0;
92
+ max-width: 100%;
93
+ }
94
+
95
  .mm-overline {
96
  margin: 0 0 0.45rem;
97
  color: var(--mm-muted);
 
110
  border-radius: 16px;
111
  background: var(--mm-surface);
112
  box-shadow: var(--mm-shadow);
113
+ min-width: 0;
114
  }
115
 
116
  .mm-brand {
117
  display: flex;
118
  align-items: center;
119
  gap: 0.75rem;
120
+ min-width: 0;
121
  }
122
 
123
  .mm-brand img {
 
136
  font-weight: 700;
137
  letter-spacing: 0.06em;
138
  text-transform: uppercase;
139
+ overflow-wrap: anywhere;
140
  }
141
 
142
  .mm-hero h1 {
 
146
  font-size: clamp(2rem, 4vw, 3rem);
147
  font-weight: 800;
148
  line-height: 1.05;
149
+ overflow-wrap: anywhere;
150
  }
151
 
152
  .mm-hero-lede {
 
155
  color: var(--mm-ink-soft);
156
  font-size: 1rem;
157
  line-height: 1.72;
158
+ overflow-wrap: anywhere;
159
  }
160
 
161
  .mm-nav {
162
  display: flex;
163
  flex-wrap: wrap;
164
  gap: 0.75rem;
165
+ min-width: 0;
166
  }
167
 
168
  .mm-nav a {
169
+ display: block;
170
  padding: 0.5rem 0.8rem;
171
  border: 1px solid var(--mm-line);
172
  border-radius: 999px;
 
175
  font-size: 0.88rem;
176
  font-weight: 700;
177
  text-decoration: none;
178
+ white-space: normal;
179
+ overflow-wrap: anywhere;
180
  transition: border-color 0.18s ease, color 0.18s ease;
181
  }
182
 
 
193
  .mm-section-head {
194
  max-width: 780px;
195
  margin-bottom: 1rem;
196
+ min-width: 0;
197
  }
198
 
199
  .mm-section-head h2 {
 
202
  font-size: clamp(1.6rem, 3vw, 2.25rem);
203
  font-weight: 800;
204
  line-height: 1.12;
205
+ overflow-wrap: anywhere;
206
  }
207
 
208
  .mm-section-head p {
 
210
  color: var(--mm-ink-soft);
211
  font-size: 1rem;
212
  line-height: 1.75;
213
+ overflow-wrap: anywhere;
214
  }
215
 
216
  .mm-video-grid {
217
+ display: flex;
218
+ flex-wrap: wrap;
219
  gap: 1rem;
220
+ min-width: 0;
221
  }
222
 
223
  .mm-video-card,
224
  .mm-compare-card,
225
  .mm-link-card {
226
+ flex: 1 1 280px;
227
+ min-width: 0;
228
+ max-width: 100%;
229
  overflow: hidden;
230
  border: 1px solid var(--mm-line);
231
  border-radius: 14px;
 
281
  overflow: visible !important;
282
  position: relative;
283
  z-index: 20;
284
+ min-width: 0;
285
  }
286
 
287
  .mm-controls-shell > div,
 
342
  border-radius: 14px;
343
  background: var(--mm-surface);
344
  box-shadow: var(--mm-shadow);
345
+ min-width: 0;
346
  }
347
 
348
  .mm-panel-head {
 
351
  align-items: flex-start;
352
  gap: 1rem;
353
  margin-bottom: 1rem;
354
+ min-width: 0;
355
  }
356
 
357
  .mm-panel-head h3 {
 
360
  font-size: 1.35rem;
361
  font-weight: 700;
362
  line-height: 1.15;
363
+ overflow-wrap: anywhere;
364
  }
365
 
366
  .mm-panel-head p {
367
  margin: 0;
368
  color: var(--mm-ink-soft);
369
  line-height: 1.7;
370
+ overflow-wrap: anywhere;
371
  }
372
 
373
  .mm-panel-head strong {
 
378
  display: flex;
379
  flex-wrap: wrap;
380
  gap: 0.5rem;
381
+ min-width: 0;
382
  }
383
 
384
  .mm-chip {
 
391
  color: var(--mm-ink-soft);
392
  font-size: 0.84rem;
393
  font-weight: 700;
394
+ max-width: 100%;
395
+ white-space: normal;
396
+ overflow-wrap: anywhere;
397
  }
398
 
399
  .mm-compare-grid {
400
+ display: flex;
401
+ flex-wrap: wrap;
402
  gap: 1rem;
403
+ min-width: 0;
404
  }
405
 
406
  .mm-compare-card {
 
445
  font-family: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
446
  font-size: 0.85rem;
447
  line-height: 1.6;
448
+ max-width: 100%;
449
+ white-space: pre-wrap;
450
+ word-break: break-word;
451
+ overflow-wrap: anywhere;
452
  }
453
 
454
  .mm-bibtex code {
 
472
  }
473
 
474
  .mm-link-strip {
475
+ display: flex;
476
+ flex-wrap: wrap;
477
  gap: 1rem;
478
  margin-top: 0.75rem;
479
+ min-width: 0;
480
  }
481
 
482
  .mm-link-card {
483
+ flex: 1 1 200px;
484
  display: flex;
485
  flex-direction: column;
486
  gap: 0.32rem;
 
499
  color: var(--mm-ink);
500
  font-size: 1rem;
501
  font-weight: 700;
502
+ overflow-wrap: anywhere;
503
  }
504
 
505
  .mm-link-note {
506
  color: var(--mm-muted);
507
  font-size: 0.9rem;
508
  line-height: 1.5;
509
+ overflow-wrap: anywhere;
 
 
 
 
 
 
 
510
  }
511
 
512
  @media (max-width: 820px) {
513
  .gradio-container {
514
+ padding: 14px 12px 40px !important;
515
  }
516
 
517
  .mm-hero,
 
525
  font-size: clamp(2rem, 9vw, 2.7rem);
526
  }
527
 
528
+ .mm-brand {
529
+ align-items: flex-start;
530
+ }
531
+
532
+ .mm-brand span {
533
+ font-size: 0.8rem;
534
+ line-height: 1.4;
535
+ }
536
+
537
  .mm-panel-head {
538
  flex-direction: column;
539
  }
540
 
541
+ .mm-bibtex {
542
+ font-size: 0.75rem;
543
+ padding: 0.75rem 0.9rem;
 
544
  }
545
  }