analytica-frontend-lib
Version:
Repositório público dos componentes utilizados nas plataformas da Analytica Ensino
1 lines • 6.84 kB
Source Map (JSON)
{"version":3,"sources":["../src/components/StudentRanking/StudentRanking.tsx"],"sourcesContent":["import { type HTMLAttributes } from 'react';\nimport { TrendUpIcon } from '@phosphor-icons/react/dist/csr/TrendUp';\nimport { TrendDownIcon } from '@phosphor-icons/react/dist/csr/TrendDown';\nimport Text from '../Text/Text';\nimport { cn } from '../../utils/utils';\nimport type { StudentHighlightItem } from '../../hooks/useStudentsHighlight';\nimport {\n type RankingVariant,\n BADGE_BACKGROUND_CLASSES,\n PERCENTAGE_BADGE_CLASSES,\n getPositionBackgroundClass,\n BaseRankingCard,\n RankingLayout,\n} from '../shared/RankingShared';\n\n/**\n * Re-export RankingVariant as StudentRankingVariant for backwards compatibility\n */\nexport type StudentRankingVariant = RankingVariant;\n\n/**\n * Re-export StudentHighlightItem as StudentRankingItem for backwards compatibility\n * and direct usage with the component\n */\nexport type StudentRankingItem = Pick<\n StudentHighlightItem,\n 'position' | 'name' | 'percentage'\n>;\n\n/**\n * Individual student card component\n */\nconst StudentCard = ({\n student,\n variant,\n}: {\n student: StudentRankingItem;\n variant: RankingVariant;\n}) => {\n const TrendIcon = variant === 'highlight' ? TrendUpIcon : TrendDownIcon;\n const backgroundClass = getPositionBackgroundClass(variant, student.position);\n\n return (\n <div\n className={cn(\n 'flex flex-row items-center w-full p-4 gap-2 rounded-xl',\n backgroundClass\n )}\n >\n {/* Position badge */}\n <Text\n size=\"xs\"\n weight=\"bold\"\n aria-label={`Posição ${student.position}`}\n className={cn(\n 'w-5 h-5 rounded-full flex items-center justify-center text-text',\n BADGE_BACKGROUND_CLASSES[variant]\n )}\n >\n {student.position}\n </Text>\n\n {/* Student name */}\n <Text\n size=\"sm\"\n weight=\"bold\"\n className=\"flex-1 min-w-0 text-text-950 tracking-[0.2px] truncate\"\n >\n {student.name}\n </Text>\n\n {/* Percentage badge */}\n <Text\n size=\"xs\"\n weight=\"bold\"\n aria-label={`Desempenho ${student.percentage}%`}\n className={cn(\n 'flex flex-row items-center h-[22px] px-2 gap-1 rounded text-text',\n PERCENTAGE_BADGE_CLASSES[variant]\n )}\n >\n <TrendIcon size={16} weight=\"bold\" aria-hidden=\"true\" />\n {student.percentage}%\n </Text>\n </div>\n );\n};\n\n/**\n * Props for a single ranking card\n */\nexport interface RankingCardProps extends HTMLAttributes<HTMLDivElement> {\n /** Card title */\n title: string;\n /** Card variant: highlight (best students) or attention (needs attention) */\n variant: RankingVariant;\n /** List of students to display */\n students: StudentRankingItem[];\n}\n\n/**\n * Single ranking card component (can be used independently)\n */\nexport const RankingCard = ({\n title,\n variant,\n students,\n className,\n ...props\n}: RankingCardProps) => (\n <BaseRankingCard\n title={title}\n variant={variant}\n items={students}\n renderItem={(student, v, index) => (\n <StudentCard\n key={`${v}-${index}-${student.position}`}\n student={student}\n variant={v}\n />\n )}\n className={className}\n {...props}\n />\n);\n\n/**\n * Props for the StudentRanking component\n */\nexport interface StudentRankingProps extends HTMLAttributes<HTMLDivElement> {\n /** Title for the highlight (best students) card */\n highlightTitle?: string;\n /** Title for the attention (needs attention) card */\n attentionTitle?: string;\n /** List of highlighted (best performing) students */\n highlightStudents: StudentRankingItem[];\n /** List of students needing attention (lowest performing) */\n attentionStudents: StudentRankingItem[];\n}\n\n/**\n * StudentRanking component - displays two cards side by side showing\n * the best performing students and students that need attention.\n *\n * @example\n * ```tsx\n * <StudentRanking\n * highlightTitle=\"Estudantes em destaque\"\n * attentionTitle=\"Estudantes precisando de atenção\"\n * highlightStudents={[\n * { position: 1, name: 'Valentina Ribeiro', percentage: 100 },\n * { position: 2, name: 'Lucas Almeida', percentage: 100 },\n * { position: 3, name: 'Fernanda Costa', percentage: 100 },\n * ]}\n * attentionStudents={[\n * { position: 1, name: 'Ricardo Silva', percentage: 80 },\n * { position: 2, name: 'Juliana Santos', percentage: 50 },\n * { position: 3, name: 'Gabriel Oliveira', percentage: 40 },\n * ]}\n * />\n * ```\n */\nexport const StudentRanking = ({\n highlightTitle = 'Estudantes em destaque',\n attentionTitle = 'Estudantes precisando de atenção',\n highlightStudents,\n attentionStudents,\n className,\n ...props\n}: StudentRankingProps) => {\n return (\n <RankingLayout className={className} {...props}>\n <RankingCard\n title={highlightTitle}\n variant=\"highlight\"\n students={highlightStudents}\n />\n <RankingCard\n title={attentionTitle}\n variant=\"attention\"\n students={attentionStudents}\n />\n </RankingLayout>\n );\n};\n\nexport default StudentRanking;\n"],"mappings":";;;;;;;;;;;;;;;AACA,SAAS,mBAAmB;AAC5B,SAAS,qBAAqB;AAgDxB,cAsBA,YAtBA;AAlBN,IAAM,cAAc,CAAC;AAAA,EACnB;AAAA,EACA;AACF,MAGM;AACJ,QAAM,YAAY,YAAY,cAAc,cAAc;AAC1D,QAAM,kBAAkB,2BAA2B,SAAS,QAAQ,QAAQ;AAE5E,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAW;AAAA,QACT;AAAA,QACA;AAAA,MACF;AAAA,MAGA;AAAA;AAAA,UAAC;AAAA;AAAA,YACC,MAAK;AAAA,YACL,QAAO;AAAA,YACP,cAAY,iBAAW,QAAQ,QAAQ;AAAA,YACvC,WAAW;AAAA,cACT;AAAA,cACA,yBAAyB,OAAO;AAAA,YAClC;AAAA,YAEC,kBAAQ;AAAA;AAAA,QACX;AAAA,QAGA;AAAA,UAAC;AAAA;AAAA,YACC,MAAK;AAAA,YACL,QAAO;AAAA,YACP,WAAU;AAAA,YAET,kBAAQ;AAAA;AAAA,QACX;AAAA,QAGA;AAAA,UAAC;AAAA;AAAA,YACC,MAAK;AAAA,YACL,QAAO;AAAA,YACP,cAAY,cAAc,QAAQ,UAAU;AAAA,YAC5C,WAAW;AAAA,cACT;AAAA,cACA,yBAAyB,OAAO;AAAA,YAClC;AAAA,YAEA;AAAA,kCAAC,aAAU,MAAM,IAAI,QAAO,QAAO,eAAY,QAAO;AAAA,cACrD,QAAQ;AAAA,cAAW;AAAA;AAAA;AAAA,QACtB;AAAA;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