Zixuan19 commited on
Commit
b384eef
·
verified ·
1 Parent(s): 2db751e

full examples as an always-open panel at the top of the form

Browse files
Files changed (4) hide show
  1. app.js +4 -9
  2. data.json +5 -21
  3. index.html +10 -13
  4. style.css +2 -12
app.js CHANGED
@@ -234,14 +234,10 @@ function renderExample() {
234
  const brief = D.dims.map(d => { const p = e.points[d.id][0]; return `<div class="dim ${d.id}"><h4>${esc(d.label[i])}</h4><ol><li>${esc(p[i])}<span class="where">${esc(p[2 + i])}</span></li></ol></div>`; }).join("");
235
  $("#ex_body").innerHTML = `<div class="ex_media">${media}</div><div class="ex_text"><div class="chips"><span>${esc(e.game[i])}</span><span>${esc(e.category[i])}</span></div>` +
236
  `<h4>${t("ex_idea")}</h4><p>${esc(e.idea[i])}</p><h4>${t("sum_points")}</h4><div class="dims">${brief}</div></div>`;
237
- // next to the form: under each field, what this example wrote there
238
- const lab = `<b class="exlab">${t("ex_label")}</b>`, pts = d => `<ol>${e.points[d].map(p => `<li>${esc(p[i])}<span class="where">${esc(p[2 + i])}</span></li>`).join("")}</ol>`;
239
- const hint = {fit: `<p>${esc(e.game[i])}: ${esc(e.fit[i])}</p>`,
240
- ref: `${media}<p>${esc(e.reference[i])}</p>${e.credit ? `<p class="credit">${esc(e.credit)}</p>` : ""}`,
241
- category: `<p>${esc(e.category[i])}</p>`, idea: `<p>${esc(e.idea[i])}</p>`, edit: `<p>${esc(e.edit[i])}</p>`,
242
- content: pts("content"), function: pts("function"), visual: pts("visual")};
243
- for (const el of $$(".exhint")) el.innerHTML = lab + hint[el.dataset.ex];
244
- $("#ex_toggle").textContent = t(document.body.classList.contains("noex") ? "ex_show" : "ex_hide");
245
  }
