Anonymous commited on
Commit
9f2b52f
·
1 Parent(s): 435f76d

Add per-case horizontal scrolling

Browse files
Files changed (2) hide show
  1. index.html +32 -30
  2. static/css/index.css +28 -49
index.html CHANGED
@@ -156,53 +156,55 @@
156
  }[char]));
157
  }
158
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
159
  function renderTable(task, manifests, taskRoot) {
160
  const wrapper = document.createElement("div");
161
- wrapper.className = "demo-table";
162
- const table = document.createElement("table");
163
- const thead = document.createElement("thead");
164
- const tbody = document.createElement("tbody");
165
- const header = document.createElement("tr");
166
- const columns = task.show_reference ? ["Script", "Reference", ...task.models] : ["Script", ...task.models];
167
- table.className = task.show_reference ? "" : "without-reference";
168
-
169
- columns.forEach((column) => {
170
- const th = document.createElement("th");
171
- th.textContent = column;
172
- header.appendChild(th);
173
- });
174
-
175
- thead.appendChild(header);
176
- table.appendChild(thead);
177
 
178
  manifests[task.models[0]].forEach((item) => {
179
- const row = document.createElement("tr");
180
- const scriptCell = document.createElement("td");
181
-
182
- scriptCell.appendChild(createScriptCell(item));
183
- row.appendChild(scriptCell);
 
184
 
185
  if (task.show_reference) {
186
- const referenceCell = document.createElement("td");
187
  const modelRoot = `${taskRoot}/${task.models[0]}`;
188
- referenceCell.appendChild(createReferenceCell(item, modelRoot));
189
- row.appendChild(referenceCell);
190
  }
191
 
192
  task.models.forEach((model) => {
193
  const modelItem = manifests[model].find((entry) => entry.utt === item.utt);
194
- const td = document.createElement("td");
195
  if (modelItem) {
196
- td.appendChild(createAudio(`${taskRoot}/${model}/${modelItem.output_audio}`));
197
  }
198
- row.appendChild(td);
199
  });
200
 
201
- tbody.appendChild(row);
 
202
  });
203
 
204
- table.appendChild(tbody);
205
- wrapper.appendChild(table);
206
  return wrapper;
207
  }
208
 
 
156
  }[char]));
157
  }
158
 
159
+ function createCaseCell(label, content) {
160
+ const cell = document.createElement("div");
161
+ cell.className = "case-cell";
162
+
163
+ const heading = document.createElement("div");
164
+ heading.className = "case-cell-label";
165
+ heading.textContent = label;
166
+
167
+ const body = document.createElement("div");
168
+ body.className = "case-cell-body";
169
+ if (content) {
170
+ body.appendChild(content);
171
+ }
172
+
173
+ cell.appendChild(heading);
174
+ cell.appendChild(body);
175
+ return cell;
176
+ }
177
+
178
  function renderTable(task, manifests, taskRoot) {
179
  const wrapper = document.createElement("div");
180
+ wrapper.className = task.show_reference ? "demo-cases" : "demo-cases without-reference";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
181
 
182
  manifests[task.models[0]].forEach((item) => {
183
+ const caseScroll = document.createElement("div");
184
+ caseScroll.className = "case-scroll";
185
+ const caseGrid = document.createElement("div");
186
+ caseGrid.className = "case-grid";
187
+ caseGrid.style.setProperty("--model-count", task.models.length);
188
+ caseGrid.appendChild(createCaseCell("Script", createScriptCell(item)));
189
 
190
  if (task.show_reference) {
 
191
  const modelRoot = `${taskRoot}/${task.models[0]}`;
192
+ caseGrid.appendChild(createCaseCell("Reference", createReferenceCell(item, modelRoot)));
 
193
  }
194
 
195
  task.models.forEach((model) => {
196
  const modelItem = manifests[model].find((entry) => entry.utt === item.utt);
197
+ const content = document.createElement("div");
198
  if (modelItem) {
199
+ content.appendChild(createAudio(`${taskRoot}/${model}/${modelItem.output_audio}`));
200
  }
201
+ caseGrid.appendChild(createCaseCell(model, content));
202
  });
203
 
204
+ caseScroll.appendChild(caseGrid);
205
+ wrapper.appendChild(caseScroll);
206
  });
207
 
 
 
208
  return wrapper;
209
  }
