style: drop one-time usage default render fns
This commit is contained in:
parent
f068161aea
commit
6b63941113
1 changed files with 12 additions and 13 deletions
25
src/lib.rs
25
src/lib.rs
|
|
@ -116,9 +116,18 @@ where
|
||||||
item: ItemSlot<<T::Item as SortableItem>::Key>|
|
item: ItemSlot<<T::Item as SortableItem>::Key>|
|
||||||
match item {
|
match item {
|
||||||
ItemSlot::Gap if let Some(render) = gap_render => {
|
ItemSlot::Gap if let Some(render) = gap_render => {
|
||||||
EitherOf3::A(render.0.run(dragged_height))
|
EitherOf3::A(view! { <li>{render.0.run(dragged_height)}</li> })
|
||||||
|
}
|
||||||
|
ItemSlot::Gap => {
|
||||||
|
EitherOf3::B(
|
||||||
|
view! {
|
||||||
|
<li
|
||||||
|
class="gap"
|
||||||
|
style:height={move || { format!("{}px", dragged_height.get()) }}
|
||||||
|
/>
|
||||||
|
},
|
||||||
|
)
|
||||||
}
|
}
|
||||||
ItemSlot::Gap => EitherOf3::B(default_gap(dragged_height)),
|
|
||||||
ItemSlot::Item(key) => {
|
ItemSlot::Item(key) => {
|
||||||
let item = SortableData::item_at(&data, index.get_untracked())
|
let item = SortableData::item_at(&data, index.get_untracked())
|
||||||
.expect("key from tracked sequence maps to an item");
|
.expect("key from tracked sequence maps to an item");
|
||||||
|
|
@ -205,7 +214,7 @@ where
|
||||||
>
|
>
|
||||||
{match handle_render {
|
{match handle_render {
|
||||||
Some(render) => Either::Left(render.0.run(())),
|
Some(render) => Either::Left(render.0.run(())),
|
||||||
None => Either::Right(default_handle()),
|
None => Either::Right(view! { class=SORTABLE, <div class="handle">"☰"</div> }),
|
||||||
}}
|
}}
|
||||||
</span>
|
</span>
|
||||||
<div class="item">{item_render(item)}</div>
|
<div class="item">{item_render(item)}</div>
|
||||||
|
|
@ -243,16 +252,6 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn default_handle() -> impl IntoView {
|
|
||||||
view! { class=SORTABLE, <div class="handle">"☰"</div> }
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_gap(height: Signal<f64>) -> impl IntoView {
|
|
||||||
view! { class=SORTABLE,
|
|
||||||
<li class="gap" style:height={move || { format!("{}px", height.get()) }} />
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
styly!(const sortable:scss {"
|
styly!(const sortable:scss {"
|
||||||
ul {
|
ul {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue