Skip to content

Instantly share code, notes, and snippets.

@peteraiello
Created August 25, 2020 09:09
Show Gist options
  • Save peteraiello/f5f355c0c664e8fe8d0c0fc56e6eecab to your computer and use it in GitHub Desktop.
Save peteraiello/f5f355c0c664e8fe8d0c0fc56e6eecab to your computer and use it in GitHub Desktop.
Thumbnail Component from Tailwind Technical Test
const ThumbnailImages = (props) => {
const imageArray = props.images;
let isActive = props.activeThumb;
let className="border-solid rounded-lg py-2 px-4 mr-2 hover:border-gray-700";
// set default border
let activeClass = "border-gray-200 border";
function thumbnailSelect(index) {
return (isActive === index ? activeClass = 'border-gray-700 border-2' : activeClass = 'border-gray-200 border');
}
return (
<div>
<ul className="flex">
{imageArray.map((image, index) => (
<li key={index}>
<button
label={ thumbnailSelect(index) }
onClick={ () => props.click(index) }
className={className + " " + activeClass
}>
<img src={ "img/" + image + ".jpg" } />
</button>
</li>
))}
</ul>
</div>
)
}
export default ThumbnailImages;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment