Skip to content

Commit

Permalink
alex-shpak#343, alex-shpak#165: Move lang selector to left menu
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-shpak committed Aug 18, 2021
1 parent 50147be commit 26de844
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 81 deletions.
67 changes: 10 additions & 57 deletions assets/_main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ ul.pagination {

.book-brand {
margin-top: 0;
margin-bottom: $padding-16;

img {
height: 1.5em;
width: auto;
vertical-align: middle;
width: 1.5em;
margin-inline-end: $padding-8;
}
}
Expand Down Expand Up @@ -147,11 +147,7 @@ body[dir="rtl"] .book-menu {
}

.book-section-flat {
margin-bottom: $padding-16 * 2;

&:not(:first-child) {
margin-top: $padding-16 * 2;
}
margin: $padding-16 * 2 0;

> a,
> span,
Expand Down Expand Up @@ -266,62 +262,19 @@ body[dir="rtl"] .book-menu {
}

.book-languages {
position: relative;
overflow: visible;

padding: $padding-16;
margin: -$padding-16;

ul {
margin: 0;
padding: 0;
list-style: none;

li {
white-space: nowrap;
cursor: pointer;
}
}
margin-block-end: $padding-16 * 2;

&:hover,
&:focus,
&:focus-within {
.book-languages-list {
display: block;
}
.book-icon {
height: 1em;
width: 1em;
margin-inline-end: .5em;
}

.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;
}
ul {
padding-inline-start: 1.5em;
}
}

.book-home {
padding: $padding-16;
}

// Responsive styles
.book-menu-content,
.book-toc-content,
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -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="}}
2 changes: 1 addition & 1 deletion layouts/partials/docs/brand.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<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 -}}
<img src="{{ . | relURL }}" alt="Logo" />
{{- end -}}
Expand Down
4 changes: 1 addition & 3 deletions layouts/partials/docs/footer.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
<div class="flex flex-wrap justify-between">
{{ if .Site.IsMultiLingual }}
{{ partial "docs/languages" . }}
{{ end }}

{{ if and .GitInfo .Site.Params.BookRepo }}
<div>
Expand All @@ -22,6 +19,7 @@
</a>
</div>
{{ end }}

</div>

{{ $script := resources.Get "clipboard.js" | resources.Minify }}
Expand Down
38 changes: 20 additions & 18 deletions layouts/partials/docs/languages.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,32 @@
{{ $bookTranslatedOnly := default false .Site.Params.BookTranslatedOnly }}
{{ $translations := dict }}
{{ if (eq $bookTranslatedOnly false ) }}
{{ range .Site.Home.AllTranslations }}
{{ range .Site.Home.Translations }}
{{ $translations = merge $translations (dict .Language.Lang .) }}
{{ end }}
{{ end }}
{{ range .Translations }}
{{ $translations = merge $translations (dict .Language.Lang .) }}
{{ end }}

<div class="book-languages" tabindex="0" aria-haspopup="true">
<ul>
<li class="flex align-center">
<img src="{{ "svg/translate.svg" | relURL }}" class="book-icon" alt="Languages" />
{{ $.Site.Language.LanguageName }}
</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">
<ul class="book-languages">
<li>
<input type="checkbox" id="languages" class="toggle" />
<label for="languages" class="flex justify-between">
<a role="button" class="flex align-center">
<img src="{{ "svg/translate.svg" | relURL }}" class="book-icon" alt="Languages" />
{{ .Language.LanguageName }}
{{ $.Site.Language.LanguageName }}
</a>
</li>
{{ end }}{{ end }}
</ul>
</div>
</label>

<ul>
{{ range .Site.Languages }}{{ with index $translations .Lang }}
<li>
<a href="{{ .Permalink }}">
{{ .Language.LanguageName }}
</a>
</li>
{{ end }}{{ end }}
</ul>
</li>
</ul>
3 changes: 3 additions & 0 deletions layouts/partials/docs/menu.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<nav>
{{ partial "docs/brand" . }}
{{ partial "docs/search" . }}
{{ if .Site.IsMultiLingual }}
{{ partial "docs/languages" . }}
{{ end }}

{{ partial "docs/inject/menu-before" . }}
{{ partial "docs/menu-hugo" .Site.Menus.before }}
Expand Down

0 comments on commit 26de844

Please sign in to comment.