Track HiveGrid Cloud planning reference
This commit is contained in:
1 parent
b3d5ea6764
commit
e341c5938a
5784 files changed
+1104929
-3
No files matched your search
@@ -0,0 +1,101 @@
|
||||
import clsx from "clsx";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Link } from "react-router";
|
||||
import { Stat } from "~/application/dtos/stats/Stat";
|
||||
import { StatChange } from "~/application/dtos/stats/StatChange";
|
||||
import { Fragment } from "react";
|
||||
import { TrendingUpIcon, TrendingDownIcon } from "~/components/ui/icons/vendor";
|
||||
|
||||
interface Props {
|
||||
items: Stat[];
|
||||
}
|
||||
|
||||
export function DashboardStats({ items }: Props) {
|
||||
return (
|
||||
<div>
|
||||
<div
|
||||
className={clsx(
|
||||
"grid grid-cols-2 gap-4 overflow-hidden rounded-lg sm:grid-cols-3",
|
||||
items.length === 1 && "md:grid-cols-1",
|
||||
items.length === 2 && "md:grid-cols-2",
|
||||
items.length === 3 && "md:grid-cols-3",
|
||||
items.length === 4 && "md:grid-cols-4",
|
||||
items.length === 5 && "md:grid-cols-4 lg:grid-cols-5",
|
||||
items.length === 6 && "md:grid-cols-4 lg:grid-cols-6"
|
||||
)}
|
||||
>
|
||||
{items.map((item, idx) => (
|
||||
<Fragment key={idx}>
|
||||
{item.path ? (
|
||||
<Link to={item.path}>
|
||||
{/* Subframe StatsCard layout: rounded-md, px-4 py-4, hover shadow */}
|
||||
<DashboardStat
|
||||
item={item}
|
||||
className="hover:shadow-lg border-border-default bg-surface-neutral-primary flex cursor-pointer justify-between space-x-1 truncate rounded-md border px-4 py-4"
|
||||
/>
|
||||
</Link>
|
||||
) : (
|
||||
<DashboardStat className="border-border-default bg-surface-neutral-primary flex justify-between space-x-1 truncate rounded-md border px-4 py-4" item={item} />
|
||||
)}
|
||||
</Fragment>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function DashboardStat({ item, loading = false, className }: { item: Stat; loading?: boolean; className?: string }) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<div key={item.name} className={className}>
|
||||
<div className="truncate">
|
||||
{/* Subframe StatsCard typo: body-default label, subtitle value, body-small comparison */}
|
||||
<div className="text-text-neutral-secondary text-body-default-regular-0 font-body-default-regular-0 flex items-baseline space-x-2">
|
||||
<div>{t(item.name)}</div>
|
||||
{item.hint && <div className="text-text-neutral-tertiary text-body-small-regular-0 font-body-small-regular-0 hidden xl:block">({t(item.hint)})</div>}
|
||||
</div>
|
||||
|
||||
<div className="text-text-neutral-primary text-subtitle-0 font-subtitle-0 flex items-baseline space-x-2">
|
||||
<div>{loading ? "..." : item.stat}</div>
|
||||
{item.previousStat !== undefined && (
|
||||
<span className="text-text-neutral-tertiary text-body-small-regular-0 font-body-small-regular-0 ml-2 hidden xl:block">
|
||||
{!loading && <span>{t("shared.statComparison", { 0: item.previousStat })}</span>}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
{item.changeType === StatChange.Increase ? (
|
||||
<div className="mt-1 flex shrink-0 gap-1 truncate text-green-700">
|
||||
{loading ? (
|
||||
"..."
|
||||
) : (
|
||||
<>
|
||||
<TrendingUpIcon className="h-4 w-4" />
|
||||
<div className="text-body-small-regular-0 font-body-small-regular-0 flex gap-2">
|
||||
<span className="font-medium">
|
||||
<div>{item.change}</div>
|
||||
</span>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
) : item.changeType === StatChange.Decrease ? (
|
||||
<div className="mt-1 flex gap-1 text-red-600">
|
||||
{loading ? (
|
||||
"..."
|
||||
) : (
|
||||
<>
|
||||
<TrendingDownIcon className="h-4 w-4" />
|
||||
|
||||
<p className="text-body-small-regular-0 font-body-small-regular-0 flex gap-2">
|
||||
<span className="font-medium">
|
||||
<div>{item.change}</div>
|
||||
</span>
|
||||
</p>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user