diff --git a/assets/react/controllers/GameGrid.jsx b/assets/react/controllers/GameGrid.jsx
new file mode 100644
index 0000000..2981c9a
--- /dev/null
+++ b/assets/react/controllers/GameGrid.jsx
@@ -0,0 +1,27 @@
+import React from 'react';
+
+export default function GameGrid({ grid, width, middle }) {
+ return (
+
+
+ {grid.map((row, rowIndex) => (
+
+ {Array.from({ length: width + 1 }, (_, colIndex) => {
+ const start = middle - row.pos;
+ const charIndex = colIndex - start;
+ const name = row.actorName;
+ const isInRange = charIndex >= 0 && charIndex < name.length;
+ const isHighlighted = charIndex === row.pos;
+
+ return (
+ |
+ {isInRange ? name[charIndex].toUpperCase() : ''}
+ |
+ );
+ })}
+
+ ))}
+
+
+ );
+}
diff --git a/src/Controller/HomepageController.php b/src/Controller/HomepageController.php
index 3db7832..547ea6a 100644
--- a/src/Controller/HomepageController.php
+++ b/src/Controller/HomepageController.php
@@ -64,9 +64,15 @@ class HomepageController extends AbstractController
$width = $rightSize + $leftSize + 1;
$middle = $leftSize;
+ // Build JSON-serializable grid for React
+ $grid = array_map(fn (array $actorData) => [
+ 'actorName' => $actorData['actor']->getName(),
+ 'actorId' => $actorData['actor']->getId(),
+ 'pos' => $actorData['pos'],
+ ], $actors);
+
return $this->render('homepage/index.html.twig', [
- 'mainActor' => $mainActor,
- 'actors' => $actors,
+ 'grid' => $grid,
'width' => $width,
'middle' => $middle,
]);
diff --git a/templates/homepage/index.html.twig b/templates/homepage/index.html.twig
index ad55659..1abd7bd 100644
--- a/templates/homepage/index.html.twig
+++ b/templates/homepage/index.html.twig
@@ -1,26 +1,9 @@
{% extends 'base.html.twig' %}
{% block body %}
-
- {% set iActor = 0 %}
- {% for mainChar in mainActor.name|split('') %}
- {% if not mainChar|match('/[a-zA-Z]/') %}
- |
- {% else %}
- {% set actor = actors[iActor] %}
-
- {% set i = 0 %}
- {% set start = middle - actor.pos %}
- {% for c in range(0, width) %}
- {% if c >= start and c - start < actor.actor.name|length %}
- | {{ actor.actor.name|slice(c - start, 1)|upper }} |
- {% else %}
- |
- {% endif %}
- {% endfor %}
-
- {% set iActor = iActor + 1 %}
- {% endif %}
- {% endfor %}
-
+ {{ react_component('GameGrid', {
+ grid: grid,
+ width: width,
+ middle: middle,
+ }) }}
{% endblock %}