From 2551a49f953c3f604c0e0abdaad0b6f029415c8c Mon Sep 17 00:00:00 2001 From: marshennikovaolga Date: Fri, 6 Sep 2024 12:49:58 +0300 Subject: [PATCH] links sidebar --- .../custom/sidebar/partial/link-section.tsx | 97 +++++++++++++++++++ web/components/custom/sidebar/sidebar.tsx | 4 +- web/components/routes/search/wrapper.tsx | 11 ++- 3 files changed, 106 insertions(+), 6 deletions(-) create mode 100644 web/components/custom/sidebar/partial/link-section.tsx diff --git a/web/components/custom/sidebar/partial/link-section.tsx b/web/components/custom/sidebar/partial/link-section.tsx new file mode 100644 index 00000000..a3da175a --- /dev/null +++ b/web/components/custom/sidebar/partial/link-section.tsx @@ -0,0 +1,97 @@ +import React from "react" +import Link from "next/link" +import { usePathname } from "next/navigation" +import { useAccount } from "@/lib/providers/jazz-provider" +import { cn } from "@/lib/utils" +import { Button } from "@/components/ui/button" +import { LaIcon } from "@/components/custom/la-icon" +import { PersonalLinkLists } from "@/lib/schema/personal-link" + +export const LinkSection: React.FC = () => { + const { me } = useAccount({ + root: { + personalLinks: [] + } + }) + + const linkCount = me?.root.personalLinks?.length || 0 + + if (!me) return null + + return ( +
+ + +
+ ) +} + +interface LinkSectionHeaderProps { + linkCount: number +} + +const LinkSectionHeader: React.FC = ({ linkCount }) => ( +
+ +

+ Links + {linkCount > 0 && {linkCount}} +

+ +
+) + +interface ListProps { + personalLinks: PersonalLinkLists +} + +const List: React.FC = ({ personalLinks }) => { + const pathname = usePathname() + + return ( +
+ +
+ ) +} + +interface ListItemProps { + label: string + href: string + count: number + isActive: boolean +} + +const ListItem: React.FC = ({ label, href, count, isActive }) => { + return ( +
+
+ +
+ +

{label}

+
+ + + {count > 0 && ( + {count} + )} +
+
+ ) +} diff --git a/web/components/custom/sidebar/sidebar.tsx b/web/components/custom/sidebar/sidebar.tsx index bfccd464..893dcebb 100644 --- a/web/components/custom/sidebar/sidebar.tsx +++ b/web/components/custom/sidebar/sidebar.tsx @@ -10,6 +10,7 @@ import { Logo } from "@/components/custom/logo" import { Button } from "@/components/ui/button" import { cn } from "@/lib/utils" import { isCollapseAtom } from "@/store/sidebar" +import { LinkSection } from "./partial/link-section" import { PageSection } from "./partial/page-section" import { TopicSection } from "./partial/topic-section" import { ProfileSection } from "./partial/profile-section" @@ -77,7 +78,7 @@ const LogoAndSearch: React.FC = React.memo(() => { return (
- +
@@ -116,6 +117,7 @@ const SidebarContent: React.FC = React.memo(() => {
+
diff --git a/web/components/routes/search/wrapper.tsx b/web/components/routes/search/wrapper.tsx index 11d59430..36cc66fb 100644 --- a/web/components/routes/search/wrapper.tsx +++ b/web/components/routes/search/wrapper.tsx @@ -130,7 +130,7 @@ export const SearchWrapper = () => { type="text" value={searchText} onChange={handleSearch} - placeholder="Search something..." + placeholder="Search topics, links, pages" className="dark:bg-input w-full rounded-lg border border-neutral-300 p-2 pl-8 focus:outline-none dark:border-neutral-600" /> {searchText && ( @@ -178,12 +178,13 @@ export const SearchWrapper = () => {
) : (
- {searchText && !showAiSearch && ( + {/* {searchText && !showAiSearch && ( */} + {searchText && (
setShowAiSearch(true)} + className="cursor-default rounded-lg bg-blue-700 p-4 font-semibold text-white" + // onClick={() => setShowAiSearch(true)} > - ✨ Didn't find what you were looking for? Ask AI + ✨ Didn't find what you were looking for? Will soon have AI assistant builtin
)} {showAiSearch && }