@orsetra/shared-ui 1.0.8 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
import { useState, useEffect } from "react"
|
|
4
4
|
import { usePathname } from "next/navigation"
|
|
5
|
-
import { MainSidebar, Sidebar, SidebarProvider, useSidebar } from "./index"
|
|
6
|
-
import { UserMenu } from "../ui"
|
|
5
|
+
import { MainSidebar, Sidebar, SidebarProvider, useSidebar, type SidebarMode } from "./index"
|
|
6
|
+
import { UserMenu, Button } from "../ui"
|
|
7
7
|
import { getMenuFromPath } from "../../lib/menu-utils"
|
|
8
|
+
import { Menu } from "lucide-react"
|
|
8
9
|
|
|
9
10
|
export interface SidebarMenus {
|
|
10
11
|
[key: string]: any[]
|
|
@@ -15,13 +16,16 @@ interface LayoutContainerProps {
|
|
|
15
16
|
sidebarMenus: SidebarMenus
|
|
16
17
|
user?: { profile?: { email?: string; preferred_username?: string } } | null
|
|
17
18
|
onSignOut?: () => void
|
|
19
|
+
mode?: SidebarMode
|
|
18
20
|
}
|
|
19
21
|
|
|
20
|
-
function LayoutContent({ children, sidebarMenus, user, onSignOut }: LayoutContainerProps) {
|
|
22
|
+
function LayoutContent({ children, sidebarMenus, user, onSignOut, mode = 'expanded' }: LayoutContainerProps) {
|
|
21
23
|
const pathname = usePathname()
|
|
22
24
|
const { setOpen } = useSidebar()
|
|
23
25
|
const [isMainSidebarOpen, setIsMainSidebarOpen] = useState(false)
|
|
24
26
|
const [currentMenu, setCurrentMenu] = useState<string>("overview")
|
|
27
|
+
const isMinimized = mode === 'minimized'
|
|
28
|
+
const isHidden = mode === 'hidden'
|
|
25
29
|
|
|
26
30
|
useEffect(() => {
|
|
27
31
|
const contextualMenu = getMenuFromPath(pathname)
|
|
@@ -45,22 +49,55 @@ function LayoutContent({ children, sidebarMenus, user, onSignOut }: LayoutContai
|
|
|
45
49
|
|
|
46
50
|
return (
|
|
47
51
|
<div className="flex h-screen w-full bg-white">
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
+
{/* Sidebar secondaire - caché en mode minimized et hidden */}
|
|
53
|
+
{!isMinimized && !isHidden && (
|
|
54
|
+
<Sidebar
|
|
55
|
+
currentMenu={currentMenu}
|
|
56
|
+
onMainMenuToggle={handleMainSidebarToggle}
|
|
57
|
+
/>
|
|
58
|
+
)}
|
|
52
59
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
+
{/* MainSidebar - en mode hidden, il s'ouvre comme un overlay */}
|
|
61
|
+
{!isHidden && (
|
|
62
|
+
<MainSidebar
|
|
63
|
+
isOpen={isMainSidebarOpen}
|
|
64
|
+
onToggle={handleMainSidebarToggle}
|
|
65
|
+
onMenuSelect={handleMenuSelect}
|
|
66
|
+
currentMenu={currentMenu}
|
|
67
|
+
onSecondarySidebarOpen={handleSecondarySidebarOpen}
|
|
68
|
+
mode={mode}
|
|
69
|
+
/>
|
|
70
|
+
)}
|
|
71
|
+
|
|
72
|
+
{/* MainSidebar overlay en mode hidden */}
|
|
73
|
+
{isHidden && (
|
|
74
|
+
<MainSidebar
|
|
75
|
+
isOpen={isMainSidebarOpen}
|
|
76
|
+
onToggle={handleMainSidebarToggle}
|
|
77
|
+
onMenuSelect={handleMenuSelect}
|
|
78
|
+
currentMenu={currentMenu}
|
|
79
|
+
onSecondarySidebarOpen={handleSecondarySidebarOpen}
|
|
80
|
+
mode="expanded"
|
|
81
|
+
/>
|
|
82
|
+
)}
|
|
60
83
|
|
|
61
84
|
<div className="flex-1 flex flex-col">
|
|
62
85
|
<header className="h-14 bg-white border-b border-ui-border flex-shrink-0">
|
|
63
|
-
<div className="h-full px-6 flex items-center justify-
|
|
86
|
+
<div className="h-full px-6 flex items-center justify-between">
|
|
87
|
+
{/* Bouton menu - affiché en mode hidden */}
|
|
88
|
+
{isHidden ? (
|
|
89
|
+
<Button
|
|
90
|
+
variant="ghost"
|
|
91
|
+
size="sm"
|
|
92
|
+
onClick={handleMainSidebarToggle}
|
|
93
|
+
className="h-8 w-8 p-0 hover:bg-ui-background text-text-secondary"
|
|
94
|
+
title="Ouvrir le menu principal"
|
|
95
|
+
>
|
|
96
|
+
<Menu className="h-5 w-5" />
|
|
97
|
+
</Button>
|
|
98
|
+
) : (
|
|
99
|
+
<div />
|
|
100
|
+
)}
|
|
64
101
|
<UserMenu
|
|
65
102
|
username={user?.profile?.email || user?.profile?.preferred_username}
|
|
66
103
|
onSignOut={onSignOut || (() => {})}
|
|
@@ -10,7 +10,7 @@ import { menuItems, menuSubItems } from "./data"
|
|
|
10
10
|
import { X, Menu } from "lucide-react"
|
|
11
11
|
import Link from "next/link"
|
|
12
12
|
|
|
13
|
-
export type SidebarMode = 'expanded' | 'minimized'
|
|
13
|
+
export type SidebarMode = 'expanded' | 'minimized' | 'hidden'
|
|
14
14
|
|
|
15
15
|
interface MainSidebarProps {
|
|
16
16
|
isOpen: boolean
|