From 02865aa76e37bea9aa357675df5592c705f16428 Mon Sep 17 00:00:00 2001 From: saicaca Date: Sat, 22 Jun 2024 17:02:43 +0800 Subject: [PATCH] feat: improve button animation --- src/components/GlobalStyles.astro | 15 +++++++++++++-- src/components/LightDarkSwitch.svelte | 14 +++++++------- src/components/Navbar.astro | 8 ++++---- src/components/Search.svelte | 2 +- src/components/widget/WidgetLayout.astro | 2 +- 5 files changed, 26 insertions(+), 15 deletions(-) diff --git a/src/components/GlobalStyles.astro b/src/components/GlobalStyles.astro index 2322680..0904e23 100644 --- a/src/components/GlobalStyles.astro +++ b/src/components/GlobalStyles.astro @@ -216,8 +216,19 @@ color_set({ @apply pointer-events-none text-black/10 dark:text-white/10 } .btn-plain { - @apply transition flex items-center justify-center bg-none hover:bg-[var(--btn-plain-bg-hover)] active:bg-[var(--btn-plain-bg-active)] - text-black/75 hover:text-[var(--primary)] dark:text-white/75 dark:hover:text-[var(--primary)] + @apply transition relative flex items-center justify-center bg-none + overflow-hidden text-black/75 hover:text-[var(--primary)] dark:text-white/75 dark:hover:text-[var(--primary)]; + &:not(.scale-animation) { + @apply hover:bg-[var(--btn-plain-bg-hover)] active:bg-[var(--btn-plain-bg-active)] + } + &.scale-animation { + @apply before:ease-out hover:bg-none relative active:bg-none hover:before:bg-[var(--btn-plain-bg-hover)] active:before:bg-[var(--btn-plain-bg-active)] z-0 + before:absolute before:rounded-[inherit] before:inset-0 before:transition before:scale-[0.85] hover:before:scale-100 before:-z-10; + + &.current-theme-btn { + @apply before:scale-100 before:opacity-100 before:bg-[var(--btn-plain-bg-hover)] text-[var(--primary)] + } + } } .btn-regular { @apply transition flex items-center justify-center bg-[var(--btn-regular-bg)] hover:bg-[var(--btn-regular-bg-hover)] active:bg-[var(--btn-regular-bg-active)] diff --git a/src/components/LightDarkSwitch.svelte b/src/components/LightDarkSwitch.svelte index abd9824..9b44385 100644 --- a/src/components/LightDarkSwitch.svelte +++ b/src/components/LightDarkSwitch.svelte @@ -73,7 +73,7 @@ function hidePanel() { diff --git a/src/components/Search.svelte b/src/components/Search.svelte index 1e18639..df64cf8 100644 --- a/src/components/Search.svelte +++ b/src/components/Search.svelte @@ -80,7 +80,7 @@ $: search(keywordMobile, false) diff --git a/src/components/widget/WidgetLayout.astro b/src/components/widget/WidgetLayout.astro index 3d8e1a4..8e58486 100644 --- a/src/components/widget/WidgetLayout.astro +++ b/src/components/widget/WidgetLayout.astro @@ -29,7 +29,7 @@ const className = Astro.props.class {isCollapsed &&
-