refactor: enhance area creation form with color picker and display area color in the card

This commit is contained in:
MayaTheShy
2026-02-20 04:21:07 -05:00
parent 465a8bacf4
commit 681b4e1fa9

View File

@@ -76,6 +76,7 @@ export default function MiningAreasPanel({ turtles, selectedTurtle, apiUrl }) {
setShowCreateForm(false); setShowCreateForm(false);
setNewArea({ setNewArea({
areaName: '', areaName: '',
color: '#4a8c2a',
startX: '', startX: '',
startY: '', startY: '',
startZ: '', startZ: '',
@@ -261,6 +262,27 @@ export default function MiningAreasPanel({ turtles, selectedTurtle, apiUrl }) {
/> />
</div> </div>
<div className="form-group">
<label>Area Color:</label>
<div className="color-picker-row">
<input
type="color"
value={newArea.color}
onChange={(e) => setNewArea({ ...newArea, color: e.target.value })}
className="color-input"
/>
{['#4a8c2a', '#345ec3', '#c9a000', '#cc3333', '#8833cc', '#33aacc', '#cc6633'].map(c => (
<button
key={c}
type="button"
className={`color-swatch ${newArea.color === c ? 'active' : ''}`}
style={{ backgroundColor: c }}
onClick={() => setNewArea({ ...newArea, color: c })}
/>
))}
</div>
</div>
<div className="form-group"> <div className="form-group">
<label>Assign Turtle:</label> <label>Assign Turtle:</label>
<select <select
@@ -366,7 +388,10 @@ export default function MiningAreasPanel({ turtles, selectedTurtle, apiUrl }) {
return ( return (
<div key={area.areaID} className={`area-card ${conflicts.length > 0 ? 'has-conflict' : ''}`}> <div key={area.areaID} className={`area-card ${conflicts.length > 0 ? 'has-conflict' : ''}`}>
<div className="area-header"> <div className="area-header">
<h3>{area.areaName}</h3> <div className="area-title-row">
<span className="area-color-dot" style={{ backgroundColor: area.color || '#4a8c2a' }} />
<h3>{area.areaName}</h3>
</div>
<StatusBadge status={area.status} /> <StatusBadge status={area.status} />
</div> </div>