Add releases tab

#6
by lysandre HF Staff - opened
Files changed (2) hide show
  1. index.html +64 -8
  2. style.css +98 -0
index.html CHANGED
@@ -18,6 +18,7 @@
18
  <script src="https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/4.3.2/iframeResizer.contentWindow.min.js"></script>
19
  <script src="https://cdnjs.cloudflare.com/ajax/libs/timeago.js/4.0.2/timeago.min.js"></script>
20
  <script src="https://cdn.tailwindcss.com"></script>
 
21
  <script>
22
  const REPO_NAME = "spaces/transformers-discussion-board/Support";
23
  const NUM_DISCUSSIONS = 5;
@@ -105,6 +106,59 @@
105
 
106
  hookPoint.appendChild(clone);
107
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
  }
109
 
110
  document.onreadystatechange = function (e) {
@@ -113,8 +167,8 @@
113
 
114
  // Check for system dark mode preference
115
  if (
116
- window.matchMedia &&
117
- window.matchMedia("(prefers-color-scheme: dark)").matches
118
  ) {
119
  document.documentElement.classList.add("dark");
120
  }
@@ -123,6 +177,7 @@
123
  </script>
124
  </head>
125
  <body class="dark:bg-gray-900 dark:text-white">
 
126
  <div class="flex flex-col p-12 md:p-32 font-sans">
127
  <h1 class="text-2xl font-bold mb-4">Transformers Discussions</h1>
128
  <h2 class="dark:text-gray-200">
@@ -130,9 +185,9 @@
130
  </h2>
131
  <p class="text-gray-500 dark:text-gray-400">
132
  <a
133
- href="https://huggingface.co/spaces/transformers-discussion-board/Support/discussions"
134
- class="underline hover:text-gray-800 dark:hover:text-gray-300"
135
- >Go to the community tab</a
136
  >
137
  to get started
138
  </p>
@@ -142,11 +197,11 @@
142
 
143
  <div class="hidden">
144
  <div
145
- id="template-discussion"
146
- class="relative h-[4.25rem] w-full overflow-hidden"
147
  >
148
  <a
149
- class="group flex h-full items-stretch overflow-hidden rounded-lg border border-gray-100 dark:border-gray-800"
150
  href="https://huggingface.co/spaces/huggingface/HuggingDiscussions/discussions/14"
151
  >
152
  <div
@@ -294,5 +349,6 @@
294
  </div>
295
  </div>
296
  </div>
 
297
  </body>
298
  </html>
 
18
  <script src="https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/4.3.2/iframeResizer.contentWindow.min.js"></script>
19
  <script src="https://cdnjs.cloudflare.com/ajax/libs/timeago.js/4.0.2/timeago.min.js"></script>
20
  <script src="https://cdn.tailwindcss.com"></script>
21
+ <link rel="stylesheet" href="style.css">
22
  <script>
23
  const REPO_NAME = "spaces/transformers-discussion-board/Support";
24
  const NUM_DISCUSSIONS = 5;
 
106
 
107
  hookPoint.appendChild(clone);
108
  }
