@orsetra/shared-ui 1.0.66 → 1.1.0

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.
@@ -6,6 +6,7 @@ import { Button } from "../ui/button"
6
6
 
7
7
  interface PageWithSidePanelProps {
8
8
  children: ReactNode
9
+ contentHeader?: ReactNode
9
10
  sidePanel?: ReactNode
10
11
  sidePanelHeader?: ReactNode
11
12
  sidePanelWidth?: "sm" | "md" | "lg"
@@ -17,19 +18,14 @@ interface PageWithSidePanelProps {
17
18
  }
18
19
 
19
20
  const PANEL_WIDTHS = {
20
- sm: "w-64", // 256px
21
- md: "w-72", // 288px
22
- lg: "w-80", // 320px
21
+ sm: "w-64",
22
+ md: "w-72",
23
+ lg: "w-80",
23
24
  }
24
25
 
25
- const PANEL_PADDING = {
26
- sm: "lg:pr-64",
27
- md: "lg:pr-72",
28
- lg: "lg:pr-80",
29
- }
30
-
31
- export function PageWithSidePanel({
32
- children,
26
+ export function PageWithSidePanel({
27
+ children,
28
+ contentHeader,
33
29
  sidePanel,
34
30
  sidePanelHeader,
35
31
  sidePanelWidth = "md",
@@ -37,11 +33,10 @@ export function PageWithSidePanel({
37
33
  defaultOpen = true,
38
34
  showBorder = true,
39
35
  onClose,
40
- onOpen
36
+ onOpen,
41
37
  }: PageWithSidePanelProps) {
42
38
  const [isOpen, setIsOpen] = useState(defaultOpen)
43
39
  const panelWidthClass = PANEL_WIDTHS[sidePanelWidth]
44
- const panelPaddingClass = PANEL_PADDING[sidePanelWidth]
45
40
 
46
41
  const handleClose = () => {
47
42
  setIsOpen(false)
@@ -54,53 +49,71 @@ export function PageWithSidePanel({
54
49
  }
55
50
 
56
51
  return (
57
- <div className="min-h-screen bg-white overflow-hidden">
58
- {/* Main content */}
59
- <div className={`w-full px-6 py-8 transition-all duration-300 ${sidePanel && isOpen ? panelPaddingClass : ''}`}>
60
- {children}
52
+ <div className="flex items-start">
53
+
54
+ {/* Main content column grows to fill space left by the panel */}
55
+ <div className="flex-1 min-w-0 flex flex-col">
56
+
57
+ {/* Content header — sticks at the top of the scroll container */}
58
+ {contentHeader && (
59
+ <div className="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">
60
+ {contentHeader}
61
+ </div>
62
+ )}
63
+
64
+ {/* Content body */}
65
+ <div className="px-6 py-8">
66
+ {children}
67
+ </div>
61
68
  </div>
62
69
 
63
- {/* Side panel - fixed */}
70
+ {/* Side panel sticky in the flex row, stays anchored while content scrolls.
71
+ Being in the flex flow (not fixed) means it naturally accounts for scrollbars,
72
+ preventing the gap between the content header border and the panel border. */}
64
73
  {sidePanel && (
65
74
  <>
66
- <div
67
- className={`hidden lg:block ${panelWidthClass} flex-shrink-0 fixed top-14 bottom-0 right-0 bg-white flex flex-col ${showBorder ? 'border-l border-ibm-gray-40' : ''} transition-transform duration-300 ease-in-out ${
68
- isOpen ? 'translate-x-0' : 'translate-x-full'
69
- }`}
75
+ <div
76
+ className={`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 ${
77
+ isOpen && showBorder ? "border-l border-ibm-gray-40" : ""
78
+ } ${isOpen ? panelWidthClass : "w-0"}`}
70
79
  >
71
- {/* Header */}
72
- {(sidePanelHeader || closable) && (
73
- <div className="flex items-center justify-between p-4 border-b border-ibm-gray-20 flex-shrink-0">
74
- <div className="flex-1">
75
- {sidePanelHeader}
80
+ {/* Inner wrapper at fixed width to prevent content reflow during animation */}
81
+ <div className={`flex flex-col h-full bg-white ${panelWidthClass}`}>
82
+
83
+ {/* Panel header */}
84
+ {(sidePanelHeader || closable) && (
85
+ <div className="flex items-center justify-between h-14 flex-shrink-0 px-4 border-b border-ibm-gray-20">
86
+ <div className="flex-1 min-w-0">
87
+ {sidePanelHeader}
88
+ </div>
89
+ {closable && (
90
+ <Button
91
+ variant="ghost"
92
+ size="xs"
93
+ onClick={handleClose}
94
+ className="h-8 w-8 p-0 ml-2 flex-shrink-0"
95
+ >
96
+ <X className="h-4 w-4" />
97
+ </Button>
98
+ )}
76
99
  </div>
77
- {closable && (
78
- <Button
79
- variant="ghost"
80
- size="xs"
81
- onClick={handleClose}
82
- className="h-8 w-8 p-0 ml-2"
83
- >
84
- <X className="h-4 w-4" />
85
- </Button>
86
- )}
87
- </div>
88
- )}
100
+ )}
89
101
 
90
- {/* Content */}
91
- <div className="flex-1 overflow-y-auto">
92
- {sidePanel}
102
+ {/* Panel scrollable content */}
103
+ <div className="flex-1 overflow-y-auto">
104
+ {sidePanel}
105
+ </div>
93
106
  </div>
94
107
  </div>
95
108
 
96
- {/* Toggle button - shown when panel is closed */}
109
+ {/* Toggle button fixed keeps it vertically centered in the viewport */}
97
110
  {closable && !isOpen && (
98
111
  <button
99
112
  onClick={handleOpen}
100
- className="hidden lg:flex fixed top-1/2 right-0 -translate-y-1/2 items-center justify-center w-8 h-16 bg-white border border-ibm-gray-40 border-r-0 rounded-l-lg shadow-md hover:bg-ibm-gray-10 transition-colors duration-200"
113
+ className="hidden lg:flex fixed top-1/2 right-0 -translate-y-1/2 items-center justify-center w-6 h-16 bg-white border border-ibm-gray-40 border-r-0 rounded-l-lg shadow-md hover:bg-ibm-gray-10 transition-colors duration-200"
101
114
  aria-label="Open side panel"
102
115
  >
103
- <ChevronLeft className="h-5 w-5 text-ibm-gray-70" />
116
+ <ChevronLeft className="h-4 w-4 text-ibm-gray-70" />
104
117
  </button>
105
118
  )}
106
119
  </>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orsetra/shared-ui",
3
- "version": "1.0.66",
3
+ "version": "1.1.0",
4
4
  "description": "Shared UI components for Orsetra platform",
5
5
  "main": "./index.ts",
6
6
  "types": "./index.ts",
@@ -93,4 +93,4 @@
93
93
  "next": "^16.0.7",
94
94
  "typescript": "^5"
95
95
  }
96
- }
96
+ }