analytica-frontend-lib
Version:
Repositório público dos componentes utilizados nas plataformas da Analytica Ensino
48 lines (46 loc) • 1.3 kB
JavaScript
import {
cn
} from "./chunk-53ICLDGS.mjs";
// src/components/LevelBar/LevelBar.tsx
import { jsx } from "react/jsx-runtime";
var SEGMENTS = 4;
var LevelBar = ({
value,
colorClass = "bg-success-400",
trackColorClass = "bg-background-400",
className = "",
...props
}) => {
const filled = Math.min(Math.max(Math.trunc(value), 0), SEGMENTS);
return (
// Decorative: the level is always rendered as adjacent text ("Nível 2 de
// 4"), so announcing the bar too would just repeat it. Wrap it with your
// own label if you render it without that text.
/* @__PURE__ */ jsx(
"div",
{
"data-component": "LevelBar",
className: cn("flex w-full items-center gap-1", className),
"aria-hidden": "true",
...props,
children: Array.from({ length: SEGMENTS }, (_, index) => /* @__PURE__ */ jsx(
"span",
{
"data-testid": index < filled ? "level-bar-filled" : "level-bar-empty",
className: cn(
"flex-1 h-1.5 rounded-full",
index < filled ? colorClass : trackColorClass
)
},
index
))
}
)
);
};
var LevelBar_default = LevelBar;
export {
LevelBar,
LevelBar_default
};
//# sourceMappingURL=chunk-OCECSMIX.mjs.map