#343, #165: Move lang selector to left menu

This commit is contained in:
Alex Shpak 2021-08-18 11:12:50 +02:00
parent 50147be131
commit 26de844a19
7 changed files with 37 additions and 81 deletions

View file

@ -86,11 +86,11 @@ ul.pagination {
.book-brand { .book-brand {
margin-top: 0; margin-top: 0;
margin-bottom: $padding-16;
img { img {
height: 1.5em; height: 1.5em;
width: auto; width: 1.5em;
vertical-align: middle;
margin-inline-end: $padding-8; margin-inline-end: $padding-8;
} }
} }
@ -147,11 +147,7 @@ body[dir="rtl"] .book-menu {
} }
.book-section-flat { .book-section-flat {
margin-bottom: $padding-16 * 2; margin: $padding-16 * 2 0;
&:not(:first-child) {
margin-top: $padding-16 * 2;
}
> a, > a,
> span, > span,
@ -266,60 +262,17 @@ body[dir="rtl"] .book-menu {
} }
.book-languages { .book-languages {
position: relative; margin-block-end: $padding-16 * 2;
overflow: visible;
padding: $padding-16; .book-icon {
margin: -$padding-16; height: 1em;
width: 1em;
margin-inline-end: .5em;
}
ul { ul {
margin: 0; padding-inline-start: 1.5em;
padding: 0;
list-style: none;
li {
white-space: nowrap;
cursor: pointer;
}
} }
&:hover,
&:focus,
&:focus-within {
.book-languages-list {
display: block;
}
}
.book-languages-list {
display: none;
position: absolute;
bottom: 100%;
left: 0;
padding: $padding-8 0;
background: var(--body-background);
box-shadow: 0 0 $padding-4 rgba(0, 0, 0, 0.1);
li img {
opacity: 0.25;
}
li.active img,
li:hover img {
opacity: initial;
}
a {
color: inherit;
padding: $padding-8 $padding-16;
}
}
}
.book-home {
padding: $padding-16;
} }
// Responsive styles // Responsive styles

View file

@ -1 +1 @@
{"Target":"book.min.3e90539cf7130f0a89ba2f8b9f54ac5e5ecdd1fa345b6c8e3e5a83ec6f19ec8e.css","MediaType":"text/css","Data":{"Integrity":"sha256-PpBTnPcTDwqJui+Ln1SsXl7N0fo0W2yOPlqD7G8Z7I4="}} {"Target":"book.min.8599444fcc48ee6b435b5b62c955ab7d914fa1e2a453df90c4b97cc9769665d1.css","MediaType":"text/css","Data":{"Integrity":"sha256-hZlET8xI7mtDW1tiyVWrfZFPoeKkU9+QxLl8yXaWZdE="}}

View file

@ -1,5 +1,5 @@
<h2 class="book-brand"> <h2 class="book-brand">
<a href="{{ cond (not .Site.Home.File) .Sites.First.Home.RelPermalink .Site.Home.RelPermalink }}"> <a class="flex align-center" href="{{ cond (not .Site.Home.File) .Sites.First.Home.RelPermalink .Site.Home.RelPermalink }}">
{{- with .Site.Params.BookLogo -}} {{- with .Site.Params.BookLogo -}}
<img src="{{ . | relURL }}" alt="Logo" /> <img src="{{ . | relURL }}" alt="Logo" />
{{- end -}} {{- end -}}

View file

@ -1,7 +1,4 @@
<div class="flex flex-wrap justify-between"> <div class="flex flex-wrap justify-between">
{{ if .Site.IsMultiLingual }}
{{ partial "docs/languages" . }}
{{ end }}
{{ if and .GitInfo .Site.Params.BookRepo }} {{ if and .GitInfo .Site.Params.BookRepo }}
<div> <div>
@ -22,6 +19,7 @@
</a> </a>
</div> </div>
{{ end }} {{ end }}
</div> </div>
{{ $script := resources.Get "clipboard.js" | resources.Minify }} {{ $script := resources.Get "clipboard.js" | resources.Minify }}

View file

@ -2,7 +2,7 @@
{{ $bookTranslatedOnly := default false .Site.Params.BookTranslatedOnly }} {{ $bookTranslatedOnly := default false .Site.Params.BookTranslatedOnly }}
{{ $translations := dict }} {{ $translations := dict }}
{{ if (eq $bookTranslatedOnly false ) }} {{ if (eq $bookTranslatedOnly false ) }}
{{ range .Site.Home.AllTranslations }} {{ range .Site.Home.Translations }}
{{ $translations = merge $translations (dict .Language.Lang .) }} {{ $translations = merge $translations (dict .Language.Lang .) }}
{{ end }} {{ end }}
{{ end }} {{ end }}
@ -10,22 +10,24 @@
{{ $translations = merge $translations (dict .Language.Lang .) }} {{ $translations = merge $translations (dict .Language.Lang .) }}
{{ end }} {{ end }}
<div class="book-languages" tabindex="0" aria-haspopup="true"> <ul class="book-languages">
<ul> <li>
<li class="flex align-center"> <input type="checkbox" id="languages" class="toggle" />
<img src="{{ "svg/translate.svg" | relURL }}" class="book-icon" alt="Languages" /> <label for="languages" class="flex justify-between">
{{ $.Site.Language.LanguageName }} <a role="button" class="flex align-center">
</li>
</ul>
<ul class="book-languages-list">
{{ range .Site.Languages }}{{ with index $translations .Lang }}
<li class="{{ if (eq $.Site.Language .Language) }}active{{ end }}">
<a href="{{ .Permalink }}" class="flex align-center">
<img src="{{ "svg/translate.svg" | relURL }}" class="book-icon" alt="Languages" /> <img src="{{ "svg/translate.svg" | relURL }}" class="book-icon" alt="Languages" />
{{ .Language.LanguageName }} {{ $.Site.Language.LanguageName }}
</a> </a>
</li> </label>
{{ end }}{{ end }}
</ul> <ul>
</div> {{ range .Site.Languages }}{{ with index $translations .Lang }}
<li>
<a href="{{ .Permalink }}">
{{ .Language.LanguageName }}
</a>
</li>
{{ end }}{{ end }}
</ul>
</li>
</ul>

View file

@ -1,6 +1,9 @@
<nav> <nav>
{{ partial "docs/brand" . }} {{ partial "docs/brand" . }}
{{ partial "docs/search" . }} {{ partial "docs/search" . }}
{{ if .Site.IsMultiLingual }}
{{ partial "docs/languages" . }}
{{ end }}
{{ partial "docs/inject/menu-before" . }} {{ partial "docs/inject/menu-before" . }}
{{ partial "docs/menu-hugo" .Site.Menus.before }} {{ partial "docs/menu-hugo" .Site.Menus.before }}