tfrere HF Staff commited on
Commit
05de8cb
·
1 Parent(s): 62ba8ec
app/src/components/Image.astro CHANGED
@@ -96,10 +96,10 @@ const hasCaption =
96
  hasCaptionSlot || (typeof caption === "string" && caption.length > 0);
97
  const hasTitle = Astro.slots.has("title");
98
  const uid = `ri_${Math.random().toString(36).slice(2)}`;
99
- const dataZoomable =
100
- zoomable !== false || (imgProps as any)["data-zoomable"] ? "1" : "1";
101
  const dataDownloadable =
102
- downloadable !== false || (imgProps as any)["data-downloadable"] ? "1" : "1";
103
  const hasLink = typeof linkHref === "string" && linkHref.length > 0;
104
  const resolvedTarget = hasLink ? linkTarget || "_blank" : undefined;
105
  const resolvedRel = hasLink ? linkRel || "noopener noreferrer" : undefined;
@@ -109,8 +109,8 @@ const resolvedDownloadSrc = downloadSrc || originalSrc;
109
  ---
110
 
111
  <div
112
- class={`ri-root`}
113
- data-ri-root={uid}
114
  data-has-title={hasTitle}
115
  data-has-caption={hasCaption}
116
  >
@@ -123,7 +123,7 @@ const resolvedDownloadSrc = downloadSrc || originalSrc;
123
  <span class="img-dl-wrap">
