UNPKG

analytica-frontend-lib

Version:

Repositório público dos componentes utilizados nas plataformas da Analytica Ensino

183 lines (181 loc) 5.19 kB
import { BADGE_BACKGROUND_CLASSES, BaseRankingCard, PERCENTAGE_BADGE_CLASSES, RankingLayout, getPositionBackgroundClass } from "./chunk-Z7JWDZES.mjs"; import { Text_default } from "./chunk-IMCIR6TJ.mjs"; import { cn } from "./chunk-53ICLDGS.mjs"; // src/components/PerformanceRanking/PerformanceRanking.tsx import { TrendUpIcon, TrendDownIcon, MedalIcon, SealWarningIcon } from "@phosphor-icons/react"; import { jsx, jsxs } from "react/jsx-runtime"; var POSITION_TEXT_CLASSES = { highlight: "text-text-950", attention: "text-text" }; var COUNT_BADGE_CLASSES = { highlight: "bg-success-background text-success-800", attention: "bg-error-background text-error-800" }; function TrendIcon({ trend, variant }) { if (trend === "up") { return /* @__PURE__ */ jsx(TrendUpIcon, { size: 16, weight: "bold", "aria-hidden": "true" }); } if (trend === "down") { return /* @__PURE__ */ jsx(TrendDownIcon, { size: 16, weight: "bold", "aria-hidden": "true" }); } const DefaultIcon = variant === "highlight" ? TrendUpIcon : TrendDownIcon; return /* @__PURE__ */ jsx(DefaultIcon, { size: 16, weight: "bold", "aria-hidden": "true" }); } function buildDisplayName(item) { const parts = [item.name]; if (item.shift) parts.push(`(${item.shift})`); if (item.grade) parts.push(`(${item.grade})`); return parts.join(" "); } function PerformanceItemCard({ item, variant, countLabel }) { const backgroundClass = getPositionBackgroundClass(variant, item.position); const displayName = buildDisplayName(item); const countText = countLabel ? `${item.count} ${countLabel}` : String(item.count); return /* @__PURE__ */ jsxs( "div", { className: cn( "flex flex-row items-center w-full p-4 gap-2 rounded-xl", backgroundClass ), children: [ /* @__PURE__ */ jsx( Text_default, { size: "xs", weight: "bold", "aria-label": `Position ${item.position}`, className: cn( "w-5 h-5 rounded-full flex items-center justify-center flex-shrink-0", POSITION_TEXT_CLASSES[variant], BADGE_BACKGROUND_CLASSES[variant] ), children: item.position } ), /* @__PURE__ */ jsx( Text_default, { size: "sm", weight: "bold", className: "flex-1 min-w-0 text-text-950 tracking-[0.2px] truncate", children: displayName } ), /* @__PURE__ */ jsx( Text_default, { size: "xs", "aria-label": `Count ${item.count}`, className: cn( "flex-shrink-0 h-[22px] px-2 flex items-center rounded", COUNT_BADGE_CLASSES[variant] ), children: countText } ), /* @__PURE__ */ jsxs( Text_default, { size: "xs", weight: "bold", "aria-label": `Performance ${item.percentage}%`, className: cn( "flex flex-row items-center flex-shrink-0 h-[22px] px-2 gap-1 rounded text-text", PERCENTAGE_BADGE_CLASSES[variant] ), children: [ /* @__PURE__ */ jsx(TrendIcon, { trend: item.trend, variant }), item.percentage, "%" ] } ) ] } ); } function createRenderPerformanceItem(countLabel) { return function renderPerformanceItem(item, variant, index) { if (!item) { return /* @__PURE__ */ jsx( "div", { className: "flex items-center justify-center w-full p-4 rounded-xl bg-background-50 border border-dashed border-border-100", children: /* @__PURE__ */ jsx(Text_default, { size: "xs", className: "text-text-400", children: "Sem dados" }) }, `${variant}-empty-${index}` ); } return /* @__PURE__ */ jsx( PerformanceItemCard, { item, variant, countLabel }, `${variant}-${index}-${item.position}` ); }; } var PerformanceRanking = ({ data, highlightTitle = "Em destaque", attentionTitle = "Precisando de aten\xE7\xE3o", countLabel, className, ...props }) => { const renderItem = createRenderPerformanceItem(countLabel); return /* @__PURE__ */ jsxs(RankingLayout, { className, ...props, children: [ /* @__PURE__ */ jsx( BaseRankingCard, { title: highlightTitle, variant: "highlight", items: data.highlighted, renderItem, headerIcon: /* @__PURE__ */ jsx(MedalIcon, { size: 14, className: "text-text-950" }) } ), /* @__PURE__ */ jsx( BaseRankingCard, { title: attentionTitle, variant: "attention", items: data.needsAttention, renderItem, headerIcon: /* @__PURE__ */ jsx(SealWarningIcon, { size: 14, className: "text-text" }) } ) ] }); }; var PerformanceRanking_default = PerformanceRanking; export { PerformanceRanking, PerformanceRanking_default }; //# sourceMappingURL=chunk-A5UC667P.mjs.map