Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

X2-6273 added smart breakdown item wrapping #246

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
22 changes: 14 additions & 8 deletions src/components/Breakdown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,20 @@ const BreakdownItem = ({ children, info, methodIcon, secondary, value, className
return (
<tr className={clsx("ui-breakdown-item", colors[color], className)} {...rest}>
<td colSpan={2} className="text-left leading-none">
<span className="mr-0.5">{methodIcon}</span>
<span>{children}</span>
<span className="ml-1 text-sm">
{info && (
<span className="mr-2 rounded bg-white p-1 uppercase text-black empty:hidden">{info}</span>
)}
{secondary && <span className="empty:hidden">{secondary}</span>}
</span>
<div className="flex flex-wrap items-center leading-3.5">
<span className="break-word">
<span className="mr-0.5">{methodIcon}</span>
{children}
</span>
<span className="ml-1 text-sm">
{info && (
<span className="mr-2 ml-1 rounded bg-white p-1 uppercase leading-6 text-black empty:hidden">
{info}
</span>
)}
{secondary && <span className="empty:hidden">{secondary}</span>}
</span>
</div>
</td>

<td className="w-[1%] whitespace-nowrap pl-4 text-right">
Expand Down
6 changes: 3 additions & 3 deletions src/stories/Other/Breakdown.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const Default = () => {
<Breakdown currency="USD">
<Breakdown.Item value={100}>Line item caption</Breakdown.Item>
<Breakdown.Item value={29} secondary="($29.00 x 1)">
Children
Very long really Children
</Breakdown.Item>
<Breakdown.Item value={29} secondary="($29.00 x 1)">
Adults
Expand All @@ -46,12 +46,12 @@ export const Default = () => {
Payment
</Breakdown.Item>

<Breakdown.Item color="primary" secondary="07/23/2021" value={-62} methodIcon={<CardIcon />}>
<Breakdown.Item color="primary" info="*0259" secondary="07/23/2021" value={-62} methodIcon={<CardIcon />}>
Return Payment
</Breakdown.Item>

<Breakdown.Item secondary="07/23/2021" info={<EmptyComponent />} value={0} methodIcon={<CardIcon />}>
This is a really long message that should wrap somehow
This is a really long message that should wrap somehow more long
</Breakdown.Item>

<Breakdown.Separator />
Expand Down