124
  {hasLink ? (
125
  <a
126
- class="ri-link"
127
  href={linkHref}
128
  target={resolvedTarget}
129
  rel={resolvedRel}
@@ -166,7 +166,7 @@ const resolvedDownloadSrc = downloadSrc || originalSrc;
166
  </span>
167
  ) : hasLink ? (
168
  <a
169
- class="ri-link"
170
  href={linkHref}
171
  target={resolvedTarget}
172
  rel={resolvedRel}
@@ -200,7 +200,7 @@ const resolvedDownloadSrc = downloadSrc || originalSrc;
200
  <span class="img-dl-wrap">
201
  {hasLink ? (
202
  <a
203
- class="ri-link"
204
  href={linkHref}
205
  target={resolvedTarget}
206
  rel={resolvedRel}
@@ -241,7 +241,7 @@ const resolvedDownloadSrc = downloadSrc || originalSrc;
241
  </span>
242
  ) : hasLink ? (
243
  <a
244
- class="ri-link"
245
  href={linkHref}
246
  target={resolvedTarget}
247
  rel={resolvedRel}
@@ -300,7 +300,7 @@ const resolvedDownloadSrc = downloadSrc || originalSrc;
300
  };
301
 
302
  const initZoomIfNeeded = () => {
303
- if (img.getAttribute("data-zoomable") !== "1") return;
304
  const isDark =
305
  document.documentElement.getAttribute("data-theme") === "dark";
306
  const background = isDark ? "rgba(0,0,0,.9)" : "rgba(0,0,0,.85)";
@@ -355,13 +355,13 @@ const resolvedDownloadSrc = downloadSrc || originalSrc;
355
  // Global zoom management to hide other Figures
356
  const setupGlobalZoomBehavior = () => {
357
  img.addEventListener("click", () => {
358
- if (img.getAttribute("data-zoomable") === "1") {
359
- // Enlever zoom-active de tous les autres ri-root
360
  document
361
- .querySelectorAll(".ri-root.zoom-active")
362
  .forEach((el) => el.classList.remove("zoom-active"));
363
 
364
- // Add zoom-active to this ri-root
365
  root.classList.add("zoom-active");
366
  }
367
  });
@@ -427,9 +427,28 @@ const resolvedDownloadSrc = downloadSrc || originalSrc;
427
  </script>
428
 
429
  <style>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
430
  figure {
431
  margin: var(--block-spacing-y) 0;
 
 
432
  }
 
433
  figcaption {
434
  text-align: left;
435
  font-size: 0.9rem;
@@ -480,10 +499,10 @@ const resolvedDownloadSrc = downloadSrc || originalSrc;
480
  }
481
 
482
  /* Opt-in zoomable images */
483
- img[data-zoomable] {
484
  cursor: zoom-in;
485
  }
486
- .medium-zoom--opened img[data-zoomable] {
487
  cursor: zoom-out;
488
  }
489
 
@@ -495,6 +514,7 @@ const resolvedDownloadSrc = downloadSrc || originalSrc;
495
  position: relative;
496
  }
497
  .img-dl-wrap {
 
498
  position: relative;
499
  display: inline-block;
500
  }
@@ -516,20 +536,20 @@ const resolvedDownloadSrc = downloadSrc || originalSrc;
516
  }
517
 
518
  /* When an image is zoomed, hide ALL Figures on the page */
519
- :global(.medium-zoom--opened) .ri-root {
520
  opacity: 0;
521
  z-index: calc(var(--z-base) - 1);
522
  transition: opacity 0.3s ease;
523
  }
524
 
525
  /* The currently zoomed image remains visible */
526
- :global(.medium-zoom--opened) .ri-root:has(.medium-zoom--opened) {
527
  opacity: 1;
528
  z-index: var(--z-overlay);
529
  }
530
 
531
  /* Fallback for browsers without :has() support */
532
- :global(.medium-zoom--opened) .ri-root.zoom-active {
533
  opacity: 1 !important;
534
  z-index: var(--z-overlay) !important;
535
  }
@@ -548,12 +568,12 @@ const resolvedDownloadSrc = downloadSrc || originalSrc;
548
  }
549
 
550
  /* Even for active zoomed image, hide button and caption for clean experience */
551
- :global(.medium-zoom--opened) .ri-root.zoom-active .img-dl-btn {
552
  opacity: 0;
553
  z-index: calc(var(--z-base) - 1);
554
  }
555
 
556
- :global(.medium-zoom--opened) .ri-root.zoom-active figcaption {
557
  opacity: 0;
558
  z-index: calc(var(--z-base) - 1);
559
  }
@@ -579,11 +599,11 @@ const resolvedDownloadSrc = downloadSrc || originalSrc;
579
  }
580
 
581
  /* Conditional margins based on title and caption presence */
582
- .ri-root:not([data-has-title="true"]) {
583
  margin-top: 20px;
584
  }
585
 
586
- .ri-root:not([data-has-caption="true"]) {
587
  margin-bottom: 20px;
588
  }
589
 
@@ -595,7 +615,7 @@ const resolvedDownloadSrc = downloadSrc || originalSrc;
595
  }
596
 
597
  /* Dark mode: invert luminosity while preserving color harmony */
598
- :global([data-theme="dark"]) .ri-root img {
599
  filter: invert(0.925) hue-rotate(180deg);
600
  }
601
 
 
96
  hasCaptionSlot || (typeof caption === "string" && caption.length > 0);
97
  const hasTitle = Astro.slots.has("title");
98
  const uid = `ri_${Math.random().toString(36).slice(2)}`;
99
+ // Use booleans instead of strings to avoid truthy "0" problem
100
+ const dataZoomable = zoomable !== false || !!(imgProps as any)["data-zoomable"];
101
  const dataDownloadable =
102
+ downloadable !== false || !!(imgProps as any)["data-downloadable"];
103
  const hasLink = typeof linkHref === "string" && linkHref.length > 0;
104
  const resolvedTarget = hasLink ? linkTarget || "_blank" : undefined;
105
  const resolvedRel = hasLink ? linkRel || "noopener noreferrer" : undefined;
 
109
  ---
110
 
111
  <div
112
+ class={`image-wrapper`}
113
+ data-image-wrapper={uid}
114
  data-has-title={hasTitle}
115
  data-has-caption={hasCaption}
116
  >
 
123
  <span class="img-dl-wrap">
