mirror of
https://github.com/danbee/chess
synced 2025-03-04 08:39:06 +00:00
Extract turn_class function
This commit is contained in:
parent
693263fb6d
commit
97a23ff9e7
@ -3,7 +3,7 @@
|
|||||||
<table class="table">
|
<table class="table">
|
||||||
<tbody>
|
<tbody>
|
||||||
<%= for game <- @games do %>
|
<%= for game <- @games do %>
|
||||||
<tr class="<%= if your_turn?(@conn, game), do: "your-turn" %>">
|
<tr class="<%= turn_class(@conn, game) %>">
|
||||||
<td>
|
<td>
|
||||||
<span class="player-indicator"><img src="images/pawn_<%= player_colour(@conn, game) %>.svg"></span>
|
<span class="player-indicator"><img src="images/pawn_<%= player_colour(@conn, game) %>.svg"></span>
|
||||||
<%= link "Game with #{opponent(@conn, game).name}", to: game_path(@conn, :show, game), class: "btn btn-default btn-xs" %>
|
<%= link "Game with #{opponent(@conn, game).name}", to: game_path(@conn, :show, game), class: "btn btn-default btn-xs" %>
|
||||||
|
|||||||
@ -3,6 +3,12 @@ defmodule ChessWeb.GameView do
|
|||||||
|
|
||||||
import Chess.Auth, only: [current_user: 1]
|
import Chess.Auth, only: [current_user: 1]
|
||||||
|
|
||||||
|
def turn_class(conn, game) do
|
||||||
|
if your_turn?(conn, game) do
|
||||||
|
"your-turn"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def your_turn?(conn, game) do
|
def your_turn?(conn, game) do
|
||||||
player_colour(conn, game) == game.turn
|
player_colour(conn, game) == game.turn
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user