Skip to content

Commit

Permalink
Consolidate heex files into ex files
Browse files Browse the repository at this point in the history
Following the Phoenix standards
  • Loading branch information
m1foley committed Jul 9, 2024
1 parent e682e32 commit 72a466a
Show file tree
Hide file tree
Showing 6 changed files with 191 additions and 173 deletions.
91 changes: 91 additions & 0 deletions lib/mjw_web/live/game_live/game_menu_component.ex
Original file line number Diff line number Diff line change
@@ -1,6 +1,97 @@
defmodule MjwWeb.GameLive.GameMenuComponent do
use MjwWeb, :live_component

@impl true
def render(assigns) do
~H"""
<div id={@id} class="phx-modal relative" phx-target="#game" phx-click="closegamemenu">
<div class="gamemenu-content">
<%= if @player_seats_finalized do %>
<div
phx-target="#game"
phx-click="draw"
class="bg-white hover:bg-gray-100 text-gray-800 font-semibold py-2 px-4 border border-gray-400 rounded shadow cursor-pointer my-4"
>
Declare draw 🤝
</div>
<div id="dqs" phx-hook="DeclareDq" phx-click="">
<div
id="declare-dq-btn"
class="bg-white hover:bg-gray-100 text-gray-800 font-semibold py-2 px-4 border border-gray-400 rounded shadow cursor-pointer my-4"
>
Declare DQ 🙅🏻‍♀️
</div>
<div class="dqplayer opacity-30 bg-white text-gray-800 font-semibold py-2 px-4 border border-gray-400 rounded shadow cursor-default my-4 hidden">
Declare DQ 🙅🏻‍♀️
</div>
<%= for seat <- @relative_game_seats |> Enum.drop(1) do %>
<div
class="dqplayer bg-red-600 hover:bg-red-500 text-gray-200 font-semibold py-2 px-4 border border-gray-400 rounded shadow cursor-pointer my-4 hidden"
phx-target="#game"
phx-click="dq"
phx-value-seatno={seat.seatno}
>
<%= seat.player_name %>
</div>
<% end %>
</div>
<% end %>
<%= if length(@relative_game_seats_with_players) > 1 do %>
<div id="bootplayers" phx-hook="BootPlayer" phx-click="">
<div
id="boot-player-btn"
class="bg-white hover:bg-gray-100 text-gray-800 font-semibold py-2 px-4 border border-gray-400 rounded shadow cursor-pointer my-4"
>
Boot player 🥾
</div>
<div class="bootplayer opacity-30 bg-white text-gray-800 font-semibold py-2 px-4 border border-gray-400 rounded shadow cursor-default my-4 hidden">
Boot player 🥾
</div>
<%= for seat <- @relative_game_seats_with_players |> Enum.drop(1) do %>
<div
class="bootplayer bg-red-600 hover:bg-red-500 text-gray-200 font-semibold py-2 px-4 border border-gray-400 rounded shadow cursor-pointer my-4 hidden"
phx-target="#game"
phx-click="bootplayer"
phx-value-seatno={seat.seatno}
>
<%= seat.player_name %>
</div>
<% end %>
</div>
<% end %>
<div
phx-target={@myself}
class="bg-white hover:bg-gray-100 text-gray-800 font-semibold py-2 px-4 border border-gray-400 rounded shadow cursor-pointer my-4"
phx-click="quit"
>
Leave game
</div>
<div
phx-target="#game"
phx-click="reset"
class="bg-white hover:bg-gray-100 text-gray-800 font-semibold py-2 px-4 border border-gray-400 rounded shadow cursor-pointer my-4"
>
<div phx-target="#game" phx-click="reset">
Reset game
</div>
</div>
<div phx-click="">
<.invite_link id="invite-link-gamemenu" game_id={@game.id} game_state={@game_state} />
</div>
</div>
</div>
"""
end

@impl true
def update(assigns, socket) do
relative_game_seats_with_players =
Expand Down
85 changes: 0 additions & 85 deletions lib/mjw_web/live/game_live/game_menu_component.html.heex

This file was deleted.

28 changes: 28 additions & 0 deletions lib/mjw_web/live/game_live/index.ex
Original file line number Diff line number Diff line change
@@ -1,6 +1,34 @@
defmodule MjwWeb.GameLive.Index do
use MjwWeb, :live_view

