Skip to content

Commit 1ea9b9a

Browse files
committed
feat: new prop to unit input needed for ordersummary
1 parent 25e4783 commit 1ea9b9a

File tree

7 files changed

+82
-45
lines changed

7 files changed

+82
-45
lines changed

.changeset/tangy-friends-open.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+
`<UnitInput />`: New prop `selectInputMaxWidth`

packages/form/src/components/UnitInputField/__tests__/__snapshots__/index.test.tsx.snap

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ exports[`UnitInputField > should handles onChange and selection 1`] = `
301301
.emotion-16 {
302302
width: 100%;
303303
width: 12.6rem;
304+
max-width: 12.6rem;
304305
}
305306
306307
.emotion-16 #unit {
@@ -635,11 +636,11 @@ exports[`UnitInputField > should handles onChange and selection 1`] = `
635636
<svg
636637
aria-label="show dropdown"
637638
class="emotion-29 emotion-30"
638-
viewBox="0 0 20 20"
639+
viewBox="0 0 16 16"
639640
>
640641
<path
641642
clip-rule="evenodd"
642-
d="M5.47 7.47a.75.75 0 0 1 1.06 0l3.72 3.72 3.72-3.72a.75.75 0 1 1 1.06 1.06l-4.25 4.25a.75.75 0 0 1-1.06 0L5.47 8.53a.75.75 0 0 1 0-1.06"
643+
d="M4.22 6.22a.75.75 0 0 1 1.06 0L8 8.94l2.72-2.72a.75.75 0 1 1 1.06 1.06l-3.25 3.25a.75.75 0 0 1-1.06 0L4.22 7.28a.75.75 0 0 1 0-1.06"
643644
fill-rule="evenodd"
644645
/>
645646
</svg>
@@ -927,6 +928,7 @@ exports[`UnitInputField > should render correctly 1`] = `
927928
.emotion-12 {
928929
width: 100%;
929930
width: 12.6rem;
931+
max-width: 12.6rem;
930932
}
931933
932934
.emotion-12 #unit {
@@ -1197,11 +1199,11 @@ exports[`UnitInputField > should render correctly 1`] = `
11971199
<svg
11981200
aria-label="show dropdown"
11991201
class="emotion-25 emotion-26"
1200-
viewBox="0 0 20 20"
1202+
viewBox="0 0 16 16"
12011203
>
12021204
<path
12031205
clip-rule="evenodd"
1204-
d="M5.47 7.47a.75.75 0 0 1 1.06 0l3.72 3.72 3.72-3.72a.75.75 0 1 1 1.06 1.06l-4.25 4.25a.75.75 0 0 1-1.06 0L5.47 8.53a.75.75 0 0 1 0-1.06"
1206+
d="M4.22 6.22a.75.75 0 0 1 1.06 0L8 8.94l2.72-2.72a.75.75 0 1 1 1.06 1.06l-3.25 3.25a.75.75 0 0 1-1.06 0L4.22 7.28a.75.75 0 0 1 0-1.06"
12051207
fill-rule="evenodd"
12061208
/>
12071209
</svg>

