← All changes
|
backend/views/components/Main/utilities/utilities.js
+25
-0
1.4.0
→
1.4.19
View file →
| @@ -336,4 +336,29 @@ | ||
| 336 | 336 | return str.slice(0, maxLength) + '...'; |
| 337 | 337 | } |
| 338 | 338 | return str; |
| 339 | 339 | } |
| 340 | + | |
| 341 | +/** | |
| 342 | + * | |
| 343 | + * @param {String} rawText | |
| 344 | + * @returns {String} | |
| 345 | + */ | |
| 346 | +export const renderBadgeText = (rawText) => { | |
| 347 | + const text = typeof rawText === 'string' ? rawText : ''; | |
| 348 | + return text | |
| 349 | + .replace(/\[discounted_percentage\]/g, '20%') | |
| 350 | + .replace(/\[discounted_amount\]/g, '$10') | |
| 351 | + .replace(/\[remaining_quantity\]/g, '5') | |
| 352 | + .replace(/\[remaining_amount\]/g, '$50') | |
| 353 | + .replace(/\[remaining_cart_items\]/g, '2'); | |
| 354 | +}; | |
| 355 | + | |
| 356 | +/** | |
| 357 | + * | |
| 358 | + * @param {Object} radius | |
| 359 | + * @returns {String} | |
| 360 | + */ | |
| 361 | +export const getBorderRadius = (radius) => { | |
| 362 | + if (!radius) return undefined; | |
| 363 | + return `${radius['top-left'] || '0px'} ${radius['top-right'] || '0px'} ${radius['bottom-right'] || '0px'} ${radius['bottom-left'] || '0px'}`; | |
| 364 | +}; | |