124
  {hasLink ? (
125
  <a
126
+ class="image-link"
127
  href={linkHref}
128
  target={resolvedTarget}
129
  rel={resolvedRel}
 
166
  </span>
167
  ) : hasLink ? (
168
  <a
169
+ class="image-link"
170
  href={linkHref}
171
  target={resolvedTarget}
172
  rel={resolvedRel}
 
200
  <span class="img-dl-wrap">
201
  {hasLink ? (
202
  <a
203
+ class="image-link"
204
  href={linkHref}
205
  target={resolvedTarget}
206
  rel={resolvedRel}
 
241
  </span>
242
  ) : hasLink ? (
243
  <a
244
+ class="image-link"
245
  href={linkHref}
246
  target={resolvedTarget}
247
  rel={resolvedRel}
 
300
  };
301
 
302
  const initZoomIfNeeded = () => {
303
+ if (img.getAttribute("data-zoomable") !== "true") return;
304
  const isDark =
305
  document.documentElement.getAttribute("data-theme") === "dark";
306
  const background = isDark ? "rgba(0,0,0,.9)" : "rgba(0,0,0,.85)";
 
355
  // Global zoom management to hide other Figures
356
  const setupGlobalZoomBehavior = () => {
357
  img.addEventListener("click", () => {
358
+ if (img.getAttribute("data-zoomable") === "true") {
359
+ // Remove zoom-active from all other image wrappers
360
  document
361
+ .querySelectorAll(".image-wrapper.zoom-active")
362
  .forEach((el) => el.classList.remove("zoom-active"));
363
 
364
+ // Add zoom-active to this image wrapper
365
  root.classList.add("zoom-active");
366
  }
367
  });
 
427
  </script>
428
 
429
  <style>
430
+ .image-wrapper {
431
+ display: block;
432
+ width: 100%;
433
+ }
434
+
435
+ .image-link {
436
+ display: block;
437
+ width: 100%;
438
+ }
439
+
440
+ .image-wrapper img {
441
+ display: block;
442
+ width: 100%;
443
+ height: auto;
444
+ }
445
+
446
  figure {
447
  margin: var(--block-spacing-y) 0;
448
+ display: block;
449
+ width: 100%;
450
  }
451
+
452
  figcaption {
453
  text-align: left;
454
  font-size: 0.9rem;
 
499
  }
500
 
501
  /* Opt-in zoomable images */
502
+ img[data-zoomable="true"] {
503
  cursor: zoom-in;
504
  }
505
+ .medium-zoom--opened img[data-zoomable="true"] {
506
  cursor: zoom-out;
507
  }
508
 
 
514
  position: relative;
515
  }
516
  .img-dl-wrap {
517
+ width: 100%;
518
  position: relative;
519
  display: inline-block;
520
  }
 
536
  }
537
 
538
  /* When an image is zoomed, hide ALL Figures on the page */
539
+ :global(.medium-zoom--opened) .image-wrapper {
540
  opacity: 0;
541
  z-index: calc(var(--z-base) - 1);
542
  transition: opacity 0.3s ease;
543
  }
544
 
545
  /* The currently zoomed image remains visible */
546
+ :global(.medium-zoom--opened) .image-wrapper:has(.medium-zoom--opened) {
547
  opacity: 1;
548
  z-index: var(--z-overlay);
549
  }
550
 
551
  /* Fallback for browsers without :has() support */
552
+ :global(.medium-zoom--opened) .image-wrapper.zoom-active {
553
  opacity: 1 !important;
554
  z-index: var(--z-overlay) !important;
555
  }
 
568
  }
569
 
570
  /* Even for active zoomed image, hide button and caption for clean experience */
571
+ :global(.medium-zoom--opened) .image-wrapper.zoom-active .img-dl-btn {
572
  opacity: 0;
573
  z-index: calc(var(--z-base) - 1);
574
  }
575
 
576
+ :global(.medium-zoom--opened) .image-wrapper.zoom-active figcaption {
577
  opacity: 0;
578
  z-index: calc(var(--z-base) - 1);
579
  }
 
599
  }
600
 
601
  /* Conditional margins based on title and caption presence */
602
+ .image-wrapper:not([data-has-title="true"]) {
603
  margin-top: 20px;
604
  }
605
 
606
+ .image-wrapper:not([data-has-caption="true"]) {
607
  margin-bottom: 20px;
608
  }
609
 
 
615
  }
