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

Resize article edit input based on length (fixes #51)

This commit is contained in:
Felix Ableitner 2024-10-14 11:24:06 +02:00
parent 442e1ce75c
commit 8b08d99d99
3 changed files with 20 additions and 2 deletions

View file

@ -39,6 +39,19 @@ pre {
white-space: pre-wrap;
}
#edit-article textarea {
height: auto;
width: 100%;
}
#edit-article .inputs {
display: flex;
}
#edit-article .inputs input {
flex: 1;
margin: 5px;
}
@media only screen and (max-width: 720px) {
body {
flex-direction: column;

View file

@ -3,6 +3,8 @@ set -e
IBIS__BIND="${IBIS_BIND:-"127.0.0.1:8081"}"
killall trunk || true
# run processes in parallel
# https://stackoverflow.com/a/52033580
(trap 'kill 0' INT;

View file

@ -118,9 +118,10 @@ pub fn EditArticle() -> impl IntoView {
}
set_text.set(article.article.text.clone());
let article_ = article.clone();
let rows = article.article.text.lines().count() + 1;
view! {
// set initial text, otherwise submit with no changes results in empty text
<div class="item-view">
<div id="edit-article" class="item-view">
<h1>{article_title(&article.article)}</h1>
{move || {
edit_error
@ -130,7 +131,7 @@ pub fn EditArticle() -> impl IntoView {
})
}}
<textarea on:keyup=move |ev| {
<textarea id="edit-article-textarea" rows=rows on:keyup=move |ev| {
let val = event_target_value(&ev);
set_text.update(|p| *p = val);
}>{article.article.text.clone()}</textarea>
@ -140,6 +141,7 @@ pub fn EditArticle() -> impl IntoView {
</a>
" formatting is supported"
</div>
<div class="inputs">
<input
type="text"
placeholder="Edit summary"
@ -166,6 +168,7 @@ pub fn EditArticle() -> impl IntoView {
Submit
</button>
</div>
</div>
}
})
}}