analytica-frontend-lib
Version:
Repositório público dos componentes utilizados nas plataformas da Analytica Ensino
124 lines (122 loc) • 3.61 kB
JavaScript
import {
DataBar,
GridLines,
LegendItem,
YAxis,
calculateYAxisTicks
} from "./chunk-Y4MZ2KAU.mjs";
import {
Text_default
} from "./chunk-IMCIR6TJ.mjs";
import {
cn
} from "./chunk-53ICLDGS.mjs";
// src/components/QuestionsData/QuestionsData.tsx
import { jsx, jsxs } from "react/jsx-runtime";
var BAR_COLORS = {
total: "bg-info-600",
corretas: "bg-success-200",
incorretas: "bg-warning-400",
emBranco: "bg-background-300"
};
var QuestionsData = ({
title = "Dados de quest\xF5es",
data,
showEmBranco = false,
maxValue,
chartHeight = 180,
className,
...props
}) => {
const chartMaxValue = maxValue ?? data.total;
const yAxisTicks = calculateYAxisTicks(chartMaxValue);
const adjustedMaxValue = yAxisTicks[0];
const blankSuffix = showEmBranco && data.emBranco !== void 0 ? `, ${data.emBranco} em branco` : "";
const chartDescription = `Gr\xE1fico de barras mostrando ${data.total} quest\xF5es respondidas, ${data.corretas} corretas, ${data.incorretas} incorretas${blankSuffix}`;
const barItems = [
{
key: "total",
label: "Total",
legendLabel: "Total de quest\xF5es respondidas",
value: data.total,
colorClass: BAR_COLORS.total
},
{
key: "corretas",
label: "Corretas",
legendLabel: "Quest\xF5es corretas",
value: data.corretas,
colorClass: BAR_COLORS.corretas
},
{
key: "incorretas",
label: "Incorretas",
legendLabel: "Quest\xF5es incorretas",
value: data.incorretas,
colorClass: BAR_COLORS.incorretas
}
];
if (showEmBranco && data.emBranco !== void 0) {
barItems.push({
key: "emBranco",
label: "Em branco",
legendLabel: "Quest\xF5es em branco",
value: data.emBranco,
colorClass: BAR_COLORS.emBranco
});
}
return /* @__PURE__ */ jsxs(
"div",
{
className: cn(
"flex flex-col p-5 gap-4 bg-background border border-border-50 rounded-xl",
className
),
...props,
children: [
/* @__PURE__ */ jsx(
Text_default,
{
as: "h3",
size: "lg",
weight: "bold",
className: "text-text-950 tracking-[0.2px]",
children: title
}
),
/* @__PURE__ */ jsx("div", { className: "flex flex-row flex-wrap gap-x-6 gap-y-2 mb-4", children: barItems.map((item) => /* @__PURE__ */ jsx(
LegendItem,
{
color: BAR_COLORS[item.key],
label: item.legendLabel
},
item.key
)) }),
/* @__PURE__ */ jsxs("div", { className: "flex flex-row", "aria-label": chartDescription, children: [
/* @__PURE__ */ jsx(YAxis, { ticks: yAxisTicks, chartHeight }),
/* @__PURE__ */ jsx("div", { className: "w-4" }),
/* @__PURE__ */ jsxs("div", { className: "flex-1 relative", children: [
/* @__PURE__ */ jsx(GridLines, { ticks: yAxisTicks, chartHeight }),
/* @__PURE__ */ jsx("div", { className: "flex flex-row flex-1 gap-4 relative z-10", children: barItems.map((item) => /* @__PURE__ */ jsx(
DataBar,
{
label: item.label,
value: item.value,
maxValue: adjustedMaxValue,
colorClass: item.colorClass,
chartHeight
},
item.key
)) })
] })
] })
]
}
);
};
var QuestionsData_default = QuestionsData;
export {
QuestionsData,
QuestionsData_default
};
//# sourceMappingURL=chunk-VLSFQH37.mjs.map