Help please. I have an image like this image below to display on a home page ( a much larger one). Notice that there is a white and blue marker with a black arrow in the middle on the "FORGE" house.
The same for the "Rentals" house.
Each one of these markers will behave as an interactive button. Here is the expected behavior on interaction:
- When hover, the blue background will expand to show a text like "Forge" or "Rentals"
- When clicked, it will navigate user to the respective page "Forge" or "Rentals".
Also would like it to be responsive, if when the screen resizes, the buttons should remain on these specific position.
I was hacking around with absolute positioning, x, y coordinates to try to make it work. But can't come up to a working solution due to my like of experience with these kind of UI. Not sure if I should use a canvas or other approach.
Any help would be much appreciated.
My code look like this, but looks like I'm not on the right track:
const ImageComponent = () => {
const markers = [
{ name: 'Forge', x: 100, y: 200 },
{ name: 'Rentals', x: 300, y: 150 },
// Add more
];
const handleMarkerClick = (m) => {
// do something with marker
};
return (
<div style={{ position: 'relative' }}>
<img src="path/to/image.jpg" alt="Image with markers" />
{markers.map((marker, index) => (
<div
key={index}
className="marker"
style={{ left: marker.x, top: marker.y, position: "absolute" }}
onClick={() => handleMarkerClick(marker)}
/>
))}
</div>
);
};