diff --git a/config.toml b/config.toml index ff1d2e4..3ba6fbd 100644 --- a/config.toml +++ b/config.toml @@ -112,6 +112,11 @@ links = [ { url = "@/blog/_index.md", name = "Blog" }, { url = "@/demo/index.md", name = "Demo" }, { url = "@/tricks/index.md", name = "Tricks" }, + { name = "Menu" , sublinks = [ + { url = "@/blog/_index.md", name = "Blog" }, + { url = "@/demo/index.md", name = "Demo" }, + { url = "@/tricks/index.md", name = "Tricks" }, + ]}, ] [extra.footer] diff --git a/sass/_nav.scss b/sass/_nav.scss index 9b88618..ea5c62b 100644 --- a/sass/_nav.scss +++ b/sass/_nav.scss @@ -60,14 +60,7 @@ list-style: none; @media only screen and (max-width: 480px) { - &:not( - #search, - #language-switcher, - #theme-switcher, - #theme-switcher li, - #feed, - #repo - ) { + &:not(.circle) { flex: 0 0 100%; } } @@ -103,21 +96,10 @@ color: var(--fg-muted-5); font-weight: 800; - &:hover { - color: var(--primary-color); - - .icon { - background-color: var(--primary-color); - } - } - &.active { - box-shadow: var(--edge-highlight); - background-color: var(--primary-color-alpha); color: var(--primary-color); &:hover { - background-color: var(--primary-color); color: var(--contrast-color); .icon { @@ -125,10 +107,6 @@ } } - &::before { - display: none; - } - .icon { background-color: var(--primary-color); } @@ -156,11 +134,11 @@ &#search button, &#language-switcher summary, &#theme-switcher summary, - &#theme-switcher button { + &#theme-switcher button, + details summary { &:hover { box-shadow: var(--edge-highlight); background-color: var(--fg-muted-1); - color: var(--primary-color); } &:active { @@ -184,61 +162,21 @@ } &.active { - &::before { - display: block; - position: absolute; - top: -0.5rem; - right: 1.5rem; - left: 1.5rem; - transition: var(--transition); - border-block-end: 0.25rem solid var(--fg-muted-2); - border-end-start-radius: 0.25rem; - border-end-end-radius: 0.25rem; - content: ""; + box-shadow: var(--edge-highlight); + background-color: var(--primary-color-alpha); + color: var(--primary-color); - @media only screen and (max-width: 480px) { - top: 0.25rem; - right: unset; - bottom: 0.25rem; - left: -0.5rem; - border-inline-end: 0.25rem solid - var(--fg-muted-2); - border-block-end: none; - border-start-end-radius: 0.25rem; - border-end-start-radius: 0; - content: ""; + &:hover { + background-color: var(--primary-color); + color: var(--contrast-color); - :root[dir*="rtl"] & { - right: -0.5rem; - left: unset; - } + .icon { + background-color: var(--contrast-color); } } - &:hover::before { - right: 1rem; - left: 1rem; - border-block-end: 0.25rem solid var(--primary-color); - - @media only screen and (max-width: 480px) { - top: 0; - right: unset; - bottom: 0; - left: -0.5rem; - border-inline-end: 0.25rem solid - var(--primary-color); - border-block-end: none; - content: ""; - - :root[dir*="rtl"] & { - right: -0.5rem; - left: unset; - } - } - } - - &:active::before { - border-radius: 0.25rem; + .icon { + background-color: var(--primary-color); } } } @@ -251,10 +189,6 @@ &#repo a { padding: 0.5rem 0.625rem; - &:hover .icon { - background-color: var(--primary-color); - } - .icon { vertical-align: -0.125em; transition: var(--transition); @@ -276,7 +210,7 @@ font-size: 1rem; } - &#search button .icon { + &#search .icon { $icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16'%3E%3Cpath d='M6.57.063c-3.578 0-6.5 2.921-6.5 6.5 0 3.578 2.922 6.5 6.5 6.5a6.46 6.46 0 0 0 3.83-1.256l2.975 2.974c.957.938 2.363-.5 1.406-1.437l-2.96-2.961a6.46 6.46 0 0 0 1.25-3.82c0-3.579-2.923-6.5-6.5-6.5m0 2c2.5 0 4.5 2.003 4.5 4.5 0 2.5-2 4.5-4.5 4.5-2.496 0-4.5-2-4.5-4.5 0-2.497 2.004-4.5 4.5-4.5'/%3E%3C/svg%3E"); -webkit-mask-image: $icon; mask-image: $icon; @@ -305,6 +239,7 @@ details { position: relative; + flex: 1; box-shadow: none; border-radius: 0; background-color: transparent; @@ -314,22 +249,45 @@ transition: var(--transition); border-radius: 999px; background-color: transparent; + padding: 0.5rem 0.75rem; color: var(--fg-muted-4); + font-weight: bold; + line-height: 1.25; list-style: none; + text-align: center; + text-decoration: none; &::marker, &::-webkit-details-marker { display: none; } + + .icon.arrow { + $icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16'%3E%3Cpath d='m2.293 6.707 5 5a1 1 0 0 0 1.414 0l5-5a1 1 0 1 0-1.414-1.414L8 9.586 3.707 5.293a1 1 0 1 0-1.414 1.414m0 0'/%3E%3C/svg%3E"); + -webkit-mask-image: $icon; + vertical-align: -0.125em; + mask-image: $icon; + transition: var(--transition); + margin-inline-end: 0.25rem; + background-color: var(--fg-muted-4); + width: 1rem; + height: 1rem; + } } - &[open] ul { - animation: dropdown-open var(--transition); + &[open] { + .icon.arrow { + transform: scaleY(-100%); + } - @keyframes dropdown-open { - from { - transform: translate(-50%, 0); - opacity: 0; + ul { + animation: dropdown-open var(--transition); + + @keyframes dropdown-open { + from { + transform: translate(-50%, 0); + opacity: 0; + } } } } @@ -345,102 +303,67 @@ box-shadow: var(--edge-highlight), 0 0.75rem 1.5rem -1rem rgb(0 0 0 / 0.5); + border-radius: calc(var(--rounded-corner) + 0.25rem); background-color: var(--nav-bg); padding: 0.25rem; + @media only screen and (max-width: 480px) { + transform: translate(-50%, 0.5rem); + } + li { width: 100%; a { border-radius: var(--rounded-corner); - width: 100%; + text-align: start; } } } } - &#language-switcher { - details { - summary { - .icon { - $icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16'%3E%3Cpath d='M3.98 1v3H1v2h2.947a4.8 4.8 0 0 1-.592 1.871c-.425.758-1.101 1.488-2.062 2.45l1.414 1.413c.92-.92 1.703-1.728 2.283-2.697.38.632.844 1.196 1.377 1.768l.668-2.309a6 6 0 0 1-.41-.625A4.75 4.75 0 0 1 6.033 6h1.53l.511-2H6V1zm5.24 1L6 15h2l.781-3h4.438L14 15h2L12.781 2zm1.562 2h.438l1.5 6H9.28z'/%3E%3C/svg%3E"); - -webkit-mask-image: $icon; - mask-image: $icon; - } - } - - ul { - border-radius: calc( - var(--rounded-corner) + 0.25rem - ); - } - } + &#language-switcher .icon { + $icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16'%3E%3Cpath d='M3.98 1v3H1v2h2.947a4.8 4.8 0 0 1-.592 1.871c-.425.758-1.101 1.488-2.062 2.45l1.414 1.413c.92-.92 1.703-1.728 2.283-2.697.38.632.844 1.196 1.377 1.768l.668-2.309a6 6 0 0 1-.41-.625A4.75 4.75 0 0 1 6.033 6h1.53l.511-2H6V1zm5.24 1L6 15h2l.781-3h4.438L14 15h2L12.781 2zm1.562 2h.438l1.5 6H9.28z'/%3E%3C/svg%3E"); + -webkit-mask-image: $icon; + mask-image: $icon; } &#theme-switcher { - details { - summary { - .icon { - $icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16'%3E%3Cpath d='M8 0C3.594 0 0 3.594 0 8s3.594 8 8 8 8-3.594 8-8-3.594-8-8-8m0 1.941c3.36 0 6.059 2.7 6.059 6.059s-2.7 6.059-6.059 6.059zm0 0'/%3E%3C/svg%3E"); - -webkit-mask-image: $icon; - mask-image: $icon; - - :root[dir*="rtl"] & { - transform: scaleX(-100%); - } - } - - .icon.light { - $icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16'%3E%3Cpath d='M8.004-.008a1 1 0 0 0-1 1v1a1 1 0 1 0 2 0v-1c0-.554-.445-1-1-1M3.053 2.035a1 1 0 0 0-.26.035.994.994 0 0 0-.45 1.672l.708.707a1 1 0 1 0 1.414-1.414l-.707-.707a1 1 0 0 0-.705-.293m9.9.012a1 1 0 0 0-.707.293l-.707.707a1 1 0 1 0 1.414 1.414l.707-.707a1 1 0 0 0-.707-1.707M8 4C5.785 4 4 5.785 4 8s1.785 4 4 4 4-1.785 4-4-1.785-4-4-4m0 2c1.098 0 2 .902 2 2s-.902 2-2 2-2-.902-2-2 .902-2 2-2m-7.004.984a1 1 0 1 0 0 2h1a1 1 0 1 0 0-2zM14 7c-.55 0-1 .45-1 1s.45 1 1 1h1c.55 0 1-.45 1-1s-.45-1-1-1zM3.748 11.234a1 1 0 0 0-.705.293l-.711.707a1.007 1.007 0 0 0 0 1.414c.39.391 1.027.391 1.418 0l.707-.707a1 1 0 0 0-.709-1.707m8.49.006q-.131 0-.261.033a1.01 1.01 0 0 0-.707.711 1 1 0 0 0 .261.965l.707.707a.995.995 0 0 0 1.672-.445 1 1 0 0 0-.258-.969l-.707-.707a1 1 0 0 0-.707-.295m-4.246 1.756c-.554 0-1 .445-1 1v1a1 1 0 1 0 2 0v-1a1 1 0 0 0-1-1'/%3E%3C/svg%3E"); - -webkit-mask-image: $icon; - mask-image: $icon; - } - - .icon.dark { - $icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16'%3E%3Cpath d='M.918 8.004a7.072 7.072 0 0 0 14.102.793 1.01 1.01 0 0 0-.457-.957 1 1 0 0 0-1.063-.004 3.9 3.9 0 0 1-2.031.578 3.89 3.89 0 0 1-3.883-3.883c0-.715.203-1.422.578-2.031a1 1 0 0 0-.004-1.062c-.207-.32-.578-.5-.957-.458A7.07 7.07 0 0 0 .918 8.004M5.586 4.53a5.877 5.877 0 0 0 8.965 5.004l-1.52-.96a5.09 5.09 0 0 1-5.035 4.507 5.09 5.09 0 0 1-5.078-5.078 5.09 5.09 0 0 1 4.508-5.035l-.961-1.52a5.9 5.9 0 0 0-.88 3.082m0 0'/%3E%3C/svg%3E"); - -webkit-mask-image: $icon; - mask-image: $icon; - - :root[dir*="rtl"] & { - transform: scaleX(-100%); - } - } - } - } - ul { flex-wrap: nowrap; border-radius: 999px; li { - display: flex; - width: 100%; + flex: 1; + } + } - #theme-light .icon { - $icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16'%3E%3Cpath d='M8.004-.008a1 1 0 0 0-1 1v1a1 1 0 1 0 2 0v-1c0-.554-.445-1-1-1M3.053 2.035a1 1 0 0 0-.26.035.994.994 0 0 0-.45 1.672l.708.707a1 1 0 1 0 1.414-1.414l-.707-.707a1 1 0 0 0-.705-.293m9.9.012a1 1 0 0 0-.707.293l-.707.707a1 1 0 1 0 1.414 1.414l.707-.707a1 1 0 0 0-.707-1.707M8 4C5.785 4 4 5.785 4 8s1.785 4 4 4 4-1.785 4-4-1.785-4-4-4m0 2c1.098 0 2 .902 2 2s-.902 2-2 2-2-.902-2-2 .902-2 2-2m-7.004.984a1 1 0 1 0 0 2h1a1 1 0 1 0 0-2zM14 7c-.55 0-1 .45-1 1s.45 1 1 1h1c.55 0 1-.45 1-1s-.45-1-1-1zM3.748 11.234a1 1 0 0 0-.705.293l-.711.707a1.007 1.007 0 0 0 0 1.414c.39.391 1.027.391 1.418 0l.707-.707a1 1 0 0 0-.709-1.707m8.49.006q-.131 0-.261.033a1.01 1.01 0 0 0-.707.711 1 1 0 0 0 .261.965l.707.707a.995.995 0 0 0 1.672-.445 1 1 0 0 0-.258-.969l-.707-.707a1 1 0 0 0-.707-.295m-4.246 1.756c-.554 0-1 .445-1 1v1a1 1 0 1 0 2 0v-1a1 1 0 0 0-1-1'/%3E%3C/svg%3E"); - -webkit-mask-image: $icon; - mask-image: $icon; - } + #theme-system .icon, + .icon { + $icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16'%3E%3Cpath d='M8 0C3.594 0 0 3.594 0 8s3.594 8 8 8 8-3.594 8-8-3.594-8-8-8m0 1.941c3.36 0 6.059 2.7 6.059 6.059s-2.7 6.059-6.059 6.059zm0 0'/%3E%3C/svg%3E"); + -webkit-mask-image: $icon; + mask-image: $icon; - #theme-dark .icon { - $icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16'%3E%3Cpath d='M.918 8.004a7.072 7.072 0 0 0 14.102.793 1.01 1.01 0 0 0-.457-.957 1 1 0 0 0-1.063-.004 3.9 3.9 0 0 1-2.031.578 3.89 3.89 0 0 1-3.883-3.883c0-.715.203-1.422.578-2.031a1 1 0 0 0-.004-1.062c-.207-.32-.578-.5-.957-.458A7.07 7.07 0 0 0 .918 8.004M5.586 4.53a5.877 5.877 0 0 0 8.965 5.004l-1.52-.96a5.09 5.09 0 0 1-5.035 4.507 5.09 5.09 0 0 1-5.078-5.078 5.09 5.09 0 0 1 4.508-5.035l-.961-1.52a5.9 5.9 0 0 0-.88 3.082m0 0'/%3E%3C/svg%3E"); - -webkit-mask-image: $icon; - mask-image: $icon; + :root[dir*="rtl"] & { + transform: scaleX(-100%); + } + } - :root[dir*="rtl"] & { - transform: scaleX(-100%); - } - } + #theme-light .icon, + .icon.light { + $icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16'%3E%3Cpath d='M8.004-.008a1 1 0 0 0-1 1v1a1 1 0 1 0 2 0v-1c0-.554-.445-1-1-1M3.053 2.035a1 1 0 0 0-.26.035.994.994 0 0 0-.45 1.672l.708.707a1 1 0 1 0 1.414-1.414l-.707-.707a1 1 0 0 0-.705-.293m9.9.012a1 1 0 0 0-.707.293l-.707.707a1 1 0 1 0 1.414 1.414l.707-.707a1 1 0 0 0-.707-1.707M8 4C5.785 4 4 5.785 4 8s1.785 4 4 4 4-1.785 4-4-1.785-4-4-4m0 2c1.098 0 2 .902 2 2s-.902 2-2 2-2-.902-2-2 .902-2 2-2m-7.004.984a1 1 0 1 0 0 2h1a1 1 0 1 0 0-2zM14 7c-.55 0-1 .45-1 1s.45 1 1 1h1c.55 0 1-.45 1-1s-.45-1-1-1zM3.748 11.234a1 1 0 0 0-.705.293l-.711.707a1.007 1.007 0 0 0 0 1.414c.39.391 1.027.391 1.418 0l.707-.707a1 1 0 0 0-.709-1.707m8.49.006q-.131 0-.261.033a1.01 1.01 0 0 0-.707.711 1 1 0 0 0 .261.965l.707.707a.995.995 0 0 0 1.672-.445 1 1 0 0 0-.258-.969l-.707-.707a1 1 0 0 0-.707-.295m-4.246 1.756c-.554 0-1 .445-1 1v1a1 1 0 1 0 2 0v-1a1 1 0 0 0-1-1'/%3E%3C/svg%3E"); + -webkit-mask-image: $icon; + mask-image: $icon; + } - #theme-system .icon { - $icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16'%3E%3Cpath d='M8 0C3.594 0 0 3.594 0 8s3.594 8 8 8 8-3.594 8-8-3.594-8-8-8m0 1.941c3.36 0 6.059 2.7 6.059 6.059s-2.7 6.059-6.059 6.059zm0 0'/%3E%3C/svg%3E"); - -webkit-mask-image: $icon; - mask-image: $icon; + #theme-dark .icon, + .icon.dark { + $icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16'%3E%3Cpath d='M.918 8.004a7.072 7.072 0 0 0 14.102.793 1.01 1.01 0 0 0-.457-.957 1 1 0 0 0-1.063-.004 3.9 3.9 0 0 1-2.031.578 3.89 3.89 0 0 1-3.883-3.883c0-.715.203-1.422.578-2.031a1 1 0 0 0-.004-1.062c-.207-.32-.578-.5-.957-.458A7.07 7.07 0 0 0 .918 8.004M5.586 4.53a5.877 5.877 0 0 0 8.965 5.004l-1.52-.96a5.09 5.09 0 0 1-5.035 4.507 5.09 5.09 0 0 1-5.078-5.078 5.09 5.09 0 0 1 4.508-5.035l-.961-1.52a5.9 5.9 0 0 0-.88 3.082m0 0'/%3E%3C/svg%3E"); + -webkit-mask-image: $icon; + mask-image: $icon; - :root[dir*="rtl"] & { - transform: scaleX(-100%); - } - } + :root[dir*="rtl"] & { + transform: scaleX(-100%); } } } diff --git a/templates/partials/language_switcher.html b/templates/partials/language_switcher.html index 40d18dc..600d6e4 100644 --- a/templates/partials/language_switcher.html +++ b/templates/partials/language_switcher.html @@ -1,6 +1,6 @@ {#- Based on https://github.com/welpo/tabi/blob/main/templates/partials/language_switcher.html -#} -
  • +
  • diff --git a/templates/partials/nav.html b/templates/partials/nav.html index a1a992d..bf56991 100644 --- a/templates/partials/nav.html +++ b/templates/partials/nav.html @@ -16,7 +16,39 @@
  • {%- for link in config.extra.nav.links %} - {%- if link.url is matching('https?://') %} + {%- if link.sublinks and link.sublinks | length > 0 -%} +
  • +
    + + + {{- macros_translate::translate(key=link.name, default=link.name, language_strings=language_strings) -}} + + +
    +
  • + {%- elif link.url is matching('https?://') %}
  • +
  • +
  • @@ -73,14 +105,14 @@
  • {%- endif %} {%- if config.generate_feeds and config.extra.nav.show_feed %} -
  • +
  • {%- endif %} {%- if config.extra.source_url and config.extra.nav.show_repo %} -
  • +