@impl true
def render(assigns) do
~H"""
<div class="lobby">
<img src="/images/cursive.png" alt="Mahjong Wind" class="lobbytitle" />
<.form for={%{}} action={~p"/games"}>
<.button type="submit" class="new-game">Start a game</.button>
</.form>
<div class="lobbygames">
<%= unless Enum.empty?(@games) do %>
<div class="pt-12 pb-10 text-xl font-semibold">or join a game in progress:</div>
<%= for game <- @games do %>
<.lobby_game game={game} />
<% end %>
<% end %>
</div>
</div>
<div class="footer">
<span>Email:</span>
<span class="pl-1">hello&#64;<span class="hidden">REMOVE</span>mahjongwind.com</span>
<span class="pl-4">Twitter:</span>
<span class="pl-1"><a href="https://www.twitter.com/m1foley">@m1foley</a></span>
</div>
"""
end

@impl true
def mount(_params, session, socket) do
socket =
Expand Down
22 changes: 0 additions & 22 deletions lib/mjw_web/live/game_live/index.html.heex

This file was deleted.

72 changes: 72 additions & 0 deletions lib/mjw_web/live/game_live/win_menu_component.ex
Original file line number Diff line number Diff line change
@@ -1,6 +1,78 @@
defmodule MjwWeb.GameLive.WinMenuComponent do
use MjwWeb, :live_component

@impl true
def render(assigns) do
~H"""
<div id={@id}>
<div id="winmenu-inner" phx-hook="Simpledrag">
<%= if Mjw.Seat.confirmed_win?(@current_user_seat) do %>
<div class="opacity-30 bg-white text-gray-800 font-semibold py-1 px-8 border border-gray-400 rounded shadow cursor-default my-4">
Waiting for everyone to shuffle... 👋
</div>
<% else %>
<div
class="bg-white hover:bg-gray-100 text-gray-800 font-semibold py-1 px-8 border border-gray-400 rounded shadow cursor-pointer my-4"
phx-target="#game"
phx-click="confirm_win"
>
Okay, let's start shuffling... 👋
</div>
<% end %>
<%= if Mjw.Seat.win_expose?(@current_user_seat) do %>
<div class="bg-white text-gray-800 font-semibold py-1 px-8 border border-gray-400 rounded shadow my-4 cursor-default opacity-30">
Expose hand
</div>
<% else %>
<div
class="bg-white text-gray-800 font-semibold py-1 px-8 border border-gray-400 rounded shadow my-4 cursor-pointer hover:bg-gray-100"
phx-target="#game"
phx-click="expose"
>
Expose hand
</div>
<% end %>
<%= if @showdeck do %>
<div
class="bg-white hover:bg-gray-100 text-gray-800 font-semibold py-1 px-8 border border-gray-400 rounded shadow cursor-pointer my-4"
phx-target={@myself}
phx-click="hidedeck"
>
Hide remaining deck
</div>
<div class="flex flex-row flex-wrap text-left justify-start justify-items-start">
<span class="pr-1 cursor-default" title="Next tile in the deck">&#8594;</span>
<%= for tile <- @game.deck do %>
<.tile id={tile} tile={tile} />
<% end %>
</div>
<% else %>
<div
class="bg-white hover:bg-gray-100 text-gray-800 font-semibold py-1 px-8 border border-gray-400 rounded shadow cursor-pointer my-4"
phx-target={@myself}
phx-click="showdeck"
>
View remaining deck
</div>
<% end %>
<%= unless Mjw.Seat.declared_win?(@current_user_seat) do %>
<div
class="bg-white hover:bg-gray-100 text-gray-800 font-semibold py-1 px-8 border border-gray-400 rounded shadow cursor-pointer my-4"
phx-target="#game"
phx-click="dqdeclared"
>
Declare DQ 🙅🏻‍♀️
</div>
<% end %>
</div>
</div>
"""
end

@impl true
def update(assigns, socket) do
socket =
Expand Down
66 changes: 0 additions & 66 deletions lib/mjw_web/live/game_live/win_menu_component.html.heex

This file was deleted.

0 comments on commit 72a466a

Please sign in to comment.