Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/google/docsy.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Deininger <adeininger@urbanonline.de>2022-10-14 09:35:51 +0300
committerGeri Ochoa <gerino@protonmail.com>2022-10-21 20:14:56 +0300
commitcfa70e3d5fbb9cf8d01c11c1cd06357c8797450b (patch)
treefac534116cfc10f53473e0ab01d00b6cb2c65399
parentabb7307a311f04de5e97d0fda6cafa49c0d9ddf7 (diff)
Fix: Tabpane shows multiple tabs at the same time #1271
-rw-r--r--assets/scss/shortcodes/tabbed-pane.scss24
-rw-r--r--layouts/shortcodes/tabpane.html56
2 files changed, 50 insertions, 30 deletions
diff --git a/assets/scss/shortcodes/tabbed-pane.scss b/assets/scss/shortcodes/tabbed-pane.scss
index f63b50d..65096ae 100644
--- a/assets/scss/shortcodes/tabbed-pane.scss
+++ b/assets/scss/shortcodes/tabbed-pane.scss
@@ -1,14 +1,17 @@
.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;
@@ -16,7 +19,7 @@
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 {
@@ -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;
+ }
}
}
diff --git a/layouts/shortcodes/tabpane.html b/layouts/shortcodes/tabpane.html
index a25aab1..de644ea 100644
--- a/layouts/shortcodes/tabpane.html
+++ b/layouts/shortcodes/tabpane.html
@@ -1,26 +1,26 @@
{{/* Check parameter types */ -}}
{{ with .Get "langEqualsHeader" -}}
-{{ if ne ( printf "%T" . ) "bool" -}}
-{{ errorf "shortcode tabpane: parameter 'langEqualsHeader' must be either true or false" -}}
-{{ end -}}
+ {{ if ne ( printf "%T" . ) "bool" -}}
+ {{ errorf "shortcode tabpane: parameter 'langEqualsHeader' must be either true or false" -}}
+ {{ end -}}
{{ end -}}
{{ with .Get "text" -}}
-{{ if ne ( printf "%T" . ) "bool" -}}
-{{ errorf "shortcode tabpane: parameter 'text' must be either true or false" -}}
-{{ end -}}
+ {{ if ne ( printf "%T" . ) "bool" -}}
+ {{ errorf "shortcode tabpane: parameter 'text' must be either true or false" -}}
+ {{ end -}}
{{ end -}}
{{ with .Get "persistLang" -}}
-{{ if ne ( printf "%T" . ) "bool" -}}
-{{ errorf "shortcode tabpane: parameter 'persistLang' must be either true or false" -}}
-{{ end -}}
+ {{ if ne ( printf "%T" . ) "bool" -}}
+ {{ errorf "shortcode tabpane: parameter 'persistLang' must be either true or false" -}}
+ {{ end -}}
{{ end -}}
{{ with .Get "right" -}}
-{{ if ne ( printf "%T" . ) "bool" -}}
-{{ errorf "shortcode tabpane: parameter 'right' must be either true or false" -}}
-{{ end -}}
+ {{ if ne ( printf "%T" . ) "bool" -}}
+ {{ errorf "shortcode tabpane: parameter 'right' must be either true or false" -}}
+ {{ end -}}
{{ end -}}
{{/* Set values given defined within tabpane */ -}}
@@ -30,15 +30,22 @@
{{ $langEqualsHeader := default false ($.Get "langEqualsHeader") -}}
{{ $persistLang := default true ($.Get "persistLang") -}}
{{ $rightPane := default false ($.Get "right") -}}
-{{ $disabled := false -}}
-{{ $rightpush := false -}}
{{ $activeSet := false -}}
{{- /* Scratchpad gets populated through call to .Inner */ -}}
{{- .Inner -}}
+{{ $langs := slice -}}
+{{ $duplicate := false -}}
+{{ $duplicateLang := "" -}}
+
<ul class="nav nav-tabs{{ if $rightPane }} justify-content-end{{ end }}" id="tabs-{{- $.Ordinal -}}" role="tablist">
{{ range $index, $element := $.Scratch.Get "tabs" -}}
+ {{ $disabled := false -}}
+ {{ with $element.disabled -}}
+ {{ $disabled = . -}}
+ {{ end -}}
+
{{ $lang := $langPane -}}
{{ if $langEqualsHeader -}}
{{ $lang = $element.header -}}
@@ -47,9 +54,15 @@
{{ $lang = $element.language -}}
{{ end -}}
- {{ $disabled := false -}}
- {{ with $element.disabled -}}
- {{ $disabled = . -}}
+ {{/* Check for duplicate languages */ -}}
+ {{ if and $persistLang (not $duplicate) -}}
+ {{ if and (not $disabled) (ne $lang "") -}}
+ {{ $langs = $langs | append $lang -}}
+ {{ end -}}
+ {{ if ne $langs (uniq $langs) -}}
+ {{ $duplicate = true -}}
+ {{ $duplicateLang = $lang -}}
+ {{ end -}}
{{ end -}}
{{ $rightpush := false -}}
@@ -64,9 +77,9 @@
{{ $tabid := printf "tabs-%02v-%v-tab" $.Ordinal $index | anchorize -}}
{{ $entryid := printf "tabs-%02v-%v" $.Ordinal $index | anchorize -}}
- <a class="nav-link{{ if and ( not $activeSet ) ( not $disabled ) }} active{{ end }}{{ if $disabled }} disabled{{ end }}{{ if ne $lang "" }}{{ if $persistLang }} persistLang-{{- $lang -}}{{ end }}{{ end }}"
+ <a class="nav-link{{ if and ( not $activeSet ) ( not $disabled ) }} active{{ end }}{{ if $disabled }} disabled{{ end }}{{ if ne $lang "" }}{{ if and $persistLang (not $duplicate) }} persistLang-{{- $lang -}}{{ end }}{{ end }}"
id="{{ $tabid }}" data-toggle="tab" href="#{{ $entryid }}" role="tab"
- {{ if ne $lang "" }}{{ if $persistLang }}onclick="persistLang({{ $lang }});"{{ end }}{{ end -}}
+ {{ if ne $lang "" }}{{ if and $persistLang (not $duplicate) }}onclick="persistLang({{ $lang }});"{{ end }}{{ end -}}
aria-controls="{{- $entryid -}}" aria-selected="{{- and ( not $activeSet ) ( not $disabled ) "true" "false" -}}">
{{ index . "header" | markdownify }}
</a>
@@ -79,6 +92,11 @@
{{- end }}
</ul>
+{{ if $duplicate -}}
+ {{ warnf "Tabpane on page '%s': duplicate language '%s' detected, disabling persistance of language to avoid multiple tab display." .Page.Title $duplicateLang -}}
+{{ end -}}
+{{ $duplicate = false -}}
+{{ $langs = slice -}}
{{ $activeSet = false -}}
{{/* Inner content */ -}}