1
0
Fork 0
mirror of https://github.com/Nutomic/ibis.git synced 2024-11-25 19:11:08 +00:00

various improvements

This commit is contained in:
Felix Ableitner 2024-10-30 13:02:27 +01:00
parent af80819eca
commit 9be6abf776
6 changed files with 72 additions and 57 deletions

View file

@ -91,7 +91,7 @@ pub fn App() -> impl IntoView {
provide_context(create_rw_signal(global_state)); provide_context(create_rw_signal(global_state));
view! { view! {
<Html attr:data-theme="emerald"/> <Html attr:data-theme="emerald" />
<> <>
<Stylesheet id="daisyui" href="/daisyui.css" /> <Stylesheet id="daisyui" href="/daisyui.css" />
<Stylesheet id="ibis" href="/ibis.css" /> <Stylesheet id="ibis" href="/ibis.css" />

View file

@ -13,10 +13,11 @@ pub fn EditorView(
let (show_preview, set_show_preview) = create_signal(false); let (show_preview, set_show_preview) = create_signal(false);
view! { view! {
<div class="my-4">
<textarea <textarea
value=content value=content
placeholder="Article text..." placeholder="Article text..."
class="textarea textarea-bordered textarea-primary min-w-full" class="textarea textarea-primary min-w-full min-h-80 resize-none"
on:input=move |evt| { on:input=move |evt| {
let val = event_target_value(&evt); let val = event_target_value(&evt);
set_preview.set(render_markdown(&val)); set_preview.set(render_markdown(&val));
@ -26,17 +27,21 @@ pub fn EditorView(
> >
{content.get()} {content.get()}
</textarea> </textarea>
<button class="btn" on:click=move |_| { set_show_preview.update(|s| *s = !*s) }> <button
class="btn btn-secondary my-4"
on:click=move |_| { set_show_preview.update(|s| *s = !*s) }
>
Preview Preview
</button> </button>
<Show when=move || { show_preview.get() }> <Show when=move || { show_preview.get() }>
<div id="preview" inner_html=move || preview.get()></div> <div id="preview" inner_html=move || preview.get()></div>
</Show> </Show>
<div> <div>
<a href="https://commonmark.org/help/" target="blank_"> <a class="link link-secondary" href="https://commonmark.org/help/" target="blank_">
Markdown Markdown
</a> </a>
" formatting is supported" " formatting is supported"
</div> </div>
</div>
} }
} }

View file

@ -50,13 +50,14 @@ pub fn CreateArticle() -> impl IntoView {
}); });
view! { view! {
<h1>Create new Article</h1> <h1 class="text-4xl font-bold font-serif my-4">Create new Article</h1>
<Show <Show
when=move || create_response.get().is_some() when=move || create_response.get().is_some()
fallback=move || { fallback=move || {
view! { view! {
<div class="item-view"> <div class="item-view">
<input <input
class="input input-primary w-full"
type="text" type="text"
required required
placeholder="Title" placeholder="Title"
@ -77,7 +78,9 @@ pub fn CreateArticle() -> impl IntoView {
}) })
}} }}
<div class="flex flex-row">
<input <input
class="input input-primary grow mr-2"
type="text" type="text"
placeholder="Edit summary" placeholder="Edit summary"
on:keyup=move |ev| { on:keyup=move |ev| {
@ -87,14 +90,17 @@ pub fn CreateArticle() -> impl IntoView {
/> />
<button <button
class="btn btn-primary"
prop:disabled=move || button_is_disabled.get() prop:disabled=move || button_is_disabled.get()
on:click=move |_| { on:click=move |_| {
submit_action.dispatch((title.get(), content.get(), summary.get())) submit_action
.dispatch((title.get(), content.get(), summary.get()))
} }
> >
Submit Submit
</button> </button>
</div> </div>
</div>
} }
} }
> >

View file

@ -136,13 +136,11 @@ pub fn EditArticle() -> impl IntoView {
.map(|err| { .map(|err| {
view! { <p style="color:red;">{err}</p> } view! { <p style="color:red;">{err}</p> }
}) })
}} }} <EditorView textarea_ref content set_content />
<EditorView textarea_ref content set_content /> <div class="flex flex-row mr-2">
<div class="inputs">
<input <input
type="text" type="text"
class="input input-secondary" class="input input-secondary grow"
placeholder="Edit summary" placeholder="Edit summary"
value=summary.get_untracked() value=summary.get_untracked()
on:keyup=move |ev| { on:keyup=move |ev| {

View file

@ -35,11 +35,16 @@ pub fn ArticleHistory() -> impl IntoView {
edit.edit.hash.0, edit.edit.hash.0,
); );
view! { view! {
<li> <li class="card card-compact bg-base-100 card-bordered m-2 rounded-s">
{render_date_time(edit.edit.created)}": " <div class="card-body">
<a class="link link-primary" href=path> <a class="link link-primary text-lg w-full" href=path>
{edit.edit.summary} {edit.edit.summary}
</a> " by " {user_link(&edit.creator)} </a>
<p>
{render_date_time(edit.edit.created)}" by "
{user_link(&edit.creator)}
</p>
</div>
</li> </li>
} }
}) })

View file

@ -33,11 +33,12 @@ pub fn EditDiff() -> impl IntoView {
render_date_time(edit.edit.created), render_date_time(edit.edit.created),
); );
view! { view! {
<div class="item-view"> <h2 class="text-xl font-bold font-serif my-2">{label}</h2>
<h1>{article.article.title.replace('_', " ")}</h1>
<h2>{label}</h2>
<p>"by " {user_link(&edit.creator)}</p> <p>"by " {user_link(&edit.creator)}</p>
<pre>{edit.edit.diff.clone()}</pre> <div class="bg-gray-200 p-2 rounded my-2">
<pre>
<code>{edit.edit.diff.clone()}</code>
</pre>
</div> </div>
} }
}) })