Skip to content

Commit 3c64a48

Browse files
committed
feat: strike through text and estimated cost ordersummary
1 parent 7bde3d9 commit 3c64a48

File tree

9 files changed

+1455
-301
lines changed

9 files changed

+1455
-301
lines changed

.changeset/itchy-taxes-jam.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"@ultraviolet/plus": patch
3+
---
4+
5+
`OrderSummary`:
6+
- new prop `totalPriceInfoPlacement` for the placement of `totalPriceInfo`
7+
- new prop `hideBeforePrice` to only show discounted price
8+
- `discount = 1` interpreted as 100% instead of 1€ for the total price

.changeset/wet-dingos-clean.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@ultraviolet/ui": patch
3+
---
4+
5+
`Text`: fix prop strikeThrough by removing useless `textDecoration` in variant definition

packages/plus/src/components/OrderSummary/NonScrollableContent.tsx

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,33 @@ type NonScrollableContentProps = {
1212
footer: ReactNode
1313
children: ReactNode
1414
totalPriceInfo?: ReactNode
15+
totalPriceInfoPlacement?: 'left' | 'right'
1516
totalPriceDescription?: ReactNode
1617
additionalInfo?: string
1718
hideDetails: boolean
1819
unit: TimeUnit
20+
hideBeforePrice?: boolean
1921
}
2022

2123
export const NonScrollableContent = ({
2224
totalPrice,
2325
footer,
2426
children,
2527
totalPriceInfo,
28+
totalPriceInfoPlacement,
2629
hideDetails,
2730
unit,
2831
totalPriceDescription,
2932
additionalInfo,
33+
hideBeforePrice,
3034
}: NonScrollableContentProps) => {
3135
const { locales } = useContext(OrderSummaryContext)
3236

3337
return (
3438
<Stack className={orderSummaryNonScrollableContainer} gap={3}>
3539
{children}
3640
<Stack alignItems="center" direction="row" justifyContent="space-between">
37-
{totalPriceInfo ? (
41+
{totalPriceInfo && totalPriceInfoPlacement === 'left' ? (
3842
<Stack>
3943
<Stack alignItems="center" direction="row" gap={1}>
4044
<Text
@@ -63,28 +67,9 @@ export const NonScrollableContent = ({
6367
{totalPriceDescription}
6468
</Stack>
6569
)}
66-
{totalPrice.totalPrice === totalPrice.totalPriceWithDiscount ? (
67-
<Text
68-
as="span"
69-
data-testid="total-price"
70-
prominence="strong"
71-
sentiment="neutral"
72-
variant="headingSmallStrong"
73-
>
74-
<DisplayPrice beforeOrAfter="after" price={totalPrice} />
75-
{hideDetails ? `/${unit}` : null}
76-
</Text>
77-
) : (
78-
<Stack alignItems="center" direction="row" gap={1}>
79-
<Text
80-
as="span"
81-
prominence="weak"
82-
sentiment="neutral"
83-
strikeThrough
84-
variant="bodySmallStrong"
85-
>
86-
<DisplayPrice beforeOrAfter="before" price={totalPrice} />
87-
</Text>
70+
<Stack alignItems="end" direction="column">
71+
{totalPrice.totalPrice === totalPrice.totalPriceWithDiscount ||
72+
hideBeforePrice ? (
8873
<Text
8974
as="span"
9075
data-testid="total-price"
@@ -95,8 +80,33 @@ export const NonScrollableContent = ({
9580
<DisplayPrice beforeOrAfter="after" price={totalPrice} />
9681
{hideDetails ? `/${unit}` : null}
9782
</Text>
98-
</Stack>
99-
)}
83+
) : (
84+
<Stack alignItems="center" direction="row" gap={1}>
85+
<Text
86+
as="span"
87+
prominence="weak"
88+
sentiment="neutral"
89+
strikeThrough
90+
variant="bodySmallStrong"
91+
>
92+
<DisplayPrice beforeOrAfter="before" price={totalPrice} />
93+
</Text>
94+
<Text
95+
as="span"
96+
data-testid="total-price"
97+
prominence="strong"
98+
sentiment="neutral"
99+
variant="headingSmallStrong"
100+
>
101+
<DisplayPrice beforeOrAfter="after" price={totalPrice} />
102+
{hideDetails ? `/${unit}` : null}
103+
</Text>
104+
</Stack>
105+
)}
106+
{totalPriceInfo && totalPriceInfoPlacement === 'right'
107+
? totalPriceInfo
108+
: null}
109+
</Stack>
100110
</Stack>
101111
{footer}
102112
</Stack>

packages/plus/src/components/OrderSummary/__stories__/TotalPriceInfo.stories.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,21 @@ export const TotalPriceInfo = Template.bind({})
66
TotalPriceInfo.args = {
77
...Template.args,
88
discount: 0.5,
9+
hideBeforePrice: false,
910
hideTimeUnit: false,
1011
totalPriceInfo: (
1112
<Badge prominence="strong" sentiment="warning" size="small">
1213
50% OFF DURING BETA
1314
</Badge>
1415
),
16+
totalPriceInfoPlacement: 'left',
1517
}
1618

1719
TotalPriceInfo.parameters = {
1820
docs: {
1921
description: {
20-
story: 'Add information right beneath the total price.',
22+
story:
23+
'Add information right beneath the total price. You can place it on the left or the right using prop `totalPriceInfoPlacement`. You can also hide the undiscounted price using prop `hideBeforePrice`.',
2124
},
2225
},
2326
}

0 commit comments

Comments
 (0)