« get me outta code hell

generateExpandableGallerySection.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/generateExpandableGallerySection.js
blob: 122ca4b1c672b30c3c0b7f0c4569ed36a405a510 (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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
export default {
  contentDependencies: ['generateContentHeading'],
  extraDependencies: ['html', 'language'],

  relations: (relation) => ({
    contentHeading:
      relation('generateContentHeading'),
  }),

  slots: {
    title: {
      type: 'html',
      mutable: false,
    },

    contentAboveCut: {
      type: 'html',
      mutable: false,
    },

    contentBelowCut: {
      type: 'html',
      mutable: false,
    },

    caption: {
      type: 'html',
      mutable: false,
    },

    expandCue: {
      type: 'html',
      mutable: false,
    },

    collapseCue: {
      type: 'html',
      mutable: false,
    },
  },

  generate: (relations, slots, {html, language}) =>
    html.tag('section', {class: 'expandable-gallery-section'}, [
      relations.contentHeading.slots({
        tag: 'h2',
        title: slots.title,
      }),

      html.tag('div', {class: 'section-content-above-cut'},
        {[html.onlyIfContent]: true},

        slots.contentAboveCut),

      html.tag('div', {class: 'section-content-below-cut'},
        {[html.onlyIfContent]: true},

        !html.isBlank(slots.contentBelowCut) &&
          {style: 'display: none'},

        slots.contentBelowCut),

      html.tag('div', {class: 'section-expando'},
        {[html.onlyIfSiblings]: true},

        html.tag('div', {class: 'section-expando-content'},
          {[html.joinChildren]: html.tag('br')},

          [
            html.tag('span', {class: 'section-caption'},
              slots.caption),

            !html.isBlank(slots.contentBelowCut) &&
              language.$('misc.coverGrid.expandCollapseCue', {
                cue:
                  html.tag('a', {class: 'section-expando-toggle'},
                    {href: '#'},

                    {[html.joinChildren]: ''},
                    {[html.noEdgeWhitespace]: true},

                    [
                      html.tag('span', {class: 'section-expand-cue'},
                        slots.expandCue),

                      html.tag('span', {class: 'section-collapse-cue'},
                        {style: 'display: none'},
                        slots.collapseCue),
                    ]),
              }),
          ])),
    ]),
};