change theme switcher to icon #167
This commit is contained in:
parent
57eb2998cf
commit
ae1e0fc880
@ -224,9 +224,11 @@ header h2 {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
|
margin-top: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.site-title {
|
.site-title {
|
||||||
|
display: inline;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -245,8 +247,8 @@ header nav a {
|
|||||||
|
|
||||||
/* Social icons */
|
/* Social icons */
|
||||||
.social-icons {
|
.social-icons {
|
||||||
margin-top: 1em;
|
display: inline;
|
||||||
margin-bottom: 0;
|
margin: 1em 0 0 3em;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
list-style-type: none;
|
list-style-type: none;
|
||||||
}
|
}
|
||||||
@ -688,12 +690,11 @@ ul.language-select > li, ul.footer-menu > li {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.theme-switcher {
|
.theme-switcher {
|
||||||
color: var(--switcher-color);
|
cursor: pointer;
|
||||||
background: var(--switcher-bg-color);
|
}
|
||||||
padding: 0.5em 1em;
|
|
||||||
font-size: 16px;
|
.theme-switcher-svg {
|
||||||
border: none;
|
fill: currentColor;
|
||||||
margin-bottom: 1em;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.h-card {
|
.h-card {
|
||||||
|
@ -37,11 +37,5 @@ toAllCategories:
|
|||||||
skipToContent:
|
skipToContent:
|
||||||
other: "প্রচ্ছদে প্রবেশ করুন"
|
other: "প্রচ্ছদে প্রবেশ করুন"
|
||||||
|
|
||||||
darkTheme:
|
|
||||||
other: "অন্ধকার থিম"
|
|
||||||
|
|
||||||
lightTheme:
|
|
||||||
other: "আলোক থিম"
|
|
||||||
|
|
||||||
readNext:
|
readNext:
|
||||||
other: "পরের প্রচ্ছদ"
|
other: "পরের প্রচ্ছদ"
|
@ -37,11 +37,5 @@ toAllCategories:
|
|||||||
skipToContent:
|
skipToContent:
|
||||||
other: "Zum Hauptinhalt springen"
|
other: "Zum Hauptinhalt springen"
|
||||||
|
|
||||||
darkTheme:
|
|
||||||
other: "Dunkles Theme"
|
|
||||||
|
|
||||||
lightTheme:
|
|
||||||
other: "Helles Theme"
|
|
||||||
|
|
||||||
readNext:
|
readNext:
|
||||||
other: "Weiter lesen"
|
other: "Weiter lesen"
|
@ -43,12 +43,6 @@ toAllCategories:
|
|||||||
skipToContent:
|
skipToContent:
|
||||||
other: "Skip to main content"
|
other: "Skip to main content"
|
||||||
|
|
||||||
darkTheme:
|
|
||||||
other: "Dark theme"
|
|
||||||
|
|
||||||
lightTheme:
|
|
||||||
other: "Light theme"
|
|
||||||
|
|
||||||
readNext:
|
readNext:
|
||||||
other: "Read next"
|
other: "Read next"
|
||||||
|
|
||||||
|
@ -37,11 +37,5 @@ toAllCategories:
|
|||||||
skipToContent:
|
skipToContent:
|
||||||
other: "Saltar al contenido principal"
|
other: "Saltar al contenido principal"
|
||||||
|
|
||||||
darkTheme:
|
|
||||||
other: "Dark theme"
|
|
||||||
|
|
||||||
lightTheme:
|
|
||||||
other: "Light theme"
|
|
||||||
|
|
||||||
readNext:
|
readNext:
|
||||||
other: "Leer el siguiente"
|
other: "Leer el siguiente"
|
||||||
|
@ -37,11 +37,5 @@ toAllCategories:
|
|||||||
skipToContent:
|
skipToContent:
|
||||||
other: "Aller au contenu"
|
other: "Aller au contenu"
|
||||||
|
|
||||||
darkTheme:
|
|
||||||
other: "Thème sombre"
|
|
||||||
|
|
||||||
lightTheme:
|
|
||||||
other: "Thème clair"
|
|
||||||
|
|
||||||
readNext:
|
readNext:
|
||||||
other: "Lire la suite"
|
other: "Lire la suite"
|
@ -37,11 +37,5 @@ toAllCategories:
|
|||||||
skipToContent:
|
skipToContent:
|
||||||
other: "Lompat ke konten"
|
other: "Lompat ke konten"
|
||||||
|
|
||||||
darkTheme:
|
|
||||||
other: "Tema Gelap"
|
|
||||||
|
|
||||||
lightTheme:
|
|
||||||
other: "Tema Terang"
|
|
||||||
|
|
||||||
readNext:
|
readNext:
|
||||||
other: "Baca Selanjutnya"
|
other: "Baca Selanjutnya"
|
@ -37,11 +37,5 @@ toAllCategories:
|
|||||||
skipToContent:
|
skipToContent:
|
||||||
other: "Przejdź do głównej zawartości"
|
other: "Przejdź do głównej zawartości"
|
||||||
|
|
||||||
darkTheme:
|
|
||||||
other: "Ciemny schemat"
|
|
||||||
|
|
||||||
lightTheme:
|
|
||||||
other: "Jasny schemat"
|
|
||||||
|
|
||||||
readNext:
|
readNext:
|
||||||
other: "Czytaj dalej"
|
other: "Czytaj dalej"
|
@ -37,11 +37,5 @@ toAllCategories:
|
|||||||
skipToContent:
|
skipToContent:
|
||||||
other: "Pular para o conteúdo principal"
|
other: "Pular para o conteúdo principal"
|
||||||
|
|
||||||
darkTheme:
|
|
||||||
other: "Tema Escuro"
|
|
||||||
|
|
||||||
lightTheme:
|
|
||||||
other: "Tema Claro"
|
|
||||||
|
|
||||||
readNext:
|
readNext:
|
||||||
other: "Leia a seguir"
|
other: "Leia a seguir"
|
@ -40,12 +40,6 @@ toAllCategories:
|
|||||||
skipToContent:
|
skipToContent:
|
||||||
other: "Перейти к основному контенту"
|
other: "Перейти к основному контенту"
|
||||||
|
|
||||||
darkTheme:
|
|
||||||
other: "Тёмная тема"
|
|
||||||
|
|
||||||
lightTheme:
|
|
||||||
other: "Светлая тема"
|
|
||||||
|
|
||||||
readNext:
|
readNext:
|
||||||
other: "Читать далее"
|
other: "Читать далее"
|
||||||
|
|
||||||
|
@ -37,11 +37,5 @@ toAllCategories:
|
|||||||
skipToContent:
|
skipToContent:
|
||||||
other: "跳至內容"
|
other: "跳至內容"
|
||||||
|
|
||||||
darkTheme:
|
|
||||||
other: "暗色主題"
|
|
||||||
|
|
||||||
lightTheme:
|
|
||||||
other: "亮色主題"
|
|
||||||
|
|
||||||
readNext:
|
readNext:
|
||||||
other: "閱讀下一篇"
|
other: "閱讀下一篇"
|
@ -43,11 +43,5 @@ toAllCategories:
|
|||||||
skipToContent:
|
skipToContent:
|
||||||
other: "跳至内容"
|
other: "跳至内容"
|
||||||
|
|
||||||
darkTheme:
|
|
||||||
other: "暗色主题"
|
|
||||||
|
|
||||||
lightTheme:
|
|
||||||
other: "亮色主题"
|
|
||||||
|
|
||||||
readNext:
|
readNext:
|
||||||
other: "继续阅读"
|
other: "继续阅读"
|
||||||
|
3
layouts/partials/fa-icons/halfcircle.svg
Normal file
3
layouts/partials/fa-icons/halfcircle.svg
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<svg xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 290 290">
|
||||||
|
<path d="M142.959,0C64.131,0,0,64.132,0,142.96c0,78.828,64.131,142.959,142.959,142.959c78.828,0,142.96-64.131,142.96-142.959 C285.919,64.132,221.787,0,142.959,0z M142.959,260.919V142.96V25c65.043,0,117.96,52.917,117.96,117.96 C260.919,208.003,208.002,260.919,142.959,260.919z"/>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 358 B |
@ -19,8 +19,6 @@
|
|||||||
{{ partial "footer-extra.html" . }}
|
{{ partial "footer-extra.html" . }}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{ partial "theme-switcher.html" . }}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{ partial "h-card.html" . }}
|
{{ partial "h-card.html" . }}
|
||||||
|
@ -1,7 +1,13 @@
|
|||||||
<div class="header-top">
|
<div class="header-top">
|
||||||
{{ partial "site-title.html" . }}
|
<div class="header-top-left">
|
||||||
{{ partial "social.html" . }}
|
{{ partial "site-title.html" . }}
|
||||||
|
{{ partial "social.html" . }}
|
||||||
|
</div>
|
||||||
|
<div class="header-top-right">
|
||||||
|
{{ partial "theme-switcher.html" . }}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{ if .Site.Menus.main }}
|
{{ if .Site.Menus.main }}
|
||||||
<nav>
|
<nav>
|
||||||
{{ $currentPage := . }}
|
{{ $currentPage := . }}
|
||||||
@ -15,4 +21,4 @@
|
|||||||
|
|
||||||
{{ if .Site.Params.mathjax }}{{ partial "mathjax_support.html" . }}{{ end }}
|
{{ if .Site.Params.mathjax }}{{ partial "mathjax_support.html" . }}{{ end }}
|
||||||
|
|
||||||
{{ partial "header-extra.html" . }}
|
{{ partial "header-extra.html" . }}
|
@ -5,9 +5,9 @@
|
|||||||
|
|
||||||
{{ if not (in (slice "light-without-switcher" "dark-without-switcher") $style) }}
|
{{ if not (in (slice "light-without-switcher" "dark-without-switcher") $style) }}
|
||||||
{{ if ne "auto-without-switcher" $style }}
|
{{ if ne "auto-without-switcher" $style }}
|
||||||
<button class="theme-switcher">
|
<div class="theme-switcher">
|
||||||
{{ i18n "darkTheme" }}
|
{{ partial "font-awesome.html" (dict "iconName" "halfcircle" "custom" false) }}
|
||||||
</button>
|
</div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@ -21,7 +21,6 @@ let autoDefinedScheme = window.matchMedia('(prefers-color-scheme: dark)')
|
|||||||
const autoChangeScheme = e => {
|
const autoChangeScheme = e => {
|
||||||
currentTheme = e.matches ? 'dark' : 'light'
|
currentTheme = e.matches ? 'dark' : 'light'
|
||||||
document.documentElement.setAttribute('data-theme', currentTheme)
|
document.documentElement.setAttribute('data-theme', currentTheme)
|
||||||
changeButtonText()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
@ -36,7 +35,6 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (switchButton) {
|
if (switchButton) {
|
||||||
changeButtonText()
|
|
||||||
switchButton.addEventListener('click', switchTheme, false)
|
switchButton.addEventListener('click', switchTheme, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,13 +57,6 @@ function detectCurrentScheme() {
|
|||||||
return 'light'
|
return 'light'
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeButtonText()
|
|
||||||
{
|
|
||||||
if (switchButton) {
|
|
||||||
switchButton.textContent = currentTheme == 'dark' ? {{ i18n "lightTheme" }} : {{ i18n "darkTheme" }}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function switchTheme(e) {
|
function switchTheme(e) {
|
||||||
if (currentTheme == 'dark') {
|
if (currentTheme == 'dark') {
|
||||||
if (localStorage !== null)
|
if (localStorage !== null)
|
||||||
@ -78,7 +69,6 @@ function switchTheme(e) {
|
|||||||
document.documentElement.setAttribute('data-theme', 'dark')
|
document.documentElement.setAttribute('data-theme', 'dark')
|
||||||
currentTheme = 'dark'
|
currentTheme = 'dark'
|
||||||
}
|
}
|
||||||
changeButtonText()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function showContent() {
|
function showContent() {
|
||||||
|
Loading…
Reference in New Issue
Block a user