Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import { cn } from '../../lib/cn';
type OverviewCardProps = {
title: string;
icon: ReactNode;
value: string | number;
value: ReactNode;
/** Rendered baseline-aligned to the right of the value (e.g. secondary currency amounts). */
secondaryValue?: ReactNode;
bottomLineText?: string;
onClick?: () => void;
iconWrapperClassName?: string;
Expand All @@ -16,6 +18,7 @@ const OverviewCard = ({
title,
icon,
value,
secondaryValue,
bottomLineText,
onClick,
iconWrapperClassName,
Expand Down Expand Up @@ -45,7 +48,13 @@ const OverviewCard = ({
{title}
</span>
</div>
<p className="font-bold text-[32px]/[32px] text-foreground">{value}</p>
<div className="flex items-baseline gap-2 flex-wrap">
{/* div, not p: value is a ReactNode and may legally contain non-phrasing content */}
<div className="font-bold text-[32px]/[32px] text-foreground">
{value}
</div>
{secondaryValue}
</div>
{bottomLineText && (
<p className="font-normal text-sm text-gray-400">{bottomLineText}</p>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,18 @@ export const CustomIconWrapperClassName: Story = {
iconWrapperClassName: 'bg-green-400',
},
};

/**
* Card with a secondary value rendered baseline-aligned next to the main value
* (e.g. remaining currency amounts for a multi-currency total).
*/
export const WithSecondaryValue: Story = {
args: {
value: '$12.4K',
secondaryValue: (
<span className="text-xs font-medium text-muted-foreground">
+ €3.1K · £980
</span>
),
},
};
Loading