tracker
All repositories: gitoria
6.6 KB
// components/franchise.hl — `/franchises/:slug` (a franchise's index: its timelines, each a list of its titles) AND// `/timelines/:tslug` (one timeline, its franchise above it) — tracker.worldapi.org#19, mission 066. Each timeline has its own// sort toggle: "Timeline" (the in-world order, as edited) | "Release" (a movie by its release, a series by the release date of// its LAST episode — franchises.hl releaseKeyOf). A row: small poster, title (year), Movie/Series and the date the release// sort uses.//// ONE FLAT LIST of rows (a `head` row per timeline, then its `item` rows), not a nested for over timelines > titles: the same// proven shape as the show page's seasons (hybriel#86). Both orders of every timeline come with the page (`blocks`); a toggle// only rebuilds `rows` in the browser (`flatRows` is pure) — no request.parent './main.hl'import { appTitle } from '../project.hl'import { franchisePage, timelinePage, isEditorSession } from '../lib/franchises.hl'import { pillClassOfWord } from '../lib/shows.hl'// static + LOCAL: an mpackdb-backed helper must be `static` (hybriel#115/#116, mission 047)static pageOf = (slug, &tslug) => {p = tslug != null ? timelinePage(tslug) : franchisePage(slug)return p != null ? p : { kind = 'none' name = '' slug = '' summary = '' franchiseName = '' franchiseHref = '' blocks = [] editHref = '' }}static editorOf = (&session) => { return isEditorSession(&session) }// pure (runs in the browser on a toggle): the rows of every timeline in its chosen order. `named`: a head shows the timeline's// name (the franchise index); a timeline's own page has it in its h1 already (mission 025: the name was there twice)static flatRows = (&blocks, &modes, &named) => {out = []for (b of blocks) {byRelease = modes[b.id] == 'release'out.push({ kind = 'head' isHead = true isItem = false key = b.id id = b.id name = b.name hasName = named href = b.href countText = b.countTexttimelineClass = byRelease ? 'sortbtn' : 'sortbtn on' releaseClass = byRelease ? 'sortbtn on' : 'sortbtn' })list = byRelease ? b.byRelease : b.itemsfor (it of list) {out.push({ kind = 'item' isHead = false isItem = true key = b.id + ':' + it.id id = it.id timeline = b.id pos = it.pos title = it.title href = it.hrefposterUrl = it.posterUrl typeLabel = it.kind typeClass = pillClassOfWord(&it.kind) dateLabel = it.dateLabel })}}return out}slug = nulltslug = nullsession = nullcanEdit = editorOf(&session)data = pageOf(&slug, &tslug)found = data.kind != 'none'notFound = data.kind == 'none'isTimeline = data.kind == 'timeline'name = data.namesummary = data.summaryhasSummary = summary != ''hasFranchise = data.franchiseName != ''franchiseName = data.franchiseNamefranchiseHref = data.franchiseHrefeditHref = data.editHrefshowEdit = canEdit && isTimeline// tracker#20 (merge, mission 070): "Franchise | Star Trek", "Timeline | …" — the type word in its colour (styles.hl type-*)typeText = isTimeline ? 'Timeline' : 'Franchise'typeClass = isTimeline ? 'type-word type-timeline' : 'type-word type-franchise'blocks = data.blockshasBlocks = blocks.length > 0noBlocks = found && blocks.length == 0modes = {}namedHeads = !isTimelinerows = flatRows(&blocks, &modes, &namedHeads)__title = found ? name + ' — ' + appTitle : appTitle// Component styles use the shared theme variables.Style {franchisePage {display = 'block'}'a.franchise-up' {display = 'inline-block'marginBottom = '.3rem'fontSize = '.85rem'fontWeight = '600'letterSpacing = '.04em'textTransform = 'uppercase'}'p.franchise-summary' {margin = '-.3rem 0 1rem'color = 'var(--color-text)'}timelineBlocks {display = 'block'}timelineHead {display = 'flex'flexWrap = 'wrap'alignItems = 'center'gap = '.4rem .8rem'padding = '.8rem 0 .4rem'marginTop = '.6rem'}timelineTitle {flex = '1 1 12rem'minWidth = '0'display = 'flex'flexWrap = 'wrap'alignItems = 'baseline'gap = '.2rem .6rem'}'a.timeline-name' {minWidth = '2.75rem'fontSize = '1.05rem'fontWeight = '600'color = 'var(--color-text-strong)'overflowWrap = 'anywhere'padding = '.7rem 0'margin = '-.7rem 0'}timelineCount {flex = 'none'fontSize = '.85rem'color = 'var(--color-text-muted)'}sortToggle {flex = 'none'display = 'flex'padding = '.15rem'background = 'var(--color-surface)'borderRadius = 'var(--radius-small)'}'button.sortbtn' {padding = '.25rem .7rem'fontSize = '.85rem'color = 'var(--color-text)'background = 'transparent'}'button.sortbtn.on' {color = 'var(--color-accent-text)'background = 'var(--color-accent)'}'a.timeline-item' {display = 'flex'alignItems = 'center'gap = '.8rem'padding = '.45rem 0'color = 'var(--color-text)'hover {textDecoration = 'none'filmTitle {color = 'var(--color-accent)'}}}}View {franchisePage { "data-kind" = data.kindif (notFound) {h1 { "Not found" }p { "This franchise or timeline doesn't exist." }}if (found) {if (hasFranchise) { a { id = "franchise-up" class = "franchise-up" href = franchiseHref franchiseName } }franchisesHead {h1 { class = "typed" typeWord { class = typeClass typeText } typeSep { "|" } typeName { name } }if (showEdit) { a { id = "timeline-edit" class = "button" href = editHref "Edit" } }}if (hasSummary) { p { class = "franchise-summary" summary } }if (noBlocks) { p { class = "muted" "No timelines yet." } }if (hasBlocks) {timelineBlocks {for (row of rows) {if (row.isHead) {timelineHead { "data-timeline" = row.idtimelineTitle {if (row.hasName) { a { class = "timeline-name" href = row.href row.name } }timelineCount { row.countText }}sortToggle { "aria-label" = "Sort"button { type = "button" class = row.timelineClass value = "timeline" "Timeline" on click(e) { emit sortTimeline(row.id, 'timeline') } }button { type = "button" class = row.releaseClass value = "release" "Release" on click(e) { emit sortTimeline(row.id, 'release') } }}}}if (row.isItem) {a { class = "timeline-item" href = row.href "data-timeline" = row.timelineimg { class = "film-poster" src = row.posterUrl alt = "" loading = "lazy" }filmText {filmTitle { row.title }filmMeta {span { class = row.typeClass row.typeLabel }span { class = "timeline-date" row.dateLabel }}}}}}}}}}}on sortTimeline(timelineId, mode) {m = modesm[timelineId] = modemodes = mrows = flatRows(&blocks, &modes, &namedHeads)}
Branches
Latest commits
- 1dcb87a7Use plain declarations for unchanged bindingsmre
- 9edcc2dflog: #58 live, HM57 startedmre
- 73fa20ddMerge hm49b-styles: tracker#49 rest of the component stylesmre
- 14195720log: HM49B done, HM51 startedmre
- 78ee6b56Move remaining component styles into Style blocksmre
- 7f04de33log: HM49Bmre
- 00616cf3log: #49 batch merged, DP67 startedmre
- d7232e86Merge hm49-styles: tracker#49 first batch of component stylesmre
- 079f376dMove seven components' styles into Style blocksmre
- 17d66feelog: #58 mergedmre
- 69a6640bMerge hm58-map: tracker#58 project.hl only the mapmre
- a85f7900Move route logic out of the project mapmre
- 13dea5belog: #56 live, HM49 and HM58 startedmre
- a31c8f2fdocs: tracker#36 remaining listmre
- 975d06d1log: #36 live, DP66 startedmre
- d6d03fa3mission: T36Bmre
- e7512d00status: #36 rolled back, retry askedmre
- c98e2043log: T36A rollbackmre
- ae905f15Merge t36a: tracker#36 apply rechecks, reportmre
- 796bfaceT36A: report validated fixes, failed live SSH check and verified rollbackmre