-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4e82a08
commit 76ee9d7
Showing
5 changed files
with
45 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
<section class="py-16" data-role="cart"> | ||
<%= if @total_quantity == 0 do %> | ||
<%= if @cart.total_qty == 0 do %> | ||
<.empty_cart /> | ||
<% else %> | ||
<.live_component module={Details} id="cart-details" /> | ||
<.live_component module={Details} id="cart-details" cart={@cart} /> | ||
<% end %> | ||
</section> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
defmodule FoodOrderWeb.CartLive.Details do | ||
use FoodOrderWeb, :live_component | ||
alias __MODULE__.Item | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
defmodule FoodOrderWeb.CartLive.Details.Item do | ||
use FoodOrderWeb, :live_component | ||
|
||
def render(assigns) do | ||
~H""" | ||
<div id={@id} data-role="item" class="flex items-center my-8 shadow-lg p-2 hover:bg-neutral-100"> | ||
<img data-role="item-image" src={~p"/images/products/#{@item.item.image_url}"} alt="" class="h-16 w-16 rounded-full"/> | ||
<div class="flex-1 ml-4"> | ||
<h1><%= @item.item.name %></h1> | ||
<span><%= @item.item.size %></span> | ||
</div> | ||
<div class="flex-1" data-role="quantity"> | ||
<div class="flex items-center"> | ||
<button data-role="dec" class="p-1 m-2 rounded-full text-white font-bold bg-fuchsia-500">-</button> | ||
<span><%= @item.qty %> Item(s)</span> | ||
<button data-role="add" class="p-1 m-2 rounded-full text-white font-bold bg-fuchsia-500">+</button> | ||
</div> | ||
</div> | ||
<div class="flex flex-1 items-center" data-role="total-item"> | ||
<span class="font-bold text-lg"><%= @item.item.price %></span> | ||
<button class="ml-2 w-6 h-6 rounded-full text-white bg-fuchsia-500 font-bold"> | ||
× | ||
</button> | ||
</div> | ||
</div> | ||
""" | ||
end | ||
end |