analytica-frontend-lib
Version:
Repositório público dos componentes utilizados nas plataformas da Analytica Ensino
112 lines (110 loc) • 2.94 kB
JavaScript
import {
Text_default
} from "./chunk-IMCIR6TJ.mjs";
import {
cn
} from "./chunk-53ICLDGS.mjs";
// src/components/shared/RankingShared.tsx
import { TrophyIcon } from "@phosphor-icons/react/dist/csr/Trophy";
import { WarningIcon } from "@phosphor-icons/react/dist/csr/Warning";
import { jsx, jsxs } from "react/jsx-runtime";
var CARD_BACKGROUND_CLASSES = {
highlight: {
1: "bg-success-200",
2: "bg-success-100",
3: "bg-success-background"
},
attention: {
1: "bg-error-200",
2: "bg-error-100",
3: "bg-error-background"
}
};
var BADGE_BACKGROUND_CLASSES = {
highlight: "bg-indicator-positive",
attention: "bg-indicator-negative"
};
var PERCENTAGE_BADGE_CLASSES = {
highlight: "bg-success-700",
attention: "bg-indicator-negative"
};
var HEADER_BADGE_CLASSES = BADGE_BACKGROUND_CLASSES;
var getPositionBackgroundClass = (variant, position) => {
const positionKey = Math.max(1, Math.min(position, 3));
return CARD_BACKGROUND_CLASSES[variant][positionKey];
};
function BaseRankingCard({
title,
variant,
items,
renderItem,
headerIcon,
className,
...props
}) {
const DefaultIcon = variant === "highlight" ? TrophyIcon : WarningIcon;
return /* @__PURE__ */ jsxs(
"div",
{
className: cn(
"flex flex-col flex-1 min-h-[254px] p-5 gap-4 bg-background border border-border-50 rounded-xl",
className
),
...props,
children: [
/* @__PURE__ */ jsxs("div", { className: "flex flex-row justify-between items-center h-6 gap-4", children: [
/* @__PURE__ */ jsx(
Text_default,
{
as: "h3",
size: "lg",
weight: "bold",
className: "text-text-950 tracking-[0.2px]",
children: title
}
),
/* @__PURE__ */ jsx(
"span",
{
className: cn(
"w-6 h-6 rounded-full flex items-center justify-center",
HEADER_BADGE_CLASSES[variant]
),
children: headerIcon ?? /* @__PURE__ */ jsx(
DefaultIcon,
{
size: 14,
weight: "fill",
className: variant === "highlight" ? "text-text-950" : "text-text"
}
)
}
)
] }),
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-2", children: items.map((item, index) => renderItem(item, variant, index)) })
]
}
);
}
function RankingLayout({
children,
className,
...props
}) {
return /* @__PURE__ */ jsx(
"div",
{
className: cn("grid grid-cols-1 sm:grid-cols-2 w-full gap-4", className),
...props,
children
}
);
}
export {
BADGE_BACKGROUND_CLASSES,
PERCENTAGE_BADGE_CLASSES,
getPositionBackgroundClass,
BaseRankingCard,
RankingLayout
};
//# sourceMappingURL=chunk-Z7JWDZES.mjs.map