All files / web/src/components/nav GameControlButtons.tsx

89.38% Statements 101/113
62.5% Branches 5/8
20% Functions 2/10
89.38% Lines 101/113

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 1141x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 10x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 10x 10x             10x 10x             10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 10x 10x 10x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 10x 10x 10x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 10x 10x 10x 10x  
import type React from 'react'
 
interface GameControlButtonsProps {
  onSetup?: () => void
  onNewGame?: () => void
  onQuit?: () => void
}
 
// Button configurations matching the refined translucent aesthetic
const buttonConfigs = {
  setup: {
    emoji: '⚙️',
    label: 'Setup',
    color: '#6b7280', // neutral gray
  },
  newGame: {
    emoji: '🎮',
    label: 'New Game',
    color: '#3b82f6', // blue
  },
  quit: {
    emoji: '🏟️',
    label: 'Quit',
    color: '#f59e0b', // amber/orange
  },
}
 
export function GameControlButtons({ onSetup, onNewGame, onQuit }: GameControlButtonsProps) {
  const createButtonStyle = (color: string, isHovered = false): React.CSSProperties => ({
    background: isHovered ? `linear-gradient(135deg, ${color}30, ${color}40)` : `${color}20`,
    border: `2px solid ${color}${isHovered ? '60' : '40'}`,
    borderRadius: '6px',
    padding: '4px 10px',
    fontSize: '12px',
    fontWeight: 'bold',
    color: color,
    cursor: 'pointer',
    display: 'flex',
    alignItems: 'center',
    gap: '4px',
    transition: 'all 0.2s ease',
    boxShadow: isHovered ? `0 2px 8px ${color}30` : 'none',
  })
 
  const handleMouseEnter = (e: React.MouseEvent<HTMLButtonElement>, color: string) => {
    const btn = e.currentTarget
    btn.style.background = `linear-gradient(135deg, ${color}30, ${color}40)`
    btn.style.borderColor = `${color}60`
    btn.style.boxShadow = `0 2px 8px ${color}30`
    btn.style.transform = 'translateY(-1px)'
  }
 
  const handleMouseLeave = (e: React.MouseEvent<HTMLButtonElement>, color: string) => {
    const btn = e.currentTarget
    btn.style.background = `${color}20`
    btn.style.borderColor = `${color}40`
    btn.style.boxShadow = 'none'
    btn.style.transform = 'translateY(0)'
  }
 
  return (
    <div
      style={{
        display: 'flex',
        gap: '6px',
        alignItems: 'center',
        flexWrap: 'nowrap',
      }}
    >
      {onSetup && (
        <button
          type="button"
          onClick={onSetup}
          style={createButtonStyle(buttonConfigs.setup.color)}
          onMouseEnter={(e) => handleMouseEnter(e, buttonConfigs.setup.color)}
          onMouseLeave={(e) => handleMouseLeave(e, buttonConfigs.setup.color)}
          aria-label="Setup game"
        >
          <span style={{ fontSize: '12px' }}>{buttonConfigs.setup.emoji}</span>
          <span style={{ whiteSpace: 'nowrap' }}>{buttonConfigs.setup.label}</span>
        </button>
      )}
 
      {onNewGame && (
        <button
          type="button"
          onClick={onNewGame}
          style={createButtonStyle(buttonConfigs.newGame.color)}
          onMouseEnter={(e) => handleMouseEnter(e, buttonConfigs.newGame.color)}
          onMouseLeave={(e) => handleMouseLeave(e, buttonConfigs.newGame.color)}
          aria-label="Start new game"
        >
          <span style={{ fontSize: '12px' }}>{buttonConfigs.newGame.emoji}</span>
          <span style={{ whiteSpace: 'nowrap' }}>{buttonConfigs.newGame.label}</span>
        </button>
      )}
 
      {onQuit && (
        <button
          type="button"
          onClick={onQuit}
          style={createButtonStyle(buttonConfigs.quit.color)}
          onMouseEnter={(e) => handleMouseEnter(e, buttonConfigs.quit.color)}
          onMouseLeave={(e) => handleMouseLeave(e, buttonConfigs.quit.color)}
          aria-label="Quit to arcade"
        >
          <span style={{ fontSize: '12px' }}>{buttonConfigs.quit.emoji}</span>
          <span style={{ whiteSpace: 'nowrap' }}>{buttonConfigs.quit.label}</span>
        </button>
      )}
    </div>
  )
}