'use client' import { useState, useRef, useEffect, useCallback } from 'react' import { SimpleCard, CONFIDENCE_LEVELS } from '../data' interface SimpleFlipCardProps { card: SimpleCard onAnswer: (confidence: number) => void } export function SimpleFlipCard({ card, onAnswer }: SimpleFlipCardProps) { const [isFlipped, setIsFlipped] = useState(false) const [selectedConfidence, setSelectedConfidence] = useState(null) const [cardHeight, setCardHeight] = useState(400) const frontRef = useRef(null) const backRef = useRef(null) // 智能高度計算 (復用原有邏輯) useEffect(() => { const updateCardHeight = () => { if (backRef.current) { const backHeight = backRef.current.scrollHeight // 響應式最小高度設定 (復用原有響應式邏輯) const minHeightByScreen = window.innerWidth <= 480 ? 300 : window.innerWidth <= 768 ? 350 : 400 const finalHeight = Math.max(minHeightByScreen, backHeight) setCardHeight(finalHeight) } } const timer = setTimeout(updateCardHeight, 100) window.addEventListener('resize', updateCardHeight) return () => { clearTimeout(timer) window.removeEventListener('resize', updateCardHeight) } }, [card.word, card.definition, card.example]) const handleFlip = useCallback(() => { setIsFlipped(!isFlipped) }, [isFlipped]) const handleConfidenceSelect = useCallback((level: number) => { setSelectedConfidence(level) }, []) const handleSubmit = () => { if (selectedConfidence) { onAnswer(selectedConfidence) // 重置狀態為下一張卡片準備 setIsFlipped(false) setSelectedConfidence(null) } } const hasAnswered = selectedConfidence !== null return (
{/* 高級3D翻卡容器 (復用原有設計) */}
{/* 正面 - 單字 (復用原有設計風格) */}

點擊卡片翻面,根據你對單字的熟悉程度進行自我評估:

{card.word}

{card.pronunciation}
{/* 背面 - 詳細資訊 (復用原有布局) */}
{/* 定義區塊 */}

定義

{card.definition}

{/* 例句區塊 */}

例句

"{card.example}"

"{card.translation}"

{/* 信心度選擇 - 復用原有的精美設計 */} {isFlipped && (

請選擇您對這個詞彙的熟悉程度:

{CONFIDENCE_LEVELS.map(({ level, label, color }) => { const isSelected = selectedConfidence === level const colorClasses = { 'bg-red-500': 'bg-red-100 text-red-700 border-red-200 hover:bg-red-200', 'bg-orange-500': 'bg-orange-100 text-orange-700 border-orange-200 hover:bg-orange-200', 'bg-yellow-500': 'bg-yellow-100 text-yellow-700 border-yellow-200 hover:bg-yellow-200', 'bg-blue-500': 'bg-blue-100 text-blue-700 border-blue-200 hover:bg-blue-200', 'bg-green-500': 'bg-green-100 text-green-700 border-green-200 hover:bg-green-200' }[color] || 'bg-gray-100 text-gray-700 border-gray-200 hover:bg-gray-200' return ( ) })}
{/* 提交按鈕 - 選擇後顯示 */} {hasAnswered && ( )}
)} {/* 翻卡提示 - 只在未翻轉時顯示 */} {!isFlipped && (

點擊卡片翻轉查看詳細資訊

)}
) }