Add tailwind and styling for views
Some checks failed
CI / scan_ruby (push) Has been cancelled
CI / scan_js (push) Has been cancelled
CI / lint (push) Has been cancelled
CI / test (push) Has been cancelled
CI / system-test (push) Has been cancelled

This commit is contained in:
2025-10-27 16:09:04 +01:00
parent 9f42deee95
commit 40e832bfa2
21 changed files with 534 additions and 129 deletions

View File

@@ -1,21 +1,47 @@
<%= form_with model: project do |f| %>
<%= form_with model: project, class: "space-y-6" do |f| %>
<% if project.errors.any? %>
<div class="errors">
<h2><%= pluralize(project.errors.count, "error") %> prohibited this project from being saved:</h2>
<ul>
<% project.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
<div class="bg-red-50 border-l-4 border-red-400 p-4 mb-6">
<div class="flex">
<div class="flex-shrink-0">
<svg class="h-5 w-5 text-red-400" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z" clip-rule="evenodd" />
</svg>
</div>
<div class="ml-3">
<h3 class="text-sm font-medium text-red-800">
<%= pluralize(project.errors.count, "error") %> prohibited this project from being saved:
</h3>
<div class="mt-2 text-sm text-red-700">
<ul class="list-disc pl-5 space-y-1">
<% project.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
</div>
</div>
</div>
<% end %>
<div class="field">
<%= f.label :name %>
<%= f.text_field :name %>
<div>
<%= f.label :name, class: "block text-sm font-medium text-gray-700" %>
<div class="mt-1">
<%= f.text_field :name, class: "shadow-sm focus:ring-indigo-500 focus:border-indigo-500 block w-full sm:text-sm border-gray-300 rounded-md" %>
</div>
</div>
<div class="actions">
<%= f.submit %>
<div>
<%= f.label :active, class: "block text-sm font-medium text-gray-700" %>
<div class="mt-1">
<%= f.check_box :active, class: "h-4 w-4 text-indigo-600 focus:ring-indigo-500 border-gray-300 rounded" %>
<span class="ml-2 text-sm text-gray-600">Mark as active</span>
</div>
</div>
<% end %>
<div class="pt-5">
<div class="flex justify-end">
<%= link_to "Cancel", projects_path, class: "bg-white py-2 px-4 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500" %>
<%= f.submit class: "ml-3 inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500" %>
</div>
</div>
<% end %>

View File

@@ -1,3 +1,17 @@
<h1>Edit Project</h1>
<%= render "form", project: @project %>
<div class="md:grid md:grid-cols-3 md:gap-6">
<div class="md:col-span-1">
<div class="px-4 sm:px-0">
<h1 class="text-2xl font-bold text-gray-900 mb-2">Edit Project</h1>
<p class="mt-1 text-sm text-gray-600">
Update your project's details.
</p>
</div>
</div>
<div class="mt-5 md:mt-0 md:col-span-2">
<div class="shadow sm:rounded-md sm:overflow-hidden">
<div class="px-4 py-5 bg-white space-y-6 sm:p-6">
<%= render "form", project: @project %>
</div>
</div>
</div>
</div>

View File

@@ -1,6 +1,40 @@
<h1>Projects</h1>
<div class="flex justify-between items-center mb-6">
<h1 class="text-3xl font-bold text-gray-900">Projects</h1>
<%= link_to "New Project", new_project_path, class: "px-4 py-2 bg-indigo-600 text-white rounded-md hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 transition-colors" %>
</div>
<% @projects.each do |project| %>
<li><%= link_to project.name, project_path(project) %></li>
<% end %>
<p><%= link_to "New project", new_project_path %></p>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
<% @projects.each do |project| %>
<div class="bg-white rounded-lg shadow overflow-hidden hover:shadow-md transition-shadow">
<div class="p-6">
<h2 class="text-xl font-semibold text-gray-900 mb-2">
<%= project.name %>
</h2>
<div class="mt-4 flex items-center text-sm text-gray-600">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-1" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2" />
</svg>
<span><%= project.todos.count %> <%= "Todo".pluralize(project.todos.count) %></span>
</div>
<div class="mt-6">
<%= link_to "View Project", project_path(project), class: "inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md text-indigo-700 bg-indigo-100 hover:bg-indigo-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500" %>
</div>
</div>
</div>
<% end %>
</div>
<% if @projects.empty? %>
<div class="text-center py-12">
<svg xmlns="http://www.w3.org/2000/svg" class="mx-auto h-12 w-12 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2" />
</svg>
<h3 class="mt-2 text-sm font-medium text-gray-900">No projects</h3>
<p class="mt-1 text-sm text-gray-500">Get started by creating a new project.</p>
<div class="mt-6">
<%= link_to "New Project", new_project_path, class: "inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500" %>
</div>
</div>
<% end %>

View File