246
  function counters() {
247
  for (const k of ["idea", "fit", "edit", "new_modding"]) { const [a, b] = lim(k), n = size($("#" + k).value), c = $(`#${k}_n`);
@@ -262,7 +258,6 @@ function render() {
262
  $("#links").innerHTML = D.links.filter(([k]) => k !== "l_home").map(([k, url]) => `<a href="${esc(url)}" target="_blank" rel="noopener">${t(k)}</a>`).join("");
263
  for (const id of ["#ex_tabs", "#exf_tabs"]) $(id).innerHTML = D.examples.map((e, k) => `<button type="button" role="tab" data-i="${k}">${esc(e.tab[li()])}</button>`).join("");
264
  $$("#ex_tabs button, #exf_tabs button").forEach(b => b.onclick = () => { exTab = +b.dataset.i; renderExample(); });
265
- $("#ex_toggle").onclick = () => { document.body.classList.toggle("noex"); renderExample(); };
266
  renderExample();
267
  for (const el of $$("[data-t]")) el.textContent = t(el.dataset.t);
268
  for (const el of $$("[data-ph]")) el.placeholder = t(el.dataset.ph);
 
234
  const brief = D.dims.map(d => { const p = e.points[d.id][0]; return `<div class="dim ${d.id}"><h4>${esc(d.label[i])}</h4><ol><li>${esc(p[i])}<span class="where">${esc(p[2 + i])}</span></li></ol></div>`; }).join("");
235
  $("#ex_body").innerHTML = `<div class="ex_media">${media}</div><div class="ex_text"><div class="chips"><span>${esc(e.game[i])}</span><span>${esc(e.category[i])}</span></div>` +
236
  `<h4>${t("ex_idea")}</h4><p>${esc(e.idea[i])}</p><h4>${t("sum_points")}</h4><div class="dims">${brief}</div></div>`;
237
+ $("#exf_body").innerHTML = `<div class="ex_media">${media}<p class="ex_ref"><b>${t("ex_ref")}</b> ${esc(e.reference[i])}</p>${e.credit ? `<p class="credit">${esc(e.credit)}</p>` : ""}` +
238
+ `<h4>${t("ex_fit")}</h4><p>${esc(e.fit[i])}</p><h4>${t("ex_idea")}</h4><p>${esc(e.idea[i])}</p><h4>${t("ex_edit")}</h4><p>${esc(e.edit[i])}</p></div>` +
239
+ `<div class="ex_text"><div class="chips"><span>${esc(e.game[i])}</span><span>${esc(e.category[i])}</span></div>` +
240
+ `<h4>${t("sum_points")}</h4><div class="dims">${dims}</div><p class="result">${esc(e.result[i])}</p></div>`;
 
 
 
 
241
  }
242
  function counters() {
243
  for (const k of ["idea", "fit", "edit", "new_modding"]) { const [a, b] = lim(k), n = size($("#" + k).value), c = $(`#${k}_n`);
 
258
  $("#links").innerHTML = D.links.filter(([k]) => k !== "l_home").map(([k, url]) => `<a href="${esc(url)}" target="_blank" rel="noopener">${t(k)}</a>`).join("");
259
  for (const id of ["#ex_tabs", "#exf_tabs"]) $(id).innerHTML = D.examples.map((e, k) => `<button type="button" role="tab" data-i="${k}">${esc(e.tab[li()])}</button>`).join("");
260
  $$("#ex_tabs button, #exf_tabs button").forEach(b => b.onclick = () => { exTab = +b.dataset.i; renderExample(); });
 
261
  renderExample();
262
  for (const el of $$("[data-t]")) el.textContent = t(el.dataset.t);
263
  for (const el of $$("[data-ph]")) el.placeholder = t(el.dataset.ph);
data.json CHANGED
@@ -117,28 +117,12 @@
117
  "一道题长什么样"
118
  ],
119
  "ex_more": [
120
- "In the form below, each field shows how these three challenges filled it in.",
121
- "下面填表时,每一栏旁边都能看到这三道题在那一栏是怎么写的。"
122
  ],
123
- "exbar": [
124
- "Example to follow",
125
- "参考例子"
126
- ],
127
- "exbar_sub": [
128
- "The purple box under each field shows how this example filled it in.",
129
- "每一栏下面的紫色框,是这道例题在那一栏的写法。"
130
- ],
131
- "ex_hide": [
132
- "Hide examples",
133
- "隐藏例子"
134
- ],
135
- "ex_show": [
136
- "Show examples",
137
- "显示例子"
138
- ],
139
- "ex_label": [
140
- "Example",
141
- "例子"
142
  ],
143
  "ex_excerpt": [
144
  "Excerpt from the reference text",
 
117
  "一道题长什么样"
118
  ],
119
  "ex_more": [
120
+ "The full write-up of these three challenges is next to the form below, for reference while you fill it in.",
121
+ "这三道题的完整写法放在下面填表的地方,填的时候可以对照。"
122
  ],
123
+ "exf_title": [
124
+ "Reference: three complete challenges, field by field",
125
+ "参考例子:三道完整的题,每一栏怎么填"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
  ],
127
  "ex_excerpt": [
128
  "Excerpt from the reference text",
index.html CHANGED
@@ -83,11 +83,11 @@
83
  <section id="form" hidden>
84
  <div class="step" id="s2"><span class="num">02</span><div><h2 data-t="s2"></h2><p data-t="s2_sub"></p></div></div>
85
  <div id="auth"></div>
86
- <div class="exbar" id="exbar">
87
- <b data-t="exbar"></b><div id="exf_tabs" class="chips" role="tablist"></div>
88
- <span class="exbar_sub" data-t="exbar_sub"></span>
89
- <button type="button" id="ex_toggle" class="linkbtn"></button>
90
- </div>
91
  <div class="cols">
92
  <div class="fields">
93
  <section class="panel" id="sec_game">
@@ -104,14 +104,14 @@
104
  <fieldset><legend data-t="new_help"></legend><div class="opts col" id="new_help"></div></fieldset>
105
  </fieldset>
106
  <label class="q" for="fit" data-t="fit"></label><p class="info" data-t="fit_info"></p>
107
- <textarea id="fit" rows="2" data-ph="fit_ph"></textarea><div id="fit_n" class="count"></div><div class="exhint" data-ex="fit"></div>
108
  </section>
109
 
110
  <section class="panel" id="sec_ref">
111
  <h3 class="sec"><span data-t="sec_ref"></span></h3>
112
  <div class="q" data-t="files"></div>
113
  <label class="drop" id="drop"><input id="file" type="file" multiple accept=".png,.jpg,.jpeg,.webp,.mp4,.webm,.mov,.txt,.md"><b data-t="drop"></b><small data-t="drop_sub"></small></label>
114
- <ul id="filelist" class="filelist"></ul><div class="exhint" data-ex="ref"></div>
115
  <div class="row">
116
  <div class="grow"><label class="q" for="link" data-t="link"></label><input id="link" type="url" placeholder="https://..."></div>
117
  <div><label class="q" for="time_range" data-t="time_range"></label><input id="time_range" type="text" placeholder="1:12-1:41"></div>
@@ -122,25 +122,22 @@
122
 
123
  <section class="panel" id="sec_task">
124
  <h3 class="sec"><span data-t="sec_task"></span></h3>
125
- <fieldset><legend data-t="category"></legend><div class="opts col" id="category"></div></fieldset><div class="exhint" data-ex="category"></div>
126
  <label class="q" for="idea" data-t="idea"></label><p class="info" data-t="idea_info"></p>
127
- <textarea id="idea" rows="4" data-ph="idea_ph"></textarea><div id="idea_n" class="count"></div><div class="exhint" data-ex="idea"></div>
128
  </section>
129
 
130
  <section class="panel">
131
  <h3 class="sec"><span data-t="pts"></span><span id="pts_n" class="pill"></span></h3>
132
  <p class="info" data-t="pts_info"></p>
133
  <fieldset class="dimbox content"><legend data-t="content"></legend><p class="info" data-t="content_info"></p>
134
- <div class="exhint" data-ex="content"></div>
135
  <div id="content_rows" class="rows"></div><button type="button" id="content_add" class="add"><span aria-hidden="true">+</span> <span data-t="p_add"></span></button></fieldset>
136
  <fieldset class="dimbox function"><legend data-t="function"></legend><p class="info" data-t="function_info"></p>
137
- <div class="exhint" data-ex="function"></div>
138
  <div id="function_rows" class="rows"></div><button type="button" id="function_add" class="add"><span aria-hidden="true">+</span> <span data-t="p_add"></span></button></fieldset>
139
  <fieldset class="dimbox visual"><legend data-t="visual"></legend><p class="info" data-t="visual_info"></p>
140
- <div class="exhint" data-ex="visual"></div>
141
  <div id="visual_rows" class="rows"></div><button type="button" id="visual_add" class="add"><span aria-hidden="true">+</span> <span data-t="p_add"></span></button></fieldset>
142
  <label class="q" for="edit" data-t="edit"></label><p class="info" data-t="edit_info"></p>
143
- <input id="edit" type="text" data-ph="edit_ph"><div id="edit_n" class="count"></div><div class="exhint" data-ex="edit"></div>
144
  </section>
145
 
146
  <section class="panel" id="sec_submit">
 
83
  <section id="form" hidden>
84
  <div class="step" id="s2"><span class="num">02</span><div><h2 data-t="s2"></h2><p data-t="s2_sub"></p></div></div>
85
  <div id="auth"></div>
86
+ <section class="panel examples" id="exfull">
87
+ <h3 class="sec"><span data-t="exf_title"></span></h3>
88
+ <div id="exf_tabs" class="chips" role="tablist"></div>
89
+ <div id="exf_body" class="ex_grid"></div>
90
+ </section>
91
  <div class="cols">
92
  <div class="fields">
93
  <section class="panel" id="sec_game">
 
104
  <fieldset><legend data-t="new_help"></legend><div class="opts col" id="new_help"></div></fieldset>
105
  </fieldset>
106
  <label class="q" for="fit" data-t="fit"></label><p class="info" data-t="fit_info"></p>
107
+ <textarea id="fit" rows="2" data-ph="fit_ph"></textarea><div id="fit_n" class="count"></div>
108
  </section>
109
 
110
  <section class="panel" id="sec_ref">
111
  <h3 class="sec"><span data-t="sec_ref"></span></h3>
112
  <div class="q" data-t="files"></div>
113
  <label class="drop" id="drop"><input id="file" type="file" multiple accept=".png,.jpg,.jpeg,.webp,.mp4,.webm,.mov,.txt,.md"><b data-t="drop"></b><small data-t="drop_sub"></small></label>
114
+ <ul id="filelist" class="filelist"></ul>
115
  <div class="row">
116
  <div class="grow"><label class="q" for="link" data-t="link"></label><input id="link" type="url" placeholder="https://..."></div>
117
  <div><label class="q" for="time_range" data-t="time_range"></label><input id="time_range" type="text" placeholder="1:12-1:41"></div>
 
122
 
123
  <section class="panel" id="sec_task">
124
  <h3 class="sec"><span data-t="sec_task"></span></h3>
125
+ <fieldset><legend data-t="category"></legend><div class="opts col" id="category"></div></fieldset>
126
  <label class="q" for="idea" data-t="idea"></label><p class="info" data-t="idea_info"></p>
127
+ <textarea id="idea" rows="4" data-ph="idea_ph"></textarea><div id="idea_n" class="count"></div>
128
  </section>
129
 
130
  <section class="panel">
131
  <h3 class="sec"><span data-t="pts"></span><span id="pts_n" class="pill"></span></h3>
132
  <p class="info" data-t="pts_info"></p>
133
  <fieldset class="dimbox content"><legend data-t="content"></legend><p class="info" data-t="content_info"></p>
 
134
  <div id="content_rows" class="rows"></div><button type="button" id="content_add" class="add"><span aria-hidden="true">+</span> <span data-t="p_add"></span></button></fieldset>
135
  <fieldset class="dimbox function"><legend data-t="function"></legend><p class="info" data-t="function_info"></p>
 
136
  <div id="function_rows" class="rows"></div><button type="button" id="function_add" class="add"><span aria-hidden="true">+</span> <span data-t="p_add"></span></button></fieldset>
137
  <fieldset class="dimbox visual"><legend data-t="visual"></legend><p class="info" data-t="visual_info"></p>
 
138
  <div id="visual_rows" class="rows"></div><button type="button" id="visual_add" class="add"><span aria-hidden="true">+</span> <span data-t="p_add"></span></button></fieldset>
139
  <label class="q" for="edit" data-t="edit"></label><p class="info" data-t="edit_info"></p>
140
+ <input id="edit" type="text" data-ph="edit_ph"><div id="edit_n" class="count"></div>
141
  </section>
142
 
143
  <section class="panel" id="sec_submit">
style.css CHANGED
@@ -79,17 +79,7 @@ main { padding-block: 26px 48px; }
79
 
80
  /* examples */
81
  .ex_more { margin-top: 14px; }
82
- .exbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 0 0 18px; padding: 12px 16px; background: var(--accent-soft); border: 1px solid var(--accent-mid); border-radius: 10px; }
83
- .exbar > b { font: 600 15px/1.3 var(--sans); color: var(--accent); } .exbar .chips { margin: 0; }
84
- .exbar_sub { flex: 1 1 240px; font-size: 14px; color: var(--muted); }
85
- .linkbtn { border: 0; background: none; padding: 0; font: 600 14px/1.3 var(--sans); color: var(--accent); cursor: pointer; text-decoration: underline; }
86
- .exhint { margin: 8px 0 4px; padding: 10px 12px 10px 14px; background: #f6f3fc; border-left: 3px solid var(--accent-mid); border-radius: 0 6px 6px 0; font-size: 14px; line-height: 1.5; color: var(--body); }
87
- .exhint .exlab { display: block; margin-bottom: 4px; font: 600 11px/1.2 var(--sans); letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
88
- .exhint ol { margin: 0; padding-left: 20px; } .exhint li + li { margin-top: 4px; } .exhint p + p, .exhint .gallery + p, .exhint video + p, .exhint .quote + p { margin-top: 8px; }
89
- .exhint .gallery { grid-template-columns: repeat(6, minmax(0, 1fr)); max-width: 560px; } .exhint video { max-width: 420px; } .exhint .quote { background: #fff; font-size: 14px; }
90
- .exhint .credit { font-size: 12px; color: var(--dim); }
91
- body.noex .exhint, body.noex .exbar_sub, body.noex #exf_tabs { display: none; }
92
- #ex_body { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 26px; align-items: start; margin-top: 16px; }
93
  .gallery { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
94
  .gallery a { position: relative; display: block; aspect-ratio: 1; border-radius: 6px; overflow: hidden; background: var(--surface); border: 1px solid var(--line); }
95
  .gallery a:hover { border-color: var(--accent-mid); }
@@ -220,7 +210,7 @@ textarea { resize: vertical; line-height: 1.5; }
220
  .foot { border-top: 1px solid var(--line); padding-block: 22px 34px; font-size: 13px; color: var(--dim); background: var(--surface); } .foot p + p { margin-top: 4px; }
221
 
222
  @media (max-width: 1080px) { #steps { display: none; } .hero_grid { grid-template-columns: minmax(0, 1fr); } .hero_art { display: none; } }
223
- @media (max-width: 900px) { .cols, #ex_body { grid-template-columns: minmax(0, 1fr); } .notes { position: static; max-height: none; } .notes h2 { position: static; } }
224
  @media (max-width: 640px) {
225
  :root { --gut: 16px; }
226
  .how, .two, .tiers { grid-template-columns: minmax(0, 1fr); }
 
79
 
80
  /* examples */
81
  .ex_more { margin-top: 14px; }
82
+ #ex_body, .ex_grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 26px; align-items: start; margin-top: 16px; }
 
 
 
 
 
 
 
 
 
 
83
  .gallery { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
84
  .gallery a { position: relative; display: block; aspect-ratio: 1; border-radius: 6px; overflow: hidden; background: var(--surface); border: 1px solid var(--line); }
85
  .gallery a:hover { border-color: var(--accent-mid); }
 
210
  .foot { border-top: 1px solid var(--line); padding-block: 22px 34px; font-size: 13px; color: var(--dim); background: var(--surface); } .foot p + p { margin-top: 4px; }
211
 
212
  @media (max-width: 1080px) { #steps { display: none; } .hero_grid { grid-template-columns: minmax(0, 1fr); } .hero_art { display: none; } }
213
+ @media (max-width: 900px) { .cols, #ex_body, .ex_grid { grid-template-columns: minmax(0, 1fr); } .notes { position: static; max-height: none; } .notes h2 { position: static; } }
214
  @media (max-width: 640px) {
215
  :root { --gut: 16px; }
216
  .how, .two, .tiers { grid-template-columns: minmax(0, 1fr); }