Download static/index.html from CCockrum/Casseuse: direct link, hf CLI and curl.
- Browser
- Download file 30.4 kB
-
https://huggingface.co/spaces/CCockrum/Casseuse/resolve/main/static/index.html
- Command line
-
hf download hf://spaces/CCockrum/Casseuse/static/index.html
-
curl -L -o index.html https://huggingface.co/spaces/CCockrum/Casseuse/resolve/main/static/index.html
30.4 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8" /> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
| <title>La Casseuse - French Language Tutor</title> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <script crossorigin src="https://unpkg.com/react@18/umd/react.production.min.js"></script> | |
| <script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script> | |
| <script src="https://unpkg.com/@babel/standalone/babel.min.js"></script> | |
| </head> | |
| <body> | |
| <div id="root"></div> | |
| <script type="text/babel"> | |
| const { useState, useEffect, useRef } = React; | |
| // Lucide Icons as inline SVG components | |
| const Send = () => <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2"><line x1="22" y1="2" x2="11" y2="13"></line><polygon points="22 2 15 22 11 13 2 9 22 2"></polygon></svg>; | |
| const Loader2 = () => <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" className="animate-spin"><line x1="12" y1="2" x2="12" y2="6"></line><line x1="12" y1="18" x2="12" y2="22"></line><line x1="4.93" y1="4.93" x2="7.76" y2="7.76"></line><line x1="16.24" y1="16.24" x2="19.07" y2="19.07"></line><line x1="2" y1="12" x2="6" y2="12"></line><line x1="18" y1="12" x2="22" y2="12"></line><line x1="4.93" y1="19.07" x2="7.76" y2="16.24"></line><line x1="16.24" y1="7.76" x2="19.07" y2="4.93"></line></svg>; | |
| const Mic = () => <svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2"><path d="M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"></path><path d="M19 10v2a7 7 0 0 1-14 0v-2"></path><line x1="12" y1="19" x2="12" y2="23"></line><line x1="8" y1="23" x2="16" y2="23"></line></svg>; | |
| const MicOff = () => <svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2"><line x1="1" y1="1" x2="23" y2="23"></line><path d="M9 9v3a3 3 0 0 0 5.12 2.12M15 9.34V4a3 3 0 0 0-5.94-.6"></path><path d="M17 16.95A7 7 0 0 1 5 12v-2m14 0v2a7 7 0 0 1-.11 1.23"></path><line x1="12" y1="19" x2="12" y2="23"></line><line x1="8" y1="23" x2="16" y2="23"></line></svg>; | |
| const Volume2 = ({ size = 16 }) => <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2"><polygon points="11 5 6 9 2 9 2 15 6 15 11 19 11 5"></polygon><path d="M19.07 4.93a10 10 0 0 1 0 14.14M15.54 8.46a5 5 0 0 1 0 7.07"></path></svg>; | |
| const VolumeX = () => <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2"><polygon points="11 5 6 9 2 9 2 15 6 15 11 19 11 5"></polygon><line x1="23" y1="9" x2="17" y2="15"></line><line x1="17" y1="9" x2="23" y2="15"></line></svg>; | |
| const MessageSquare = ({ size = 24 }) => <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path></svg>; | |
| const Settings = ({ size = 20 }) => <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2"><circle cx="12" cy="12" r="3"></circle><path d="M12 1v6m0 6v6m9-9h-6m-6 0H3"></path></svg>; | |
| const BookOpen = ({ size = 20 }) => <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2"><path d="M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z"></path><path d="M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z"></path></svg>; | |
| const Trophy = ({ size = 16 }) => <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2"><path d="M6 9H4.5a2.5 2.5 0 0 1 0-5H6"></path><path d="M18 9h1.5a2.5 2.5 0 0 0 0-5H18"></path><path d="M4 22h16"></path><path d="M10 14.66V17c0 .55-.47.98-.97 1.21C7.85 18.75 7 20.24 7 22"></path><path d="M14 14.66V17c0 .55.47.98.97 1.21C16.15 18.75 17 20.24 17 22"></path><path d="M18 2H6v7a6 6 0 0 0 12 0V2Z"></path></svg>; | |
| const Target = ({ size = 16 }) => <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2"><circle cx="12" cy="12" r="10"></circle><circle cx="12" cy="12" r="6"></circle><circle cx="12" cy="12" r="2"></circle></svg>; | |
| const RotateCcw = ({ size = 20 }) => <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2"><polyline points="1 4 1 10 7 10"></polyline><path d="M3.51 15a9 9 0 1 0 2.13-9.36L1 10"></path></svg>; | |
| function FrenchTutor() { | |
| const [messages, setMessages] = useState([]); | |
| const [input, setInput] = useState(''); | |
| const [loading, setLoading] = useState(false); | |
| const [level, setLevel] = useState('intermediate'); | |
| const [feedbackMode, setFeedbackMode] = useState('balanced'); | |
| const [showSettings, setShowSettings] = useState(false); | |
| const [isListening, setIsListening] = useState(false); | |
| const [autoSpeak, setAutoSpeak] = useState(true); | |
| const [voiceSpeed, setVoiceSpeed] = useState(0.9); | |
| const [currentMode, setCurrentMode] = useState('conversation'); | |
| const [vocabularyList, setVocabularyList] = useState([]); | |
| const [showVocab, setShowVocab] = useState(false); | |
| const [pronunciationScore, setPronunciationScore] = useState(null); | |
| const messagesEndRef = useRef(null); | |
| const recognitionRef = useRef(null); | |
| const synthRef = useRef(window.speechSynthesis); | |
| const conversationTopics = { | |
| beginner: [ | |
| 'Introducing yourself', | |
| 'Ordering food at a café', | |
| 'Asking for directions', | |
| 'Shopping for clothes', | |
| 'Talking about hobbies', | |
| 'Describing your family' | |
| ], | |
| intermediate: [ | |
| 'Planning a vacation', | |
| 'Discussing current events', | |
| 'Describing your job', | |
| 'Talking about movies and books', | |
| 'Health and wellness', | |
| 'French culture and traditions' | |
| ], | |
| advanced: [ | |
| 'Debating social issues', | |
| 'Discussing philosophy and ethics', | |
| 'Analyzing French literature', | |
| 'French politics and history', | |
| 'Business and professional topics', | |
| 'Idioms and expressions' | |
| ] | |
| }; | |
| const scrollToBottom = () => { | |
| messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' }); | |
| }; | |
| useEffect(() => { | |
| scrollToBottom(); | |
| }, [messages]); | |
| useEffect(() => { | |
| if (messages.length === 0) { | |
| const welcomeMessage = { | |
| role: 'assistant', | |
| content: level === 'beginner' | |
| ? "Bonjour ! Je suis La Casseuse, votre tutrice de français. Hello! I'm La Casseuse, your French tutor. Choose a conversation topic or start speaking freely!" | |
| : level === 'intermediate' | |
| ? "Bonjour ! Comment allez-vous ? Choose a topic or start a free conversation. I'll track your vocabulary and help with pronunciation." | |
| : "Bonjour ! Ravi de vous rencontrer. Select a discussion topic or let's have a natural conversation. I'll help you master advanced French.", | |
| timestamp: new Date().toISOString() | |
| }; | |
| setMessages([welcomeMessage]); | |
| if (autoSpeak) { | |
| setTimeout(() => speak(welcomeMessage.content), 500); | |
| } | |
| } | |
| }, [level]); | |
| useEffect(() => { | |
| if ('webkitSpeechRecognition' in window || 'SpeechRecognition' in window) { | |
| const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition; | |
| recognitionRef.current = new SpeechRecognition(); | |
| recognitionRef.current.continuous = false; | |
| recognitionRef.current.interimResults = false; | |
| recognitionRef.current.lang = 'fr-FR'; | |
| recognitionRef.current.onresult = (event) => { | |
| const transcript = event.results[0][0].transcript; | |
| const confidence = event.results[0][0].confidence; | |
| const score = Math.round(confidence * 100); | |
| setPronunciationScore(score); | |
| setInput(transcript); | |
| setIsListening(false); | |
| }; | |
| recognitionRef.current.onerror = (event) => { | |
| console.error('Speech recognition error:', event.error); | |
| setIsListening(false); | |
| }; | |
| recognitionRef.current.onend = () => { | |
| setIsListening(false); | |
| }; | |
| } | |
| return () => { | |
| if (recognitionRef.current) { | |
| recognitionRef.current.stop(); | |
| } | |
| }; | |
| }, []); | |
| const buildSystemPrompt = () => { | |
| const levelDescriptions = { | |
| beginner: 'A1-A2 level learner who is just starting with French. Use simple vocabulary and grammar. Provide translations for most French text. Be encouraging and patient.', | |
| intermediate: 'B1-B2 level learner with basic French knowledge. Use more complex structures. Provide translations selectively. Challenge them while being supportive.', | |
| advanced: 'C1-C2 level learner approaching fluency. Use natural, native-level French. Minimal translations. Focus on nuance, idioms, and cultural context.' | |
| }; | |
| const feedbackDescriptions = { | |
| minimal: 'Only correct major errors. Keep the conversation flowing naturally.', | |
| balanced: 'Correct important errors and occasionally highlight good usage. Balance correction with encouragement.', | |
| detailed: 'Provide thorough feedback on grammar, vocabulary choices, and pronunciation tips. Explain rules and alternatives.' | |
| }; | |
| let basePrompt = `You are La Casseuse, an expert French language tutor having a conversation with a ${levelDescriptions[level]} | |
| Feedback style: ${feedbackDescriptions[feedbackMode]} | |
| Guidelines: | |
| 1. Respond naturally in French at the appropriate level | |
| 2. Keep responses conversational and relatively concise (2-4 sentences typically) since this is spoken conversation | |
| 3. When providing corrections, integrate them naturally | |
| 4. Use encouragement: "Très bien!", "Excellent!", "C'est ça!"`; | |
| if (currentMode === 'vocabulary') { | |
| basePrompt += `\n\nVOCABULARY MODE: At the end of your response, list 2-3 key vocabulary words or phrases from your message in this exact format:\nVOCAB: word1 (translation), word2 (translation), word3 (translation)`; | |
| } else if (currentMode === 'pronunciation') { | |
| basePrompt += `\n\nPRONUNCIATION MODE: Focus on helping them pronounce difficult words. When they make pronunciation errors, gently correct them and provide tips on French phonetics.`; | |
| } | |
| basePrompt += `\n\nFor beginners: Provide English translations in parentheses after French sentences.\nFor intermediate: Provide translations only for complex phrases or new vocabulary.\nFor advanced: Use French almost exclusively, with minimal English support.`; | |
| return basePrompt; | |
| }; | |
| const extractVocabulary = (text) => { | |
| const vocabMatch = text.match(/VOCAB: (.+?)(?:\n|$)/); | |
| if (vocabMatch) { | |
| const vocabItems = vocabMatch[1].split(',').map(item => { | |
| const parts = item.trim().match(/(.+?)\s*\((.+?)\)/); | |
| if (parts) { | |
| return { word: parts[1].trim(), translation: parts[2].trim() }; | |
| } | |
| return null; | |
| }).filter(Boolean); | |
| setVocabularyList(prev => [...vocabItems, ...prev].slice(0, 30)); | |
| return text.replace(/VOCAB: .+?(?:\n|$)/, '').trim(); | |
| } | |
| return text; | |
| }; | |
| const handleSend = async (textToSend = input) => { | |
| if (!textToSend.trim() || loading) return; | |
| const userMessage = { | |
| role: 'user', | |
| content: textToSend, | |
| timestamp: new Date().toISOString() | |
| }; | |
| setMessages(prev => [...prev, userMessage]); | |
| setInput(''); | |
| setLoading(true); | |
| try { | |
| const conversationHistory = [...messages, userMessage].map(msg => ({ | |
| role: msg.role, | |
| content: msg.content | |
| })); | |
| // Call OUR backend instead of Claude directly | |
| const response = await fetch('/api/chat', { | |
| method: 'POST', | |
| headers: { | |
| 'Content-Type': 'application/json', | |
| }, | |
| body: JSON.stringify({ | |
| model: 'claude-sonnet-4-20250514', | |
| max_tokens: 1000, | |
| system: buildSystemPrompt(), | |
| messages: conversationHistory | |
| }) | |
| }); | |
| const data = await response.json(); | |
| if (data.content && data.content[0]) { | |
| let content = data.content[0].text; | |
| if (currentMode === 'vocabulary') { | |
| content = extractVocabulary(content); | |
| } | |
| const assistantMessage = { | |
| role: 'assistant', | |
| content: content, | |
| timestamp: new Date().toISOString() | |
| }; | |
| setMessages(prev => [...prev, assistantMessage]); | |
| if (autoSpeak) { | |
| setTimeout(() => speak(assistantMessage.content), 300); | |
| } | |
| } else if (data.error) { | |
| setMessages(prev => [...prev, { | |
| role: 'assistant', | |
| content: `Error: ${data.error}`, | |
| timestamp: new Date().toISOString() | |
| }]); | |
| } | |
| } catch (error) { | |
| console.error('Error:', error); | |
| setMessages(prev => [...prev, { | |
| role: 'assistant', | |
| content: 'Désolé, there was an error. Please try again.', | |
| timestamp: new Date().toISOString() | |
| }]); | |
| } finally { | |
| setLoading(false); | |
| } | |
| }; | |
| const speak = (text) => { | |
| synthRef.current.cancel(); | |
| const cleanText = text.replace(/[✏️📚🗣️🇫🇷*]/g, '').replace(/\([^)]*\)/g, ''); | |
| const utterance = new SpeechSynthesisUtterance(cleanText); | |
| utterance.lang = 'fr-FR'; | |
| utterance.rate = voiceSpeed; | |
| const voices = synthRef.current.getVoices(); | |
| const frenchVoice = voices.find(voice => voice.lang.startsWith('fr')); | |
| if (frenchVoice) { | |
| utterance.voice = frenchVoice; | |
| } | |
| synthRef.current.speak(utterance); | |
| }; | |
| const toggleListening = () => { | |
| if (!recognitionRef.current) { | |
| alert('Speech recognition is not supported in your browser. Please use Chrome, Edge, or Safari.'); | |
| return; | |
| } | |
| if (isListening) { | |
| recognitionRef.current.stop(); | |
| setIsListening(false); | |
| } else { | |
| synthRef.current.cancel(); | |
| setInput(''); | |
| setPronunciationScore(null); | |
| recognitionRef.current.start(); | |
| setIsListening(true); | |
| } | |
| }; | |
| const stopSpeaking = () => { | |
| synthRef.current.cancel(); | |
| }; | |
| const startTopicConversation = async (topic) => { | |
| const topicMessage = `Let's practice: ${topic}`; | |
| setInput(topicMessage); | |
| await handleSend(topicMessage); | |
| }; | |
| const resetConversation = () => { | |
| setMessages([]); | |
| setVocabularyList([]); | |
| setPronunciationScore(null); | |
| const welcomeMessage = { | |
| role: 'assistant', | |
| content: "Bonjour ! Ready for a new conversation? Choose a topic or start speaking!", | |
| timestamp: new Date().toISOString() | |
| }; | |
| setMessages([welcomeMessage]); | |
| if (autoSpeak) speak(welcomeMessage.content); | |
| }; | |
| useEffect(() => { | |
| if (input && !isListening) { | |
| handleSend(input); | |
| } | |
| }, [input, isListening]); | |
| const getPronunciationColor = (score) => { | |
| if (score >= 80) return 'text-green-600'; | |
| if (score >= 60) return 'text-yellow-600'; | |
| return 'text-red-600'; | |
| }; | |
| const getPronunciationLabel = (score) => { | |
| if (score >= 90) return 'Excellent!'; | |
| if (score >= 80) return 'Very Good'; | |
| if (score >= 70) return 'Good'; | |
| if (score >= 60) return 'Fair'; | |
| return 'Keep Practicing'; | |
| }; | |
| return ( | |
| <div className="flex flex-col h-screen bg-gradient-to-br from-blue-50 to-indigo-50"> | |
| {/* Header */} | |
| <div className="bg-white shadow-sm border-b border-gray-200 px-6 py-4"> | |
| <div className="flex items-center justify-between max-w-6xl mx-auto"> | |
| <div className="flex items-center gap-3"> | |
| <div className="bg-blue-600 text-white p-2 rounded-lg"> | |
| <MessageSquare size={24} /> | |
| </div> | |
| <div> | |
| <h1 className="text-2xl font-bold text-gray-900">La Casseuse</h1> | |
| <p className="text-sm text-gray-600">Your French conversation partner</p> | |
| </div> | |
| </div> | |
| <div className="flex gap-2"> | |
| <button | |
| onClick={() => setShowVocab(!showVocab)} | |
| className={`p-2 rounded-lg transition-colors ${showVocab ? 'bg-blue-100 text-blue-600' : 'hover:bg-gray-100 text-gray-600'}`} | |
| title="Vocabulary List" | |
| > | |
| <BookOpen size={20} /> | |
| {vocabularyList.length > 0 && ( | |
| </div> | |
| </div> | |
| ))} | |
| {loading && ( | |
| <div className="flex justify-start"> | |
| <div className="bg-white text-gray-900 shadow-sm border border-gray-200 rounded-2xl px-4 py-3"> | |
| <Loader2 /> | |
| </div> | |
| </div> | |
| )} | |
| <div ref={messagesEndRef} /> | |
| </div> | |
| </div> | |
| </div> | |
| {/* Voice Controls */} | |
| <div className="bg-white border-t border-gray-200 px-4 py-6"> | |
| <div className="max-w-6xl mx-auto"> | |
| <div className="flex flex-col items-center gap-4"> | |
| {/* Microphone Button */} | |
| <button | |
| onClick={toggleListening} | |
| disabled={loading} | |
| className={`w-20 h-20 rounded-full flex items-center justify-center transition-all shadow-lg ${ | |
| isListening | |
| ? 'bg-red-500 hover:bg-red-600 animate-pulse' | |
| : 'bg-blue-600 hover:bg-blue-700' | |
| } text-white disabled:opacity-50 disabled:cursor-not-allowed`} | |
| > | |
| {isListening ? <MicOff /> : <Mic />} | |
| </button> | |
| {isListening && ( | |
| <div className="text-center"> | |
| <p className="text-sm font-medium text-gray-700">Listening...</p> | |
| <p className="text-xs text-gray-500">Speak in French</p> | |
| </div> | |
| )} | |
| {/* Text Input Alternative */} | |
| <div className="w-full flex gap-2"> | |
| <input | |
| type="text" | |
| value={input} | |
| onChange={(e) => setInput(e.target.value)} | |
| onKeyPress={(e) => e.key === 'Enter' && handleSend()} | |
| placeholder="Or type your message in French..." | |
| className="flex-1 px-4 py-2 border border-gray-300 rounded-xl focus:ring-2 focus:ring-blue-500 focus:border-transparent text-sm" | |
| disabled={loading || isListening} | |
| /> | |
| <button | |
| onClick={() => handleSend()} | |
| disabled={loading || !input.trim() || isListening} | |
| className="bg-blue-600 text-white px-4 py-2 rounded-xl hover:bg-blue-700 transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2" | |
| > | |
| {loading ? <Loader2 /> : <Send />} | |
| </button> | |
| <button | |
| onClick={stopSpeaking} | |
| className="bg-gray-600 text-white px-4 py-2 rounded-xl hover:bg-gray-700 transition-colors flex items-center gap-2" | |
| title="Stop speaking" | |
| > | |
| <VolumeX /> | |
| </button> | |
| </div> | |
| <p className="text-xs text-gray-500 text-center"> | |
| Click microphone to speak • Choose topics from sidebar • {currentMode === 'vocabulary' && 'Building vocabulary list'} | |
| </p> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| ); | |
| } | |
| ReactDOM.createRoot(document.getElementById('root')).render(<FrenchTutor />); | |
| </script> | |
| </body> | |
| </html><span className="ml-1 text-xs font-bold">{vocabularyList.length}</span> | |
| )} | |
| </button> | |
| <button | |
| onClick={resetConversation} | |
| className="p-2 hover:bg-gray-100 rounded-lg transition-colors text-gray-600" | |
| title="New Conversation" | |
| > | |
| <RotateCcw size={20} /> | |
| </button> | |
| <button | |
| onClick={() => setShowSettings(!showSettings)} | |
| className="p-2 hover:bg-gray-100 rounded-lg transition-colors text-gray-600" | |
| > | |
| <Settings size={20} /> | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| {/* Mode Selector */} | |
| <div className="bg-white border-b border-gray-200 px-6 py-3"> | |
| <div className="max-w-6xl mx-auto flex gap-2"> | |
| <button | |
| onClick={() => setCurrentMode('conversation')} | |
| className={`px-4 py-2 rounded-lg text-sm font-medium transition-colors ${ | |
| currentMode === 'conversation' | |
| ? 'bg-blue-600 text-white' | |
| : 'bg-gray-100 text-gray-700 hover:bg-gray-200' | |
| }`} | |
| > | |
| <MessageSquare size={16} style={{display: 'inline', marginRight: '4px'}} /> | |
| Free Talk | |
| </button> | |
| <button | |
| onClick={() => setCurrentMode('vocabulary')} | |
| className={`px-4 py-2 rounded-lg text-sm font-medium transition-colors ${ | |
| currentMode === 'vocabulary' | |
| ? 'bg-blue-600 text-white' | |
| : 'bg-gray-100 text-gray-700 hover:bg-gray-200' | |
| }`} | |
| > | |
| <BookOpen size={16} style={{display: 'inline', marginRight: '4px'}} /> | |
| Vocabulary Builder | |
| </button> | |
| <button | |
| onClick={() => setCurrentMode('pronunciation')} | |
| className={`px-4 py-2 rounded-lg text-sm font-medium transition-colors ${ | |
| currentMode === 'pronunciation' | |
| ? 'bg-blue-600 text-white' | |
| : 'bg-gray-100 text-gray-700 hover:bg-gray-200' | |
| }`} | |
| > | |
| Pronunciation Practice | |
| </button> | |
| </div> | |
| </div> | |
| {/* Settings Panel */} | |
| {showSettings && ( | |
| <div className="bg-white border-b border-gray-200 px-6 py-4"> | |
| <div className="max-w-6xl mx-auto"> | |
| <div className="grid grid-cols-1 md:grid-cols-2 gap-4"> | |
| <div> | |
| <label className="block text-sm font-medium text-gray-700 mb-2"> | |
| Proficiency Level | |
| </label> | |
| <select | |
| value={level} | |
| onChange={(e) => setLevel(e.target.value)} | |
| className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" | |
| > | |
| <option value="beginner">Beginner (A1-A2)</option> | |
| <option value="intermediate">Intermediate (B1-B2)</option> | |
| <option value="advanced">Advanced (C1-C2)</option> | |
| </select> | |
| </div> | |
| <div> | |
| <label className="block text-sm font-medium text-gray-700 mb-2"> | |
| Feedback Style | |
| </label> | |
| <select | |
| value={feedbackMode} | |
| onChange={(e) => setFeedbackMode(e.target.value)} | |
| className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" | |
| > | |
| <option value="minimal">Minimal - Flow over accuracy</option> | |
| <option value="balanced">Balanced - Mix of both</option> | |
| <option value="detailed">Detailed - Maximum learning</option> | |
| </select> | |
| </div> | |
| <div> | |
| <label className="flex items-center gap-2"> | |
| <input | |
| type="checkbox" | |
| checked={autoSpeak} | |
| onChange={(e) => setAutoSpeak(e.target.checked)} | |
| className="w-4 h-4 text-blue-600 rounded" | |
| /> | |
| <span className="text-sm font-medium text-gray-700"> | |
| Auto-play responses | |
| </span> | |
| </label> | |
| </div> | |
| <div> | |
| <label className="block text-sm font-medium text-gray-700 mb-2"> | |
| Voice Speed: {voiceSpeed.toFixed(1)}x | |
| </label> | |
| <input | |
| type="range" | |
| min="0.5" | |
| max="1.5" | |
| step="0.1" | |
| value={voiceSpeed} | |
| onChange={(e) => setVoiceSpeed(parseFloat(e.target.value))} | |
| className="w-full" | |
| /> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| )} | |
| {/* Vocabulary Sidebar */} | |
| {showVocab && ( | |
| <div className="bg-white border-b border-gray-200 px-6 py-4 max-h-64 overflow-y-auto"> | |
| <div className="max-w-6xl mx-auto"> | |
| <h3 className="text-lg font-bold text-gray-900 mb-3 flex items-center gap-2"> | |
| <BookOpen size={20} /> | |
| Your Vocabulary ({vocabularyList.length}) | |
| </h3> | |
| {vocabularyList.length === 0 ? ( | |
| <p className="text-gray-500 text-sm">Start a vocabulary building session to collect new words!</p> | |
| ) : ( | |
| <div className="grid grid-cols-1 md:grid-cols-3 gap-2"> | |
| {vocabularyList.map((item, idx) => ( | |
| <div key={idx} className="bg-blue-50 rounded-lg p-2"> | |
| <p className="font-semibold text-blue-900">{item.word}</p> | |
| <p className="text-sm text-gray-600">{item.translation}</p> | |
| </div> | |
| ))} | |
| </div> | |
| )} | |
| </div> | |
| </div> | |
| )} | |
| <div className="flex-1 flex overflow-hidden"> | |
| {/* Topic Selector Sidebar */} | |
| <div className="w-64 bg-white border-r border-gray-200 overflow-y-auto p-4"> | |
| <h3 className="text-sm font-bold text-gray-900 mb-3 flex items-center gap-2"> | |
| <Target size={16} /> | |
| Conversation Topics | |
| </h3> | |
| <div className="space-y-2"> | |
| {conversationTopics[level].map((topic, idx) => ( | |
| <button | |
| key={idx} | |
| onClick={() => startTopicConversation(topic)} | |
| disabled={loading} | |
| className="w-full text-left px-3 py-2 text-sm rounded-lg bg-gray-50 hover:bg-blue-50 hover:text-blue-700 transition-colors disabled:opacity-50" | |
| > | |
| {topic} | |
| </button> | |
| ))} | |
| </div> | |
| {pronunciationScore !== null && ( | |
| <div className="mt-6 p-3 bg-gradient-to-br from-purple-50 to-pink-50 rounded-lg"> | |
| <div className="flex items-center gap-2 mb-2"> | |
| <Trophy size={16} /> | |
| <span className="text-sm font-bold text-gray-900">Last Score</span> | |
| </div> | |
| <div className={`text-3xl font-bold ${getPronunciationColor(pronunciationScore)}`}> | |
| {pronunciationScore}% | |
| </div> | |
| <p className="text-xs text-gray-600 mt-1">{getPronunciationLabel(pronunciationScore)}</p> | |
| </div> | |
| )} | |
| </div> | |
| {/* Messages */} | |
| <div className="flex-1 overflow-y-auto px-4 py-6"> | |
| <div className="max-w-4xl mx-auto space-y-4"> | |
| {messages.map((msg, idx) => ( | |
| <div | |
| key={idx} | |
| className={`flex ${msg.role === 'user' ? 'justify-end' : 'justify-start'}`} | |
| > | |
| <div | |
| className={`max-w-2xl rounded-2xl px-4 py-3 ${ | |
| msg.role === 'user' | |
| ? 'bg-blue-600 text-white' | |
| : 'bg-white text-gray-900 shadow-sm border border-gray-200' | |
| }`} | |
| > | |
| <div className="flex items-start gap-2"> | |
| <div className="flex-1 whitespace-pre-wrap break-words"> | |
| {msg.content} | |
| </div> | |
| {msg.role === 'assistant' && ( | |
| <button | |
| onClick={() => speak(msg.content)} | |
| className="flex-shrink-0 p-1 hover:bg-gray-100 rounded transition-colors" | |
| title="Listen" | |
| > | |
| <Volume2 size={16} /> | |
| </button> | |
| )} | |
| </div> |