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
4
{{- if .Inner -}}
5
- < div class ="tabs -container " id ="{{ $tab_set_id }} ">
5
+ < div class ="tab -container " id ="{{ $tab_set_id }} ">
6
6
{{- range $i, $e := $tabs -}}
7
- {{- $id := printf "%s-tab%d" $tab_set_id $i -}}
8
7
{{- if eq $i 0 -}}
9
- < input type ="radio " name ="{{$tab_set_id}} " id ="{{$id }} " aria-hidden ="true " checked ="checked ">
8
+ < input type ="radio " name ="{{$tab_set_id}} " id ="{{$tab_set_id}}-tab{{$i }} " aria-hidden ="true " checked ="checked ">
10
9
{{- else -}}
11
- < input type ="radio " name ="{{$tab_set_id}} " id ="{{$id }} " aria-hidden ="true ">
10
+ < input type ="radio " name ="{{$tab_set_id}} " id ="{{$tab_set_id}}-tab{{$i }} " aria-hidden ="true ">
12
11
{{- end -}}
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 -}}
29
- </ ul >
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 >
12
+ < label
13
+ class ="tab-label "
14
+ role ="tab "
15
+ for ="{{$tab_set_id}}-tab{{$i}} "
16
+ tabindex ="0 "
17
+ aria-selected ="{{ if eq $i 0 }}true{{ else }}false{{ end }} "
18
+ aria-controls ="{{$tab_set_id}}-panel{{$i}} ">
19
+ {{- trim .name " " -}}
20
+ </ label >
21
+ < div class ="tab-content " role ="tabpanel " id ="{{$tab_set_id}}-panel{{$i}} " aria-labelledby ="{{$tab_set_id}}-tab{{$i}} ">
22
+ {{ with .content }}
23
+ {{ . }}
24
+ {{ end }}
25
+ </ div >
26
+ {{- end -}}
40
27
</ div >
41
- {{ end }}
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 >
28
+ {{ end }}
0 commit comments