Skip to content

Commit 5321fd4

Browse files
committed
Convert lobby game to regular component
1 parent 2cc2c8b commit 5321fd4

File tree

6 files changed

+24
-34
lines changed

6 files changed

+24
-34
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,14 @@ git push heroku main:main
4848

4949
### Research/similar sites
5050

51+
- Example of newest Phoenix version: <https://github.com/fly-apps/live_beats/blob/master/lib/live_beats_web/live/settings_live.ex>
52+
- Deploys: <https://damonvjanis.medium.com/optimizing-for-free-hosting-elixir-deployments-6bfc119a1f44>
5153
- <https://www.reddit.com/r/Mahjong/comments/ogl4yf/best_way_to_play_hk_mahjong_online/>
5254
- <http://mahjongbuddy.com>
5355
- <https://www.reddit.com/user/tthiatma/>
5456
- <https://www.reddit.com/r/Mahjong/comments/jsbsve/i_created_online_hong_kong_mahjong_web_app/>
5557
- <https://www.reddit.com/r/Mahjong/>
5658
- <https://en.wikipedia.org/wiki/Hong_Kong_Mahjong_scoring_rules>
57-
- Deploys: <https://damonvjanis.medium.com/optimizing-for-free-hosting-elixir-deployments-6bfc119a1f44>
5859

5960
### sortablejs
6061

TODO.md

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# TODO
22

3-
- Refactor: Convert Live View Components to regular Components
43
- Slider for tile size (so users don't have to increase font size)
54
- Real user accounts instead of just web sessions
65
- Shrink tile sizes on mobile

lib/mjw_web/components/game_components.ex

+21
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
defmodule MjwWeb.GameComponents do
22
use Phoenix.Component
33

4+
quote do
5+
unquote(MjwWeb.verified_routes())
6+
end
7+
8+
use Phoenix.VerifiedRoutes,
9+
endpoint: MjwWeb.Endpoint,
10+
router: MjwWeb.Router,
11+
statics: MjwWeb.static_paths()
12+
413
attr(:tile, :string, required: true)
514
attr(:class, :string, default: nil)
615
attr(:id, :string, default: nil)
@@ -296,4 +305,16 @@ defmodule MjwWeb.GameComponents do
296305
</div>
297306
"""
298307
end
308+
309+
attr(:game, Mjw.Game, required: true)
310+
311+
def lobby_game(assigns) do
312+
~H"""
313+
<div id={"join-#{@game.id}"} class="lobbygame">
314+
<.link href={~p"/games/#{@game.id}"} class="lobbygame-link">
315+
<%= Mjw.Game.seated_player_names(@game) |> Enum.join(", ") %>
316+
</.link>
317+
</div>
318+
"""
319+
end
299320
end

lib/mjw_web/live/game_live/index.html.heex

+1-5
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@
88
<%= unless Enum.empty?(@games) do %>
99
<div class="pt-12 pb-10 text-xl font-semibold">or join a game in progress:</div>
1010
<%= for game <- @games do %>
11-
<.live_component
12-
module={MjwWeb.GameLive.LobbyGameComponent}
13-
id={"join-#{game.id}"}
14-
game={game}
15-
/>
11+
<.lobby_game game={game} />
1612
<% end %>
1713
<% end %>
1814
</div>

lib/mjw_web/live/game_live/lobby_game_component.ex

-24
This file was deleted.

lib/mjw_web/live/game_live/lobby_game_component.html.heex

-3
This file was deleted.

0 commit comments

Comments
 (0)