please make it so this keyboard is not fixed width and scales to be easy to use on…
- User
please make it so this keyboard is not fixed width and scales to be easy to use on iphone: import React from 'react' import { checkGuess } from '../utils/gameLogic'
interface KeyboardProps { onKeyPress: (key: string) => void guesses: string[] secretWord: string }
const Keyboard: React.FC = ({ onKeyPress, guesses, secretWord }) => { const rows = [ ['q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p'], ['a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l'], ['Enter', 'z', 'x', 'c', 'v', 'b', 'n', 'm', 'Backspace'] ]
const getKeyStatus = (key: string) => { let status = '' for (const guess of guesses) { const statuses = checkGuess(guess, secretWord) const index = guess.indexOf(key) if (index !== -1) { if (statuses[index] === 'correct') return 'correct' if (statuses[index] === 'present') status = 'present' if (statuses[index] === 'absent' && status === '') status = 'absent' } } return status }
return ( {rows.map((row, rowIndex) => ( {row.map((key) => { const status = getKeyStatus(key.toLowerCase()) // Determine if the key is special (Enter or Backspace) const isSpecialKey = key === 'Enter' || key === 'Backspace' return ( <button key={key} onClick={() => onKeyPress(key)} className={
flex justify-center items-center mx-0.5 px-1 py-3 rounded font-semibold text-sm ${ isSpecialKey ? 'flex-[1.5]' : 'flex-1' } ${ status === 'correct' ? 'bg-green-500 text-white' : status === 'present' ? 'bg-yellow-500 text-white' : status === 'absent' ? 'bg-gray-400 text-white' : 'bg-gray-200' }} > {key === 'Backspace' ? '←' : key} ) })} ))} ) }export default Keyboard
- Assistant