@@ -21,44 +21,29 @@ export const loader = async ({ request }: LoaderFunctionArgs) => {
21
21
export default function BiblePage ( ) {
22
22
const { bibleData } = useLoaderData < typeof loader > ( ) ;
23
23
const user = useUser ( ) ;
24
- const [ isSidebarOpen , setIsSidebarOpen ] = useState ( false ) ;
25
- const [ selectedBook , setSelectedBook ] = useState < string > ( Object . keys ( bibleData . books ) [ 0 ] || "" ) ; // Default to first book, ensure string
26
- const [ selectedChapter , setSelectedChapter ] = useState < string > ( "1" ) ; // Default to chapter 1, ensure string
24
+ const [ selectedBook , setSelectedBook ] = useState < string > ( Object . keys ( bibleData . books ) [ 0 ] || "" ) ; // Default to first book
25
+ const [ selectedChapter , setSelectedChapter ] = useState < string > ( "1" ) ; // Default to chapter 1
27
26
28
27
const books = Object . keys ( bibleData . books ) as string [ ] ;
29
28
const chapters = Array . from ( { length : bibleData . books [ selectedBook ] || 0 } , ( _ , i ) => ( i + 1 ) . toString ( ) ) ;
30
29
31
30
const bibleText : string = bibleData . kjv [ selectedBook ] ?. [ selectedChapter ] || "Select a book and chapter to view text." ;
32
31
32
+ // Split the text into paragraphs (assuming paragraphs are separated by double newlines `\n\n`)
33
+ const paragraphs = bibleText . split ( '\n\n' ) . map ( paragraph => paragraph . trim ( ) ) . filter ( paragraph => paragraph . length > 0 ) ;
34
+
33
35
return (
34
36
< div className = "flex h-full min-h-screen flex-col" >
35
37
{ /* Main container with padding-top to account for header */ }
36
- < main className = "flex-1 flex flex-col md:flex-row-reverse h-full bg-white" style = { { paddingTop : '64px' } } >
37
- { /* Hamburger menu button for mobile only, positioned below header on the right, hides when sidebar is open */ }
38
- { ! isSidebarOpen && (
39
- < button
40
- onClick = { ( ) => setIsSidebarOpen ( true ) }
41
- className = "md:hidden fixed top-16 right-4 z-50 p-4 text-blue-500 focus:outline-none"
42
- >
43
- < svg className = "h-6 w-6" fill = "none" stroke = "currentColor" viewBox = "0 0 24 24" >
44
- < path strokeLinecap = "round" strokeLinejoin = "round" strokeWidth = "2" d = "M4 6h16M4 12h16m-7 6h7" />
45
- </ svg >
46
- </ button >
47
- ) }
48
-
49
- { /* Sidebar for Bible sections - hidden on mobile by default, fixed width on desktop, now on the right */ }
50
- < div className = { `
51
- fixed inset-y-0 right-0 transform ${ isSidebarOpen ? 'translate-x-0' : 'translate-x-full' }
52
- md:relative md:translate-x-0 md:flex md:w-80 md:border-l md:bg-gray-50 md:shadow
53
- transition-transform duration-300 ease-in-out z-40
54
- h-full
55
- ` } style = { { top : '64px' , boxShadow : '-2px 0 5px rgba(0, 0, 0, 0.1)' } } >
56
- < div className = "h-full w-full overflow-y-auto p-4" >
38
+ < main className = "flex-1 flex flex-col h-full bg-white" style = { { paddingTop : '64px' } } >
39
+ { /* Picker container fixed below header, ensuring it doesn't overlap nav drawer */ }
40
+ < div className = "fixed top-16 left-0 right-0 bg-white shadow-md z-30 p-4 border-b" style = { { zIndex : 30 } } >
41
+ < div className = "flex flex-col md:flex-row gap-4 items-center justify-center" >
57
42
{ /* Book Selector */ }
58
43
< select
59
44
value = { selectedBook }
60
45
onChange = { ( e ) => setSelectedBook ( e . target . value ) }
61
- className = "w-full p-2 mb-4 border rounded"
46
+ className = "w-full md:w-auto p-2 border rounded"
62
47
>
63
48
{ books . map ( ( book ) => (
64
49
< option key = { book } value = { book } > { book } </ option >
@@ -69,42 +54,26 @@ export default function BiblePage() {
69
54
< select
70
55
value = { selectedChapter }
71
56
onChange = { ( e ) => setSelectedChapter ( e . target . value ) }
72
- className = "w-full p-2 mb-4 border rounded"
57
+ className = "w-full md:w-auto p-2 border rounded"
73
58
>
74
59
{ chapters . map ( ( chapter ) => (
75
60
< option key = { chapter } value = { chapter } > Chapter { chapter } </ option >
76
61
) ) }
77
62
</ select >
78
63
</ div >
79
-
80
- { /* Close button for mobile sidebar - now on the right when sidebar is open */ }
81
- { isSidebarOpen && (
82
- < button
83
- onClick = { ( ) => setIsSidebarOpen ( false ) }
84
- className = "md:hidden absolute top-4 right-4 text-gray-500 hover:text-gray-800 focus:outline-none"
85
- >
86
- < svg className = "h-6 w-6" fill = "none" stroke = "currentColor" viewBox = "0 0 24 24" >
87
- < path strokeLinecap = "round" strokeLinejoin = "round" strokeWidth = "2" d = "M6 18L18 6M6 6l12 12" />
88
- </ svg >
89
- </ button >
90
- ) }
91
64
</ div >
92
65
93
- { /* Overlay for mobile when sidebar is open - now covers left side */ }
94
- { isSidebarOpen && (
95
- < div
96
- className = "fixed inset-0 bg-black opacity-50 md:hidden z-30"
97
- onClick = { ( ) => setIsSidebarOpen ( false ) }
98
- > </ div >
99
- ) }
100
-
101
- { /* Main content area - adjusts for sidebar width on desktop, now on the left, displays Bible text */ }
102
- < div className = "flex-1 p-6" style = { { marginRight : '320px' , transition : 'margin-right 300ms ease-in-out' } } >
66
+ { /* Main content area - adjusts for picker height, displays Bible text */ }
67
+ < div className = "flex-1 p-6" style = { { paddingTop : '120px' } } > { /* Increased padding to account for picker */ }
103
68
< h1 className = "text-2xl font-bold mb-4" > { selectedBook } Chapter { selectedChapter } </ h1 >
104
69
< div className = "prose max-w-none" >
105
- { bibleText . split ( '\n' ) . map ( ( line : string , index : number ) => ( // Explicitly type line and index
106
- < p key = { index } > { line } </ p >
107
- ) ) }
70
+ { paragraphs . length > 0 ? (
71
+ paragraphs . map ( ( paragraph , index ) => (
72
+ < p key = { index } className = "mb-4" > { paragraph . split ( '\n' ) . join ( ' ' ) } </ p >
73
+ ) )
74
+ ) : (
75
+ < p > { bibleText } </ p >
76
+ ) }
108
77
</ div >
109
78
</ div >
110
79
</ main >
0 commit comments