1+ import { RightSidebarTrigger } from "@features/right-sidebar/components/RightSidebarTrigger" ;
2+ import { useRightSidebarStore } from "@features/right-sidebar/stores/rightSidebarStore" ;
13import { SidebarTrigger } from "@features/sidebar/components/SidebarTrigger" ;
24import { useSidebarStore } from "@features/sidebar/stores/sidebarStore" ;
5+ import { ChangesTabBadge } from "@features/task-detail/components/ChangesTabBadge" ;
36import { Box , Flex } from "@radix-ui/themes" ;
47import { useHeaderStore } from "@stores/headerStore" ;
5- import { useEffect } from "react " ;
8+ import { useNavigationStore } from "@stores/navigationStore " ;
69
710const HEADER_HEIGHT = 40 ;
811const COLLAPSED_WIDTH = 110 ;
9- const MIN_WIDTH = 140 ;
1012
1113export function HeaderRow ( ) {
1214 const content = useHeaderStore ( ( state ) => state . content ) ;
15+ const view = useNavigationStore ( ( state ) => state . view ) ;
16+
1317 const sidebarOpen = useSidebarStore ( ( state ) => state . open ) ;
1418 const sidebarWidth = useSidebarStore ( ( state ) => state . width ) ;
1519 const isResizing = useSidebarStore ( ( state ) => state . isResizing ) ;
16- const setWidth = useSidebarStore ( ( state ) => state . setWidth ) ;
1720 const setIsResizing = useSidebarStore ( ( state ) => state . setIsResizing ) ;
1821
19- const handleMouseDown = ( e : React . MouseEvent ) => {
22+ const rightSidebarOpen = useRightSidebarStore ( ( state ) => state . open ) ;
23+ const rightSidebarWidth = useRightSidebarStore ( ( state ) => state . width ) ;
24+ const rightSidebarIsResizing = useRightSidebarStore (
25+ ( state ) => state . isResizing ,
26+ ) ;
27+ const setRightSidebarIsResizing = useRightSidebarStore (
28+ ( state ) => state . setIsResizing ,
29+ ) ;
30+
31+ const showRightSidebarSection = view . type === "task-detail" ;
32+
33+ const handleLeftSidebarMouseDown = ( e : React . MouseEvent ) => {
2034 e . preventDefault ( ) ;
2135 setIsResizing ( true ) ;
2236 document . body . style . cursor = "col-resize" ;
2337 document . body . style . userSelect = "none" ;
2438 } ;
2539
26- useEffect ( ( ) => {
27- const handleMouseMove = ( e : MouseEvent ) => {
28- if ( ! isResizing ) return ;
29-
30- const maxWidth = window . innerWidth * 0.5 ;
31- const newWidth = Math . max ( MIN_WIDTH , Math . min ( maxWidth , e . clientX ) ) ;
32- setWidth ( newWidth ) ;
33- } ;
34-
35- const handleMouseUp = ( ) => {
36- if ( isResizing ) {
37- setIsResizing ( false ) ;
38- document . body . style . cursor = "" ;
39- document . body . style . userSelect = "" ;
40- }
41- } ;
42-
43- document . addEventListener ( "mousemove" , handleMouseMove ) ;
44- document . addEventListener ( "mouseup" , handleMouseUp ) ;
45-
46- return ( ) => {
47- document . removeEventListener ( "mousemove" , handleMouseMove ) ;
48- document . removeEventListener ( "mouseup" , handleMouseUp ) ;
49- } ;
50- } , [ setWidth , isResizing , setIsResizing ] ) ;
40+ const handleRightSidebarMouseDown = ( e : React . MouseEvent ) => {
41+ e . preventDefault ( ) ;
42+ setRightSidebarIsResizing ( true ) ;
43+ document . body . style . cursor = "col-resize" ;
44+ document . body . style . userSelect = "none" ;
45+ } ;
5146
5247 return (
5348 < Flex
@@ -63,6 +58,7 @@ export function HeaderRow() {
6358 align = "center"
6459 justify = "end"
6560 px = "2"
61+ pr = "3"
6662 style = { {
6763 width : sidebarOpen ? `${ sidebarWidth } px` : `${ COLLAPSED_WIDTH } px` ,
6864 minWidth : `${ COLLAPSED_WIDTH } px` ,
@@ -75,7 +71,7 @@ export function HeaderRow() {
7571 < SidebarTrigger />
7672 { sidebarOpen && (
7773 < Box
78- onMouseDown = { handleMouseDown }
74+ onMouseDown = { handleLeftSidebarMouseDown }
7975 className = "no-drag"
8076 style = { {
8177 position : "absolute" ,
@@ -102,6 +98,48 @@ export function HeaderRow() {
10298 { content }
10399 </ Flex >
104100 ) }
101+
102+ { showRightSidebarSection && view . type === "task-detail" && view . data && (
103+ < Flex
104+ align = "center"
105+ justify = "between"
106+ px = "2"
107+ pl = "3"
108+ style = { {
109+ width : rightSidebarOpen
110+ ? `${ rightSidebarWidth } px`
111+ : `${ COLLAPSED_WIDTH } px` ,
112+ minWidth : `${ COLLAPSED_WIDTH } px` ,
113+ height : "100%" ,
114+ borderLeft : "1px solid var(--gray-6)" ,
115+ transition : rightSidebarIsResizing
116+ ? "none"
117+ : "width 0.2s ease-in-out" ,
118+ position : "relative" ,
119+ } }
120+ >
121+ < RightSidebarTrigger />
122+ { rightSidebarOpen && (
123+ < ChangesTabBadge taskId = { view . data . id } task = { view . data } />
124+ ) }
125+ { rightSidebarOpen && (
126+ < Box
127+ onMouseDown = { handleRightSidebarMouseDown }
128+ className = "no-drag"
129+ style = { {
130+ position : "absolute" ,
131+ left : 0 ,
132+ top : 0 ,
133+ bottom : 0 ,
134+ width : "4px" ,
135+ cursor : "col-resize" ,
136+ backgroundColor : "transparent" ,
137+ zIndex : 100 ,
138+ } }
139+ />
140+ ) }
141+ </ Flex >
142+ ) }
105143 </ Flex >
106144 ) ;
107145}
0 commit comments