@@ -26,45 +26,67 @@ defmodule AlgoraWeb.Admin.AdminLive do
2626 |> assign ( :notes_form , to_form ( notes_changeset ) )
2727 |> assign ( :notes_preview , ( mainthing && Markdown . render ( mainthing . content ) ) || "" )
2828 |> assign ( :mainthing , mainthing )
29+ |> assign ( :notes_edit_mode , false )
30+ |> assign ( :notes_full_screen , false )
2931 |> stream ( :activities , [ ] )
3032 |> start_async ( :get_activities , fn -> Activities . all ( ) end ) }
3133 end
3234
3335 def render ( assigns ) do
3436 ~H"""
3537 < div class = "space-y-8 p-8 " >
36- < section id = "notes " >
38+ < section id = "notes " class = { [ "transition-all duration-300" , @ notes_full_screen && "h-screen" ] } >
3739 < div class = "mb-4 flex items-center justify-between " >
3840 < h1 class = "text-2xl font-bold " > Notes</ h1 >
41+ < div class = "flex gap-2 " >
42+ < . button
43+ type = "button "
44+ phx-click = "notes-toggle "
45+ variant = { if @ notes_edit_mode , do: "secondary" , else: "default" }
46+ >
47+ { if @ notes_edit_mode , do: "Preview" , else: "Edit" }
48+ </ . button >
49+ < . button type = "button " variant = "secondary " phx-click = "notes-fullscreen-toggle " >
50+ { if @ notes_full_screen , do: "Minimize" , else: "Maximize" }
51+ </ . button >
52+ </ div >
3953 </ div >
4054
41- < . simple_form for = { @ notes_form } phx-change = " validate_notes " phx-submit = " save_notes " >
42- < div class = " grid grid-cols-2 gap-4 " >
43- < div class = " flex flex-col gap-2 " >
44- < h3 class = " font-medium text-sm " > Content </ h3 >
45- < div class = " flex-1 [&>div]:h-full " >
46- < . input
47- field = { @ notes_form [ :content ] }
48- type = " textarea "
49- class = " h-full scrollbar-thin "
50- phx-debounce = " 300 "
51- rows = { 10 }
52- / >
53- </ div >
54- </ div >
55- < div class = " flex flex-col gap-2 " >
56- < h3 class = "font-medium text-sm " > Preview </ h3 >
57- < div class = " flex-1 rounded-lg border bg-muted/40 p-4 " >
58- < div class = " prose prose-sm max-w-none dark:prose-invert " >
59- { raw ( @ notes_preview ) }
55+ < div
56+ id = " notes-container "
57+ class = { [
58+ "overflow-hidden transition-all duration-300" ,
59+ if ( @ notes_full_screen , do: "max-h-none" , else: "max-h-[500px]" )
60+ ] }
61+ >
62+ < div id = " notes-edit " class = { [ "hidden" , @ notes_edit_mode && "!block" ] } >
63+ < . simple_form for = { @ notes_form } phx-change = " validate_notes " phx-submit = " save_notes " >
64+ < div class = " flex flex-col gap-2 h-full " >
65+ < h3 class = " font-medium text-sm " > Content </ h3 >
66+ < div class = " flex-1 [&>div]:h-full " >
67+ < . input
68+ field = { @ notes_form [ :content ] }
69+ type = " textarea "
70+ class = "h-full scrollbar-thin "
71+ phx-debounce = " 300 "
72+ rows = { 10 }
73+ />
6074 </ div >
6175 </ div >
76+ <: actions >
77+ < . button type = "submit " > Save Notes</ . button >
78+ </: actions >
79+ </ . simple_form >
80+ </ div >
81+
82+ < div id = "notes-preview " class = { [ "h-full" , ! @ notes_edit_mode && "!block" ] } >
83+ < div class = "h-full rounded-lg border bg-muted/40 p-4 overflow-y-auto " >
84+ < div class = "prose prose-sm max-w-none dark:prose-invert " >
85+ { raw ( @ notes_preview ) }
86+ </ div >
6287 </ div >
6388 </ div >
64- <: actions >
65- < . button type = "submit " > Save Notes</ . button >
66- </: actions >
67- </ . simple_form >
89+ </ div >
6890 </ section >
6991
7092 < section id = "analytics " >
@@ -231,6 +253,14 @@ defmodule AlgoraWeb.Admin.AdminLive do
231253 end
232254 end
233255
256+ def handle_event ( "notes-toggle" , _ , socket ) do
257+ { :noreply , assign ( socket , :notes_edit_mode , ! socket . assigns . notes_edit_mode ) }
258+ end
259+
260+ def handle_event ( "notes-fullscreen-toggle" , _ , socket ) do
261+ { :noreply , assign ( socket , :notes_full_screen , ! socket . assigns . notes_full_screen ) }
262+ end
263+
234264 def handle_info ( % Activities.Activity { } = activity , socket ) do
235265 { :noreply , stream_insert ( socket , :activities , activity , at: 0 ) }
236266 end
0 commit comments