1
1
{{- .Page.Scratch.Add "tabset-counter" 1 -}}
2
2
{{- $tab_set_id := .Get "name" | default (printf "tabset-%s-%d" (.Page.RelPermalink) (.Page.Scratch.Get "tabset-counter") ) | anchorize -}}
3
3
{{- $tabs := .Scratch.Get "tabs" -}}
4
- {{- if .Inner -}}{{- /* We don't use the inner content, but Hugo will complain if we don't reference it. */ -}}{{- end -}}
5
- < div class ="tabs-container ">
6
- < ul class ="nav nav-tabs " id ="{{ $tab_set_id }} " role ="tablist ">
7
- {{- range $i, $e := $tabs -}}
8
- {{- $id := printf "%s-%d" $tab_set_id $i -}}
9
- {{- if (eq $i 0) -}}
10
- < li class ="nav-item "> < a data-toggle ="tab " class ="nav-link active " href ="#{{ $id }} " role ="tab " aria-controls ="{{ $id }} " aria-selected ="true "> {{- trim .name " " -}}</ a > </ li >
11
- {{ else }}
12
- < li class ="nav-item "> < a data-toggle ="tab " class ="nav-link " href ="#{{ $id }} " role ="tab " aria-controls ="{{ $id }} "> {{- trim .name " " -}}</ a > </ li >
13
- {{- end -}}
4
+ {{- if .Inner -}}
5
+ < div class ="tabs-container " id ="{{ $tab_set_id }} ">
6
+ {{- range $i, $e := $tabs -}}
7
+ {{- $id := printf "%s-tab%d" $tab_set_id $i -}}
8
+ {{- if eq $i 0 -}}
9
+ < input type ="radio " name ="{{$tab_set_id}} " id ="{{$id}} " aria-hidden ="true " checked ="checked ">
10
+ {{- else -}}
11
+ < input type ="radio " name ="{{$tab_set_id}} " id ="{{$id}} " aria-hidden ="true ">
12
+ {{- end -}}
14
13
{{- end -}}
14
+ < ul class ="tab-labels " role ="tablist " id ="{{ $tab_set_id }} ">
15
+ {{- range $i, $e := $tabs -}}
16
+ {{- $id := printf "%s-tab%d" $tab_set_id $i -}}
17
+ < li >
18
+ {{- if eq $i 0 -}}
19
+ < label class ="tab-label " role ="tab " id ="{{$id}} " for ="{{$id}} " aria-controls ="{{ $id }} " aria-selected ="true " tabindex ="0 ">
20
+ {{- trim .name " " -}}
21
+ </ label >
22
+ {{- else -}}
23
+ < label class ="tab-label " role ="tab " id ="{{$id}} " for ="{{$id}} " aria-controls ="{{ $id }} " tabindex ="0 ">
24
+ {{- trim .name " " -}}
25
+ </ label >
26
+ {{- end -}}
27
+ </ li >
28
+ {{- end -}}
15
29
</ ul >
16
- </ div >
17
- < div class ="tab-content " id ="{{ $tab_set_id }} ">
18
- {{- range $i, $e := $tabs -}}
19
- {{- $id := printf "%s-%d" $tab_set_id $i -}}
20
- {{- if (eq $i 0) -}}
21
- < div id ="{{ $id }} " class ="tab-pane show active " role ="tabpanel " aria-labelledby ="{{ $id }} ">
22
- {{ else }}
23
- < div id ="{{ $id }} " class ="tab-pane " role ="tabpanel " aria-labelledby ="{{ $id }} ">
30
+ < div class ="tabs-content ">
31
+ {{- range $i, $e := $tabs -}}
32
+ {{- $id := printf "%s-panel%d" $tab_set_id $i -}}
33
+ < div class ="tab-content " role ="tabpanel " id ="{{ $tab_set_id }}-panel{{ $i }} " aria-labelledby ="{{ $id }} ">
34
+ {{ with .content }}
35
+ {{ . }}
36
+ {{ end }}
37
+ </ div >
38
+ {{- end -}}
39
+ </ div >
40
+ </ div >
24
41
{{ end }}
25
- {{- with .content -}}
26
- {{- . -}}
27
- {{- else -}}
28
- {{- if eq $.Page.BundleType "leaf" -}}
29
- {{- /* find the file somewhere inside the bundle. Note the use of double asterisk */ -}}
30
- {{- with $.Page.Resources.GetMatch (printf "**%s*" .include) -}}
31
- {{- if ne .ResourceType "page" -}}
32
- {{- /* Assume it is a file that needs code highlighting. */ -}}
33
- {{- $codelang := $e.codelang | default ( path.Ext .Name | strings.TrimPrefix ".") -}}
34
- {{- highlight .Content $codelang "" -}}
35
- {{- else -}}
36
- {{- .Content -}}
37
- {{- end -}}
38
- {{- end -}}
39
- {{- else -}}
40
- {{- $path := path.Join $.Page.File.Dir .include -}}
41
- {{- $page := site.GetPage "page" $path -}}
42
- {{- with $page -}}
43
- {{- .Content -}}
44
- {{- else -}}
45
- {{- errorf "[%s] tabs include not found for path %q" site.Language.Lang $path -}}
46
- {{- end -}}
47
- {{- end -}}
48
- {{- end -}}
49
- </ div >
50
- {{- end -}}
51
- </ div >
42
+ < style >
43
+ {{- range $i, $e : = $tabs - }}
44
+ .tabs-container input [type = "radio" ]: checked : nth-of-type ({{ add $i 1 }}) ~ .tab-labels li : nth-of-type ({{ add $i 1 }}) {
45
+ bor der: none;
46
+ bor der- to p: 1px solid oklch(var(- - color - for eground));
47
+ bor der- left: 1px solid oklch(var(- - color - for eground));
48
+ bor der- botto m: none;
49
+ color : oklch(var(- - color - for eground));
50
+
51
+ + li {
52
+ bor der- left: 1px solid oklch(var(- - color - for eground));
53
+ }
54
+
55
+ & : last-of-type {
56
+ border-right : 1px solid oklch (var (--color-foreground ));
57
+ }
58
+ }
59
+
60
+ .tabs-container input [type = "radio" ]: checked : nth-of-type ({{ add $i 1 }}) ~ .tabs-content div : nth-of-type ({{ add $i 1 }}) {
61
+ dis play: block;
62
+ }
63
+ {{- end - }}
64
+ </ style >
0 commit comments