@@ -1,3 +1,17 @@
<h1>New project</h1>
<%= render "form", project: @project %>
<div class="md:grid md:grid-cols-3 md:gap-6">
<div class="md:col-span-1">
<div class="px-4 sm:px-0">
<h1 class="text-2xl font-bold text-gray-900 mb-2">New Project</h1>
<p class="mt-1 text-sm text-gray-600">
Create a new project to organize your todos.
</p>
</div>
</div>
<div class="mt-5 md:mt-0 md:col-span-2">
<div class="shadow sm:rounded-md sm:overflow-hidden">
<div class="px-4 py-5 bg-white space-y-6 sm:p-6">
<%= render "form", project: @project %>
</div>
</div>
</div>
</div>

View File

@@ -1,9 +1,95 @@
<h1><%= @project.name %></h1>
<div class="bg-white shadow-sm rounded-lg overflow-hidden mb-8">
<div class="px-6 py-4 border-b border-gray-200 bg-gray-50">
<div class="flex justify-between items-center">
<h1 class="text-2xl font-bold text-gray-900"><%= @project.name %></h1>
<div class="flex space-x-2">
<%= link_to edit_project_path(@project), class: "text-gray-400 hover:text-gray-500" do %>
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
<path d="M13.586 3.586a2 2 0 112.828 2.828l-.793.793-2.828-2.828.793-.793zM11.379 5.793L3 14.172V17h2.828l8.38-8.379-2.83-2.828z" />
</svg>
<% end %>
</div>
</div>
<% if @project.active? %>
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800 mt-2">
Active
</span>
<% else %>
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-gray-100 text-gray-800 mt-2">
Inactive
</span>
<% end %>
</div>
</div>
<% @project.todos.each do |todo| %>
<li><%= link_to todo.name, todo_path(todo) %></li>
<div class="flex justify-between items-center mb-6">
<h2 class="text-xl font-semibold text-gray-800">Todos for this project</h2>
<%= link_to new_todo_path(project_id: @project.id), class: "inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500" do %>
<svg xmlns="http://www.w3.org/2000/svg" class="-ml-1 mr-2 h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M10 3a1 1 0 011 1v5h5a1 1 0 110 2h-5v5a1 1 0 11-2 0v-5H4a1 1 0 110-2h5V4a1 1 0 011-1z" clip-rule="evenodd" />
</svg>
Add Todo
<% end %>
</div>
<% if @project.todos.any? %>
<div class="bg-white shadow overflow-hidden sm:rounded-md">
<ul class="divide-y divide-gray-200">
<% @project.todos.each do |todo| %>
<li>
<div class="px-4 py-4 sm:px-6 hover:bg-gray-50">
<div class="flex items-center justify-between">
<div class="flex items-center">
<div class="min-w-0 flex-1 flex items-center">
<% if todo.completed %>
<span class="flex-shrink-0 h-5 w-5 text-green-500">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd" />
</svg>
</span>
<% else %>
<span class="flex-shrink-0 h-5 w-5 text-gray-300 border-2 border-gray-300 rounded-full"></span>
<% end %>
<div class="ml-4">
<p class="text-sm font-medium text-indigo-600 truncate"><%= link_to todo.name, todo_path(todo) %></p>
<p class="text-sm text-gray-500 truncate"><%= truncate(todo.description, length: 100) %></p>
</div>
</div>
</div>
<div class="ml-4 flex-shrink-0 flex items-center space-x-4">
<% if todo.priority && todo.priority > 0 %>
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-yellow-100 text-yellow-800">
Priority: <%= todo.priority %>
</span>
<% end %>
<%= link_to edit_todo_path(todo), class: "text-gray-400 hover:text-gray-500" do %>
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
<path d="M13.586 3.586a2 2 0 112.828 2.828l-.793.793-2.828-2.828.793-.793zM11.379 5.793L3 14.172V17h2.828l8.38-8.379-2.83-2.828z" />
</svg>
<% end %>
</div>
</div>
</div>
</li>
<% end %>
</ul>
</div>
<% else %>
<div class="text-center py-12 bg-white shadow overflow-hidden sm:rounded-md">
<svg xmlns="http://www.w3.org/2000/svg" class="mx-auto h-12 w-12 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-3 7h3m-3 4h3m-6-4h.01M9 16h.01" />
</svg>
<h3 class="mt-2 text-sm font-medium text-gray-900">No todos</h3>
<p class="mt-1 text-sm text-gray-500">Get started by creating a new todo.</p>
<div class="mt-6">
<%= link_to new_todo_path(project_id: @project.id), class: "inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500" do %>
Add a todo
<% end %>
</div>
</div>
<% end %>
<%= link_to "Edit", edit_project_path %>
<%= button_to "Delete", project_path, method: :delete %>
<%= link_to "Back", projects_path %>
<div class="mt-8 flex space-x-4 items-center">
<%= link_to "Back to Projects", projects_path, class: "inline-flex items-center px-4 py-2 border border-gray-300 shadow-sm text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500" %>
<%= button_to "Delete Project", project_path(@project), method: :delete, class: "inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md text-white bg-red-600 hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500", data: { confirm: "Are you sure you want to delete this project and all its todos?" } %>
</div>