109
+
110
+ const pypi_svg = `<svg clip-rule="evenodd" fill-rule="evenodd" height="20" stroke-linecap="square" stroke-linejoin="round" stroke-miterlimit="1.5" viewBox=".006 0 673.409 600" width="20" xmlns="http://www.w3.org/2000/svg"><path d="m.006 0h600v600h-600z" fill="#111827"/><g transform="translate(72.59 -63.209)"><path d="m673.41 236.016-64.271 8.252v281.357h64.276z" fill="#ffca1e" stroke="#d7c5b2" stroke-width="1.11" transform="matrix(1.02365 -.37275 .22115 .08093 -423.086 457.448)"/><path d="m609.139 244.268h64.276v281.357h-64.276z" fill="#ffd241" stroke="#d7c5b2" stroke-width=".35" transform="matrix(3.93359 -1.43837 0 .53084 -2266.43 1087.94)"/><path d="m609.139 244.268h64.276v281.357h-64.276z" fill="#2f6490" stroke="#d1e3f2" stroke-width=".62" transform="matrix(1.9604 -.71685 .2216 .07927 -1118.55 639.339)"/><path d="m609.139 244.268h64.276v281.357h-64.276z" fill="#3775a8" stroke="#d1e3f2" stroke-width="1.15" transform="matrix(1.02281 -.374 0 1.05695 -430.773 214.178)"/><path d="m609.139 244.268h64.276v281.357h-64.276z" fill="#2f6490" stroke="#fff" stroke-width="1.17" transform="matrix(-.97499 -.34924 0 1.05695 786.194 199.208)"/><path d="m609.139 244.268h64.276v281.357h-64.276z" fill="#efeeea" stroke="#d8d8d8" stroke-width="1.44" transform="matrix(-.97499 -.35652 0 .26885 786.194 618.355)"/><g stroke="#d1e3f2"><path d="m609.139 244.268h64.276v281.357h-64.276z" fill="#2f6490" stroke-width="1.44" transform="matrix(-.96834 -.35409 0 .53077 719.483 427.5)"/><path d="m609.139 244.268h64.276v281.357h-64.276z" fill="#3775a8" stroke-width="1.2" transform="matrix(.93554 -.3421 0 1.05695 -311.892 170.492)"/><path d="m609.139 244.268h64.276v281.357h-64.276z" fill="#3775a8" stroke-width="1.43" transform="matrix(.9742 -.35623 0 .53084 -463.744 428.761)"/><path d="m67.575 393.161 62.121 22.465 188.708-68.299m-125.165-29.141 124.732-45.602" fill="none"/></g><path d="m318.404 347.327 63.939-23.209" fill="none" stroke="#d7c5b2"/><path d="m609.139 244.268h64.276v281.357h-64.276z" fill="#2f6490" stroke="#d1e3f2" stroke-width="1.16" transform="matrix(.96788 -.35244 .22115 .08093 -576.168 513.583)"/><circle cx="637.517" cy="260.001" fill="#fff" r="15.71" transform="matrix(.7826 -.4024 .05494 .8614 -295.363 304.934)"/><path d="m195.786 198.125 61.696 22.126" fill="none" stroke="#d1e3f2"/><path d="m673.415 244.268h-64.276l.018 282.405 64.258-1.048z" fill="#ffd241" stroke="#d7c5b2" stroke-width="1.37" transform="matrix(1.02281 -.374 0 .52843 -430.773 491.983)"/><path d="m673.415 244.268h-64.276l.001 281.758 64.275-.401z" fill="#ffd241" stroke="#d7c5b2" stroke-width="1.48" transform="matrix(.93554 -.3421 0 .52743 -311.892 448.822)"/><circle cx="637.517" cy="260.001" fill="#fefdfd" r="15.71" transform="matrix(.77074 -.3963 .05156 .80832 -205.916 509.411)"/><path d="m192.412 468.059 126.028-45.977" fill="none" stroke="#d7c5b2"/></g></svg>`
111
+
112
+ const dataURL = 'https://datasets-server.huggingface.co/rows?dataset=reach-vb%2Ftransformers-releases&config=default&split=train&offset=0&length=100'
113
+ const dateOptions = { year: 'numeric', month: 'long', day: 'numeric' };
114
+ const releases = await fetch(dataURL)
115
+ .then(e => e.json())
116
+ .then(e => e.rows.map(a => {
117
+ return {
118
+ title: a['row']['name'],
119
+ publishedAt: a['row']['published_at'],
120
+ desc: `${a['row']['tag_name']}, released on ${new Date(a['row']['published_at']).toLocaleString("en-US", dateOptions)}`,
121
+ pypi: !a['row']['name'].includes('based'),
122
+ tag: a['row']['tag_name'],
123
+ }
124
+ }).sort((a, b) => new Date(a.publishedAt) - new Date(b.publishedAt)))
125
+
126
+ for (let i = 1; i < releases.length + 1; i++) {
127
+ const release = releases[i - 1];
128
+ const styleTop = `${i}0%`
129
+
130
+ const commitTree = document.getElementById('commit-tree');
131
+ const commitNode = document.createElement('div');
132
+ const tooltip = document.createElement('div')
133
+
134
+ commitNode.classList.add('commit-node');
135
+ commitNode.style.top = styleTop;
136
+
137
+ tooltip.style.animation = "fade-in ease 1s";
138
+
139
+ tooltip.innerHTML = `<div class="tooltip">
140
+ <div class="title relative h-[4.25rem] w-full overflow-hidden">
141
+ <a class="group flex h-full items-stretch overflow-hidden rounded-lg border border-gray-100 dark:border-gray-800"
142
+ href="https://github.com/huggingface/transformers/releases/tag/${release.tag}">
143
+ <div class="flex-1 overflow-hidden whitespace-nowrap px-4 bg-white dark:bg-gray-800 dark:bg-gradient-to-r dark:from-gray-900 dark:to-gray-950">
144
+ <div class="mt-2.5 flex items-center justify-between overflow-hidden leading-snug">
145
+ <div class="flex items-center overflow-hidden">
146
+ <h4 class="truncate font-semibold group-hover:underline dark:text-white">${release.title}</h4>
147
+ ${release.pypi ? `<div class="outer_svg">${pypi_svg}</div>` : ""}
148
+ </div>
149
+ <div class="flex h-full items-start pt-2.5"></div>
150
+ </div>
151
+ </div>
152
+ </a>
153
+ <div class="desc absolute bottom-2.5 max-w-full truncate pl-4 pr-4 text-sm text-gray-500 dark:text-gray-400">
154
+ <span class="discussion-num">${release['desc']}</span>
155
+ </div>
156
+ </div>
157
+ </div>`
158
+
159
+ commitNode.appendChild(tooltip);
160
+ commitTree.appendChild(commitNode);
161
+ }
162
  }
