diff --git a/assets/css/hub.css b/assets/css/hub.css index dbb7726..5c36054 100644 --- a/assets/css/hub.css +++ b/assets/css/hub.css @@ -2931,3 +2931,105 @@ a.cont-chip { text-decoration: none; } .cont-chip.go, .cont-chip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .cont-chip:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; } .lp-note.build a { font-weight: 800; color: var(--accent); text-underline-offset: 3px; } +/* curriculum as a syllabus: Level 0–4 as rows that open in place; the open level leads with the next topic. + One square per topic shows how far a level has been started (kept in this browser only). */ +.lt-card { grid-template-columns: minmax(0, 1fr) auto; gap: 10px 20px; margin: 0 0 14px; padding: 12px 14px 12px 20px; border-radius: 16px; } +.lt-card.lt-slim { padding: 12px 14px 12px 20px; gap: 10px 20px; margin-bottom: 14px; border-radius: 16px; } +.lt-card .lt-t { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; margin: 0; font-size: 15px; font-weight: 400; line-height: 1.45; } +.lt-card .lt-t b { font-weight: 750; color: #fff; } +.lt-card .lt-k { font-size: 12.5px; font-weight: 800; padding: 1px 9px; border-radius: 999px; background: #FFC93C; color: #1E2160; align-self: center; } +.lt-card .lt-s { font-size: 13.5px; color: rgba(255, 255, 255, .78); } +.lt-card .pill, .lt-card.lt-slim .pill { min-height: 38px; padding: 0 16px; font-size: 14px; } +@media (max-width: 960px) { .lt-card, .lt-card.lt-slim { grid-template-columns: minmax(0, 1fr) auto; } } +.tabs-row { margin-bottom: 12px; } +.tabs-row .tabs.big { margin: 0 0 8px; } + +.sy { display: grid; gap: 8px; } +.sy-layer { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; margin: 10px 2px 0; font-size: 14px; font-weight: 800; color: var(--ink); } +.sy-layer:first-child { margin-top: 0; } +.sy-layer span { font-size: 13px; font-weight: 600; color: var(--muted); } +.sy-lv { border: 1px solid var(--rule); border-radius: 18px; background: var(--surface); } +.sy-lv[open] { box-shadow: var(--shadow); } +.sy-lv > summary { list-style: none; cursor: pointer; display: grid; grid-template-columns: 40px minmax(0, 1fr) auto 20px; align-items: center; gap: 14px; padding: 14px 18px; border-radius: 18px; } +.sy-lv > summary::-webkit-details-marker { display: none; } +.sy-lv > summary:hover .sy-tt b { color: var(--accent); } +.sy-lv > summary:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; } +.sy-num { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-family: var(--f-display); font-weight: 800; font-size: 17px; border: 3px solid var(--l-main); color: var(--ink); background: var(--surface); } +.sy-lv.build .sy-num { border-color: var(--l-ml); } +.sy-lv.mine .sy-num { background: #FFC93C; border-color: #FFC93C; color: #1E2160; } +.sy-lv.past .sy-num { border-color: var(--rule); color: var(--muted); } +.sy-lv.cleared .sy-num { background: var(--l-main); border-color: var(--l-main); color: #fff; } +.sy-h { min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 14px; } +.sy-tt { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; } +.sy-tt b { font-size: 18px; font-weight: 800; letter-spacing: -.01em; } +.sy-tt .lr-mine { align-self: center; } +.sy-q { font-size: 14.5px; color: var(--muted); } +.sy-tag { align-self: center; font-size: 12px; font-weight: 800; padding: 1px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); } +.sy-tag.on { background: color-mix(in srgb, #FFC93C 40%, var(--surface)); color: var(--ink); } +.sy-p { display: inline-flex; align-items: center; gap: 10px; } +.sy-sq { display: inline-flex; flex-wrap: wrap; gap: 3px; max-width: 160px; } +.sy-sq i { width: 11px; height: 11px; border-radius: 3px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--rule); } +.sy-sq i.on { background: var(--l-main); box-shadow: none; } +.sy-lv.build .sy-sq i.on { background: var(--l-ml); } +.sy-n { min-width: 38px; text-align: right; font-size: 13.5px; font-weight: 750; color: var(--muted); font-variant-numeric: tabular-nums; } +.sy-chev { width: 10px; height: 10px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg) translate(-2px, -2px); transition: transform .2s ease; justify-self: center; } +.sy-lv[open] .sy-chev { transform: rotate(225deg) translate(-2px, -2px); } +.sy-body { padding: 2px 22px 20px 72px; } +.sy-body > .lr-clear { margin: 0 0 12px; } +.sy-body .lp-note.build { margin: 0 0 14px; } +.sy-next { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 0 0 14px; padding: 12px 14px; border-radius: 14px; background: var(--accent-soft); } +.sy-next-k { font-size: 13.5px; font-weight: 800; color: var(--ink); } +.sy-go { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 16px; border-radius: 999px; border: 0; background: var(--l-main); color: #fff; font: inherit; font-size: 14.5px; font-weight: 750; text-decoration: none; cursor: pointer; max-width: 100%; } +.sy-go i { font-style: normal; font-size: 12px; font-weight: 800; padding: 1px 7px; border-radius: 999px; background: rgba(255, 255, 255, .22); } +.sy-go:hover { filter: brightness(1.08); } +.sy-go:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; } +:root[data-theme="dark"] .sy-go { color: #0E1020; } +@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .sy-go { color: #0E1020; } } +.sy-next.done { background: var(--surface-2); } +.sy-body .lt-list { margin-bottom: 0; } +@media (min-width: 1000px) { + .sy-body .lt-list { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 36px; } + .sy-body .lt-list > .lt:nth-child(2) { border-top: 0; } +} +.lt-up { display: none; font-size: 11.5px; font-weight: 800; padding: 0 8px; border-radius: 999px; background: var(--l-main); color: #fff; } +.lt.next .lt-up { display: inline-block; } +:root[data-theme="dark"] .lt-up { color: #0E1020; } +@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .lt-up { color: #0E1020; } } +.sy-foot { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--rule); display: grid; gap: 8px 36px; } +@media (min-width: 1000px) { .sy-foot { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } } +.sy-f { display: grid; grid-template-columns: 96px minmax(0, 1fr); align-items: baseline; gap: 4px 12px; margin: 0; font-size: 14px; line-height: 1.5; } +.sy-f > b { font-size: 12.5px; font-weight: 800; color: var(--muted); } +.sy-f.lr-crew { display: flex; flex-wrap: wrap; align-items: center; margin: 0; } +.sy-f.lr-crew > b { width: 96px; margin-right: 12px; } +.sy-links { display: flex; flex-wrap: wrap; gap: 4px 14px; } +.sy-links a, .sy-links button { padding: 0; border: 0; background: none; font: inherit; font-weight: 700; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; } +.sy-f .lr-repos button { min-height: 32px; font-size: 13.5px; } +.sy-map { margin: 14px 2px 0; font-size: 14px; color: var(--muted); } +.sy-lv.flash { animation: lr-flash 1.6s ease-out; } +@media (max-width: 720px) { + .sy-lv > summary { grid-template-columns: 34px minmax(0, 1fr) 16px; grid-template-areas: "n h c" "n p c"; gap: 6px 12px; padding: 12px 14px; } + .sy-num { grid-area: n; width: 32px; height: 32px; font-size: 15px; border-width: 2.5px; align-self: start; margin-top: 2px; } + .sy-h { grid-area: h; gap: 0 10px; } + .sy-p { grid-area: p; } + .sy-chev { grid-area: c; } + .sy-tt b { font-size: 16.5px; } + .sy-q { font-size: 13.5px; } + .sy-sq { max-width: none; } + .sy-n { min-width: 0; } + .sy-body { padding: 0 14px 16px; } + .sy-next { padding: 10px 12px; } + .sy-go { width: 100%; justify-content: flex-start; } + .sy-f { grid-template-columns: 1fr; gap: 2px; } + .sy-f.lr-crew > b { width: 100%; } +} +@media (max-width: 720px) { + /* the header already carries the passport, so the curriculum leaves it out on phones */ + .tabs-row .quest-hud { display: none; } + .tabs-row { margin-bottom: 10px; } + .lt-card, .lt-card.lt-slim { grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px 12px; padding: 10px 10px 10px 16px; margin-bottom: 10px; } + .lt-card .lt-t { font-size: 14.5px; } + .lt-card.lt-slim .lt-s { display: none; } + .lt-card:not(.lt-slim) { grid-template-columns: minmax(0, 1fr); } +} +.sy-lv { scroll-margin-top: 24px; } +#panel-course > #progress:not(:empty) { margin-bottom: 14px; } diff --git a/assets/js/hub.js b/assets/js/hub.js index 39e4920..947b516 100644 --- a/assets/js/hub.js +++ b/assets/js/hub.js @@ -387,38 +387,18 @@ const lvIndex = (id) => state.levels.findIndex((l) => l.id === id); /* the level on screen: the one picked, else the tested level, else Level 0 */ const shownLevel = () => (levelOf(state.level) ? state.level : (myLevel() || {}).level || "L0"); - /* where this level sits for the visitor: their level, passed by the test, cleared, or not yet */ + /* where a level sits for the visitor: cleared, their tested level, passed by the test, or not yet */ function levelStatus(lv) { const mine = myLevel(), mi = mine ? lvIndex(mine.level) : -1, i = lvIndex(lv.id); - if (levelDone(lv.id)) return { cls: "cleared", label: "클리어" }; - if (mine && i === mi) return { cls: "mine", label: "내 레벨" }; - if (mine && i < mi) return { cls: "past", label: "통과" }; - const q = questsOf(lv.id), unit = (lv.quests || []).length ? "" : "주제 "; - return { cls: !mine && i > 0 ? "ahead" : "", label: `${unit}${q.filter(questDone).length} / ${q.length}` }; - } - /* five stations on one line; the line is filled up to the visitor's level */ - function renderRail(reveal) { - const box = $("#lv-rail"); - if (!box) return; - const mine = myLevel(), mi = mine ? lvIndex(mine.level) : -1, sel = lvIndex(shownLevel()); - const n = state.levels.length; - box.innerHTML = `
    - - ${state.levels.map((lv, i) => { - const st = levelStatus(lv), q = questsOf(lv.id), pct = q.length ? q.filter(questDone).length / q.length : 0; - const mark = st.cls === "cleared" ? "★" : st.cls === "past" ? "✓" : String(i); - return `
  1. -
  2. `; - }).join("")} - -
`; - } + if (levelDone(lv.id)) return "cleared"; + if (mine && i === mi) return "mine"; + if (mine && i < mi) return "past"; + return ""; + } + /* one square per topic (per thing to do on build levels), filled once it has been started */ + const squaresHTML = (lv) => ``; + const countOf = (lv) => { const q = questsOf(lv.id); return { done: q.filter(questDone).length, n: q.length }; }; + const countLabel = (lv) => { const c = countOf(lv); return `${(lv.quests || []).length ? "할 일" : "주제"} ${c.n}개 중 ${c.done}개 ${(lv.quests || []).length ? "완료" : "시작"}`; }; /* the library topics a level covers, in order, each with the one or two materials to start from (data/levels.json topics + data/topics.json). A material's level follows the library: web book chapters 1–16 are Level 1 and the rest Level 2; other materials take their repository's level. */ @@ -449,120 +429,157 @@ const isOpened = (x) => (doneCheck || (doneCheck = openedCheck()))(x); const topicById = (id) => ((state.topicData && state.topicData.topics) || []).find((tp) => tp.id === id); const topicStarted = (id) => { const tp = topicById(id); return !!tp && (tp.items || []).some(isOpened); }; - /* topic rows carry their progress as an element that is updated in place, so returning to the page or + /* progress is painted in place (rows, squares, counts, the next-topic button), so returning to the page or opening a material never redraws the list under the reader */ function paintTopicProgress() { const all = (state.topicData && state.topicData.topics) || []; - const rows = document.querySelectorAll("#shelf .lt[data-topic]"); - if (!rows.length) return; const done = isOpened; - let started = 0; - rows.forEach((li) => { - const t = all.find((x) => x.id === li.dataset.topic); - const items = (t && t.items) || []; - const n = items.length, d = items.filter(done).length; - if (d) started += 1; - li.classList.toggle("on", d > 0); - li.classList.toggle("full", n > 0 && d === n); - const p = li.querySelector(".lt-p"); - if (p) { - p.hidden = !d; - p.setAttribute("aria-label", `자료 ${n}개 중 ${d}개 열어봄`); - p.querySelector("b").textContent = `${d}/${n}`; - p.querySelector("i").style.width = `${n ? Math.round((d / n) * 100) : 0}%`; - } + document.querySelectorAll("#shelf .sy-lv").forEach((box) => { + const lv = levelOf(box.dataset.row); + if (!lv) return; + let started = 0; + box.querySelectorAll(".lt[data-topic]").forEach((li) => { + const t = all.find((x) => x.id === li.dataset.topic); + const items = (t && t.items) || []; + const n = items.length, d = items.filter(done).length; + if (d) started += 1; + li.classList.toggle("on", d > 0); + li.classList.toggle("full", n > 0 && d === n); + li.classList.remove("next"); + const p = li.querySelector(".lt-p"); + if (p) { + p.hidden = !d; + p.setAttribute("aria-label", `자료 ${n}개 중 ${d}개 열어봄`); + p.querySelector("b").textContent = `${d}/${n}`; + p.querySelector("i").style.width = `${n ? Math.round((d / n) * 100) : 0}%`; + } + }); + const s = box.querySelector(".lt-started"); + if (s) { s.hidden = !started; s.textContent = ` · ${started}개 시작함`; } + questsOf(lv.id).forEach((q) => { const sq = box.querySelector(`[data-sq="${CSS.escape(q.repo)}"]`); if (sq) sq.classList.toggle("on", questDone(q)); }); + const c = countOf(lv), cn = box.querySelector(".sy-n"), cl = box.querySelector(".sy-c"); + if (cn) cn.textContent = `${c.done}/${c.n}`; + if (cl) cl.textContent = countLabel(lv); + const nb = box.querySelector(".sy-next-box"); + if (nb) nb.innerHTML = nextHTML(lv); + const nx = nextTopic(lv); + const row = nx && box.querySelector(`.lt[data-topic="${CSS.escape(nx.t.id)}"]`); + if (row) row.classList.add("next"); }); - const s = document.querySelector("#shelf .lt-started"); - if (s) { s.hidden = !started; s.textContent = ` · ${started}개 시작함`; } } - function topicOrder(lv) { - const all = (state.topicData && state.topicData.topics) || []; - const ts = (lv.topics || []).map((id) => all.find((t) => t.id === id)).filter(Boolean); + /* the first topic of a level not started yet, and the material to open first */ + function nextTopic(lv) { + if ((lv.quests || []).length) return null; + const q = questsOf(lv.id).filter((x) => x.topic); + const t = q.find((x) => !questDone(x)); + const x = t && startWith(t.t, lv.id)[0]; + return x ? { t: t.t, x, k: q.indexOf(t) + 1 } : null; + } + const outLink = (url) => /^https?:/.test(url) && !/^https:\/\/causalinferencelab\.github\.io\//.test(url); + function nextHTML(lv) { + const n = nextTopic(lv); + if (!n) { + const nx = state.levels[lvIndex(lv.id) + 1]; + return nx ? `

이 레벨의 주제를 모두 시작했습니다

` : ""; + } + return `

다음 주제 · ${n.k}. ${esc(n.t.name)} + ${esc(KIND_NAME[n.x.kind] || "자료")}${esc(n.x.title)}

`; + } + /* a level's topics in study order, each with the one or two materials to start from */ + function topicRows(lv) { + const ts = (lv.topics || []).map(topicById).filter(Boolean); if (!ts.length) return ""; const ev = (topic, target) => `data-event="level_topic" data-event-params='${esc(JSON.stringify({ level: lv.id, topic, target }))}'`; const row = (t, k) => `
  • -
    ${esc(t.name)} +
    ${esc(t.name)}다음 - ${startWith(t, lv.id).map((x) => `${esc(KIND_NAME[x.kind] || "자료")}${esc(x.title)}`).join("")} + ${startWith(t, lv.id).map((x) => `${esc(KIND_NAME[x.kind] || "자료")}${esc(x.title)}`).join("")} 자료 ${(t.items || []).length}개
  • `; - const FIRST = 5, head = ts.slice(0, FIRST), rest = ts.slice(FIRST); - return `

    배우는 주제 ${ts.length}개, 순서대로

    -
      ${head.map((t, k) => row(t, k + 1)).join("")}
    - ${rest.length ? `
    주제 ${rest.length}개 더
      ${rest.map((t, k) => row(t, FIRST + k + 1)).join("")}
    ` : ""}`; + const build = (lv.quests || []).length > 0; + return `

    ${build ? "관련 주제" : "배우는 주제"} ${ts.length}개${build ? "" : ", 순서대로"}

    +
      ${ts.map((t, k) => row(t, k + 1)).join("")}
    `; } - /* one level in full: who it is for, what it covers, what you can do after it, and the order to take it */ - function levelPanel(lv, i) { - const mine = myLevel(), mi = mine ? lvIndex(mine.level) : -1; + /* one level opened: what to open next, the topics in order, then who it is for and what is behind it */ + function levelBody(lv) { const steps = stepsOf(lv), quests = questsOf(lv.id), done = quests.filter(questDone).length, cleared = levelDone(lv.id); const inSteps = new Set(steps.map((s) => s.repo)); const items = levelItems(lv.id); const extra = items.filter((r) => !inSteps.has(r.repo) && r.kind !== "paid"); const books = items.filter((r) => r.kind === "paid"); const build = (lv.quests || []).length > 0; - const topics = topicOrder(lv); + const topics = topicRows(lv); const crew = [...new Set(items.flatMap((r) => r.builders || []))]; - const count = `${done} / ${quests.length}`; - /* a learning level is one path, its topics in order; the repositories behind them are listed once, small */ - const repoList = (label) => `

    ${label}

    `; - const buildNote = build ? `

    Level 3·4는 따라 보는 코스가 아니라 직접 만드는 단계입니다. 아래를 하나씩 해 보고, 다음 기수에 러너로 참여하거나 Builder로 프로젝트를 열어 보세요. 참여 방법 보기

    ` : ""; - const list = build - ? `

    직접 해 보기 ${count}

      ${quests.map((q, k) => questRow(q, k + 1)).join("")}
    - ${repoList("함께 만드는 레포")}` - : topics ? repoList("이 레벨의 자료를 만든 레포") - : `

    이 순서로 ${count}

      ${steps.map((s, k) => stepRow(s.r, k + 1, s.note)).join("")}
    - ${extra.length ? `
    골라 보기 ${extra.length}개
    ` : ""}`; - const text = books.length ? `

    함께 보는 교재${books.map((b) => ``).join("")}

    ` : ""; - /* extras that are not already a topic's material: the game, the lab */ - const inTopics = new Set(questsOf(lv.id).flatMap((q) => (q.t ? q.t.items || [] : []).map((x) => x.url))); + const repos = [...steps.map((s) => [s.r, s.note]), ...extra.map((r) => [r, r.format || ""])]; + const main = build + ? `

    Level 3·4는 따라 보는 코스가 아니라 직접 만드는 단계입니다. 아래를 하나씩 해 보고, 다음 기수에 러너로 참여하거나 Builder로 프로젝트를 열어 보세요. 참여 방법 보기

    +

    직접 해 보기 ${done} / ${quests.length}

      ${quests.map((q, k) => questRow(q, k + 1)).join("")}
    ${topics}` + : topics ? `
    ${topics}` + : `

    이 순서로

      ${steps.map((s, k) => stepRow(s.r, k + 1, s.note)).join("")}
    `; + const inTopics = new Set(quests.flatMap((q) => (q.t ? q.t.items || [] : []).map((x) => x.url))); const extras = (lv.more || []).filter((m) => !inTopics.has(m.href)); - const more = extras.length ? `

    직접 해 보기${extras.map((m) => `${esc(m.title)}`).join("")}

    ` : ""; + const foot = [ + lv.for ? `

    이런 분께${esc(lv.for)}

    ` : "", + lv.outcome ? `

    끝나면${esc(lv.outcome)}

    ` : "", + extras.length ? `

    직접 해 보기${extras.map((m) => `${esc(m.title)}`).join("")}

    ` : "", + books.length ? `

    함께 보는 교재${books.map((b) => ``).join("")}

    ` : "", + repos.length ? `
    ${build ? "함께 만드는 레포" : "자료를 만든 레포"}
    ` : "", + crew.length ? `

    만든 Builder${crew.slice(0, 6).map((n) => `${avatarHTML(n, "sm")}${esc(n)}`).join("")}${crew.length > 6 ? `외 ${crew.length - 6}명` : ""}

    ` : "" + ].join(""); const goal = cleared ? `
    클리어여권에 스탬프가 찍혔습니다.
    ` : ""; - /* one line on why this level is on screen for this visitor */ - const note = !mine - ? (i === 0 ? `

    처음이라면 여기부터 보세요. 아는 내용이라면 으로 내 레벨을 찾아 바로 건너뛸 수 있습니다.

    ` : "") - : i === mi ? `

    진단 결과, 여기서 시작하면 됩니다.${mi > 0 ? ` 앞의 Level ${mi === 1 ? "0" : `0–${mi - 1}`}은 통과했습니다.` : ""}

    ` - : i < mi ? `

    진단에서 통과한 레벨입니다. 필요할 때 복습하세요.

    ` : ""; - const prev = state.levels[i - 1], next = state.levels[i + 1]; - const nav = `
    ${prev ? `` : ""}${next ? `` : ""}
    `; - return `
    -
    -

    ${LV(lv.id)}${esc(lv.tier || lv.name)}${mine && i === mi ? `내 레벨` : ""}

    -

    ${esc(lv.question)}

    - ${note}${buildNote} - ${lv.for ? `

    이런 분께${esc(lv.for)}

    ` : ""} -
    -
    - ${(lv.learn || []).length && !topics ? `

    배우는 것

    ` : ""} - ${lv.outcome ? `

    끝나면${esc(lv.outcome)}

    ` : ""} - ${crew.length ? `

    만든 Builder${crew.slice(0, 5).map((n) => `${avatarHTML(n, "sm")}${esc(n)}`).join("")}${crew.length > 5 ? `외 ${crew.length - 5}명` : ""}

    ` : ""} -
    -
    ${topics}${list}${text}${more}${goal}
    - ${nav} -
    `; - } - function renderShelf(_, dir, reveal) { + return `
    ${goal}${main}
    ${foot}
    `; + } + + /* one level as a row of the syllabus: number, name, question, progress squares; the body opens below it */ + function levelBlock(lv, i, open) { + const st = levelStatus(lv), build = (lv.quests || []).length > 0, c = countOf(lv); + const prev = state.levels[i - 1]; + const layer = i === 0 ? `

    배우기Level 0–2 · 무료 자료로 끝까지

    ` + : lv.layer === "build" && prev && prev.layer !== "build" ? `

    만들기Level 3–4 · 직접 기여하기

    ` : ""; + const tag = st === "mine" ? `내 레벨` : st === "past" ? `통과` : st === "cleared" ? `클리어` : ""; + return `${layer}
    + + + ${LV(lv.id)}${esc(lv.tier || lv.name)}${tag}${esc(lv.question)} + ${squaresHTML(lv)}${esc(countLabel(lv))} + + + ${levelBody(lv)} +
    `; + } + function renderShelf() { const shelf = $("#shelf"); if (!shelf) return; - const id = shownLevel(), lv = levelOf(id), i = lvIndex(id); + const id = shownLevel(); state.level = id; - const keep = shelf.querySelector(`details[data-more="${id}"]`); - const wasOpen = keep && keep.open; - const keepT = shelf.querySelector(`details[data-topics="${id}"]`), topicsOpen = keepT && keepT.open; - shelf.innerHTML = levelPanel(lv, i); - if (wasOpen) { const d = shelf.querySelector("details[data-more]"); if (d) d.open = true; } - if (topicsOpen) { const d = shelf.querySelector("details[data-topics]"); if (d) d.open = true; } - if (dir && !reduceMotion) { const a = shelf.firstElementChild; a.classList.add(dir > 0 ? "enter-r" : "enter-l"); } + if (!state.openLv) state.openLv = new Set([id]); + shelf.innerHTML = `
    ${state.levels.map((lv, i) => levelBlock(lv, i, state.openLv.has(lv.id))).join("")}
    +

    레벨 대신 주제별로 이어서 보고 싶다면

    `; wireAvatars(shelf); paintTopicProgress(); - renderRail(reveal); renderHud(); renderTestCard(); + renderHud(); renderTestCard(); const repos = [...state.repos.values()].filter((r) => !r.kind && r.status !== "depot"); const depot = [...state.repos.values()].filter((r) => r.status === "depot"); $("#n-course").textContent = repos.length; $("#n-course").title = `레포 ${repos.length}개`; - $("#shelf-foot").innerHTML = `자료 이름을 누르면 자세한 정보와 링크가 열립니다. 진단 결과와 클리어 기록은 이 브라우저에만 남습니다. 운영·보관 레포: ${depot.map((r) => `${esc(r.title)}`).join(", ")}`; + $("#shelf-foot").innerHTML = `주제 이름을 누르면 자료실에서 그 주제의 자료를 모두 볼 수 있습니다. 진단 결과와 진도는 이 브라우저에만 남습니다. 운영·보관 레포: ${depot.map((r) => `${esc(r.title)}`).join(", ")}`; + } + /* which levels are open is remembered while the page is open, and a click on a level row is counted */ + function wireSyllabus() { + const shelf = $("#shelf"); + if (!shelf) return; + shelf.addEventListener("toggle", (e) => { + const d = e.target; + if (!(d instanceof HTMLDetailsElement) || !d.classList.contains("sy-lv")) return; + if (!state.openLv) state.openLv = new Set(); + if (d.open) { state.openLv.add(d.dataset.row); state.level = d.dataset.row; } else state.openLv.delete(d.dataset.row); + }, true); + shelf.addEventListener("click", (e) => { + const sm = e.target.closest(".sy-lv > summary"); + if (sm) track("select_level", { level: sm.parentElement.dataset.row, source: sm.parentElement.open ? "syllabus_close" : "syllabus" }); + }); } /* each section arrives once as it comes into view: its station dot, then the heading, then the content */ function revealSections() { @@ -582,18 +599,6 @@ const show = () => { const t = /^#[\w-]+$/.test(location.hash) && document.getElementById(location.hash.slice(1)); const sec = t && t.closest("section.band"); if (sec) sec.classList.add("rv-in"); }; window.addEventListener("hashchange", show); show(); } - /* the rail draws itself once, the first time the curriculum comes into view */ - function watchRail() { - const rail = $("#lv-rail"); - if (!rail || reduceMotion || !("IntersectionObserver" in window)) return; - rail.classList.add("pre"); - const io = new IntersectionObserver((ens) => ens.forEach((en) => { - if (!en.isIntersecting) return; - rail.classList.remove("pre"); rail.classList.add("drawn"); io.disconnect(); - }), { threshold: 0, rootMargin: "0px 0px 20% 0px" }); - io.observe(rail); - } - /* ---------- level test: concept questions place the visitor on a level ---------- */ const test = { step: 0, picks: [], interest: null, done: false }; function meterHTML(levelId) { @@ -608,10 +613,10 @@ const n = state.leveltest.questions.length; box.classList.toggle("lt-slim", !lv); box.innerHTML = lv - ? `

    내 레벨 진단 결과

    ${LV(lv.id)} · ${esc(lv.tier || lv.name)}

    ${esc(bandLine(mine))}${(() => { const q = questsOf(lv.id); return q.length && q[0].topic ? ` · 주제 ${q.length}개 중 ${q.filter(questDone).length}개 시작` : ""; })()}

    -
    ` - : `

    어디서 시작할지 모르겠다면, 3분 레벨 진단

    실무 상황 문제 ${n}개를 풀면 시작할 Level과 첫 자료, 다시 볼 개념을 알려 드립니다.

    -
    `; + ? `

    내 레벨${LV(lv.id)} · ${esc(lv.tier || lv.name)}${esc(bandLine(mine))}

    +
    ` + : `

    어디서 시작할지 모르겠다면실무 문제 ${n}개로 시작할 레벨과 첫 자료를 찾아 드립니다.

    +
    `; } function scoreTest() { const T = state.leveltest, bands = {}; @@ -1101,21 +1106,25 @@ function gotoLevel(levelId, source) { if (!levelOf(levelId)) return; selectTab("tab-course"); - const from = lvIndex(shownLevel()); state.level = levelId; - renderShelf(null, lvIndex(levelId) - from, source === "test"); - const top = $("#lv-rail"); - if (top && (top.getBoundingClientRect().top < 0 || top.getBoundingClientRect().top > innerHeight * 0.5)) top.scrollIntoView({ behavior: reduceMotion ? "auto" : "smooth", block: "start" }); + (state.openLv || (state.openLv = new Set())).add(levelId); + let el = $(`#lv-${levelId}`); + if (!el) { renderShelf(); el = $(`#lv-${levelId}`); } + if (!el) return; + el.open = true; + const top = el.getBoundingClientRect().top; + if (top < 0 || top > innerHeight * 0.6) el.scrollIntoView({ behavior: reduceMotion ? "auto" : "smooth", block: "start" }); + if (source === "test") flash(el); } - /* Jump to one material: show its level, then mark it briefly. */ + /* Jump to one material: open its level, then mark it briefly. */ function gotoItem(id) { closeStation(); const r = state.repos.get(id); - if (r && r.level) { selectTab("tab-course"); const from = lvIndex(shownLevel()); state.level = r.level; renderShelf(null, lvIndex(r.level) - from); } + if (r && r.level) { selectTab("tab-course"); state.level = r.level; (state.openLv || (state.openLv = new Set())).add(r.level); const d = $(`#lv-${r.level}`); if (d) d.open = true; } const el = $(`#shelf [data-id="${CSS.escape(id)}"]`); if (!el) return; - const more = el.closest("details"); if (more) more.open = true; + const lvBox = el.closest("details.sy-lv"); if (lvBox) lvBox.open = true; document.querySelectorAll("#shelf .picked").forEach((x) => x.classList.remove("picked", "flash")); el.classList.add("picked"); el.scrollIntoView({ behavior: reduceMotion ? "auto" : "smooth", block: "center" }); @@ -1653,7 +1662,7 @@ after.filter((id) => !before.has(id)).forEach((id) => track("stage_clear", { level: id })); syncStageStamps(); if (after.includes(state.level) && !before.has(state.level)) renderShelf(); - else { paintTopicProgress(); renderRail(); renderHud(); renderTestCard(); } + else { paintTopicProgress(); renderHud(); renderTestCard(); } renderWeek(); } /* a cleared stage puts its stamp in the passport (once; stamps stay) */ @@ -2114,7 +2123,7 @@ try { await load(); } catch (err) { fail(err); return; } renderGrowth(); renderContrib(); - renderShelf(); renderWeek(); watchRail(); revealSections(); + wireSyllabus(); renderShelf(); renderWeek(); revealSections(); getJSON("data/topics.json").then((d) => { state.topicData = d; doneCheck = null; syncStageStamps(); renderShelf(); renderWeek(); }).catch(() => { /* the course shows without its topic order */ }); /* a material opened here, or a chapter read in the web book in another tab, shows when the reader is back */ document.addEventListener("hub:opened", refreshProgress); diff --git a/index.html b/index.html index 1c3a84d..c1cd17f 100644 --- a/index.html +++ b/index.html @@ -92,7 +92,7 @@

    Causal Inference Hub

    커리큘럼

    -

    Level 0부터 4까지, 레벨마다 정해진 순서대로 보면 됩니다. Level 0–2는 무료 자료만으로 끝까지 갈 수 있습니다.

    +

    Level 0부터 4까지 순서대로 보면 됩니다. 레벨을 펼치고 '다음 주제'부터 열어 보세요.

    @@ -105,8 +105,7 @@

    커리큘럼

    -
    -
    +