File size: 1,889 Bytes
5c022de
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15106a9
5c022de
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
'use client';

/** Chat screen layout: RoomsPanel (Hubs & People) beside the conversation card. */
import { ReactNode, useState } from 'react';
import { PanelLeft, X } from 'lucide-react';
import RoomsPanel from '../Sidebar';

export default function ChatShell({ children, landing = false }: { children: ReactNode; landing?: boolean }) {
  const [drawer, setDrawer] = useState(false);

  return (
    <div className="flex h-full gap-3 p-2.5 md:p-3.5">
      {/* desktop rooms */}
      <div className="hidden md:block">
        <RoomsPanel />
      </div>

      {/* mobile: on the landing page show rooms inline; elsewhere a drawer */}
      {landing ? (
        <div className="block w-full md:hidden">
          <RoomsPanel />
        </div>
      ) : (
        <>
          <button
            onClick={() => setDrawer(true)}
            className="grad fixed bottom-[84px] left-4 z-30 flex h-11 w-11 items-center justify-center rounded-full text-white shadow-pop md:hidden"
            aria-label="Open hubs and people"
          >
            <PanelLeft className="h-5 w-5" />
          </button>
          {drawer && (
            <div className="fixed inset-0 z-40 md:hidden">
              <div className="absolute inset-0 bg-black/40" onClick={() => setDrawer(false)} />
              <div className="absolute inset-y-2 left-2 flex" onClick={() => setDrawer(false)}>
                <RoomsPanel onNavigate={() => setDrawer(false)} />
              </div>
              <button onClick={() => setDrawer(false)} className="absolute right-4 top-4 rounded-full bg-white p-2 shadow-pop" aria-label="Close">
                <X className="h-4 w-4" />
              </button>
            </div>
          )}
        </>
      )}

      <div className={`panel min-h-0 min-w-0 flex-1 overflow-hidden ${landing ? 'hidden md:block' : ''}`}>
        {children}
      </div>
    </div>
  );
}