@@ -4,6 +4,7 @@ import Link from 'next/link';
4
4
import { IconButton } from '@/components/IconButton' ;
5
5
import { Button , Icon , IconProps , Logo , Tooltip } from '@/components/Shared' ;
6
6
import { env } from '@/env.mjs' ;
7
+ import { useIsDesktop } from '@/hooks/breakpoint' ;
7
8
import { useSettingsStore } from '@/stores' ;
8
9
import { cn } from '@/utils' ;
9
10
@@ -18,6 +19,9 @@ export const AgentsSidePanel: React.FC<React.PropsWithChildren> = ({ children })
18
19
setIsAgentsSidePanelOpen,
19
20
} = useSettingsStore ( ) ;
20
21
22
+ const isDesktop = useIsDesktop ( ) ;
23
+ const isMobile = ! isDesktop ;
24
+
21
25
const navigationItems : {
22
26
label : string ;
23
27
icon : IconProps [ 'name' ] ;
@@ -29,78 +33,93 @@ export const AgentsSidePanel: React.FC<React.PropsWithChildren> = ({ children })
29
33
] ;
30
34
31
35
return (
32
- < div
33
- className = { cn (
34
- 'box-content px-4 py-6' ,
35
- 'flex flex-grow flex-col gap-y-8 rounded-lg border' ,
36
- 'border-marble-400 bg-marble-100' ,
37
- 'transition-[min-width,max-width]' ,
38
- {
39
- 'min-w-12 max-w-12' : ! isAgentsSidePanelOpen ,
40
- 'min-w-64 max-w-64' : isAgentsSidePanelOpen ,
41
- }
42
- ) }
36
+ < Transition
37
+ show = { isAgentsSidePanelOpen || isDesktop }
38
+ as = "div"
39
+ className = { cn ( 'absolute bottom-0 left-0 top-0 z-30 lg:static' , {
40
+ 'right-1/4' : isAgentsSidePanelOpen ,
41
+ } ) }
42
+ enter = "transition-all transform ease-in-out duration-500"
43
+ enterFrom = "-translate-x-full"
44
+ enterTo = "translate-x-0"
45
+ leave = "transition-all transform ease-in-out duration-500"
46
+ leaveFrom = "translate-x-0 opacity-100"
47
+ leaveTo = "-translate-x-full opacity-0"
43
48
>
44
49
< div
45
- className = { cn ( 'flex flex-shrink-0 items-center' , {
46
- 'justify-between gap-x-3' : isAgentsSidePanelOpen ,
47
- 'justify-center' : ! isAgentsSidePanelOpen ,
48
- } ) }
50
+ className = { cn (
51
+ 'box-content h-full px-4 py-6' ,
52
+ 'flex flex-grow flex-col gap-y-8 rounded-lg border' ,
53
+ 'border-marble-400 bg-marble-100' ,
54
+ 'transition-[min-width,max-width]' ,
55
+ {
56
+ 'min-w-12 max-w-12' : ! isAgentsSidePanelOpen ,
57
+ 'min-w-64 max-w-64' : isAgentsSidePanelOpen ,
58
+ }
59
+ ) }
49
60
>
50
- < Transition
51
- show = { isAgentsSidePanelOpen }
52
- as = "div"
53
- enter = "transition-all transform ease-in-out duration-200"
54
- enterFrom = "-translate-x-full"
55
- enterTo = "translate-x-0"
61
+ < div
62
+ className = { cn ( 'flex flex-shrink-0 items-center' , {
63
+ 'justify-between gap-x-3' : isAgentsSidePanelOpen || isMobile ,
64
+ 'justify-center' : ! isAgentsSidePanelOpen && isDesktop ,
65
+ } ) }
56
66
>
57
- < Link href = "/" shallow >
58
- < div className = "mr-3 flex items-baseline" >
59
- < Logo hasCustomLogo = { env . NEXT_PUBLIC_HAS_CUSTOM_LOGO === 'true' } />
60
- </ div >
61
- </ Link >
62
- </ Transition >
67
+ < Transition
68
+ show = { isAgentsSidePanelOpen || isMobile }
69
+ appear
70
+ as = "div"
71
+ enter = "transition-all transform ease-in-out duration-200"
72
+ enterFrom = "-translate-x-full"
73
+ enterTo = "translate-x-0"
74
+ >
75
+ < Link href = "/" shallow >
76
+ < div className = "mr-3 flex items-baseline" >
77
+ < Logo hasCustomLogo = { env . NEXT_PUBLIC_HAS_CUSTOM_LOGO === 'true' } />
78
+ </ div >
79
+ </ Link >
80
+ </ Transition >
63
81
64
- < IconButton
65
- iconName = "close-drawer"
66
- onClick = { ( ) => setIsAgentsSidePanelOpen ( ! isAgentsSidePanelOpen ) }
67
- className = { cn ( 'transition delay-100 duration-200 ease-in-out' , {
68
- 'rotate-180 transform text-secondary-700' : isAgentsSidePanelOpen ,
69
- } ) }
70
- />
71
- </ div >
72
- < div className = "flex-grow overflow-y-auto" > { children } </ div >
73
- { isAgentsSidePanelOpen ? (
74
- < div className = "flex flex-shrink-0 flex-col gap-y-4" >
75
- { navigationItems . map ( ( { label, icon, href, onClick } ) => (
76
- < Button
77
- key = { label }
78
- kind = "secondary"
79
- className = "truncate text-secondary-900"
80
- startIcon = { < Icon name = { icon } kind = "outline" className = "text-secondary-900" /> }
81
- label = { label }
82
- href = { href }
83
- shallow
84
- onClick = { onClick }
85
- />
86
- ) ) }
82
+ < IconButton
83
+ iconName = "close-drawer"
84
+ onClick = { ( ) => setIsAgentsSidePanelOpen ( ! isAgentsSidePanelOpen ) }
85
+ className = { cn ( 'transition delay-100 duration-200 ease-in-out' , {
86
+ 'rotate-180 transform text-secondary-700' : isAgentsSidePanelOpen || isMobile ,
87
+ } ) }
88
+ />
87
89
</ div >
88
- ) : (
89
- < div className = "flex flex-shrink-0 flex-col gap-y-4" >
90
- { navigationItems . map ( ( { label, icon, href, onClick } ) => (
91
- < Tooltip key = { label } label = { label } hover placement = "right" >
92
- < IconButton
93
- iconName = { icon }
94
- iconClassName = "text-secondary-900"
90
+ < div className = "flex-grow overflow-y-auto" > { children } </ div >
91
+ { isAgentsSidePanelOpen || isMobile ? (
92
+ < div className = "flex flex-shrink-0 flex-col gap-y-4" >
93
+ { navigationItems . map ( ( { label, icon, href, onClick } ) => (
94
+ < Button
95
+ key = { label }
96
+ kind = "secondary"
97
+ className = "truncate text-secondary-900"
98
+ startIcon = { < Icon name = { icon } kind = "outline" className = "text-secondary-900" /> }
99
+ label = { label }
100
+ href = { href }
95
101
shallow
96
102
onClick = { onClick }
97
- href = { href }
98
- className = "w-full text-secondary-900"
99
103
/>
100
- </ Tooltip >
101
- ) ) }
102
- </ div >
103
- ) }
104
- </ div >
104
+ ) ) }
105
+ </ div >
106
+ ) : (
107
+ < div className = "flex flex-shrink-0 flex-col gap-y-4" >
108
+ { navigationItems . map ( ( { label, icon, href, onClick } ) => (
109
+ < Tooltip key = { label } label = { label } hover placement = "right" >
110
+ < IconButton
111
+ iconName = { icon }
112
+ iconClassName = "text-secondary-900"
113
+ shallow
114
+ onClick = { onClick }
115
+ href = { href }
116
+ className = "w-full text-secondary-900"
117
+ />
118
+ </ Tooltip >
119
+ ) ) }
120
+ </ div >
121
+ ) }
122
+ </ div >
123
+ </ Transition >
105
124
) ;
106
125
} ;
0 commit comments