1
0
Fork 0
mirror of https://github.com/Nutomic/ibis.git synced 2024-11-22 01:21:10 +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));
view! {
<Html attr:data-theme="emerald"/>
<Html attr:data-theme="emerald" />
<>
<Stylesheet id="daisyui" href="/daisyui.css" />
<Stylesheet id="ibis" href="/ibis.css" />

View file

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

View file

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

View file

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

View file

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

View file

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