refactor: compartilha utilitários e refina widgets e calendário

This commit is contained in:
Felipe Coutinho
2026-03-16 01:14:55 +00:00
parent 959db963b8
commit 132f98c0f8
10 changed files with 310 additions and 322 deletions

View File

@@ -12,7 +12,7 @@ export type WidgetCardProps = {
title: string;
subtitle: string;
children: React.ReactNode;
icon: React.ReactNode;
icon?: React.ReactNode;
action?: React.ReactNode;
};
@@ -37,11 +37,11 @@ export default function WidgetCard({
<CardHeader>
<div className="flex w-full items-start justify-between">
<div>
<CardTitle className="flex items-center gap-1 tracking-tight lowercase">
<span className="size-4">{icon}</span>
<CardTitle className="flex items-center gap-1 tracking-tight">
{icon && <span className="size-4">{icon}</span>}
{title}
</CardTitle>
<CardDescription className="text-muted-foreground text-sm lowercase mt-1.5 tracking-tight">
<CardDescription className="text-muted-foreground text-sm mt-1.5 tracking-tight">
{subtitle}
</CardDescription>
</div>

View File

@@ -0,0 +1,15 @@
/**
* Builds a 2-character initials string from a name.
* Falls back to the provided `fallback` (default "??") when the name is empty.
*/
export function buildInitials(value: string, fallback = "??"): string {
const parts = value.trim().split(/\s+/).filter(Boolean);
if (parts.length === 0) return fallback;
if (parts.length === 1) {
const firstPart = parts[0];
return firstPart ? firstPart.slice(0, 2).toUpperCase() : fallback;
}
const firstChar = parts[0]?.[0] ?? "";
const secondChar = parts[1]?.[0] ?? "";
return `${firstChar}${secondChar}`.toUpperCase() || fallback;
}