From 8b5f9ce31974bb43f81ca8bb3d89429d1bc398fb Mon Sep 17 00:00:00 2001 From: TalionSD <101660980+TalionSD@users.noreply.github.com> Date: Mon, 22 Sep 2025 10:50:50 +0330 Subject: [PATCH 1/4] Update SearchBar component --- components/search-bar.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/components/search-bar.tsx b/components/search-bar.tsx index 5f09b86..38e28f3 100644 --- a/components/search-bar.tsx +++ b/components/search-bar.tsx @@ -5,6 +5,7 @@ import { Search, X, ExternalLink } from "lucide-react"; import { Dialog, DialogTrigger, DialogContent } from "@/components/ui/dialog"; import { Input } from "@/components/ui/input"; import { Button } from "@/components/ui/button"; +import { ScrollArea } from "@/components/ui/scroll-area"; import { useTranslations, useLocale } from "next-intl"; import Fuse from "fuse.js"; @@ -72,7 +73,7 @@ export default function SearchBar() { @@ -97,11 +98,11 @@ export default function SearchBar() { setResults([]); }} > - + )} -
+ {results.length > 0 ? (
    {results.map((result) => ( @@ -138,7 +139,7 @@ export default function SearchBar() { {t("search.startTyping") || "Start typing to search..."}

    )} -
+
); From 24b87f132b759a64413b37d2a3f8ca53bd2a9e0a Mon Sep 17 00:00:00 2001 From: TalionSD <101660980+TalionSD@users.noreply.github.com> Date: Wed, 8 Oct 2025 10:36:52 +0330 Subject: [PATCH 2/4] Improve SearchBar UI --- components/search-bar.tsx | 116 ++++++++++++++++++++++++++------------ messages/fa.json | 4 +- 2 files changed, 81 insertions(+), 39 deletions(-) diff --git a/components/search-bar.tsx b/components/search-bar.tsx index 38e28f3..4ffaf5c 100644 --- a/components/search-bar.tsx +++ b/components/search-bar.tsx @@ -15,29 +15,30 @@ interface SearchResult { path: string; content: string; searchable: string; - language: 'en' | 'fa'; + language: "en" | "fa"; category: string; } export default function SearchBar() { const t = useTranslations("Header"); - const locale = useLocale() as 'en' | 'fa'; + const locale = useLocale() as "en" | "fa"; + const [query, setQuery] = useState(""); const [results, setResults] = useState([]); const [index, setIndex] = useState([]); const [isOpen, setIsOpen] = useState(false); useEffect(() => { - fetch('/search-index.json') + fetch("/search-index.json") .then((res) => res.json()) .then((data) => setIndex(data)) - .catch((err) => console.error('Error loading search index:', err)); + .catch((err) => console.error("Error loading search index:", err)); }, []); const fuse = useMemo(() => { if (!index.length) return null; return new Fuse(index, { - keys: ['title', 'searchable'], + keys: ["title", "searchable"], threshold: 0.4, includeScore: true, ignoreLocation: true, @@ -54,6 +55,7 @@ export default function SearchBar() { .search(value) .map(({ item }) => item) .filter((item) => item.language === locale); + setResults(searchResults); }; @@ -68,61 +70,100 @@ export default function SearchBar() { return ( - + -
-
- - handleSearch(e.target.value)} - className="flex-1 pl-10" - autoFocus - /> -
+
+ + + handleSearch(e.target.value)} + className={`flex-1 ${locale === "fa" ? "pr-10" : "pl-10"}`} + autoFocus + /> + {query && ( - + + )}
- + + {results.length > 0 ? (
); -} \ No newline at end of file +} diff --git a/messages/fa.json b/messages/fa.json index b00c969..28697e6 100644 --- a/messages/fa.json +++ b/messages/fa.json @@ -122,8 +122,8 @@ "search": { "ariaLabel": "جستجو در مستندات", "placeholder": "جستجو در مستندات Cyrus...", - "noResults": "نتیجه‌ای یافت نشد. کلمات دیگری را امتحان کنید.", - "startTyping": "برای جستجو در مستندات شروع به تایپ کنید...", + "noResults": "نتیجه‌ای یافت نشد. کلمات دیگری را امتحان کنید", + "startTyping": "برای جستجو در مستندات شروع به تایپ کنید", "goToPage": "برو به صفحه" } }, From ac07b5e9ee8f06f87be09f70eab71e85f4d5b4ad Mon Sep 17 00:00:00 2001 From: TalionSD <101660980+TalionSD@users.noreply.github.com> Date: Wed, 8 Oct 2025 10:50:46 +0330 Subject: [PATCH 3/4] Update pnpm-lock.yaml --- pnpm-lock.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b869ac0..7b95cc9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -189,6 +189,9 @@ importers: specifier: ^3.24.1 version: 3.24.2 devDependencies: + '@types/aos': + specifier: ^3.0.7 + version: 3.0.7 '@types/node': specifier: ^22.18.1 version: 22.18.1 @@ -1025,6 +1028,9 @@ packages: '@tsconfig/node16@1.0.4': resolution: {integrity: sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==} + '@types/aos@3.0.7': + resolution: {integrity: sha512-sEhyFqvKauUJZDbvAB3Pggynrq6g+2PS4XB3tmUr+mDL1gfDJnwslUC4QQ7/l8UD+LWpr3RxZVR/rHoZrLqZVg==} + '@types/d3-array@3.2.1': resolution: {integrity: sha512-Y2Jn2idRrLzUfAKV2LyRImR+y4oa2AntrgID95SHJxuMUrkNXmanDSed71sRNZysveJVt1hLLemQZIady0FpEg==} @@ -3183,6 +3189,8 @@ snapshots: '@tsconfig/node16@1.0.4': {} + '@types/aos@3.0.7': {} + '@types/d3-array@3.2.1': {} '@types/d3-color@3.1.3': {} From 5d81b7752e1bcc3e38588dcc556697fbb1289014 Mon Sep 17 00:00:00 2001 From: TalionSD <101660980+TalionSD@users.noreply.github.com> Date: Wed, 8 Oct 2025 16:39:02 +0330 Subject: [PATCH 4/4] Improve SearchBar UI --- components/search-bar.tsx | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/components/search-bar.tsx b/components/search-bar.tsx index 4ffaf5c..fa7d2c8 100644 --- a/components/search-bar.tsx +++ b/components/search-bar.tsx @@ -80,14 +80,14 @@ export default function SearchBar() { -
+
)}
- + {results.length > 0 ? (
    {results.map((result) => ( @@ -181,7 +181,6 @@ export default function SearchBar() {

    )} - );