210
 
static/css/index.css CHANGED
@@ -166,72 +166,51 @@ body {
166
  line-height: 1.5;
167
  }
168
 
169
- .demo-table {
170
- overflow-x: auto;
171
- border: 0;
172
- background: var(--paper);
173
- }
174
-
175
- .demo-table table {
176
- width: 100%;
177
- min-width: 1380px;
178
- border-collapse: collapse;
179
- table-layout: fixed;
180
- }
181
-
182
- .demo-table th {
183
- position: sticky;
184
- top: 0;
185
- z-index: 1;
186
- border-bottom: 1px solid var(--line);
187
- background: var(--soft);
188
- font-size: 0.9rem;
189
- font-weight: 700;
190
- text-align: center;
191
- }
192
-
193
- .demo-table th,
194
- .demo-table td {
195
- width: 18%;
196
- border-right: 1px solid var(--line);
197
  padding: 0.9rem;
198
- vertical-align: top;
199
  }
200
 
201
- .demo-table th:first-child,
202
- .demo-table td:first-child {
203
- width: 28%;
 
204
  }
205
 
206
- .demo-table table.without-reference {
207
- min-width: 1500px;
 
 
208
  }
209
 
210
- .demo-table table.without-reference th:first-child,
211
- .demo-table table.without-reference td:first-child {
212
- width: 25%;
213
  }
214
 
215
- .demo-table table.without-reference th,
216
- .demo-table table.without-reference td {
217
- width: 15%;
 
218
  }
219
 
220
- .demo-table th:last-child,
221
- .demo-table td:last-child {
222
  border-right: 0;
223
  }
224
 
225
- .demo-table tr {
226
  border-bottom: 1px solid var(--line);
 
 
 
 
 
 
227
  }
228
 
229
- .demo-table tbody tr:nth-child(odd) {
230
- background: #fbfbfb;
231
- }
232
-
233
- .demo-table tbody tr:last-child {
234
- border-bottom: 0;
235
  }
236
 
237
  .script-cell {
 
166
  line-height: 1.5;
167
  }
168
 
169
+ .demo-cases {
170
+ display: grid;
171
+ gap: 0.8rem;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
172
  padding: 0.9rem;
173
+ background: var(--paper);
174
  }
175
 
176
+ .case-scroll {
177
+ overflow-x: auto;
178
+ border: 1px solid var(--line);
179
+ background: #fbfbfb;
180
  }
181
 
182
+ .case-grid {
183
+ display: grid;
184
+ grid-template-columns: 28rem 20rem repeat(var(--model-count), 20rem);
185
+ min-width: max-content;
186
  }
187
 
188
+ .demo-cases.without-reference .case-grid {
189
+ grid-template-columns: 30rem repeat(var(--model-count), 20rem);
 
190
  }
191
 
192
+ .case-cell {
193
+ min-width: 0;
194
+ border-right: 1px solid var(--line);
195
+ background: var(--paper);
196
  }
197
 
198
+ .case-cell:last-child {
 
199
  border-right: 0;
200
  }
201
 
202
+ .case-cell-label {
203
  border-bottom: 1px solid var(--line);
204
+ background: var(--soft);
205
+ padding: 0.55rem 0.75rem;
206
+ color: var(--ink);
207
+ font-size: 0.86rem;
208
+ font-weight: 700;
209
+ text-align: center;
210
  }
211
 
212
+ .case-cell-body {
213
+ padding: 0.85rem;
 
 
 
 
214
  }
215
 
216
  .script-cell {