« get me outta code hell

generateFlashActSidebarCurrentActBox.js « dependencies « content « src - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/dependencies/generateFlashActSidebarCurrentActBox.js
blob: c5426a41662ae1fc8a20169db6461b4c328a48db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
export default {
  contentDependencies: [
    'generatePageSidebarBox',
    'linkFlash',
    'linkFlashAct',
  ],

  extraDependencies: ['html', 'language'],

  relations: (relation, act, _flash) => ({
    box:
      relation('generatePageSidebarBox'),

    actLink:
      relation('linkFlashAct', act),

    flashLinks:
      act.flashes
        .map(flash => relation('linkFlash', flash)),
  }),

  data: (act, flash) => ({
    isFlashActPage:
      !flash,

    currentFlashIndex:
      act.flashes.indexOf(flash),

    customListTerminology:
      act.listTerminology,
  }),

  generate: (data, relations, {html, language}) =>
    relations.box.slots({
      attributes: {class: 'flash-act-map-sidebar-box'},

      content: [
        html.tag('h1', relations.actLink),

        html.tag('details',
          (data.isFlashActPage
            ? {}
            : {class: 'current', open: true}),

          [
            html.tag('summary',
              html.tag('span', {class: 'group-name'},
                (data.customListTerminology
                  ? language.sanitize(data.customListTerminology)
                  : language.$('flashSidebar.flashList.entriesInThisSection')))),

            html.tag('ul',
              relations.flashLinks
                .map((flashLink, index) =>
                  html.tag('li',
                    index === data.currentFlashIndex &&
                      {class: 'current'},

                    flashLink))),
          ]),
        ],
    }),
};