|
@@ -12,7 +12,7 @@ import {
|
|
|
ChevronRight,
|
|
ChevronRight,
|
|
|
Home
|
|
Home
|
|
|
} from "lucide-react"
|
|
} from "lucide-react"
|
|
|
-import { COLOR_PALETTE, COMPONENT_COLORS } from "@/utils/palette"
|
|
|
|
|
|
|
+import { COLOR_PALETTE } from "@/utils/palette"
|
|
|
|
|
|
|
|
interface SidebarItem {
|
|
interface SidebarItem {
|
|
|
title: string
|
|
title: string
|
|
@@ -28,9 +28,10 @@ interface SidebarSection {
|
|
|
|
|
|
|
|
interface SidebarNavigationProps {
|
|
interface SidebarNavigationProps {
|
|
|
onItemClick?: () => void
|
|
onItemClick?: () => void
|
|
|
|
|
+ isCollapsed?: boolean
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-export default function SidebarNavigation({ onItemClick }: SidebarNavigationProps) {
|
|
|
|
|
|
|
+export default function SidebarNavigation({ onItemClick, isCollapsed = false }: SidebarNavigationProps) {
|
|
|
const { data: session } = useSession()
|
|
const { data: session } = useSession()
|
|
|
const pathname = usePathname()
|
|
const pathname = usePathname()
|
|
|
const [expandedSections, setExpandedSections] = useState<string[]>([])
|
|
const [expandedSections, setExpandedSections] = useState<string[]>([])
|
|
@@ -167,77 +168,63 @@ export default function SidebarNavigation({ onItemClick }: SidebarNavigationProp
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
- <nav className="flex-1 overflow-y-auto p-4">
|
|
|
|
|
|
|
+ <nav className={`flex-1 ${isCollapsed ? 'px-2' : 'px-4'} py-4`}>
|
|
|
{sidebarSections.map((section) => (
|
|
{sidebarSections.map((section) => (
|
|
|
<div key={section.title} className="mb-6">
|
|
<div key={section.title} className="mb-6">
|
|
|
- <button
|
|
|
|
|
- onClick={() => toggleSection(section.title)}
|
|
|
|
|
- className="flex items-center justify-between w-full text-left text-sm font-semibold mb-3 px-2 py-1 rounded-md transition-colors"
|
|
|
|
|
- style={{
|
|
|
|
|
- color: COLOR_PALETTE.gray[700]
|
|
|
|
|
- }}
|
|
|
|
|
- onMouseEnter={(e) => {
|
|
|
|
|
- e.currentTarget.style.color = COLOR_PALETTE.gray[900]
|
|
|
|
|
- e.currentTarget.style.backgroundColor = COLOR_PALETTE.gray[100]
|
|
|
|
|
- }}
|
|
|
|
|
- onMouseLeave={(e) => {
|
|
|
|
|
- e.currentTarget.style.color = COLOR_PALETTE.gray[700]
|
|
|
|
|
- e.currentTarget.style.backgroundColor = 'transparent'
|
|
|
|
|
- }}
|
|
|
|
|
- >
|
|
|
|
|
- {section.title}
|
|
|
|
|
- {expandedSections.includes(section.title) ? (
|
|
|
|
|
- <ChevronDown className="w-4 h-4" style={{ color: COLOR_PALETTE.gray[500] } as React.CSSProperties} />
|
|
|
|
|
- ) : (
|
|
|
|
|
- <ChevronRight className="w-4 h-4" style={{ color: COLOR_PALETTE.gray[500] } as React.CSSProperties} />
|
|
|
|
|
- )}
|
|
|
|
|
- </button>
|
|
|
|
|
|
|
+ {!isCollapsed && (
|
|
|
|
|
+ <button
|
|
|
|
|
+ onClick={() => toggleSection(section.title)}
|
|
|
|
|
+ className="flex items-center justify-between w-full text-left text-sm font-semibold mb-3 px-2 py-1 rounded-md transition-colors hover:bg-gray-50"
|
|
|
|
|
+ style={{
|
|
|
|
|
+ color: COLOR_PALETTE.gray[700]
|
|
|
|
|
+ }}
|
|
|
|
|
+ >
|
|
|
|
|
+ {section.title}
|
|
|
|
|
+ {expandedSections.includes(section.title) ? (
|
|
|
|
|
+ <ChevronDown className="w-4 h-4" style={{ color: COLOR_PALETTE.gray[500] } as React.CSSProperties} />
|
|
|
|
|
+ ) : (
|
|
|
|
|
+ <ChevronRight className="w-4 h-4" style={{ color: COLOR_PALETTE.gray[500] } as React.CSSProperties} />
|
|
|
|
|
+ )}
|
|
|
|
|
+ </button>
|
|
|
|
|
+ )}
|
|
|
|
|
|
|
|
- {expandedSections.includes(section.title) && (
|
|
|
|
|
- <div className="space-y-1 ml-2">
|
|
|
|
|
|
|
+ {(isCollapsed || expandedSections.includes(section.title)) && (
|
|
|
|
|
+ <div className={`space-y-1 ${isCollapsed ? 'ml-0' : 'ml-2'}`}>
|
|
|
{section.items.map((item) => (
|
|
{section.items.map((item) => (
|
|
|
<Link
|
|
<Link
|
|
|
key={`${section.title}-${item.href}`}
|
|
key={`${section.title}-${item.href}`}
|
|
|
href={item.href}
|
|
href={item.href}
|
|
|
- className="flex items-center space-x-3 px-3 py-2.5 rounded-lg text-sm transition-all duration-200"
|
|
|
|
|
|
|
+ className={`flex items-center ${isCollapsed ? 'justify-center px-2' : 'space-x-3 px-3'} py-2.5 rounded-lg text-sm transition-all duration-200 hover:bg-gray-50`}
|
|
|
style={{
|
|
style={{
|
|
|
- background: isActive(item.href)
|
|
|
|
|
- ? COMPONENT_COLORS.gradients.primary
|
|
|
|
|
|
|
+ backgroundColor: isActive(item.href)
|
|
|
|
|
+ ? COLOR_PALETTE.gray[100]
|
|
|
: 'transparent',
|
|
: 'transparent',
|
|
|
- color: isActive(item.href) ? 'white' : COLOR_PALETTE.gray[600],
|
|
|
|
|
- boxShadow: isActive(item.href) ? '0 4px 6px -1px rgba(0, 0, 0, 0.1)' : 'none'
|
|
|
|
|
- }}
|
|
|
|
|
- onMouseEnter={(e) => {
|
|
|
|
|
- if (!isActive(item.href)) {
|
|
|
|
|
- e.currentTarget.style.backgroundColor = COLOR_PALETTE.gray[100]
|
|
|
|
|
- e.currentTarget.style.color = COLOR_PALETTE.gray[900]
|
|
|
|
|
- }
|
|
|
|
|
- }}
|
|
|
|
|
- onMouseLeave={(e) => {
|
|
|
|
|
- if (!isActive(item.href)) {
|
|
|
|
|
- e.currentTarget.style.backgroundColor = 'transparent'
|
|
|
|
|
- e.currentTarget.style.color = COLOR_PALETTE.gray[600]
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ color: isActive(item.href) ? COLOR_PALETTE.gray[900] : COLOR_PALETTE.gray[600],
|
|
|
|
|
+ border: isActive(item.href) ? `1px solid ${COLOR_PALETTE.gray[200]}` : 'none'
|
|
|
}}
|
|
}}
|
|
|
onClick={onItemClick}
|
|
onClick={onItemClick}
|
|
|
|
|
+ title={isCollapsed ? item.title : undefined}
|
|
|
>
|
|
>
|
|
|
<item.icon
|
|
<item.icon
|
|
|
- className="w-4 h-4"
|
|
|
|
|
|
|
+ className="w-4 h-4 flex-shrink-0"
|
|
|
style={{
|
|
style={{
|
|
|
- color: isActive(item.href) ? 'white' : COLOR_PALETTE.gray[500]
|
|
|
|
|
|
|
+ color: isActive(item.href) ? COLOR_PALETTE.gray[900] : COLOR_PALETTE.gray[500]
|
|
|
} as React.CSSProperties}
|
|
} as React.CSSProperties}
|
|
|
/>
|
|
/>
|
|
|
- <span className="flex-1 font-medium">{item.title}</span>
|
|
|
|
|
- {item.badge && (
|
|
|
|
|
|
|
+ {!isCollapsed && (
|
|
|
|
|
+ <span className="flex-1 font-medium truncate">{item.title}</span>
|
|
|
|
|
+ )}
|
|
|
|
|
+ {!isCollapsed && item.badge && (
|
|
|
<span
|
|
<span
|
|
|
- className="inline-flex items-center px-2 py-1 rounded-full text-xs font-medium"
|
|
|
|
|
|
|
+ className="inline-flex items-center px-2 py-1 rounded-full text-xs font-medium border"
|
|
|
style={{
|
|
style={{
|
|
|
backgroundColor: isActive(item.href)
|
|
backgroundColor: isActive(item.href)
|
|
|
- ? 'rgba(255, 255, 255, 0.2)'
|
|
|
|
|
- : COLOR_PALETTE.primary[100],
|
|
|
|
|
|
|
+ ? COLOR_PALETTE.gray[200]
|
|
|
|
|
+ : COLOR_PALETTE.gray[100],
|
|
|
color: isActive(item.href)
|
|
color: isActive(item.href)
|
|
|
- ? 'white'
|
|
|
|
|
- : COLOR_PALETTE.primary[800]
|
|
|
|
|
|
|
+ ? COLOR_PALETTE.gray[700]
|
|
|
|
|
+ : COLOR_PALETTE.gray[600],
|
|
|
|
|
+ borderColor: COLOR_PALETTE.gray[200]
|
|
|
}}
|
|
}}
|
|
|
>
|
|
>
|
|
|
{item.badge}
|
|
{item.badge}
|