163
 
164
  document.onreadystatechange = function (e) {
 
167
 
168
  // Check for system dark mode preference
169
  if (
170
+ window.matchMedia &&
171
+ window.matchMedia("(prefers-color-scheme: dark)").matches
172
  ) {
173
  document.documentElement.classList.add("dark");
174
  }
 
177
  </script>
178
  </head>
179
  <body class="dark:bg-gray-900 dark:text-white">
180
+ <div class="commit-timeline">
181
  <div class="flex flex-col p-12 md:p-32 font-sans">
182
  <h1 class="text-2xl font-bold mb-4">Transformers Discussions</h1>
183
  <h2 class="dark:text-gray-200">
 
185
  </h2>
186
  <p class="text-gray-500 dark:text-gray-400">
187
  <a
188
+ href="https://huggingface.co/spaces/transformers-discussion-board/Support/discussions"
189
+ class="underline hover:text-gray-800 dark:hover:text-gray-300"
190
+ >Go to the community tab</a
191
  >
192
  to get started
193
  </p>
 
197
 
198
  <div class="hidden">
199
  <div
200
+ id="template-discussion"
201
+ class="relative h-[4.25rem] w-full overflow-hidden"
202
  >
203
  <a
204
+ class="group flex h-full items-stretch overflow-hidden rounded-lg border border-gray-100 dark:border-gray-800"
205
  href="https://huggingface.co/spaces/huggingface/HuggingDiscussions/discussions/14"
206
  >
207
  <div
 
349
  </div>
350
  </div>
351
  </div>
352
+ <div class="commit-tree" id="commit-tree"></div>
353
  </body>
354
  </html>
style.css CHANGED
@@ -26,3 +26,101 @@ p {
26
  .card p:last-child {
27
  margin-bottom: 0;
28
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  .card p:last-child {
27
  margin-bottom: 0;
28
  }
29
+
30
+ .commit-timeline {
31
+ display: flex;
32
+ flex-direction: row;
33
+ }
34
+
35
+ /* Container for the vertical line and nodes */
36
+ .commit-tree {
37
+ position: absolute;
38
+ height: 42.5rem; /* Full viewport height */
39
+ width: calc(100% - 600px);
40
+ bottom: 80px;
41
+ animation: fade-in ease 1s;
42
+ }
43
+
44
+ @media (width <= 1300px) {
45
+ .commit-tree {
46
+ visibility: hidden;
47
+ opacity: 0;
48
+ }
49
+ }
50
+
51
+ /* Vertical line using pseudo-element */
52
+ .commit-tree::before {
53
+ content: '';
54
+ position: absolute;
55
+ right: 0;
56
+ top: 0;
57
+ bottom: 0;
58
+ width: 4px;
59
+ background: linear-gradient(rgb(17 24 39 / var(--tw-bg-opacity, 1)) 0%, #e5e7eb 50%, #e5e7eb 100%);
60
+ }
61
+
62
+ /* Commit node styling */
63
+ .commit-node {
64
+ position: absolute;
65
+ right: 0;
66
+ transform: translateX(4px);
67
+ width: 12px;
68
+ height: 12px;
69
+ background-color: #e5e7eb; /* Blue circle */
70
+ border-radius: 50%;
71
+ cursor: pointer;
72
+ z-index: 1;
73
+ display: flex;
74
+ flex-direction: row;
75
+ }
76
+
77
+ .outer_svg {
78
+
79
+ }
80
+
81
+ /* Tooltip styling */
82
+ .tooltip {
83
+ width: 350px;
84
+ text-align: center;
85
+ border-radius: 6px;
86
+ padding: 8px;
87
+ position: absolute;
88
+ z-index: 2;
89
+ left: 120%; /* Position to the right of the node */
90
+ top: 50%;
91
+ transform: translateY(-50%);
92
+ white-space: nowrap;
93
+ font-size: 14px;
94
+ transition: all 0.3s;
95
+ }
96
+
97
+ .tooltip:hover {
98
+ width: 500px;
99
+ }
100
+
101
+ .tooltip .title {
102
+ height: 2.6rem;
103
+ transition: all 0.3s;
104
+ }
105
+
106
+
107
+ .tooltip:hover .title {
108
+ height: 4.25rem;
109
+ }
110
+
111
+ .tooltip .desc {
112
+ visibility: hidden;
113
+ transition: all 0.3s;
114
+ opacity: 0;
115
+ }
116
+
117
+ .tooltip:hover .desc {
118
+ visibility: visible;
119
+ opacity: 1;
120
+ }
121
+
122
+ @keyframes fade-in {
123
+ from { opacity: 0; }
124
+ to { opacity: 1; }
125
+ }
126
+