Added option for language selector
Implemented a language selector submenu that can be turned on or off by a config value. Resolves: panr/hugo-theme-terminal#31
This commit is contained in:
parent
bacfb1a95a
commit
10b545bb86
@ -78,6 +78,8 @@ paginate = 5
|
||||
themeColor = "orange"
|
||||
# if you set this to 0, only submenu trigger will be visible
|
||||
showMenuItems = 2
|
||||
# show selector to switch language
|
||||
showLanguageSelector = false
|
||||
# set theme to full screen width
|
||||
fullWidthTheme = false
|
||||
# center theme with default width
|
||||
|
2
USERS.md
2
USERS.md
@ -6,3 +6,5 @@ TEMPLATE:
|
||||
- https://radoslawkoziel.pl — **Radek Kozieł** (Software designer and developer)
|
||||
|
||||
-->
|
||||
|
||||
- [rinma.dev](https://rinma.dev) - **Marvin Dalheimer** (Software Developer)
|
||||
|
@ -26,6 +26,21 @@
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{ if $.Site.Params.showLanguageSelector }}
|
||||
<div class="spacer"></div>
|
||||
<div class="language-selector">
|
||||
|
||||
<div class="language-selector-actual">
|
||||
<li class="list-inline-item">{{ .Language.LanguageName }} ▾</li>
|
||||
</div>
|
||||
<div class="language-selector-more hidden">
|
||||
{{ range $.Site.Home.AllTranslations }}
|
||||
<li class="list-inline-item"><a class="text-dark" href="{{ .Permalink }}">{{ .Language.LanguageName }}</a></li>
|
||||
{{ end }}
|
||||
</div>
|
||||
</div>
|
||||
{{ end }}
|
||||
</ul>
|
||||
|
||||
<ul class="menu__inner menu__inner--mobile">
|
||||
@ -34,5 +49,13 @@
|
||||
<li><a href="{{ .URL }}">{{ .Name }}</a></li>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ if $.Site.Params.showLanguageSelector }}
|
||||
<hr />
|
||||
{{ range $.Site.Home.AllTranslations }}
|
||||
<li class="list-inline-item">
|
||||
<a class="text-dark" href="{{ .Permalink }}">{{ .Language.LanguageName }}</a>
|
||||
</li>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
</ul>
|
||||
</nav>
|
||||
|
@ -121,6 +121,28 @@
|
||||
}
|
||||
}
|
||||
|
||||
.spacer {
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
.language-selector {
|
||||
position: relative;
|
||||
|
||||
.language-selector-actual {
|
||||
list-style-type: none;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
color: var(--accent);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.language-selector-more {
|
||||
@mixin menu;
|
||||
top: 35px;
|
||||
right: 0;
|
||||
}
|
||||
}
|
||||
|
||||
&-trigger {
|
||||
color: var(--accent);
|
||||
border: 2px solid;
|
||||
|
12
source/js/languageSelector.js
Normal file
12
source/js/languageSelector.js
Normal file
@ -0,0 +1,12 @@
|
||||
const mobileQuery = getComputedStyle(document.body).getPropertyValue("--phoneWidth");
|
||||
const isMobile = () => window.matchMedia(mobileQuery).matches;
|
||||
|
||||
if(!isMobile()) {
|
||||
languageSelector = document.getElementsByClassName("language-selector-actual")[0];
|
||||
moreLanguagesContainer = document.getElementsByClassName("language-selector-more")[0];
|
||||
|
||||
languageSelector && languageSelector.addEventListener("click", e => {
|
||||
e.stopPropagation();
|
||||
moreLanguagesContainer.classList.toggle("hidden");
|
||||
});
|
||||
}
|
@ -14,7 +14,11 @@ module.exports = {
|
||||
modules: ["source", "node_modules"],
|
||||
},
|
||||
entry: {
|
||||
"main.js": [join("source", "js", "main.js"), join("source", "js", "menu.js")],
|
||||
"main.js": [
|
||||
join("source", "js", "main.js"),
|
||||
join("source", "js", "menu.js"),
|
||||
join("source", "js", "languageSelector.js")
|
||||
],
|
||||
"prism.js": join("source", "js", "prism.js"),
|
||||
"style.css": join("source", "css", "style.css"),
|
||||
"red.css": join("source", "css", "color", "red.css"),
|
||||
|
Loading…
Reference in New Issue
Block a user