Skip to content

Commit

Permalink
refactor: extract generalized "boardgame-listing" template
Browse files Browse the repository at this point in the history
  • Loading branch information
JanWennrich committed Oct 16, 2024
1 parent 36a2320 commit c363178
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/HtmlGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function generateHtml(string $bggUsername): string
$playsGroupedByDate = [];

foreach ($plays as $play) {
$playsGroupedByDate[$play->playDateTime->format('c')][] = $play;
$playsGroupedByDate[$play->playDateTime->format('d.m.y')][] = $play->boardgame;
}

$params = [
Expand Down
13 changes: 13 additions & 0 deletions templates/boardgame-listing.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{% for sectionTitle, boardgameGroup in boardgameGroups %}
<section class="boardgame-listing-section">
<span class="boardgame-listing-section-title">
{{ sectionTitle|upper }}
</span>

<div class="boardgame-listing">
{% for boardgame in boardgameGroup %}
{{ include('boardgame.twig', {'boardgame': boardgame}) }}
{% endfor %}
</div>
</section>
{% endfor %}
12 changes: 0 additions & 12 deletions templates/boardgames-owned.twig

This file was deleted.

12 changes: 0 additions & 12 deletions templates/boardgames-played.twig

This file was deleted.

4 changes: 2 additions & 2 deletions templates/page.twig
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
</head>
<body>
<h2>Owned</h2>
{{ include('boardgames-owned.twig') }}
{{ include('boardgame-listing.twig', {'boardgameGroups': ownedBoardgamesGroupedByFirstLetter}) }}
<h2>Played</h2>
{{ include('boardgames-played.twig') }}
{{ include('boardgame-listing.twig', {'boardgameGroups': playsGroupedByDate}) }}
</body>
<script src="script.js"></script>
</html>

0 comments on commit c363178

Please sign in to comment.