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
|
import {stitchArrays} from '#sugar';
export default {
extraDependencies: ['html', 'language'],
slots: {
scopes: {
validate: v => v.strictArrayOf(v.isStringNonEmpty),
},
contents: {
validate: v => v.strictArrayOf(v.isHTML),
},
open: {
type: 'boolean',
default: true,
},
},
generate: (slots, {html, language}) =>
html.tag('details', {class: 'scoped-chronology-switcher'},
slots.open &&
{open: true},
[
html.tag('summary',
language.$('trackPage.nav.chronology.scope.title', {
scope:
slots.scopes.map((scope, index) =>
html.tag('a', {class: 'switcher-link'},
{href: '#'},
(index === 0
? {style: 'display: inline'}
: {style: 'display: none'}),
language.$('trackPage.nav.chronology.scope', scope))),
})),
stitchArrays({
scope: slots.scopes,
content: slots.contents,
}).map(({scope, content}, index) =>
html.tag('div', {class: 'scope-' + scope},
(index === 0
? {style: 'display: block'}
: {style: 'display: none'}),
content)),
]),
};
|