Make a PartialView for favorite System

This commit is contained in:
franc
2025-04-22 14:40:25 +02:00
parent cc590fa65c
commit 5f92625c16
@@ -0,0 +1,25 @@
@model Francesco.Recipes.World.Models.BackendModels.Recipe.Recipe
<button class="btn btn-link p-0"
style="width: 40px; height: 40px;"
hx-post="@Url.Action(Model.IsFavorite ? "RemoveFavorite" : "AddFavorite", "Recipe")"
hx-vals='{"recipeId": "@Model.Id"}'
hx-target="this"
hx-swap="outerHTML">
@if (Model.IsFavorite)
{
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="#FFD700">
<path d="M12 17.27L18.18 21 16.54 13.97
22 9.24l-7.19-.62L12 2 9.19 8.62
2 9.24l5.46 4.73L5.82 21z" />
</svg>
}
else
{
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#999" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M12 17.27L18.18 21 16.54 13.97
22 9.24l-7.19-.62L12 2 9.19 8.62
2 9.24l5.46 4.73L5.82 21z" />
</svg>
}
</button>