packages/form/src/components/UnitInputField/index.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ type UnitInputFieldProps<
2828
| 'width'
2929
| 'helper'
3030
| 'selectInputWidth'
31+
| 'selectInputMaxWidth'
3132
> & {
3233
onChangeUnitValue?: ComponentProps<typeof UnitInput>['onChangeUnitValue']
3334
label: string
@@ -53,6 +54,7 @@ export const UnitInputField = <
5354
required,
5455
width,
5556
selectInputWidth,
57+
selectInputMaxWidth,
5658
helper,
5759
shouldUnregister = false,
5860
validate,
@@ -102,6 +104,7 @@ export const UnitInputField = <
102104
value={valueField.value as number}
103105
unitValue={unitField.value as string}
104106
selectInputWidth={selectInputWidth}
107+
selectInputMaxWidth={selectInputMaxWidth}
105108
disabled={disabled}
106109
options={options}
107110
label={label}

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,12 @@ const SubCategory = ({ subCategory }: { subCategory: SubCategoryType }) => {
135135
) : null}
136136
{subCategory.price !== undefined && !subCategory.hidePrice ? (
137137
<Text as="span" variant="bodySmallStrong" sentiment="neutral">
138-
{subCategoryPrice[0] === subCategoryPrice[1]
138+
{subCategoryPrice[0] === subCategoryPrice[1] ||
139+
subCategory.priceUnit
139140
? formatNumber(
140-
subCategoryPrice[0],
141+
subCategory.priceUnit
142+
? subCategory.price
143+
: subCategoryPrice[0],
141144
localeFormat,
142145
currency,
143146
fractionDigits,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const mockItems = (
2626
{
2727
title: `${requestsAmount} requests`,
2828
price: 0.00000015,
29-
amount: requestsAmount,
29+
amount: requestsAmount ?? 0,
3030
priceUnit: 'request',
3131
fixedPrice: true,
3232
},

packages/plus/src/components/OrderSummary/__tests__/__snapshots__/index.test.tsx.snap

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2234,7 +2234,7 @@ exports[`OrderSummary > should work with children 1`] = `
22342234
<span
22352235
class="emotion-52 emotion-5"
22362236
>
2237-
€0.03 /request
2237+
€0.00000015 /request
22382238
</span>
22392239
</div>
22402240
<div
@@ -2296,7 +2296,7 @@ exports[`OrderSummary > should work with children 1`] = `
22962296
<span
22972297
class="emotion-52 emotion-5"
22982298
>
2299-
€0.00085625 /GB/hours
2299+
€0.00003425 /GB/hours
23002300
</span>
23012301
</div>
23022302
<div
@@ -3064,7 +3064,7 @@ exports[`OrderSummary > should work with default props 1`] = `
30643064
<span
30653065
class="emotion-22 emotion-9"
30663066
>
3067-
€0.03 /request
3067+
€0.00000015 /request
30683068
</span>
30693069
</div>
30703070
<div
@@ -3126,7 +3126,7 @@ exports[`OrderSummary > should work with default props 1`] = `
31263126
<span
31273127
class="emotion-22 emotion-9"
31283128
>
3129-
€0.00085625 /GB/hours
3129+
€0.00003425 /GB/hours
31303130
</span>
31313131
</div>
31323132
<div
@@ -8631,7 +8631,7 @@ exports[`OrderSummary > should work with footer 1`] = `
86318631
<span
86328632
class="emotion-52 emotion-5"
86338633
>
8634-
€0.03 /request
8634+
€0.00000015 /request
86358635
</span>
86368636
</div>
86378637
<div
@@ -8693,7 +8693,7 @@ exports[`OrderSummary > should work with footer 1`] = `
86938693
<span
86948694
class="emotion-52 emotion-5"
86958695
>
8696-
€0.00085625 /GB/hours
8696+
€0.00003425 /GB/hours
86978697
</span>
86988698
</div>
86998699
<div
@@ -16316,7 +16316,7 @@ exports[`OrderSummary > should work with totalPriceInfo 1`] = `
1631616316
<span
1631716317
class="emotion-52 emotion-5"
1631816318
>
16319-
€0.03 /request
16319+
€0.00000015 /request
1632016320
</span>
1632116321
</div>
1632216322
<div
@@ -16378,7 +16378,7 @@ exports[`OrderSummary > should work with totalPriceInfo 1`] = `
1637816378
<span
1637916379
class="emotion-52 emotion-5"
1638016380
>
16381-
€0.00085625 /GB/hours
16381+
€0.00003425 /GB/hours
1638216382
</span>
1638316383
</div>
1638416384
<div
@@ -17189,7 +17189,7 @@ exports[`OrderSummary > should work without unitInput 1`] = `
1718917189
<span
1719017190
class="emotion-26 emotion-5"
1719117191
>
17192-
€0.03 /request
17192+
€0.00000015 /request
1719317193
</span>
1719417194
</div>
1719517195
<div
@@ -17251,7 +17251,7 @@ exports[`OrderSummary > should work without unitInput 1`] = `
1725117251
<span
1725217252
class="emotion-26 emotion-5"
1725317253
>
17254-
€0.00085625 /GB/hours
17254+
€0.00003425 /GB/hours
1725517255
</span>
1725617256
</div>
1725717257
<div

0 commit comments

Comments
 (0)