gitoria

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitd1a91be9d1a91be9Merge hm57-let: tracker#57 let only for reassigned namesmred1a91be9/components/franchise.hl

6.6 KB

  1. // components/franchise.hl — `/franchises/:slug` (a franchise's index: its timelines, each a list of its titles) AND
  2. // `/timelines/:tslug` (one timeline, its franchise above it) — tracker.worldapi.org#19, mission 066. Each timeline has its own
  3. // sort toggle: "Timeline" (the in-world order, as edited) | "Release" (a movie by its release, a series by the release date of
  4. // its LAST episode — franchises.hl releaseKeyOf). A row: small poster, title (year), Movie/Series and the date the release
  5. // sort uses.
  6. //
  7. // ONE FLAT LIST of rows (a `head` row per timeline, then its `item` rows), not a nested for over timelines > titles: the same
  8. // proven shape as the show page's seasons (hybriel#86). Both orders of every timeline come with the page (`blocks`); a toggle
  9. // only rebuilds `rows` in the browser (`flatRows` is pure) — no request.
  10. parent './main.hl'
  11. import { appTitle } from '../project.hl'
  12. import { franchisePage, timelinePage, isEditorSession } from '../lib/franchises.hl'
  13. import { pillClassOfWord } from '../lib/shows.hl'
  14. // static + LOCAL: an mpackdb-backed helper must be `static` (hybriel#115/#116, mission 047)
  15. static pageOf = (slug, &tslug) => {
  16. p = tslug != null ? timelinePage(tslug) : franchisePage(slug)
  17. return p != null ? p : { kind = 'none' name = '' slug = '' summary = '' franchiseName = '' franchiseHref = '' blocks = [] editHref = '' }
  18. }
  19. static editorOf = (&session) => { return isEditorSession(&session) }
  20. // pure (runs in the browser on a toggle): the rows of every timeline in its chosen order. `named`: a head shows the timeline's
  21. // name (the franchise index); a timeline's own page has it in its h1 already (mission 025: the name was there twice)
  22. static flatRows = (&blocks, &modes, &named) => {
  23. out = []
  24. for (b of blocks) {
  25. byRelease = modes[b.id] == 'release'
  26. out.push({ kind = 'head' isHead = true isItem = false key = b.id id = b.id name = b.name hasName = named href = b.href countText = b.countText
  27. timelineClass = byRelease ? 'sortbtn' : 'sortbtn on' releaseClass = byRelease ? 'sortbtn on' : 'sortbtn' })
  28. list = byRelease ? b.byRelease : b.items
  29. for (it of list) {
  30. 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.href
  31. posterUrl = it.posterUrl typeLabel = it.kind typeClass = pillClassOfWord(&it.kind) dateLabel = it.dateLabel })
  32. }
  33. }
  34. return out
  35. }
  36. slug = null
  37. tslug = null
  38. session = null
  39. canEdit = editorOf(&session)
  40. data = pageOf(&slug, &tslug)
  41. found = data.kind != 'none'
  42. notFound = data.kind == 'none'
  43. isTimeline = data.kind == 'timeline'
  44. name = data.name
  45. summary = data.summary
  46. hasSummary = summary != ''
  47. hasFranchise = data.franchiseName != ''
  48. franchiseName = data.franchiseName
  49. franchiseHref = data.franchiseHref
  50. editHref = data.editHref
  51. showEdit = canEdit && isTimeline
  52. // tracker#20 (merge, mission 070): "Franchise | Star Trek", "Timeline | …" — the type word in its colour (styles.hl type-*)
  53. typeText = isTimeline ? 'Timeline' : 'Franchise'
  54. typeClass = isTimeline ? 'type-word type-timeline' : 'type-word type-franchise'
  55. blocks = data.blocks
  56. hasBlocks = blocks.length > 0
  57. noBlocks = found && blocks.length == 0
  58. modes = {}
  59. namedHeads = !isTimeline
  60. rows = flatRows(&blocks, &modes, &namedHeads)
  61. __title = found ? name + ' — ' + appTitle : appTitle
  62. // Component styles use the shared theme variables.
  63. Style {
  64. franchisePage {
  65. display = 'block'
  66. }
  67. aFranchiseUp {
  68. display = 'inline-block'
  69. marginBottom = '.3rem'
  70. fontSize = '.85rem'
  71. fontWeight = '600'
  72. letterSpacing = '.04em'
  73. textTransform = 'uppercase'
  74. }
  75. pFranchiseSummary {
  76. margin = '-.3rem 0 1rem'
  77. color = 'var(--color-text)'
  78. }
  79. timelineBlocks {
  80. display = 'block'
  81. }
  82. timelineHead {
  83. display = 'flex'
  84. flexWrap = 'wrap'
  85. alignItems = 'center'
  86. gap = '.4rem .8rem'
  87. padding = '.8rem 0 .4rem'
  88. marginTop = '.6rem'
  89. }
  90. timelineTitle {
  91. flex = '1 1 12rem'
  92. minWidth = '0'
  93. display = 'flex'
  94. flexWrap = 'wrap'
  95. alignItems = 'baseline'
  96. gap = '.2rem .6rem'
  97. }
  98. aTimelineName {
  99. minWidth = '2.75rem'
  100. fontSize = '1.05rem'
  101. fontWeight = '600'
  102. color = 'var(--color-text-strong)'
  103. overflowWrap = 'anywhere'
  104. padding = '.7rem 0'
  105. margin = '-.7rem 0'
  106. }
  107. timelineCount {
  108. flex = 'none'
  109. fontSize = '.85rem'
  110. color = 'var(--color-text-muted)'
  111. }
  112. sortToggle {
  113. flex = 'none'
  114. display = 'flex'
  115. padding = '.15rem'
  116. background = 'var(--color-surface)'
  117. borderRadius = 'var(--radius-small)'
  118. }
  119. 'button.sortbtn' {
  120. padding = '.25rem .7rem'
  121. fontSize = '.85rem'
  122. color = 'var(--color-text)'
  123. background = 'transparent'
  124. }
  125. 'button.sortbtn.on' {
  126. color = 'var(--color-accent-text)'
  127. background = 'var(--color-accent)'
  128. }
  129. aTimelineItem {
  130. display = 'flex'
  131. alignItems = 'center'
  132. gap = '.8rem'
  133. padding = '.45rem 0'
  134. color = 'var(--color-text)'
  135. hover {
  136. textDecoration = 'none'
  137. filmTitle {
  138. color = 'var(--color-accent)'
  139. }
  140. }
  141. }
  142. }
  143. View {
  144. franchisePage { "data-kind" = data.kind
  145. if (notFound) {
  146. h1 { "Not found" }
  147. p { "This franchise or timeline doesn't exist." }
  148. }
  149. if (found) {
  150. if (hasFranchise) { a { id = "franchise-up" Style.aFranchiseUp href = franchiseHref franchiseName } }
  151. franchisesHead {
  152. h1 { class = "typed" typeWord { class = typeClass typeText } typeSep { "|" } typeName { name } }
  153. if (showEdit) { a { id = "timeline-edit" class = "button" href = editHref "Edit" } }
  154. }
  155. if (hasSummary) { p { Style.pFranchiseSummary summary } }
  156. if (noBlocks) { p { class = "muted" "No timelines yet." } }
  157. if (hasBlocks) {
  158. timelineBlocks {
  159. for (row of rows) {
  160. if (row.isHead) {
  161. timelineHead { "data-timeline" = row.id
  162. timelineTitle {
  163. if (row.hasName) { a { Style.aTimelineName href = row.href row.name } }
  164. timelineCount { row.countText }
  165. }
  166. sortToggle { "aria-label" = "Sort"
  167. button { type = "button" class = row.timelineClass value = "timeline" "Timeline" on click(e) { emit sortTimeline(row.id, 'timeline') } }
  168. button { type = "button" class = row.releaseClass value = "release" "Release" on click(e) { emit sortTimeline(row.id, 'release') } }
  169. }
  170. }
  171. }
  172. if (row.isItem) {
  173. a { Style.aTimelineItem href = row.href "data-timeline" = row.timeline
  174. img { class = "film-poster" src = row.posterUrl alt = "" loading = "lazy" }
  175. filmText {
  176. filmTitle { row.title }
  177. filmMeta {
  178. span { class = row.typeClass row.typeLabel }
  179. span { class = "timeline-date" row.dateLabel }
  180. }
  181. }
  182. }
  183. }
  184. }
  185. }
  186. }
  187. }
  188. }
  189. }
  190. on sortTimeline(timelineId, mode) {
  191. m = modes
  192. m[timelineId] = mode
  193. modes = m
  194. rows = flatRows(&blocks, &modes, &namedHeads)
  195. }

Branches

Latest commits

  • d1a91be9Merge hm57-let: tracker#57 let only for reassigned namesmre
  • a404ed75Report HM57 audit, gates and integration notesmre
  • 1dcb87a7Use plain declarations for unchanged bindingsmre
  • b90395e3log: HM51 mergedmre
  • 9888d076Merge hm51-classes: tracker#51 views use Style referencesmre
  • 4399bc2fReference remaining component-owned root Style rulesmre
  • 9edcc2dflog: #58 live, HM57 startedmre
  • 73fa20ddMerge hm49b-styles: tracker#49 rest of the component stylesmre
  • aed12917Reference owned Style rules in genres and searchmre
  • 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