From 4410040bad52c44da2c57fc1ca0e8121114d4b92 Mon Sep 17 00:00:00 2001 From: sendevia Date: Tue, 25 Nov 2025 02:38:14 +0800 Subject: [PATCH] add(appbar): add appbar component with search functionality --- .vitepress/theme/components/Appbar.vue | 334 ++++++++++++++++++ .vitepress/theme/index.ts | 3 +- .../theme/styles/_components/appbar.scss | 93 ----- .vitepress/theme/styles/main.scss | 1 - 4 files changed, 336 insertions(+), 95 deletions(-) create mode 100644 .vitepress/theme/components/Appbar.vue delete mode 100644 .vitepress/theme/styles/_components/appbar.scss diff --git a/.vitepress/theme/components/Appbar.vue b/.vitepress/theme/components/Appbar.vue new file mode 100644 index 0000000..6b47b24 --- /dev/null +++ b/.vitepress/theme/components/Appbar.vue @@ -0,0 +1,334 @@ + + + + + diff --git a/.vitepress/theme/index.ts b/.vitepress/theme/index.ts index a060736..0f3db14 100644 --- a/.vitepress/theme/index.ts +++ b/.vitepress/theme/index.ts @@ -1,7 +1,7 @@ import type { Theme } from "vitepress"; - import Layout from "./layouts/Default.vue"; +import AppBar from "./components/Appbar.vue"; import Button from "./components/Button.vue"; import Footer from "./components/Footer.vue"; import Header from "./components/Header.vue"; @@ -16,6 +16,7 @@ import "./styles/main.scss"; export default { Layout, enhanceApp({ app }) { + app.component("AppBar", AppBar); app.component("Footer", Footer); app.component("Header", Header); app.component("ImageViewer", ImageViewer); diff --git a/.vitepress/theme/styles/_components/appbar.scss b/.vitepress/theme/styles/_components/appbar.scss deleted file mode 100644 index a50d913..0000000 --- a/.vitepress/theme/styles/_components/appbar.scss +++ /dev/null @@ -1,93 +0,0 @@ -@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; - } -} diff --git a/.vitepress/theme/styles/main.scss b/.vitepress/theme/styles/main.scss index 4c4c48a..501992e 100644 --- a/.vitepress/theme/styles/main.scss +++ b/.vitepress/theme/styles/main.scss @@ -8,7 +8,6 @@ @include meta.load-css("tokens"); @include meta.load-css("animation"); -@include meta.load-css("_components/appbar"); @include meta.load-css("_components/dialog"); @include meta.load-css("_components/loading-splash"); @include meta.load-css("_components/snackbar");