« get me outta code hell

generateLyricsSwitcher.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/generateLyricsSwitcher.js
blob: 1c9ee6a3f606984d06aef256df7c6fa5c4b84954 (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
export default {
  contentDependencies: ['transformContent'],
  extraDependencies: ['html', 'language'],

  relations: (relation, entries) => ({
    annotations:
      entries
        .map(entry => entry.annotation)
        .map(annotation => relation('transformContent', annotation)),
  }),

  slots: {
    tag: {type: 'string', default: 'p'},
  },

  generate: (relations, slots, {html, language}) =>
    html.tag(slots.tag, {class: 'lyrics-switcher'},
      language.$('releaseInfo.lyrics.switcher', {
        entries:
          language.formatListWithoutSeparator(
            relations.annotations
              .map((annotation, index) =>
                html.tag('span', {[html.joinChildren]: ''}, [
                  html.tag('a',
                    {href: '#'},

                    index === 0 &&
                      {style: 'display: none'},

                    annotation
                      .slots({
                        mode: 'inline',
                        textOnly: true,
                      })),

                  html.tag('a',
                    {class: 'current'},

                    index >= 1 &&
                      {style: 'display: none'},

                    annotation
                      .slots({
                        mode: 'inline',
                        textOnly: true,
                      })),
                ]))),
      })),
};