Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

Commit d8efe2a

Browse files
committed
updated the spacing for nav item
1 parent f8de48b commit d8efe2a

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

packages/akiradocs/src/components/layout/Navigation.tsx

+18-12
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ import { ErrorBoundary } from 'react-error-boundary'
1313
import { getApiNavigation } from '@/lib/content';
1414
import { useAnalytics } from '@/hooks/useAnalytics';
1515
const buttonStyles = {
16-
base: "w-full justify-start text-left font-normal rounded-lg transition-all px-3 py-2 whitespace-normal",
16+
base: "w-full justify-start text-left font-normal rounded-lg transition-all px-1.5 py-1 whitespace-normal break-words",
1717
hover: "hover:bg-accent/40 hover:text-accent-foreground",
18-
active: "bg-gradient-to-r from-accent to-accent/80 text-accent-foreground font-medium shadow-md translate-x-1",
18+
active: "w-full bg-gradient-to-r from-accent to-accent/80 text-accent-foreground font-medium shadow-md translate-x-1 px-1.5 py-1 break-words",
1919
state: "data-[state=open]:bg-accent/30",
2020
}
2121

@@ -88,7 +88,7 @@ const NavItem = React.memo(({ locale, item, pathname, depth = 0 }: NavItemProps)
8888
<motion.div
8989
ref={itemRef}
9090
className={cn(
91-
"relative",
91+
"relative mb-1",
9292
depth > 0 && "ml-3 border-l border-border/50 pl-3 before:absolute before:left-0 before:top-0 before:bottom-0 before:w-px before:bg-gradient-to-b before:from-border/0 before:via-border/50 before:to-border/0"
9393
)}
9494
initial={{ opacity: 0, x: -20 }}
@@ -103,29 +103,34 @@ const NavItem = React.memo(({ locale, item, pathname, depth = 0 }: NavItemProps)
103103
buttonStyles.state,
104104
isActive && buttonStyles.active,
105105
depth > 0 && "text-sm text-muted-foreground",
106-
"group"
106+
"group flex items-start gap-2",
107+
"min-h-[2.5rem] h-auto"
107108
)}
108109
onClick={handleClick}
109110
>
110-
{hasChildren ? (
111+
{hasChildren && (
111112
<motion.div
112-
className="text-muted-foreground/70 group-hover:text-muted-foreground"
113+
className="text-muted-foreground/70 group-hover:text-muted-foreground shrink-0 mt-1"
113114
initial={false}
114115
animate={{ rotate: isOpen ? 90 : 0 }}
115116
transition={{ duration: 0.2 }}
116117
>
117-
<ChevronRight className="mr-2 h-3.5 w-3.5" />
118+
<ChevronRight className="h-3.5 w-3.5" />
118119
</motion.div>
119-
) : ""}
120+
)}
120121
{item.path ? (
121-
<Link href={absolutePath} className="flex-1 break-words" onClick={handleClick}>
122-
{item.title}
122+
<Link
123+
href={absolutePath}
124+
className="flex-1 leading-tight py-0.5"
125+
onClick={handleClick}
126+
>
127+
<span className="inline-block">{item.title}</span>
123128
</Link>
124129
) : (
125-
<span className="flex-1 break-words">{item.title}</span>
130+
<span className="flex-1 leading-tight py-0.5 inline-block">{item.title}</span>
126131
)}
127132
{item.badge && (
128-
<span className="ml-2 px-2 py-0.5 text-xs rounded-full bg-accent text-accent-foreground shrink-0">
133+
<span className="px-2 py-0.5 text-xs rounded-full bg-accent text-accent-foreground shrink-0 self-start mt-1">
129134
{item.badge}
130135
</span>
131136
)}
@@ -137,6 +142,7 @@ const NavItem = React.memo(({ locale, item, pathname, depth = 0 }: NavItemProps)
137142
animate={{ opacity: 1, height: "auto" }}
138143
exit={{ opacity: 0, height: 0 }}
139144
transition={{ duration: 0.3, ease: "easeInOut" }}
145+
className="mt-1"
140146
>
141147
{Object.entries(item.items!).map(([key, child]) => (
142148
<NavItem locale={locale} key={key} item={child} pathname={pathname} depth={depth + 1} />

0 commit comments

Comments
 (0)