gitoria

jukebox

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit514d7cbe514d7cbeRecords: mission 008 startedmre514d7cbe/components/artist.hl

2.3 KB

  1. // components/artist.hl — `/artists/<id>`: one artist, with a switch between their albums and their songs (both are long lists for some artists, so both are virtual lists).
  2. parent './main.hl'
  3. import { navigate } from 'hl:web'
  4. import VirtualList from './virtual-list/virtual-list.hl'
  5. import { rowsFor, artistInfo } from '../lib/rows.hl'
  6. id = null
  7. info = artistInfo(id)
  8. __title = info.name + ' · Jukebox'
  9. String tab = info.albums > 1 ? 'albums' : 'songs'
  10. Hybrid artistCtx = { kind = info.albums > 1 ? 'artist-albums' : 'artist-songs' artist = id sort = 'artist' }
  11. Hybrid firstRows = rowsFor({ kind = info.albums > 1 ? 'artist-albums' : 'artist-songs' artist = id sort = 'artist' }, 0, 100)
  12. Number listTotal = firstRows.total
  13. Hybrid chunk = firstRows.rows
  14. Number chunkFrom = 0
  15. String playingId = ''
  16. String albumsClass = tab == 'albums' ? 'on' : ''
  17. String songsClass = tab == 'songs' ? 'on' : ''
  18. on artistLoad(first, wanted) {
  19. let start = first - 20
  20. if (start < 0) { start = 0 }
  21. r = emit server jbRows(artistCtx, start, 100)
  22. listTotal = r.total
  23. chunk = r.rows
  24. chunkFrom = r.offset
  25. return null
  26. }
  27. loadRange = (first, wanted) => { emit artistLoad(first, wanted) }
  28. picked = (rowId, index) => {
  29. if (tab == 'albums') { navigate('/albums/' + rowId) } else {
  30. playingId = rowId
  31. emit jbPlay(artistCtx, index, rowId)
  32. emit artistLoad(index, 0)
  33. }
  34. }
  35. on artistShuffle(e) {
  36. emit jbShuffle({ kind = 'list' ctx = { kind = 'artist-songs' artist = id sort = 'artist' } })
  37. return null
  38. }
  39. on artistTab(e) {
  40. tab = e.target.getAttribute('data-tab')
  41. artistCtx = { kind = tab == 'albums' ? 'artist-albums' : 'artist-songs' artist = id sort = 'artist' }
  42. r = emit server jbRows(artistCtx, 0, 100)
  43. listTotal = r.total
  44. chunk = r.rows
  45. chunkFrom = 0
  46. emit vlTop()
  47. return null
  48. }
  49. View {
  50. jbScreen {
  51. jbTabs {
  52. button { type = "button" class = albumsClass 'data-tab' = "albums" on click(e) { emit artistTab(e) } "Albums" }
  53. button { type = "button" class = songsClass 'data-tab' = "songs" on click(e) { emit artistTab(e) } "Songs" }
  54. button { id = "shuffle" type = "button" on click(e) { emit artistShuffle(e) } "Shuffle" }
  55. }
  56. VirtualList { itemCount = listTotal rowHeight = 56 loaded = chunk loadedFrom = chunkFrom onRange = loadRange onPick = picked selectedId = playingId listLabel = "Artist"
  57. jbHead { h1 { id = "name" info.name } p { info.line } }
  58. }
  59. }
  60. }

Branches

Latest commits

  • 514d7cbeRecords: mission 008 startedmre
  • 61c40127Mission 008: #19 + #21mre
  • 6dcaeb46Records: resetKey planmre
  • c5dbf2ecRecords: R2 resultmre
  • 956069b8Records: R1 result, mission 007mre
  • 3c8a2e12Mission 007: #20 sort scrollmre
  • deb8cef5Records: mission 006 startedmre
  • 4f0ad42fMission 006: jukebox#20mre
  • 800cae06Records: #21 planmre
  • 64bc7823Records: #21 causemre
  • 76639655Records: B1 questionmre
  • d7906b36Records: mission 005 startedmre
  • d3df773cMission 005: doc linemre
  • 6a5d840aMission 005: jukebox#22mre
  • 13e5e748Records: mission 004 startedmre
  • a8098271Mission 004: jukebox#21mre
  • df8f5205Records: jukebox#19-21, #11 closedmre
  • b7a4e692Records: hybriel#298mre
  • 9bcbb017Records: day38b waits for day39 fixmre
  • f80504e1Records: day38b repro sentmre