pages active sidebar background

This commit is contained in:
marshennikovaolga
2024-09-09 20:05:36 +03:00
parent 4347037589
commit 3dc440632f

View File

@@ -57,7 +57,8 @@ export const PageSection: React.FC<{ pathname?: string }> = ({ pathname }) => {
const [show, setShow] = useAtom(pageShowAtom) const [show, setShow] = useAtom(pageShowAtom)
const pageCount = me?.root.personalPages?.length || 0 const pageCount = me?.root.personalPages?.length || 0
const isActive = pathname ? pathname.startsWith("/pages") : false // const isActive = pathname ? pathname.startsWith("/pages") : false
const isActive = pathname === "/pages"
if (!me) return null if (!me) return null
@@ -74,21 +75,24 @@ interface PageSectionHeaderProps {
isActive: boolean isActive: boolean
} }
const PageSectionHeader: React.FC<PageSectionHeaderProps> = ({ pageCount }) => ( const PageSectionHeader: React.FC<PageSectionHeaderProps> = ({ pageCount, isActive }) => (
<div <div
className={cn("flex min-h-[30px] items-center gap-px rounded-md", "hover:bg-accent hover:text-accent-foreground")} className={cn(
"flex min-h-[30px] items-center gap-px rounded-md",
isActive ? "bg-accent text-accent-foreground" : "hover:bg-accent hover:text-accent-foreground"
)}
> >
<Link <Link
href="/pages" href="/pages"
className="size-6 flex-1 items-center justify-start rounded-md px-2 py-1 focus-visible:outline-none focus-visible:ring-0" className="flex flex-1 items-center justify-start rounded-md px-2 py-1 focus-visible:outline-none focus-visible:ring-0"
> >
<p className="flex items-center text-xs font-medium"> <p className="text-xs">
Pages Pages
{pageCount > 0 && <span className="text-muted-foreground ml-1">{pageCount}</span>} {pageCount > 0 && <span className="text-muted-foreground ml-1">{pageCount}</span>}
</p> </p>
</Link> </Link>
<div className={cn("flex items-center gap-px pr-2")}> <div className="flex items-center gap-px pr-2">
<ShowAllForm /> <ShowAllForm />
<NewPageButton /> <NewPageButton />
</div> </div>