2024-08-04 21:38:41 +00:00
@ extends ( 'layouts.writer' )
@ section ( 'title' , 'Write New Article' )
@ section ( 'content' )
2024-08-04 22:53:04 +00:00
< style >
#page-body-container {
display : flex ;
width : 100 % ;
align - items : center ;
justify - content : space - evenly ;
2025-10-13 03:57:50 +00:00
gap : 2 em ;
2024-08-04 22:53:04 +00:00
}
2025-10-13 03:57:50 +00:00
2024-08-04 22:53:04 +00:00
#new-article-form {
display : flex ;
flex - direction : column ;
}
2025-10-13 03:57:50 +00:00
#new-article-preview-container {
max - height : 90 vh ;
overflow - y : scroll ;
padding : 2 em ;
background - color : #000;
flex - grow : 1 ;
}
2024-08-04 22:53:04 +00:00
#markdown-body {
width : 40 vw ;
}
2024-08-16 22:46:59 +00:00
/* HTML: <div class="loader"></div> */
. loader {
width : 45 px ;
height : 30 px ;
background :
linear - gradient ( #004ce4 0 0) 0 100%/100% 50%,
linear - gradient ( #004ce4 0 0) 0 0 /calc(100%/3) 100%;
background - repeat : no - repeat ;
position : relative ;
clip - path : inset ( - 100 % 0 0 0 );
animation : l2 - 0 2 s infinite steps ( 4 );
}
. loader :: before ,
. loader :: after {
content : " " ;
position : absolute ;
inset :- 50 % 0 50 % ;
background :
linear - gradient ( #00e622 0 0) 0 0 /calc(2*100%/3) 50%,
linear - gradient ( #00e622 0 0) 100% 100%/calc(2*100%/3) 50%;
background - repeat : no - repeat ;
animation : inherit ;
animation - name : l2 - 1 ;
}
. loader :: after {
inset :- 100 % 0 100 % ;
background :
linear - gradient ( #e50021 0 0) 0 0/100% 50%,
linear - gradient ( #e50021 0 0) 100% 0/calc(100%/3) 100%;
background - repeat : no - repeat ;
animation - name : l2 - 2 ;
}
@ keyframes l2 - 0 {
0 % { transform : translateY ( - 250 % ); clip - path : inset ( 100 % 0 0 0 )}
25 % , 100 % { transform : translateY ( 0 ); clip - path : inset ( - 100 % 0 0 0 )}
}
@ keyframes l2 - 1 {
0 % , 25 % { transform : translateY ( - 250 % )}
50 % , 100 % { transform : translateY ( 0 )}
}
@ keyframes l2 - 2 {
0 % , 50 % { transform : translateY ( - 250 % )}
75 % , 100 % { transform : translateY ( 0 )}
}
2024-08-04 22:53:04 +00:00
</ style >
< script >
document . addEventListener ( " DOMContentLoaded " , ( event ) => {
2024-08-16 22:46:59 +00:00
document . getElementById ( 'preview-article' ) . style . display = 'none' ;
document . getElementById ( 'htmx-preview-button' ) . style . display = 'none' ;
2024-08-04 22:53:04 +00:00
});
</ script >
< div id = " page-body-container " >
< section id = " new-article-form-container " >
2025-10-13 03:57:50 +00:00
< form id = " new-article-form " method = " POST " action = " { { $article ? route('save-article-edits', ['article' => $article->id ]) : route('save-article') }} " enctype = " multipart/form-data " hx - encoding = " multipart/form-data " >
2025-03-23 20:23:47 +00:00
@ csrf
2024-08-04 22:53:04 +00:00
< label for = " publication-date " > Publication Date </ label >
2025-10-13 03:57:50 +00:00
< input id = " publication-date " name = " publication-date " type = " datetime-local " class = " affects-preview " value = " { { $article ?->publishedAtRaw }} " />
2024-08-04 22:53:04 +00:00
< label for = " title " > Title </ label >
2025-10-13 03:57:50 +00:00
< input id = " title " name = " title " type = " text " class = " affects-preview " value = " { { $article ?->title }} " />
2024-08-04 22:53:04 +00:00
< label for = " subtitle " > Subtitle </ label >
2025-10-13 03:57:50 +00:00
< input id = " subtitle " name = " subtitle " type = " text " class = " affects-preview " value = " { { $article ?->subtitle }} " />
2024-08-04 22:53:04 +00:00
< label for = " slug " > Slug </ label >
2025-10-13 03:57:50 +00:00
< input id = " slug " name = " slug " type = " text " class = " affects-preview " value = " { { $article ?->slug }} " />
<!-- Header images disabled for now
2024-08-04 22:53:04 +00:00
< label for = " header-image " > Header Image </ label >
< input id = " header-image " name = " header-image " type = " file " accept = " image/png, image/jpeg, image/jpg, image/webp " class = " affects-preview " />
2025-10-13 03:57:50 +00:00
-->
2024-08-04 22:53:04 +00:00
< label for = " markdown-body " > Markdown Body </ label >
2025-10-13 03:57:50 +00:00
< textarea id = " markdown-body " rows = " 25 " name = " markdown-body " placeholder = " Github-flavored markdown is supported! " class = " affects-preview " > {{ $article ? -> markdown_body }} </ textarea >
2024-08-04 22:53:04 +00:00
< button
id = " preview-article "
type = " submit "
>
Preview
</ button >
< button id = " save-article " type = " submit " > Save </ button >
< button
2024-08-16 22:46:59 +00:00
id = " htmx-preview-button "
2024-08-04 22:53:04 +00:00
data - hx - post = " { { route('live_preview') }} "
2025-03-23 20:23:47 +00:00
data - hx - trigger = " click, keyup changed delay:1100ms from:.affects-preview "
2024-08-04 22:53:04 +00:00
data - hx - target = " #true-container "
data - hx - swap = " innerHTML "
2024-08-16 22:46:59 +00:00
data - hx - indicator = " #preview-indicator "
2024-08-04 22:53:04 +00:00
>
HTMX Preview
</ button >
2024-08-16 22:46:59 +00:00
</ form >
2024-08-04 22:53:04 +00:00
</ section >
< section id = " new-article-preview-container " >
2024-08-16 22:46:59 +00:00
< span > Live Preview </ span >
< span id = " preview-indicator " class = " htmx-indicator " >< div class = " loader " ></ div ></ span >
< div class = " checkmark " ></ div >
2024-08-04 22:53:04 +00:00
< div id = " preview-inner-container " >
@ if ( isset ( $article_preview ))
< div id = " true-container " ></ div >
@ else
2024-08-16 22:46:59 +00:00
< div id = " true-container " >
< p > Nothing to see yet !</ p >
</ div >
2024-08-04 22:53:04 +00:00
@ endif
</ div >
</ section >
2024-08-04 21:38:41 +00:00
</ div >
@ endsection