From 8d95b0df18b9ef0407c56ed629142734049e2d73 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Tue, 12 Sep 2023 01:09:34 +0100 Subject: [PATCH] search tweaks --- src/components/Search/Search.module.css | 9 -------- src/components/Search/Search.tsx | 28 ++----------------------- 2 files changed, 2 insertions(+), 35 deletions(-) diff --git a/src/components/Search/Search.module.css b/src/components/Search/Search.module.css index 82be0ee78..bfe452131 100644 --- a/src/components/Search/Search.module.css +++ b/src/components/Search/Search.module.css @@ -4,15 +4,6 @@ right: calc(var(--spacer) / 2); top: calc(var(--spacer) / 3); z-index: 10; - transform: translate3d(0, 80px, 0); - will-change: transform; -} - -@media (min-width: 40rem) { - .search { - left: 0; - right: 0; - } } .searchInput { diff --git a/src/components/Search/Search.tsx b/src/components/Search/Search.tsx index c1ac47596..8d715ec61 100644 --- a/src/components/Search/Search.tsx +++ b/src/components/Search/Search.tsx @@ -1,8 +1,7 @@ -import { type ReactElement, useEffect, useState, useRef } from 'react' +import { type ReactElement, useEffect, useState } from 'react' import Fuse from 'fuse.js' import { useStore } from '@nanostores/react' import { isSearchOpen } from '@stores/search' -import { animate } from 'motion' import SearchResults from './Results' import styles from './Search.module.css' import type { CollectionEntry } from 'astro:content' @@ -26,19 +25,6 @@ export default function Search(): ReactElement { const [results, setResults] = useState() const [allPosts, setAllPosts] = useState() - const ref = useRef(null) - - // animate opening of search - useEffect(() => { - if (!$isSearchOpen || !ref?.current) return - - animate( - ref.current, - { transform: ['translate3d(0, 0, 0)'] }, - { duration: 0.2, easing: 'ease-out' } - ) - }, [$isSearchOpen]) - // fetch all post data on open useEffect(() => { if (!$isSearchOpen) return @@ -67,22 +53,12 @@ export default function Search(): ReactElement { // animate closing of search async function toggleSearch(): Promise { - ref.current && - (await animate( - ref.current, - { - transform: $isSearchOpen - ? 'translate3d(0, 80px, 0)' - : 'translate3d(0, 0, 0)' - }, - { duration: 0.2 } - ).finished) isSearchOpen.set(!$isSearchOpen) } return $isSearchOpen ? ( <> -
+