UNPKG

analytica-frontend-lib

Version:

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

114 lines (109 loc) 3.7 kB
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); var _chunkANT66KVKjs = require('./chunk-ANT66KVK.js'); // src/components/ScoreCircle/ScoreCircle.tsx var _jsxruntime = require('react/jsx-runtime'); var VARIANT_CLASSES = { green: { track: "stroke-background-300", fill: "stroke-success-200", score: "text-success-300" }, blue: { track: "stroke-primary-100", fill: "stroke-primary-700", score: "text-primary-700" }, warning: { track: "stroke-background-300", fill: "stroke-warning-300", score: "text-warning-600" } }; var ScoreCircle = ({ value, max = 1e3, variant = "green", size = 180, strokeWidth = 10, label, labelIcon, className = "" }) => { const clamped = Math.max(0, Math.min(value, max)); const percentage = max === 0 ? 0 : clamped / max; const radius = size / 2 - strokeWidth; const center = size / 2; const circumference = 2 * Math.PI * radius; const strokeDashoffset = circumference - percentage * circumference; const styles = VARIANT_CLASSES[variant]; return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: `relative flex flex-col items-center justify-center ${className}`, style: { width: size, height: size }, role: "img", "aria-label": label ? `${label}: ${value} de ${max}` : `${value} de ${max}`, children: [ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "svg", { className: "absolute inset-0 -rotate-90", width: size, height: size, viewBox: `0 0 ${size} ${size}`, "aria-hidden": "true", children: [ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "circle", { cx: center, cy: center, r: radius, fill: "none", strokeWidth, className: styles.track } ), /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "circle", { cx: center, cy: center, r: radius, fill: "none", strokeWidth, strokeLinecap: "round", strokeDasharray: circumference, strokeDashoffset, className: `${styles.fill} transition-all duration-500 ease-out` } ) ] } ), /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "relative z-10 flex flex-col items-center gap-1", children: [ (label || labelIcon) && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-row items-center gap-1 text-text-700", children: [ labelIcon, label && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkANT66KVKjs.Text_default, { size: "xs", className: "text-text-700", children: label }) ] }), /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkANT66KVKjs.Text_default, { size: "xl", weight: "bold", className: `${styles.score} leading-none text-4xl`, children: value } ), /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkANT66KVKjs.Text_default, { size: "xs", className: "text-text-700", children: [ "de ", max ] }) ] }) ] } ); }; var ScoreCircle_default = ScoreCircle; exports.ScoreCircle_default = ScoreCircle_default; //# sourceMappingURL=chunk-KDCWGLA6.js.map