616
 
617
  /* Dark mode: invert luminosity while preserving color harmony */
618
+ :global([data-theme="dark"]) .image-wrapper img {
619
  filter: invert(0.925) hue-rotate(180deg);
620
  }
621
 
app/src/components/Reference.astro CHANGED
@@ -40,11 +40,11 @@ const { id, caption } = Astro.props as Props;
40
  margin-bottom: 0;
41
  }
42
 
43
- .reference__content :global(.ri-root) {
44
  margin-bottom: 0;
45
  }
46
 
47
- .reference__content :global(.ri-root) :global(.reference__caption) {
48
  margin-top: 0;
49
  }
50
 
 
40
  margin-bottom: 0;
41
  }
42
 
43
+ .reference__content :global(.image-wrapper) {
44
  margin-bottom: 0;
45
  }
46
 
47
+ .reference__content :global(.image-wrapper) :global(.reference__caption) {
48
  margin-top: 0;
49
  }
50
 
app/src/content/assets/image/maintain-the-unmaintainable.png CHANGED

Git LFS Details

  • SHA256: 52db98b81d3399e673679d415498cd585915955223f296b8bc49b28095542b0f
  • Pointer size: 131 Bytes
  • Size of remote file: 218 kB

Git LFS Details

  • SHA256: 6b265d8ee4ca1413cd3af59cbf307531e0d11af8402070d54757f15ea2032cdf
  • Pointer size: 132 Bytes
  • Size of remote file: 1.17 MB
app/src/content/assets/image/smoll-training-guide.png CHANGED

Git LFS Details

  • SHA256: 9338752555b50cbf5f96f5a4579250d7d09ea6a0781fc7aa0b402eb41f542105
  • Pointer size: 130 Bytes
  • Size of remote file: 78.9 kB

Git LFS Details

  • SHA256: 8a41f479bd3b922ddd723ccf80b7bebf3e8f875ee1049794d472c67e23f0cc12
  • Pointer size: 131 Bytes
  • Size of remote file: 163 kB
app/src/content/chapters/demo/built-with-this.mdx CHANGED
@@ -11,14 +11,18 @@ export const title = "Built with this";
11
  You can see how the template is used in the following examples.
12
 
13
  <Stack direction="horizontal" gap="medium" layout="2-column" >
14
- <a href="https://huggingface.co/spaces/transformers-community/Transformers-tenets" target="_blank" rel="noopener noreferrer" class="card no-padding" style="flex: 1; min-width: 0; overflow: hidden;">
 
 
15
  <Image
16
- src={maintainUnmaintainable}
17
- alt="Maintain the unmaintainable: 1M python loc, 400+ models"
 
 
18
  />
19
  <div class="card-title-container">
20
- <h3 class="card-title">Maintain the unmaintainable: 1M python loc, 400+ models</h3>
21
- <p class="card-subtitle">A peek into software engineering for the transformers library</p>
22
  </div>
23
  </a>
24
 
@@ -26,6 +30,8 @@ You can see how the template is used in the following examples.
26
  <Image
27
  src={finevision}
28
  alt="FineVision: Open Data Is All You Need"
 
 
29
  />
30
  <div class="card-title-container">
31
  <h3 class="card-title">FineVision: Open Data Is All You Need</h3>
@@ -33,14 +39,17 @@ You can see how the template is used in the following examples.
33
  </div>
34
  </a>
35
 
36
- <a href="https://huggingface.co/spaces/HuggingFaceTB/smol-training-playbook" target="_blank" rel="noopener noreferrer" class="card no-padding" style="flex: 1; min-width: 0; overflow: hidden;">
 
