@@ -8,10 +8,14 @@ import {
8
8
Outlet ,
9
9
Scripts ,
10
10
ScrollRestoration ,
11
+ Link ,
12
+ Form ,
13
+ useLoaderData ,
11
14
} from "@remix-run/react" ;
12
15
13
16
import { getUser } from "~/session.server" ;
14
17
import stylesheet from "~/tailwind.css" ;
18
+ import React , { useState } from 'react' ; // Import React and useState
15
19
16
20
export const links : LinksFunction = ( ) => [
17
21
{ rel : "stylesheet" , href : stylesheet } ,
@@ -23,6 +27,10 @@ export const loader = async ({ request }: LoaderFunctionArgs) => {
23
27
} ;
24
28
25
29
export default function App ( ) {
30
+ const [ drawerOpen , setDrawerOpen ] = useState ( false ) ; // State for drawer
31
+ const data = useLoaderData < typeof loader > ( ) ;
32
+ const user = data . user ;
33
+
26
34
return (
27
35
< html lang = "en" className = "h-full" >
28
36
< head >
@@ -32,10 +40,48 @@ export default function App() {
32
40
< Links />
33
41
</ head >
34
42
< body className = "h-full" >
35
- < Outlet />
36
- < ScrollRestoration />
37
- < Scripts />
38
- < LiveReload />
43
+ < header className = "flex items-center justify-between bg-slate-800 p-4 text-white" >
44
+ < div className = "flex items-center" >
45
+ < button onClick = { ( ) => setDrawerOpen ( ! drawerOpen ) } className = "text-white hover:text-gray-300 focus:outline-none mr-4" >
46
+ < svg className = "h-6 w-6 fill-current" viewBox = "0 0 24 24" >
47
+ < path fillRule = "evenodd" d = "M4 5h16a1 1 0 0 1 0 2H4a1 1 0 1 1 0-2zm0 6h16a1 1 0 0 1 0 2H4a1 1 0 1 1 0-2zm0 6h16a1 1 0 0 1 0 2H4a1 1 0 1 1 0-2z" clipRule = "evenodd" />
48
+ </ svg >
49
+ </ button >
50
+ < h1 className = "text-3xl font-bold" >
51
+ < Link to = "/" > Home</ Link >
52
+ </ h1 >
53
+ </ div >
54
+ < div className = "flex items-center" >
55
+ < p className = "mr-4" > { user ?. email } </ p >
56
+ < Form action = "/logout" method = "post" >
57
+ < button
58
+ type = "submit"
59
+ className = "rounded bg-slate-600 px-4 py-2 text-blue-100 hover:bg-blue-500 active:bg-blue-600"
60
+ >
61
+ Logout
62
+ </ button >
63
+ </ Form >
64
+ </ div >
65
+ </ header >
66
+ < div className = { `fixed top-0 left-0 h-full w-64 bg-white shadow-md p-4 ${ drawerOpen ? 'translate-x-0' : '-translate-x-full' } transition-transform duration-300 z-50` } >
67
+ < button onClick = { ( ) => setDrawerOpen ( false ) } className = "absolute top-2 right-2 text-gray-500 hover:text-gray-800 focus:outline-none" >
68
+ < svg className = "h-6 w-6 fill-current" viewBox = "0 0 24 24" >
69
+ < path fill = "currentColor" d = "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" />
70
+ </ svg >
71
+ </ button >
72
+ < h2 className = "font-bold mb-4" > Navigation</ h2 >
73
+ < ul >
74
+ < li className = "mb-2" > < Link to = "/portal" className = "block py-2 px-4 hover:bg-gray-100" onClick = { ( ) => setDrawerOpen ( false ) } > Portal</ Link > </ li >
75
+ < li className = "mb-2" > < Link to = "/bible" className = "block py-2 px-4 hover:bg-gray-100" onClick = { ( ) => setDrawerOpen ( false ) } > Bible</ Link > </ li >
76
+ < li className = "mb-2" > < Link to = "/notes" className = "block py-2 px-4 hover:bg-gray-100" onClick = { ( ) => setDrawerOpen ( false ) } > Notes</ Link > </ li >
77
+ </ ul >
78
+ </ div >
79
+ < div className = "ml-0 transition-margin duration-300" style = { { marginLeft : drawerOpen ? '64px' : '0' } } >
80
+ < Outlet />
81
+ < ScrollRestoration />
82
+ < Scripts />
83
+ < LiveReload />
84
+ </ div >
39
85
</ body >
40
86
</ html >
41
87
) ;
0 commit comments