<%# WARNING: Could not add Stimulus controller to root element %>
<%# WARNING: Component uses React hook: useState. This may require manual conversion. %>
<%# WARNING: Component uses React hook: useState. This may require manual conversion. %>
<%# WARNING: Multiple JSX elements found, using heuristics to identify the root element %> <div class="max-w-md mx-auto bg-white rounded-xl shadow-md overflow-hidden md:max-w-2xl p-4"> <h2 class="text-xl font-bold mb-4 text-gray-800"> <% = title %></h2> <div class="flex mb-4"> <input type="text" class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline" placeholder="Add a new todo..." value=" <% = newTodo %>" data-action="change->change"=" <% = e => setNewTodo(e.target.value) %>" data-action="keypress->keypress"=" <% = e => e.key === 'Enter' && handleAddTodo() %>" /> <button class="ml-2 bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline" data-action="click->click"=" <% = handleAddTodo %>"> Add </button> </div> <ul class="divide-y divide-gray-200"> <% todos.each do |todo| %><li class="py-2 flex items-center justify-between"> <div class="flex items-center"> <input type="checkbox" class="mr-2" checked=" <% = todo.completed %>" data-action="change->change"=" <% = () => handleToggleTodo(todo.id) %>" /> <span class="<% if todo.completed %> <% = 'line-through text-gray-500' %><% else %> <% = 'text-gray-800' %><% end %>"> <%= todo.text %> </span> </div> <button class="text-red-500 hover:text-red-700 ml-2" data-action="click->click"=" <% = () => handleDeleteTodo(todo.id) %>"> Delete </button> </li><% end %> </ul> <% if todos.length === 0 %> <% = <p className="text-gray-500 text-center mt-4">No todos yet. Add one above!</p> %><% end %> <% if todos.length> 0 %> <% = <div className="mt-4 text-sm text-gray-600"> {todos.filter(todo => todo.completed).length} of {todos.length} completed </div> %><% end %> </div>