import React, { FC, useState, useEffect } from 'react'
import classNames from 'classnames'
import { ClassDictionary, GiphyGif } from '../../../types'

interface Props {
    gif: GiphyGif
    selected: boolean
    onSelect: (id: string) => void
}

const Gif: FC<Props> = ({ gif, selected, onSelect }) => {
    const classes: ClassDictionary = {
        gif: true,
        selected,
    }

    return (
        <div className={classNames(classes)} onClick={() => onSelect(gif.id)}>
            <img src={gif.images.fixed_height.url} alt={gif.title} />
        </div>
    )
}

export default Gif
