Basic turbo todo list implementation
Based on: https://webcrunch.com/posts/digging-into-turbo-with-ruby-on-rails-7
This commit is contained in:
@@ -1,21 +1,16 @@
|
||||
<div class="w-full">
|
||||
<div class="mx-auto max-w-3xl mt-4 sm:mt-24">
|
||||
<div class="mb-6">
|
||||
<h1 class="font-bold text-4xl mb-6">Todos</h1>
|
||||
</div>
|
||||
|
||||
<% if notice.present? %>
|
||||
<p class="py-2 px-3 bg-green-50 mb-5 text-green-500 font-medium rounded-lg inline-block" id="notice"><%= notice %></p>
|
||||
<% end %>
|
||||
|
||||
<% content_for :title, "Todos" %>
|
||||
<%= render "form", todo: Todo.new %>
|
||||
|
||||
<div class="flex justify-between items-center">
|
||||
<h1 class="font-bold text-4xl">Todos</h1>
|
||||
<%= link_to "New todo", new_todo_path, class: "rounded-lg py-3 px-5 bg-blue-600 text-white block font-medium" %>
|
||||
</div>
|
||||
|
||||
<div id="todos" class="min-w-full">
|
||||
<% @todos.each do |todo| %>
|
||||
<%= render todo %>
|
||||
<p>
|
||||
<%= link_to "Show this todo", todo, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
|
||||
</p>
|
||||
<% end %>
|
||||
</div>
|
||||
<%= turbo_stream_from "todos" %>
|
||||
<ul id="todos" class="divide-y list-none">
|
||||
<%= render @todos %>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user