<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Simple Kanban Board</title>
<!-- Optional: Tailwind CSS CDN -->
<!-- <script src="https://cdn.tailwindcss.com"></script> -->
<!-- If using Tailwind, you can remove or comment out the <style> block below -->
<!-- SortableJS CDN (Required for Drag-and-Drop) -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/Sortable/1.15.0/Sortable.min.js"></script>
<!-- Custom CSS (Fallback or Primary Styling) -->
<style>
/* Basic Reset & Body Styling */
body {
font-family: sans-serif;
margin: 0;
padding: 20px;
background-color: #f4f7f6;
color: #333;
}
h1 {
text-align: center;
margin-bottom: 30px;
color: #2c3e50;
}
/* Kanban Board Container */
.kanban-board {
display: flex;
gap: 20px; /* Space between columns */
justify-content: space-around; /* Distribute columns */
min-height: 60vh; /* Ensure board has some height */
}
/* Kanban Column Styling */
.kanban-column {
flex: 1; /* Allow columns to grow and shrink */
max-width: 300px; /* Optional: prevent columns from becoming too wide */
background-color: #e0e0e0; /* Light grey background for columns */
border-radius: 8px;
padding: 15px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
/* Column Header Styling */
.kanban-column h2 {
font-size: 1.2em;
font-weight: bold;
margin-top: 0;
margin-bottom: 15px;
padding-bottom: 10px;
border-bottom: 2px solid #c7c7c7;
text-align: center;
color: #34495e;
}
/* Task List Container */
.tasks {
min-height: 100px; /* Minimum height to allow dropping into empty columns */
padding-bottom: 10px; /* Add some space at the bottom */
}
/* Task Item Styling */
.task-item {
background-color: #ffffff;
padding: 12px;
margin-bottom: 10px;
border-radius: 5px;
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
cursor: grab; /* Indicate item is draggable */
border: 1px solid #dcdcdc;
font-size: 0.9em;
}
.task-item:last-child {
margin-bottom: 0;
}
/* Styling for the ghost element during drag (SortableJS) */
.sortable-ghost {
opacity: 0.4;
background-color: #cceeff;
border: 1px dashed #007bff;
}
/* Styling for the item being dragged (SortableJS) */
.sortable-drag {
opacity: 0.9;
background-color: #f0f8ff; /* Light blue background while dragging */
}
/* --- Tailwind Classes (if CDN is uncommented) ---
Equivalent Tailwind classes for the above styles:
body: font-sans m-0 p-5 bg-gray-100 text-gray-800
h1: text-center mb-8 text-2xl font-bold text-gray-700
.kanban-board: flex gap-5 justify-around min-h-[60vh]
.kanban-column: flex-1 max-w-xs bg-gray-200 rounded-lg p-4 shadow
.kanban-column h2: text-lg font-bold mt-0 mb-4 pb-2 border-b-2 border-gray-400 text-center text-gray-800
.tasks: min-h-[100px] pb-2 space-y-2 <-- space-y-2 adds margin between items automatically
.task-item: bg-white p-3 mb-2 rounded shadow border border-gray-300 text-sm cursor-grab
.sortable-ghost: opacity-40 bg-blue-100 border border-dashed border-blue-500
.sortable-drag: opacity-90 bg-blue-50
*/
</style>
</head>
<body>
<h1>Simple Kanban Board</h1>
<div class="kanban-board">
<!-- Column 1: To Do -->
<div class="kanban-column">
<h2>To Do</h2>
<div class="tasks" id="todo-tasks">
<!-- Sample Task Items -->
<div class="task-item">Task 1: Plan project</div>
<div class="task-item">Task 2: Gather requirements</div>
<div class="task-item">Task 3: Set up environment</div>
</div>
</div>
<!-- Column 2: Doing -->
<div class="kanban-column">
<h2>Doing</h2>
<div class="tasks" id="doing-tasks">
<!-- Sample Task Items -->
<div class="task-item">Task 4: Develop feature A</div>
<div class="task-item">Task 5: Write unit tests</div>
</div>
</div>
<!-- Column 3: Done -->
<div class="kanban-column">
<h2>Done</h2>
<div class="tasks" id="done-tasks">
<!-- Sample Task Items -->
<div class="task-item">Task 6: Deploy to staging</div>
</div>
</div>
</div>
<script>
// Wait for the DOM to be fully loaded before initializing SortableJS
document.addEventListener('DOMContentLoaded', (event) => {
// Select all elements that will contain draggable items (the task lists)
const taskLists = document.querySelectorAll('.tasks');
// Define a common group name. This allows items to be moved between lists.
const groupName = 'shared-tasks';
// Initialize SortableJS for each task list
taskLists.forEach(taskList => {
new Sortable(taskList, {
group: groupName, // Set group name for inter-list dragging
animation: 150, // Animation speed in milliseconds
ghostClass: 'sortable-ghost', // Class name for the drop placeholder
dragClass: 'sortable-drag', // Class name for the dragged item
// You can add more SortableJS options here if needed
// E.g., onEnd event listener to save state (not implemented here)
// onEnd: function (/**Event*/evt) {
// var itemEl = evt.item; // dragged HTMLElement
// console.log("Task moved:", itemEl.textContent);
// console.log("Moved from:", evt.from.id);
// console.log("Moved to:", evt.to.id);
// console.log("New index:", evt.newIndex);
// // Add logic here to persist changes (e.g., using localStorage or sending to a server)
// },
});
});
});
</script>
</body>
</html>