new battle ui
All checks were successful
Build and Deploy / Build & Push Image (push) Successful in 14s

This commit is contained in:
2026-03-16 21:13:35 -06:00
parent c5ebf5b9af
commit c2297d0fdd
2 changed files with 44 additions and 25 deletions

View File

@@ -1,8 +1,11 @@
defmodule CobblemonUiWeb.BattleComponents do defmodule CobblemonUiWeb.BattleComponents do
use CobblemonUiWeb, :html use CobblemonUiWeb, :html
import CobblemonUiWeb.PokemonComponents, only: [tier_badge: 1]
attr :battle, :map, required: true attr :battle, :map, required: true
attr :player_id, :string, required: true attr :player_id, :string, required: true
attr :tier_list, :map, default: %{}
def battle_panel(assigns) do def battle_panel(assigns) do
~H""" ~H"""
@@ -25,7 +28,7 @@ defmodule CobblemonUiWeb.BattleComponents do
else: "border-warning/25 bg-warning/5" else: "border-warning/25 bg-warning/5"
) )
]}> ]}>
<div class="flex items-center gap-2 mb-2"> <div class="flex items-center gap-2 mb-3">
<div class={[ <div class={[
"w-7 h-7 rounded-md flex items-center justify-center shrink-0", "w-7 h-7 rounded-md flex items-center justify-center shrink-0",
if(actor.type == "player", do: "bg-primary/15", else: "bg-warning/15") if(actor.type == "player", do: "bg-primary/15", else: "bg-warning/15")
@@ -47,14 +50,28 @@ defmodule CobblemonUiWeb.BattleComponents do
</div> </div>
</div> </div>
<%= for poke <- actor.active_pokemon do %> <%= for poke <- actor.active_pokemon do %>
<% tier = Map.get(@tier_list, String.downcase(poke.species || ""), nil) %>
<div class="rounded-md bg-base-100/50 border border-base-300/30 px-3 py-2"> <div class="rounded-md bg-base-100/50 border border-base-300/30 px-3 py-2">
<div class="flex items-center justify-between mb-1"> <div class="flex items-center gap-3">
<div class="flex items-center gap-1.5"> <%!-- Sprite --%>
<span class="text-sm font-bold text-base-content">{poke.species}</span> <div class="w-14 h-14 rounded-lg bg-base-300/20 flex items-center justify-center shrink-0 overflow-hidden">
<img
src={"https://img.rankedboost.com/wp-content/plugins/k-Pokemon/assets/sprites-official/#{String.downcase(poke.species || "")}.png"}
alt={poke.species}
class="w-12 h-12 object-contain drop-shadow-sm"
/>
</div>
<%!-- Info --%>
<div class="flex-1 min-w-0">
<div class="flex items-center gap-1.5 mb-1">
<span class="text-sm font-bold text-base-content capitalize">{poke.species}</span>
<span class="text-[10px] text-base-content/40 bg-base-300/40 px-1.5 py-0.5 rounded font-mono"> <span class="text-[10px] text-base-content/40 bg-base-300/40 px-1.5 py-0.5 rounded font-mono">
Lv.{poke.level} Lv.{poke.level}
</span> </span>
<.tier_badge :if={tier} tier={tier} species={poke.species} compact={true} />
</div> </div>
<div class="flex items-center justify-between mb-1">
<span class="text-[11px] text-base-content/40">HP</span>
<span class="text-xs font-mono text-base-content/50"> <span class="text-xs font-mono text-base-content/50">
{poke.hp}/{poke.max_hp} {poke.hp}/{poke.max_hp}
</span> </span>
@@ -74,6 +91,8 @@ defmodule CobblemonUiWeb.BattleComponents do
/> />
</div> </div>
</div> </div>
</div>
</div>
<% end %> <% end %>
</div> </div>
<% end %> <% end %>

View File

@@ -217,7 +217,7 @@ defmodule CobblemonUiWeb.DashboardLive do
</div> </div>
<%!-- Active battle --%> <%!-- Active battle --%>
<.battle_panel :if={@battle} battle={@battle} player_id={@selected_player} /> <.battle_panel :if={@battle} battle={@battle} player_id={@selected_player} tier_list={@tier_list} />
<%!-- View mode tabs --%> <%!-- View mode tabs --%>
<div class="flex items-center gap-1 mb-5 p-1 rounded-lg bg-base-200/40 w-fit"> <div class="flex items-center gap-1 mb-5 p-1 rounded-lg bg-base-200/40 w-fit">