From f380d777380b4efa123efefb2745a2e36fb0c895 Mon Sep 17 00:00:00 2001 From: sendevia Date: Tue, 23 Sep 2025 12:27:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E7=A7=BB=E5=8A=A8?= =?UTF-8?q?=E7=AB=AF=E9=A1=B6=E6=A0=8F=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../theme/styles/_components/appbar.scss | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 .vitepress/theme/styles/_components/appbar.scss diff --git a/.vitepress/theme/styles/_components/appbar.scss b/.vitepress/theme/styles/_components/appbar.scss new file mode 100644 index 0000000..a50d913 --- /dev/null +++ b/.vitepress/theme/styles/_components/appbar.scss @@ -0,0 +1,93 @@ +@use "sass:meta"; +@use "../mixin"; + +// https://m3.material.io/components/top-app-bar/ + +.appbar { + display: flex; + align-items: center; + flex-direction: row; + flex-wrap: nowrap; + gap: 6px; + justify-content: space-between; + + position: fixed; + top: -64px; + + height: 64px; + width: 100%; + + padding: 8px 4px; + + background-color: var(--md-sys-color-surface-container-low); + + opacity: 0; + overflow: hidden; + transition: var(--md-sys-motion-duration-long1) var(--md-sys-motion-easing-standard); + visibility: hidden; + z-index: 4; + + #appbar-dynamic-title { + @include mixin.typescale-style("title-large"); + + display: flex; + align-items: flex-start; + flex-direction: column; + flex-grow: 1; + justify-content: center; + + height: 100%; + + margin: auto; + + text-align: start; + text-transform: uppercase; + + span { + position: absolute; + + width: calc(100% - 100px); + + line-height: 1; + text-overflow: ellipsis; + white-space: nowrap; + + overflow: hidden; + transition: var(--md-sys-motion-duration-medium4) var(--md-sys-motion-easing-emphasized); + + &:nth-child(1) { + transform: translateY(0px); + opacity: 1; + } + + &:nth-child(2) { + transform: translateY(45px); + opacity: 0; + } + } + } + + &[scroll="true"] { + background-color: var(--md-sys-color-surface-container-high); + + #appbar-dynamic-title { + span { + &:nth-child(1) { + transform: translateY(-45px); + opacity: 0; + } + + &:nth-child(2) { + transform: translateY(0px); + opacity: 1; + } + } + } + } + + @media screen and (max-width: 840px) { + top: 0; + + visibility: visible; + } +}