- improved grid painting and included resizing

This commit is contained in:
2025-11-24 12:19:51 +00:00
parent c5fe6754c3
commit b084c3016d
7 changed files with 70 additions and 20 deletions

View File

@@ -0,0 +1,49 @@
import ColourPicker from "./ColourPicker";
import type { Region } from "../../../../types/types";
type RegionSelectorProps = {
regions: Region[];
selectedRegionIndex: number;
onSelectRegion: (index: number) => void;
onChangeRegionColour: (index: number, colour: string) => void;
isErasing: boolean;
onSelectErasing: (isErasing: boolean) => void;
};
const RegionSelector = ({
regions,
selectedRegionIndex,
onSelectRegion,
onChangeRegionColour,
isErasing,
onSelectErasing,
}: RegionSelectorProps) => {
const handleChange = () => {
onSelectErasing(!isErasing);
};
return (
<div>
<div>
<h2>Region Select</h2>
</div>
<div>
{regions.map((region, idx) => (
<div key={region.name}>
<label style={{ marginRight: "0.5rem" }}>
<input type="radio" checked={selectedRegionIndex === idx} onChange={() => onSelectRegion(idx)} />{" "}
{region.name}
</label>
<ColourPicker colour={region.brushColour} setColour={(c: string) => onChangeRegionColour(idx, c)} />
</div>
))}
<label htmlFor="">
<input type="checkbox" onChange={handleChange} checked={isErasing} />
Eraser
</label>
</div>
</div>
);
};
export default RegionSelector;