Spaces:
Sleeping
Sleeping
Download Frontend/src/pages/Generate/components/SummaryPanel.jsx from smit9604/ExamCraftAI: direct link, hf CLI and curl.
- Browser
- Download file 7.23 kB
-
https://huggingface.co/spaces/smit9604/ExamCraftAI/resolve/main/Frontend/src/pages/Generate/components/SummaryPanel.jsx
- Command line
-
hf download hf://spaces/smit9604/ExamCraftAI/Frontend/src/pages/Generate/components/SummaryPanel.jsx
-
curl -L -o SummaryPanel.jsx https://huggingface.co/spaces/smit9604/ExamCraftAI/resolve/main/Frontend/src/pages/Generate/components/SummaryPanel.jsx
7.23 kB
| import React from 'react'; | |
| import { motion, AnimatePresence } from 'framer-motion'; | |
| import { useGenerate } from '../GenerateContext'; | |
| import { Layers, Activity, FileStack, BookOpen, BrainCircuit } from 'lucide-react'; | |
| import { cn } from '../../../../src/utils/cn'; | |
| export const SummaryPanel = () => { | |
| const { materials, configure, step } = useGenerate(); | |
| // Calculate total questions safely handling objects vs arrays | |
| let totalQuestions = 0; | |
| if (configure?.questionTypes && Array.isArray(configure.questionTypes)) { | |
| totalQuestions = configure.questionTypes.filter(q => q.selected).reduce((acc, curr) => acc + (parseInt(curr.count) || 0), 0); | |
| } else if (configure?.questionTypes) { | |
| totalQuestions = Object.values(configure.questionTypes).reduce((acc, curr) => acc + (parseInt(curr) || 0), 0); | |
| } | |
| const bloomColors = { | |
| remember: 'bg-[#ff6b6b]', | |
| understand: 'bg-[#feca57]', | |
| apply: 'bg-[#1dd1a1]', | |
| analyze: 'bg-[#54a0ff]', | |
| evaluate: 'bg-[#5f27cd]', | |
| create: 'bg-[#ff9ff3]' | |
| }; | |
| return ( | |
| <motion.div | |
| initial={{ opacity: 0, x: 20 }} animate={{ opacity: 1, x: 0 }} | |
| className="w-full lg:w-80 shrink-0 bg-white dark:bg-[#111827] shadow-[0_8px_30px_rgb(0,0,0,0.04)] dark:shadow-[0_8px_30px_rgba(0,0,0,0.4)] rounded-2xl border border-slate-100 dark:border-slate-800 p-6 sm:p-8 flex flex-col max-h-[calc(100vh-8rem)] sticky top-28 overflow-y-auto custom-scrollbar" | |
| > | |
| <h3 className="text-sm font-bold text-slate-900 dark:text-white mb-6 uppercase tracking-widest flex items-center gap-2"> | |
| <BrainCircuit className="text-[#4F7CFF]" size={18} /> Configuration Summary | |
| </h3> | |
| <div className="space-y-6 flex-1"> | |
| {/* Materials selected */} | |
| <div className="space-y-3"> | |
| <p className="text-xs font-semibold text-slate-500 uppercase tracking-wider flex items-center gap-2"> | |
| <FileStack size={14} /> Source Materials | |
| </p> | |
| <div className="flex items-center gap-3"> | |
| <div className="flex flex-col"> | |
| <span className="text-2xl font-black text-slate-900 dark:text-white leading-none">{materials.length}</span> | |
| <span className="text-xs text-slate-500 font-medium mt-1">Files Selected</span> | |
| </div> | |
| {materials.length === 0 && <span className="text-xs text-rose-500 italic">No files selected</span>} | |
| </div> | |
| </div> | |
| <div className="h-px w-full bg-slate-100 dark:bg-slate-800" /> | |
| {/* Difficulty & Type */} | |
| <div className="space-y-3"> | |
| <p className="text-xs font-semibold text-slate-500 uppercase tracking-wider flex items-center gap-2"> | |
| <Activity size={14} /> Difficulty & Format | |
| </p> | |
| <div className="grid grid-cols-2 gap-4"> | |
| <div className="bg-slate-50 dark:bg-[#0F172A] p-3 rounded-xl border border-slate-100 dark:border-slate-800"> | |
| <span className="block text-xl font-bold text-slate-900 dark:text-white"> | |
| {configure.difficulty < 33 ? 'Easy' : configure.difficulty < 66 ? 'Med' : 'Hard'} | |
| </span> | |
| <span className="text-[10px] text-slate-500 font-medium uppercase mt-1">Level</span> | |
| </div> | |
| <div className="bg-slate-50 dark:bg-[#0F172A] p-3 rounded-xl border border-slate-100 dark:border-slate-800"> | |
| <span className="block text-xl font-bold text-slate-900 dark:text-white"> | |
| {totalQuestions} | |
| </span> | |
| <span className="text-[10px] text-slate-500 font-medium uppercase mt-1">Questions</span> | |
| </div> | |
| </div> | |
| </div> | |
| <div className="h-px w-full bg-slate-100 dark:bg-slate-800" /> | |
| {/* Bloom's Breakdown */} | |
| <div className="space-y-4"> | |
| <p className="text-xs font-semibold text-slate-500 uppercase tracking-wider flex items-center gap-2"> | |
| <Layers size={14} /> Cognitive Depth | |
| </p> | |
| {/* Mini donut/bar chart approximation */} | |
| <div className="w-full h-3 rounded-full flex overflow-hidden"> | |
| {Object.entries(configure.bloomsDistribution).map(([key, rawVal]) => { | |
| const val = parseInt(rawVal) || 0; | |
| if (val === 0) return null; | |
| return ( | |
| <div key={key} style={{ width: `${val}%` }} className={cn("h-full transition-all duration-300", bloomColors[key])} title={`${key}: ${val}%`} /> | |
| ); | |
| })} | |
| </div> | |
| <div className="grid grid-cols-2 gap-2 mt-3"> | |
| {Object.entries(configure.bloomsDistribution).map(([key, val]) => { | |
| if (val === 0) return null; | |
| return ( | |
| <div key={key} className="flex flex-col bg-slate-50 dark:bg-[#0F172A] p-2 rounded-lg border border-slate-100 dark:border-slate-800"> | |
| <div className="flex items-center gap-1.5 mb-1"> | |
| <div className={cn("w-2 h-2 rounded-full shadow-sm", bloomColors[key])} /> | |
| <span className="text-[10px] uppercase font-bold text-slate-600 dark:text-slate-400 truncate">{key}</span> | |
| </div> | |
| <span className="text-sm font-black text-slate-900 dark:text-white">{val}%</span> | |
| </div> | |
| ); | |
| })} | |
| </div> | |
| </div> | |
| </div> | |
| {/* Smart AI Recommendation hint based on bloom levels */} | |
| <AnimatePresence> | |
| {step === 2 && configure.bloomsDistribution.remember > 40 && ( | |
| <motion.div | |
| initial={{ opacity: 0, height: 0, y: 10 }} animate={{ opacity: 1, height: 'auto', y: 0 }} | |
| className="mt-6 p-4 rounded-xl bg-amber-50 dark:bg-amber-500/10 border border-amber-200 dark:border-amber-500/20 text-xs text-amber-800 dark:text-amber-200" | |
| > | |
| <p className="font-bold flex items-center gap-1"><BrainCircuit size={14} /> AI Suggestion</p> | |
| <p className="mt-1 font-medium leading-relaxed">This distribution is heavily focused on recall. Consider increasing "Apply" and "Analyze" for a more robust assessment.</p> | |
| </motion.div> | |
| )} | |
| </AnimatePresence> | |
| </motion.div> | |
| ); | |
| }; | |