Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Tabpane shows multiple tabs at the same time #1280

Merged
merged 4 commits into from
Oct 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions assets/scss/shortcodes/tabbed-pane.scss
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
.tab-content {
.highlight {
margin: 0rem 0 2rem 0;
.tab-pane {
pre {
margin: 0rem 0 0rem 0;
}
}
}

.tab-content {
.tab-pane {
.highlight {
margin: 0rem 0 0rem 0;
border: none;
max-width: 100%;
margin: 0rem 0 0rem 0;
border: none;
max-width: 100%;
}
margin-top: 0rem;
margin-bottom: 1.5rem;
max-width: 80%;
border-left: 1px solid rgba(0, 0, 0, 0.125);
border-right: 1px solid rgba(0, 0, 0, 0.125);
border-bottom: 1px solid rgba(0, 0, 0, 0.125);
}
}
}

.tab-body {
Expand All @@ -27,10 +30,9 @@
padding: 1.5rem;

@each $color, $value in $theme-colors {
&-#{$color} {

border-style: solid;
border-color: $value;
}
&-#{$color} {
border-style: solid;
border-color: $value;
}
}
}
9 changes: 7 additions & 2 deletions layouts/shortcodes/readfile.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
{{/* Store ordinal, to be retrieved by parent element */}}
{{ if ge hugo.Version "0.93.0" }}
{{ .Page.Store.Add "Ordinal" 1 }}
{{ end }}

{{/* Handle the "file" named parameter or a single unnamed parameter as the file
path */}}
{{ if .IsNamedParams }}
Expand All @@ -24,10 +29,10 @@

{{ if fileExists ($.Scratch.Get "filepath") }}
{{ if eq (.Get "code") "true" }}
{{- highlight ($.Scratch.Get "filepath" | readFile | htmlUnescape |
{{- highlight ($.Scratch.Get "filepath" | readFile | htmlUnescape |
safeHTML ) (.Get "lang") "" -}}
{{ else }}
{{- $.Scratch.Get "filepath" | readFile | .Page.RenderString | htmlUnescape | safeHTML -}}
{{- $.Scratch.Get "filepath" | os.ReadFile | .Page.RenderString | htmlUnescape | safeHTML -}}
{{ end }}
{{ else }}

Expand Down
96 changes: 48 additions & 48 deletions layouts/shortcodes/tab.html
Original file line number Diff line number Diff line change
@@ -1,52 +1,52 @@
<!-- Make sure that we are enclosed within a tabpane shortcode block -->
{{ with $.Parent }}
{{- if ne $.Parent.Name "tabpane" -}}
{{- errorf "shortcode 'tab' must be used within a 'tabpane' block" -}}
{{- end -}}
{{- end -}}
{{- /* Make sure that we are enclosed within a tabpane shortcode block */ -}}
{{ with $.Parent -}}
{{ if ne $.Parent.Name "tabpane" -}}
{{ errorf "shortcode 'tab' must be used within a 'tabpane' block" -}}
{{ end -}}
{{ end -}}

{{ $header := "Tab" }}
{{ if and (not .IsNamedParams) (.Get 0) }}
{{ $header = (.Get 0) }}
{{ else }}
<!-- Prefill header if not given as named or unnamed parameter -->
{{ $header = default (printf "Tab %v" ( add $.Ordinal 1)) (.Get "header") }}
{{ end }}
{{ $header := "Tab" -}}
{{ if and (not .IsNamedParams) (.Get 0) -}}
{{ $header = (.Get 0) -}}
{{ else -}}
{{/* Prefill header if not given as named or unnamed parameter */ -}}
{{ $header = default (printf "Tab %v" ( add $.Ordinal 1)) (.Get "header") -}}
{{ end -}}

<!-- store all tab info in dict tab -->
{{ $tab := dict "header" $header }}
{{ with $.Get "lang" }}
{{ $tab = merge $tab (dict "language" ($.Get "lang")) }}
{{ end }}
{{ with $.Get "highlight" }}
{{ $tab = merge $tab (dict "highlight" ($.Get "highlight")) }}
{{ end }}
{{ with $.Get "text" }}
{{ if ne ( printf "%T" . ) "bool" }}
{{- errorf "shortcode tab: parameter 'text' must be either true or false" -}}
{{ end }}
{{ $tab = merge $tab (dict "text" ($.Get "text")) }}
{{ end }}
{{ with $.Get "right" }}
{{ if ne ( printf "%T" . ) "bool" }}
{{- errorf "shortcode tab: parameter 'right' must be either true or false" -}}
{{ end }}
{{ $tab = merge $tab (dict "rightpush" ($.Get "right")) }}
{{ end }}
{{ with $.Get "disabled" }}
{{ if ne ( printf "%T" . ) "bool" }}
{{- errorf "shortcode tab: parameter 'disabled' must be either true or false" -}}
{{ end }}
{{ $tab = merge $tab (dict "disabled" ($.Get "disabled")) }}
{{ end }}
{{/* store all tab info in dict tab */ -}}
{{ $tab := dict "header" $header -}}
{{ with $.Get "lang" -}}
{{ $tab = merge $tab (dict "language" ($.Get "lang")) -}}
{{ end -}}
{{ with $.Get "highlight" -}}
{{ $tab = merge $tab (dict "highlight" ($.Get "highlight")) -}}
{{ end -}}
{{ with $.Get "text" -}}
{{ if ne ( printf "%T" . ) "bool" -}}
{{ errorf "shortcode tab: parameter 'text' must be either true or false" -}}
{{ end -}}
{{ $tab = merge $tab (dict "text" ($.Get "text")) -}}
{{ end -}}
{{ with $.Get "right" -}}
{{ if ne ( printf "%T" . ) "bool" -}}
{{ errorf "shortcode tab: parameter 'right' must be either true or false" -}}
{{ end -}}
{{ $tab = merge $tab (dict "rightpush" ($.Get "right")) -}}
{{ end -}}
{{ with $.Get "disabled" -}}
{{ if ne ( printf "%T" . ) "bool" -}}
{{ errorf "shortcode tab: parameter 'disabled' must be either true or false" -}}
{{ end -}}
{{ $tab = merge $tab (dict "disabled" ($.Get "disabled")) -}}
{{ end -}}

{{ with $.Inner }}
<!-- Trim any leading and trailing newlines from .Inner, this avoids
spurious lines during syntax highlighting -->
{{ $tab = merge $tab (dict "content" $.Inner ) }}
{{ end }}
{{ with $.Inner -}}
{{/* Trim any leading and trailing newlines from .Inner, this avoids
spurious lines during syntax highlighting */ -}}
{{ $tab = merge $tab (dict "content" $.Inner) -}}
{{ end -}}

<!-- add dict tab to parent's scratchpad -->
{{ with .Parent }}
{{- $.Parent.Scratch.SetInMap "tabs" (printf "%02v" $.Ordinal) $tab -}}
{{ end }}
{{/* add dict tab to parent's scratchpad */ -}}
{{ with .Parent -}}
{{ $.Parent.Scratch.SetInMap "tabs" (printf "%02v" $.Ordinal) $tab -}}
{{ end -}}
Loading