All files / web/src/arcade-games/matching/components AbacusCardFront.tsx

0% Statements 0/119
0% Branches 0/1
0% Functions 0/1
0% Lines 0/119

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120                                                                                                                                                                                                                                               
'use client'

import { AbacusReact, useAbacusConfig } from '@soroban/abacus-react'
import { css } from '../../../../styled-system/css'
import type { AbacusCard } from '../types'

/**
 * Card front rendering for the abacus matching game variant.
 * Named component (not inline arrow) so hooks can be used inside.
 */
export function AbacusCardFront({ card }: { card: AbacusCard }) {
  const appConfig = useAbacusConfig()

  if (card.type === 'abacus') {
    return (
      <div
        className={css({
          display: 'flex',
          alignItems: 'center',
          justifyContent: 'center',
          width: '100%',
          height: '100%',
          '& svg': {
            maxWidth: '100%',
            maxHeight: '100%',
          },
        })}
      >
        <AbacusReact
          value={card.number}
          columns="auto"
          beadShape={appConfig.beadShape}
          colorScheme={appConfig.colorScheme}
          hideInactiveBeads={appConfig.hideInactiveBeads}
          scaleFactor={0.8}
          interactive={false}
          showNumbers={false}
          animated={false}
        />
      </div>
    )
  }

  if (card.type === 'number') {
    return (
      <div
        className={css({
          fontSize: '32px',
          fontWeight: 'bold',
          color: 'gray.800',
          display: 'flex',
          alignItems: 'center',
          justifyContent: 'center',
        })}
      >
        {card.number}
      </div>
    )
  }

  if (card.type === 'complement') {
    return (
      <div
        className={css({
          textAlign: 'center',
          display: 'flex',
          flexDirection: 'column',
          alignItems: 'center',
          justifyContent: 'center',
          gap: '4px',
        })}
      >
        <div
          className={css({
            fontSize: '28px',
            fontWeight: 'bold',
            color: 'gray.800',
          })}
        >
          {card.number}
        </div>
        <div
          className={css({
            fontSize: '16px',
            color: 'gray.600',
            display: 'flex',
            alignItems: 'center',
            gap: '4px',
          })}
        >
          <span>{card.targetSum === 5 ? '✋' : '🔟'}</span>
          <span>Friends</span>
        </div>
        {card.complement !== undefined && (
          <div
            className={css({
              fontSize: '12px',
              color: 'gray.500',
            })}
          >
            + {card.complement} = {card.targetSum}
          </div>
        )}
      </div>
    )
  }

  // Fallback for unknown card types
  return (
    <div
      className={css({
        fontSize: '24px',
        color: 'gray.500',
      })}
    >
      ?
    </div>
  )
}