-
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.
Rework game states structure a bit more
I previously leaned towards adding CSS classes for spacing on turbo_frame_tags, but the problem with that is that the original frame tag then affects the content that it will be replaced with in the future. So it seems that content should be up to its own styling, in all cases. Perhaps the remaining reason to add CSS classes to turbo frames, then, would be just to make that element, itself, behave properly / as needed within the view. e.g. giving it a `block` class so that it responds properly to a spacing class on its container element. Also, I previously passed up breaking out _container partials for past User - Games and Metrics - Games. This was an oversight caused by these views being further tucked away (out of sight out of mind). So this commit makes structure consistent for User Games and for Metrics. Also, fix the Game Show link from Metrics - Games to link back to the `/metrics/games/<id>` path. i.e. we keep context on the source of the Game Show link via Metrics pages, the same as for User Games. - To support this, we expand the nav link for "Metrics" to make itself active when displaying Metrics::GamesController actions as well.
- Loading branch information
Paul DobbinSchmaltz
committed
Nov 11, 2024
1 parent
1b5e324
commit 4da7718
Showing
16 changed files
with
156 additions
and
89 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
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,12 +1,10 @@ | ||
<%# locals: (content:) %> | ||
<div class="space-y-12"> | ||
<%= render("games/title", title: content.title) %> | ||
<%= render("games/title", title: content.title) %> | ||
|
||
<div class="space-y-6"> | ||
<%= render("games/past/status", status: content.status) %> | ||
<%= render("games/past/board", board: content.board) %> | ||
</div> | ||
|
||
<%= render("games/just_ended/actions", actions: content.actions) %> | ||
<div class="space-y-6"> | ||
<%= render("games/past/status", status: content.status) %> | ||
<%= render("games/past/board", board: content.board) %> | ||
</div> | ||
|
||
<%= render("games/just_ended/actions", actions: content.actions) %> |
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,22 @@ | ||
# frozen_string_literal: true | ||
|
||
# Metrics::Engagements | ||
class Metrics::Engagements | ||
def cache_key | ||
[ | ||
:engagements, | ||
Game.for_status_alliance_wins.size, | ||
] | ||
end | ||
|
||
def bests_per_type = Metrics::Engagements::Bests.per_type | ||
|
||
def display_case | ||
DisplayCase.new | ||
end | ||
|
||
# Metrics::Show::Engagements::DisplayCase | ||
class DisplayCase | ||
include Games::Past::DisplayCaseBehaviors | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<%# locals: (container:) %> | ||
<%= turbo_frame_tag(container.turbo_frame_name) do %> | ||
<div class="space-y-12"> | ||
<% cache_unless(App.debug?, container.cache_key(context: layout)) do %> | ||
<%= render("metrics/games/content", content: container.content) %> | ||
<% end %> | ||
|
||
<div class="container mx-auto"> | ||
<%= render("games/past/results", results: container.results) %> | ||
</div> | ||
</div> | ||
<% 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# frozen_string_literal: true | ||
|
||
# Metrics::Games::Container represents past {Game}s in the context of the | ||
# Metrics Show page. | ||
class Metrics::Games::Container | ||
def initialize(game:) | ||
@game = game | ||
end | ||
|
||
def game_number = game.display_id | ||
|
||
def turbo_frame_name = Games::Past::Container.display_case_turbo_frame_name | ||
|
||
def cache_key(context:) | ||
[ | ||
:metrics, | ||
game, | ||
context.mobile? ? :mobile : :web, | ||
] | ||
end | ||
|
||
def content | ||
Metrics::Games::Content.new(game:) | ||
end | ||
|
||
def results | ||
Games::Past::Results.new(game:) | ||
end | ||
|
||
private | ||
|
||
attr_reader :game | ||
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 |
---|---|---|
@@ -1,13 +1,3 @@ | ||
<% title("Metrics -> Game ##{@view.game_number}") %> | ||
<%= turbo_frame_tag(@view.turbo_frame_name) do %> | ||
<div class="space-y-6"> | ||
<% cache_unless(App.debug?, @view.cache_key(context: layout)) do %> | ||
<%= render("metrics/games/content", content: @view.content) %> | ||
<% end %> | ||
|
||
<div class="container mx-auto"> | ||
<%= render("games/past/results", results: @view.results) %> | ||
</div> | ||
</div> | ||
<% end %> | ||
<%= render("metrics/games/container", container: @view.container) %> |
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,13 @@ | ||
# frozen_string_literal: true | ||
|
||
# Metrics::Games::Title is a specialization on {Games::Title} that provides | ||
# Metrics-specific {Game} paths. | ||
class Metrics::Games::Title < Games::Title | ||
def game_absolute_url | ||
Router.metrics_game_url(game) | ||
end | ||
|
||
def game_url | ||
Router.metrics_game_path(game) | ||
end | ||
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,13 @@ | ||
<%# locals: (container:) %> | ||
<%= turbo_frame_tag(container.turbo_frame_name) do %> | ||
<div class="space-y-12"> | ||
<% cache_unless(App.debug?, container.cache_key(context: layout)) do %> | ||
<%= render("users/games/content", content: container.content) %> | ||
<% end %> | ||
|
||
<div class="container mx-auto"> | ||
<%= render("games/past/results", results: container.results) %> | ||
</div> | ||
</div> | ||
<% 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# frozen_string_literal: true | ||
|
||
# Users::Games::Container represents past {Game}s in the context of a | ||
# participating player ({User}). | ||
class Users::Games::Container | ||
def initialize(game:, user:) | ||
@game = game | ||
@user = user | ||
end | ||
|
||
def turbo_frame_name = Games::Past::Container.display_case_turbo_frame_name | ||
|
||
def cache_key(context:) | ||
[ | ||
:user, | ||
game, | ||
context.mobile? ? :mobile : :web, | ||
] | ||
end | ||
|
||
def content | ||
Users::Games::Content.new(game:, user:) | ||
end | ||
|
||
def results | ||
Games::Past::Results.new(game:) | ||
end | ||
|
||
private | ||
|
||
attr_reader :game, | ||
:user | ||
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
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