All files / web/src/components/practice DebugOverlay.tsx

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

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 121 122 123 124 125 126 127 128                                                                                                                                                                                                                                                               
'use client'

import { css } from '../../../styled-system/css'

interface DebugOverlayProps {
  /** The correct answer for the current problem */
  correctAnswer: number
  /** Current part index (0-based) */
  partIndex: number
  /** Current slot index within the part */
  slotIndex: number
  /** Current part type */
  partType: string
  /** Slot purpose */
  purpose: string
  /** Submit the correct answer */
  onSubmitCorrect: () => void
  /** Submit a wrong answer */
  onSubmitWrong: () => void
}

/**
 * Floating debug panel shown when URL has ?debug=1
 * Provides quick submit buttons for automated testing
 */
export function DebugOverlay({
  correctAnswer,
  partIndex,
  slotIndex,
  partType,
  purpose,
  onSubmitCorrect,
  onSubmitWrong,
}: DebugOverlayProps) {
  return (
    <div
      data-component="debug-overlay"
      className={css({
        position: 'fixed',
        bottom: '80px',
        right: '16px',
        zIndex: 9999,
        backgroundColor: 'rgba(0, 0, 0, 0.85)',
        color: 'white',
        borderRadius: '12px',
        padding: '12px 16px',
        fontSize: '13px',
        fontFamily: 'mono',
        display: 'flex',
        flexDirection: 'column',
        gap: '8px',
        minWidth: '200px',
        boxShadow: '0 4px 20px rgba(0,0,0,0.4)',
        border: '1px solid rgba(255,255,255,0.15)',
      })}
    >
      {/* Header */}
      <div
        data-element="debug-header"
        className={css({
          display: 'flex',
          justifyContent: 'space-between',
          alignItems: 'center',
          borderBottom: '1px solid rgba(255,255,255,0.2)',
          paddingBottom: '6px',
        })}
      >
        <span className={css({ fontWeight: 'bold', color: '#ff6b6b' })}>DEBUG</span>
        <span className={css({ color: 'rgba(255,255,255,0.6)', fontSize: '11px' })}>
          Part {partIndex + 1} / Slot {slotIndex + 1}
        </span>
      </div>

      {/* Problem info */}
      <div data-element="debug-info" className={css({ color: 'rgba(255,255,255,0.7)' })}>
        <div>
          Type: {partType} | {purpose}
        </div>
        <div data-element="debug-answer" className={css({ fontWeight: 'bold', color: '#4ade80' })}>
          Answer: {correctAnswer}
        </div>
      </div>

      {/* Action buttons */}
      <div data-element="debug-actions" className={css({ display: 'flex', gap: '8px' })}>
        <button
          data-action="debug-submit-correct"
          onClick={onSubmitCorrect}
          className={css({
            flex: 1,
            padding: '8px 12px',
            borderRadius: '8px',
            border: 'none',
            backgroundColor: '#22c55e',
            color: 'white',
            fontWeight: 'bold',
            fontSize: '13px',
            cursor: 'pointer',
            transition: 'opacity 0.15s',
            _hover: { opacity: 0.85 },
          })}
        >
          Submit Correct
        </button>
        <button
          data-action="debug-submit-wrong"
          onClick={onSubmitWrong}
          className={css({
            flex: 1,
            padding: '8px 12px',
            borderRadius: '8px',
            border: 'none',
            backgroundColor: '#ef4444',
            color: 'white',
            fontWeight: 'bold',
            fontSize: '13px',
            cursor: 'pointer',
            transition: 'opacity 0.15s',
            _hover: { opacity: 0.85 },
          })}
        >
          Submit Wrong
        </button>
      </div>
    </div>
  )
}