@orsetra/shared-ui 1.1.7 → 1.1.8
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.
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { ReactNode, useState } from "react"
|
|
4
4
|
import { X, ChevronLeft } from "lucide-react"
|
|
5
5
|
import { Button } from "../ui/button"
|
|
6
|
+
import { cn } from "../../lib/utils"
|
|
6
7
|
|
|
7
8
|
interface PageWithSidePanelProps {
|
|
8
9
|
children: ReactNode
|
|
@@ -15,6 +16,9 @@ interface PageWithSidePanelProps {
|
|
|
15
16
|
showBorder?: boolean
|
|
16
17
|
onClose?: () => void
|
|
17
18
|
onOpen?: () => void
|
|
19
|
+
contentHeaderClassName?: string
|
|
20
|
+
sidePanelClassName?: string
|
|
21
|
+
sidePanelHeaderClassName?: string
|
|
18
22
|
}
|
|
19
23
|
|
|
20
24
|
const PANEL_WIDTHS = {
|
|
@@ -34,6 +38,9 @@ export function PageWithSidePanel({
|
|
|
34
38
|
showBorder = true,
|
|
35
39
|
onClose,
|
|
36
40
|
onOpen,
|
|
41
|
+
contentHeaderClassName,
|
|
42
|
+
sidePanelClassName,
|
|
43
|
+
sidePanelHeaderClassName,
|
|
37
44
|
}: PageWithSidePanelProps) {
|
|
38
45
|
const [isOpen, setIsOpen] = useState(defaultOpen)
|
|
39
46
|
const panelWidthClass = PANEL_WIDTHS[sidePanelWidth]
|
|
@@ -50,13 +57,15 @@ export function PageWithSidePanel({
|
|
|
50
57
|
|
|
51
58
|
return (
|
|
52
59
|
<div className="flex items-start">
|
|
53
|
-
|
|
54
60
|
{/* Main content column — grows to fill space left by the panel */}
|
|
55
61
|
<div className="flex-1 min-w-0 flex flex-col">
|
|
56
62
|
|
|
57
63
|
{/* Content header — sticks at the top of the scroll container */}
|
|
58
64
|
{contentHeader && (
|
|
59
|
-
<div className=
|
|
65
|
+
<div className={cn(
|
|
66
|
+
"flex sticky top-0 z-10 bg-white h-14 flex-shrink-0 items-center justify-between px-4 border-b border-ibm-gray-20",
|
|
67
|
+
contentHeaderClassName
|
|
68
|
+
)}>
|
|
60
69
|
{contentHeader}
|
|
61
70
|
</div>
|
|
62
71
|
)}
|
|
@@ -73,16 +82,22 @@ export function PageWithSidePanel({
|
|
|
73
82
|
{sidePanel && (
|
|
74
83
|
<>
|
|
75
84
|
<div
|
|
76
|
-
className={
|
|
77
|
-
|
|
78
|
-
|
|
85
|
+
className={cn(
|
|
86
|
+
"hidden lg:flex flex-col flex-shrink-0 sticky top-0 self-start h-[calc(100vh-3.5rem)] overflow-hidden transition-[width] duration-300 ease-in-out",
|
|
87
|
+
isOpen && showBorder && "border-l border-ibm-gray-40",
|
|
88
|
+
isOpen ? panelWidthClass : "w-0",
|
|
89
|
+
sidePanelClassName
|
|
90
|
+
)}
|
|
79
91
|
>
|
|
80
92
|
{/* Inner wrapper at fixed width to prevent content reflow during animation */}
|
|
81
93
|
<div className={`flex flex-col h-full bg-white ${panelWidthClass}`}>
|
|
82
94
|
|
|
83
95
|
{/* Panel header */}
|
|
84
96
|
{(sidePanelHeader || closable) && (
|
|
85
|
-
<div className=
|
|
97
|
+
<div className={cn(
|
|
98
|
+
"flex items-center justify-between h-14 flex-shrink-0 px-4 border-b border-ibm-gray-20",
|
|
99
|
+
sidePanelHeaderClassName
|
|
100
|
+
)}>
|
|
86
101
|
<div className="flex-1 min-w-0">
|
|
87
102
|
{sidePanelHeader}
|
|
88
103
|
</div>
|