|
| 1 | +import React, { useState } from "react"; |
| 2 | + |
| 3 | +interface CheckListItem { |
| 4 | + id: string; |
| 5 | + text: string; |
| 6 | + checked: boolean; |
| 7 | +} |
| 8 | + |
| 9 | +const CheckList: React.FC = () => { |
| 10 | + const [items, setItems] = useState<CheckListItem[]>([ |
| 11 | + // Equipment Requirements |
| 12 | + { id: "1", text: "Drone is a quadcopter (four rotors)", checked: false }, |
| 13 | + { id: "2", text: "Aircraft wheelbase is maximum 180mm", checked: false }, |
| 14 | + { |
| 15 | + id: "3", |
| 16 | + text: "Battery-based flight time of at least 5 minutes", |
| 17 | + checked: false, |
| 18 | + }, |
| 19 | + { |
| 20 | + id: "4", |
| 21 | + text: "Takeoff weight is less than 250g (including protective guard and battery)", |
| 22 | + checked: false, |
| 23 | + }, |
| 24 | + { |
| 25 | + id: "5", |
| 26 | + text: "Drone has fully enclosed protective guard for flight safety", |
| 27 | + checked: false, |
| 28 | + }, |
| 29 | + { |
| 30 | + id: "6", |
| 31 | + text: "Drone can be controlled via physical remote controller", |
| 32 | + checked: false, |
| 33 | + }, |
| 34 | + ]); |
| 35 | + |
| 36 | + const toggleCheck = (id: string) => { |
| 37 | + setItems( |
| 38 | + items.map((item) => |
| 39 | + item.id === id ? { ...item, checked: !item.checked } : item, |
| 40 | + ), |
| 41 | + ); |
| 42 | + }; |
| 43 | + |
| 44 | + const CheckmarkIcon = () => ( |
| 45 | + <svg |
| 46 | + xmlns="http://www.w3.org/2000/svg" |
| 47 | + className="h-4 w-4 text-white" |
| 48 | + fill="none" |
| 49 | + viewBox="0 0 24 24" |
| 50 | + stroke="currentColor" |
| 51 | + strokeWidth={2.5} |
| 52 | + > |
| 53 | + <path strokeLinecap="round" strokeLinejoin="round" d="M5 13l4 4L19 7" /> |
| 54 | + </svg> |
| 55 | + ); |
| 56 | + |
| 57 | + const completedCount = items.filter((item) => item.checked).length; |
| 58 | + const completionPercentage = (completedCount / items.length) * 100; |
| 59 | + |
| 60 | + return ( |
| 61 | + <section className="mx-auto max-w-md"> |
| 62 | + {/* Main Card Container */} |
| 63 | + <div className="overflow-hidden rounded-2xl border border-gray-100 bg-white shadow-lg"> |
| 64 | + {/* Header Section */} |
| 65 | + <div className="border-b border-gray-100 bg-white px-8 py-6"> |
| 66 | + <h2 className="subtitle mb-2 text-gray-800"> |
| 67 | + Equipment Requirements Checklist |
| 68 | + </h2> |
| 69 | + |
| 70 | + {/* Progress Indicator */} |
| 71 | + <div className="caption mb-3 flex items-center justify-between text-gray-600"> |
| 72 | + <span className="font-medium"> |
| 73 | + {completedCount} of {items.length} completed |
| 74 | + </span> |
| 75 | + <span className="medium-md font-semibold text-blue-600"> |
| 76 | + {Math.round(completionPercentage)}% |
| 77 | + </span> |
| 78 | + </div> |
| 79 | + |
| 80 | + {/* Progress Bar */} |
| 81 | + <div className="h-2 w-full overflow-hidden rounded-full bg-gray-200"> |
| 82 | + <div |
| 83 | + className="h-full rounded-full bg-gradient-to-r from-blue-500 to-indigo-600 transition-all duration-500 ease-out" |
| 84 | + style={{ width: `${completionPercentage}%` }} |
| 85 | + /> |
| 86 | + </div> |
| 87 | + </div> |
| 88 | + |
| 89 | + {/* Checklist Items */} |
| 90 | + <div className="p-6"> |
| 91 | + <div className="space-y-3"> |
| 92 | + {items.map((item, index) => ( |
| 93 | + <div key={item.id}> |
| 94 | + {/* Section Divider */} |
| 95 | + {index === 6 && ( |
| 96 | + <div className="flex items-center gap-3 py-3"> |
| 97 | + <div className="h-px flex-1 bg-gray-300"></div> |
| 98 | + <span className="caption font-medium text-gray-500"> |
| 99 | + Items to Bring |
| 100 | + </span> |
| 101 | + <div className="h-px flex-1 bg-gray-300"></div> |
| 102 | + </div> |
| 103 | + )} |
| 104 | + |
| 105 | + <div |
| 106 | + className={`group flex cursor-pointer items-center gap-4 rounded-xl p-4 transition-all duration-200 ${ |
| 107 | + item.checked |
| 108 | + ? "border border-green-200 bg-green-50" |
| 109 | + : "border border-transparent bg-gray-50 hover:border-blue-200 hover:bg-blue-50 hover:shadow-sm" |
| 110 | + }`} |
| 111 | + onClick={() => toggleCheck(item.id)} |
| 112 | + > |
| 113 | + {/* Custom Checkbox */} |
| 114 | + <div className="flex-shrink-0"> |
| 115 | + <div |
| 116 | + className={`flex h-6 w-6 items-center justify-center rounded-lg border-2 transition-all duration-200 ${ |
| 117 | + item.checked |
| 118 | + ? "border-blue-600 bg-blue-600 shadow-md" |
| 119 | + : "border-gray-300 bg-white group-hover:border-blue-400" |
| 120 | + }`} |
| 121 | + > |
| 122 | + {item.checked && ( |
| 123 | + <div className="scale-110 transform"> |
| 124 | + <CheckmarkIcon /> |
| 125 | + </div> |
| 126 | + )} |
| 127 | + </div> |
| 128 | + </div> |
| 129 | + |
| 130 | + {/* Item Text */} |
| 131 | + <span |
| 132 | + className={`body-sm flex-1 select-none transition-all duration-200 ${ |
| 133 | + item.checked |
| 134 | + ? "text-green-700 line-through" |
| 135 | + : "text-gray-800 group-hover:text-blue-800" |
| 136 | + }`} |
| 137 | + > |
| 138 | + {item.text} |
| 139 | + </span> |
| 140 | + </div> |
| 141 | + </div> |
| 142 | + ))} |
| 143 | + </div> |
| 144 | + </div> |
| 145 | + |
| 146 | + {/* Footer Section */} |
| 147 | + {completionPercentage === 100 && ( |
| 148 | + <div className="border-t border-green-100 bg-gradient-to-r from-green-50 to-emerald-50 px-6 py-4"> |
| 149 | + <div className="flex items-center gap-3"> |
| 150 | + <div className="flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-full bg-green-600"> |
| 151 | + <CheckmarkIcon /> |
| 152 | + </div> |
| 153 | + <div> |
| 154 | + <p className="body-lg text-green-800"> |
| 155 | + Equipment ready! Your drone meets all requirements |
| 156 | + </p> |
| 157 | + <p className="caption text-green-700"> |
| 158 | + Remember: All equipment will be inspected by organizers. Good |
| 159 | + luck! 🚁 |
| 160 | + </p> |
| 161 | + </div> |
| 162 | + </div> |
| 163 | + </div> |
| 164 | + )} |
| 165 | + |
| 166 | + {/* Motivational Footer */} |
| 167 | + {completionPercentage < 100 && ( |
| 168 | + <div className="border-t border-gray-100 bg-gray-50 px-6 py-4"> |
| 169 | + <p className="caption text-center text-gray-600"> |
| 170 | + <span className="font-medium text-gray-800"> |
| 171 | + {items.length - completedCount} requirements remaining |
| 172 | + </span>{" "} |
| 173 | + • Ensure your drone meets all specifications before competition! |
| 174 | + </p> |
| 175 | + </div> |
| 176 | + )} |
| 177 | + </div> |
| 178 | + </section> |
| 179 | + ); |
| 180 | +}; |
| 181 | + |
| 182 | +export default CheckList; |
0 commit comments