euchre-live

Euchre web-app for the socially distant family
git clone git://git.alexkarle.com/euchre-live.git
Log | Files | Refs | README | LICENSE

MainHand.js (1350B) [raw]


      1 import React from 'react';
      2 import PropTypes from 'prop-types';
      3 import { Link } from 'carbon-components-react';
      4 
      5 class MainHand extends React.Component {
      6 
      7     cardButtons = (cards) => {
      8         let buttons = [];
      9         cards.map((card, index) => {
     10             const cardSrc = 'cards/' + card + '.svg';
     11             buttons.push(
     12             <div key={index+'cw'}
     13                 className="mh__card__wrapper">
     14                 <div
     15                     key={index}
     16                     className="mh__card__div">
     17                     <Link
     18                         className="mh__card__link"
     19                         href="#"
     20                         onClick={(e)=> {
     21                             e.preventDefault();
     22                             this.props.cardClick(index)}
     23                         }>
     24                         <img className="mh__card" src={cardSrc} />
     25                     </Link>
     26                 </div>
     27             </div>
     28             )
     29         });
     30         return buttons;
     31     }
     32 
     33     render () {
     34         const { cards } = this.props;
     35         const cardButtons = this.cardButtons(cards);
     36         return (
     37             <div className="mh__card__row">
     38                 {cardButtons}
     39             </div>
     40         );
     41     };
     42 }
     43 MainHand.propTypes = {
     44     cards: PropTypes.arrayOf(PropTypes.string),
     45     cardClick: PropTypes.func
     46 }
     47 export default MainHand;