Skip to content

Commit 11011f3

Browse files
committed
Add empty character after currency symbol
1 parent 1fa34d4 commit 11011f3

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

components/Product/IndexProducts.component.jsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,21 @@ const IndexProducts = ({ products }) => {
7272
{onSale && (
7373
<div className="flex justify-center">
7474
<div className="pt-1 text-gray-900">
75-
{variations && filteredVariantPrice(price)}
76-
{!variations && paddedPrice(salePrice)}
75+
{variations &&
76+
filteredVariantPrice(paddedPrice(price, 'kr'))}
77+
{!variations && paddedPrice(salePrice, 'kr')}
7778
</div>
7879
<div className="pt-1 ml-2 text-gray-900 line-through">
79-
{variations && filteredVariantPrice(price, 'right')}
80-
{!variations && paddedPrice(regularPrice)}
80+
{variations &&
81+
filteredVariantPrice(paddedPrice(price, 'kr'), 'right')}
82+
{!variations && paddedPrice(regularPrice, 'kr')}
8183
</div>
8284
</div>
8385
)}
8486
{/* Display regular price when not on sale */}
8587
{!onSale && (
8688
<p className="pt-1 text-center text-gray-900">
87-
{paddedPrice(price)}
89+
{paddedPrice(price, 'kr')}
8890
</p>
8991
)}
9092
</div>

utils/functions/functions.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ import { v4 as uuidv4 } from 'uuid';
33
/**
44
* Add empty character after currency symbol
55
* @param {String} price The price string that we input
6+
* @param {String} symbol Currency symbol to add empty character/padding after
67
*/
78

8-
export const paddedPrice = (price) => price.split('kr').join('kr ');
9+
export const paddedPrice = (price, symbol) =>
10+
price.split(symbol).join(`${symbol} `);
911

1012
/**
1113
* Shorten inputted string (usually product description) to a maximum of length

0 commit comments

Comments
 (0)