import React from 'react' import { ModData, PartialModData } from '../../../utils/gamebanana' import './ModTile.css' import Like from '../../../resources/icons/like.svg' import Eye from '../../../resources/icons/eye.svg' import Download from '../../../resources/icons/download.svg' import Folder from '../../../resources/icons/folder.svg' import { shell } from '@tauri-apps/api' interface IProps { mod: ModData | PartialModData path?: string onClick: (mod: ModData) => void } interface IState { hover: boolean } export class ModTile extends React.Component { constructor(props: IProps) { super(props) this.state = { hover: false, } } async openInExplorer() { if (this.props.path) shell.open(this.props.path) } render() { const { mod } = this.props return (
this.setState({ hover: true })} onMouseLeave={() => this.setState({ hover: false })} onClick={() => { // Disable downloading installed mods if (this.props.path) return this.openInExplorer() if (!('id' in mod)) return this.props.onClick(mod) }} > {mod.name} {mod.submitter.name}
{this.state.hover && (!this.props.path ? ( Download ) : ( Open ))}
{mod.likes.toLocaleString()}
{mod.views.toLocaleString()}
) } }