37
  <Image
38
- src={smolTrainingGuide}
39
- alt="The Smol Training Guide: The Secrets to Building World-Class LLMs"
 
 
40
  />
41
  <div class="card-title-container">
42
- <h3 class="card-title">The Smol Training Guide: The Secrets to Building World-Class LLMs</h3>
43
- <p class="card-subtitle">A practical journey through the challenges, decisions, and messy reality behind training state-of-the-art language models</p>
44
  </div>
45
  </a>
46
 
 
11
  You can see how the template is used in the following examples.
12
 
13
  <Stack direction="horizontal" gap="medium" layout="2-column" >
14
+
15
+
16
+ <a href="https://huggingface.co/spaces/HuggingFaceTB/smol-training-playbook" target="_blank" rel="noopener noreferrer" class="card no-padding" style="flex: 1; min-width: 0; overflow: hidden;">
17
  <Image
18
+ src={smolTrainingGuide}
19
+ alt="The Smol Training Playbook: The Secrets to Building World-Class LLMs"
20
+ zoomable={false}
21
+ downloadable={false}
22
  />
23
  <div class="card-title-container">
24
+ <h3 class="card-title">The Smol Training Playbook: The Secrets to Building World-Class LLMs</h3>
25
+ <p class="card-subtitle">A practical journey through the challenges, decisions, and messy reality behind training state-of-the-art language models</p>
26
  </div>
27
  </a>
28
 
 
30
  <Image
31
  src={finevision}
32
  alt="FineVision: Open Data Is All You Need"
33
+ zoomable={false}
34
+ downloadable={false}
35
  />
36
  <div class="card-title-container">
37
  <h3 class="card-title">FineVision: Open Data Is All You Need</h3>
 
39
  </div>
40
  </a>
41
 
42
+
43
+ <a href="https://huggingface.co/spaces/transformers-community/Transformers-tenets" target="_blank" rel="noopener noreferrer" class="card no-padding" style="flex: 1; min-width: 0; overflow: hidden;">
44
  <Image
45
+ src={maintainUnmaintainable}
46
+ alt="Maintain the unmaintainable: 1M python loc, 400+ models"
47
+ zoomable={false}
48
+ downloadable={false}
49
  />
50
  <div class="card-title-container">
51
+ <h3 class="card-title">Maintain the unmaintainable: 1M python loc, 400+ models</h3>
52
+ <p class="card-subtitle">A peek into software engineering for the transformers library</p>
53
  </div>
54
  </a>
55
 
app/src/styles/components/_card.css CHANGED
@@ -38,24 +38,24 @@
38
  margin: 0 !important;
39
  }
40
 
41
- .card .ri-root,
42
- .card .ri-root figure {
43
  margin: 0 !important;
 
 
44
  }
45
 
46
  .card img {
47
  border-radius: 8px 8px 0 0 !important;
48
- width: 100%;
49
- height: 120px;
50
- object-fit: cover;
 
 
51
  border-bottom: 1px solid var(--border-color) !important;
52
  transition: all 0.2s ease;
53
  }
54
 
55
- .card:hover img {
56
- border-color: var(--muted-color) !important;
57
- }
58
-
59
 
60
  .card h3,
61
  .card h4,
 
38
  margin: 0 !important;
39
  }
40
 
41
+ .card .image-wrapper,
42
+ .card .image-wrapper figure {
43
  margin: 0 !important;
44
+ width: 100% !important;
45
+ display: block !important;
46
  }
47
 
48
  .card img {
49
  border-radius: 8px 8px 0 0 !important;
50
+ width: 100% !important;
51
+ max-width: 100% !important;
52
+ height: 120px !important;
53
+ object-fit: cover !important;
54
+ display: block !important;
55
  border-bottom: 1px solid var(--border-color) !important;
56
  transition: all 0.2s ease;
57
  }
58
 
 
 
 
 
59
 
60
  .card h3,
61
  .card h4,