Download components/ProgrammingLevelQuestionnaire.tsx from brightmind-ai/codepractice-ai: direct link, hf CLI and curl.
- Browser
- Download file 7.01 kB
-
https://huggingface.co/spaces/brightmind-ai/codepractice-ai/resolve/main/components/ProgrammingLevelQuestionnaire.tsx
- Command line
-
hf download hf://spaces/brightmind-ai/codepractice-ai/components/ProgrammingLevelQuestionnaire.tsx
-
curl -L -o ProgrammingLevelQuestionnaire.tsx https://huggingface.co/spaces/brightmind-ai/codepractice-ai/resolve/main/components/ProgrammingLevelQuestionnaire.tsx
7.01 kB
| 'use client' | |
| import { useState } from 'react' | |
| import { motion, AnimatePresence } from 'framer-motion' | |
| import { ArrowRight, Code, GraduationCap, Briefcase, Rocket } from 'lucide-react' | |
| import { trackActivity } from '@/lib/activity-tracker' | |
| interface ProgrammingLevelQuestionnaireProps { | |
| isOpen: boolean | |
| onComplete: (level: string) => void | |
| onTrackClick?: (action: string, data?: any) => void | |
| } | |
| const levels = [ | |
| { | |
| id: 'beginner', | |
| label: 'Beginner', | |
| description: 'Just starting out or learning to code', | |
| icon: GraduationCap, | |
| color: 'from-green-500 to-emerald-500' | |
| }, | |
| { | |
| id: 'intermediate', | |
| label: 'Intermediate', | |
| description: 'Some experience, comfortable with basics', | |
| icon: Code, | |
| color: 'from-blue-500 to-cyan-500' | |
| }, | |
| { | |
| id: 'advanced', | |
| label: 'Advanced', | |
| description: 'Experienced developer, ready for challenges', | |
| icon: Briefcase, | |
| color: 'from-purple-500 to-pink-500' | |
| }, | |
| { | |
| id: 'senior', | |
| label: 'Senior', | |
| description: 'Senior developer, preparing for senior roles', | |
| icon: Rocket, | |
| color: 'from-orange-500 to-red-500' | |
| } | |
| ] | |
| export default function ProgrammingLevelQuestionnaire({ isOpen, onComplete, onTrackClick }: ProgrammingLevelQuestionnaireProps) { | |
| const [selectedLevel, setSelectedLevel] = useState<string | null>(null) | |
| if (!isOpen) return null | |
| const handleSelect = (levelId: string) => { | |
| setSelectedLevel(levelId) | |
| onTrackClick?.('programming_level_selected', { level: levelId }) | |
| trackActivity('questionnaire_response', { | |
| question: 'programming_level', | |
| answer: levelId, | |
| page: window.location.pathname | |
| }) | |
| // Auto-advance after a short delay | |
| setTimeout(() => { | |
| onTrackClick?.('programming_level_continue', { level: levelId }) | |
| trackActivity('questionnaire_completed', { | |
| programming_level: levelId, | |
| page: window.location.pathname | |
| }) | |
| onComplete(levelId) | |
| }, 500) // 500ms delay for visual feedback | |
| } | |
| const handleContinue = () => { | |
| if (selectedLevel) { | |
| onTrackClick?.('programming_level_continue', { level: selectedLevel }) | |
| trackActivity('questionnaire_completed', { | |
| programming_level: selectedLevel, | |
| page: window.location.pathname | |
| }) | |
| onComplete(selectedLevel) | |
| } | |
| } | |
| return ( | |
| <AnimatePresence> | |
| {isOpen && ( | |
| <div className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/60 backdrop-blur-sm overflow-y-auto"> | |
| <motion.div | |
| initial={{ opacity: 0, scale: 0.9, y: 20 }} | |
| animate={{ opacity: 1, scale: 1, y: 0 }} | |
| exit={{ opacity: 0, scale: 0.9, y: 20 }} | |
| className="relative w-full max-w-md bg-white dark:bg-gray-800 rounded-2xl shadow-2xl p-6 my-4 max-h-[90vh] flex flex-col" | |
| > | |
| {/* Content - Scrollable */} | |
| <div className="space-y-6 overflow-y-auto flex-1 pr-2"> | |
| {/* Header */} | |
| <div className="text-center"> | |
| <h2 className="text-2xl font-bold text-gray-900 dark:text-white mb-2"> | |
| What's Your Programming Level? | |
| </h2> | |
| <p className="text-gray-600 dark:text-gray-400"> | |
| We'll personalize your practice experience | |
| </p> | |
| </div> | |
| {/* Level Options */} | |
| <div className="space-y-3"> | |
| {levels.map((level) => { | |
| const Icon = level.icon | |
| const isSelected = selectedLevel === level.id | |
| return ( | |
| <motion.button | |
| key={level.id} | |
| onClick={() => handleSelect(level.id)} | |
| whileHover={{ scale: 1.02 }} | |
| whileTap={{ scale: 0.98 }} | |
| className={`w-full p-4 rounded-xl border-2 transition-all text-left ${ | |
| isSelected | |
| ? 'border-primary-600 bg-primary-50 dark:bg-primary-900/20' | |
| : 'border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 hover:border-primary-400' | |
| }`} | |
| > | |
| <div className="flex items-center gap-4"> | |
| <div className={`p-3 rounded-lg bg-gradient-to-r ${level.color}`}> | |
| <Icon className="w-6 h-6 text-white" /> | |
| </div> | |
| <div className="flex-1"> | |
| <p className={`font-semibold ${isSelected ? 'text-primary-600 dark:text-primary-400' : 'text-gray-900 dark:text-white'}`}> | |
| {level.label} | |
| </p> | |
| <p className="text-sm text-gray-600 dark:text-gray-400"> | |
| {level.description} | |
| </p> | |
| </div> | |
| {isSelected && ( | |
| <motion.div | |
| initial={{ scale: 0 }} | |
| animate={{ scale: 1 }} | |
| className="w-6 h-6 rounded-full bg-primary-600 flex items-center justify-center" | |
| > | |
| <svg className="w-4 h-4 text-white" fill="none" viewBox="0 0 24 24" stroke="currentColor"> | |
| <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={3} d="M5 13l4 4L19 7" /> | |
| </svg> | |
| </motion.div> | |
| )} | |
| </div> | |
| </motion.button> | |
| ) | |
| })} | |
| </div> | |
| </div> | |
| {/* Continue Button - Always visible at bottom, sticky */} | |
| <div className="mt-4 pt-4 border-t border-gray-200 dark:border-gray-700 flex-shrink-0"> | |
| {selectedLevel ? ( | |
| <motion.button | |
| onClick={handleContinue} | |
| whileHover={{ scale: 1.02 }} | |
| whileTap={{ scale: 0.98 }} | |
| className="w-full py-4 px-6 font-bold text-lg rounded-xl shadow-lg transition-all flex items-center justify-center gap-2 bg-gradient-to-r from-primary-600 to-purple-600 text-white hover:shadow-xl" | |
| > | |
| <span>Continue</span> | |
| <ArrowRight className="w-5 h-5" /> | |
| </motion.button> | |
| ) : ( | |
| <button | |
| disabled | |
| className="w-full py-4 px-6 font-bold text-lg rounded-xl shadow-lg transition-all flex items-center justify-center gap-2 bg-gray-300 dark:bg-gray-700 text-gray-500 dark:text-gray-400 cursor-not-allowed" | |
| > | |
| <span>Continue</span> | |
| <ArrowRight className="w-5 h-5" /> | |
| </button> | |
| )} | |
| </div> | |
| </motion.div> | |
| </div> | |
| )} | |
| </AnimatePresence> | |
| ) | |
| } | |