add link icon

This commit is contained in:
Romulus21
2025-06-04 23:37:44 +02:00
parent 4a8d22cb47
commit 735abf577c
7 changed files with 29 additions and 22 deletions

View File

@@ -13,8 +13,8 @@ pub async fn get_links() -> Result<Vec<crate::models::Link>, ServerFnError> {
}
#[server(LinkAction, "/api")]
pub async fn add_value(name: String, link: String) -> Result<(), ServerFnError> {
crate::models::Link::insert(name, link)
pub async fn add_value(name: String, link: String, icon: String) -> Result<(), ServerFnError> {
crate::models::Link::insert(name, link, icon)
.await
.map(|_| ())
.map_err(|x| {
@@ -67,6 +67,7 @@ pub fn Links() -> impl IntoView {
<input type="url"
name="icon"
placeholder="http..."
prop:value=move || reset_form.get()
class="text-center bg-prim border border-transparent rounded-lg focus:border-third px-2 py-2 w-60" />
</div>
<div>
@@ -134,7 +135,12 @@ fn Link<T: 'static + Clone, S: 'static>(
<a class="bg-prim-light hover:bg-prim-lightest border-b hover:border-third border-transparent text-xl rounded-lg text-center hover:text-third transition-colors px-5 py-4 min-w-60 inline-block"
target="_blank"
href={move || link.with(|x| x.link.to_string())}>
{move || link.with(|x| x.name.to_string())}
<div class="size-54 min-w-54 bg-red-400 mb-2">
<img src={move || link.with(|x| x.icon.to_string())}
alt={move || link.with(|x| x.name.to_string())} class="size-54 object-cover" />
</div>
<span>{move || link.with(|x| x.name.to_string())}</span>
</a>
{move || {
edit.get().then(|| {