@bytebrand/fe-ui-core 4.2.115 → 4.2.117
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/source/components/FormattedNumber/FormattedNumber.tsx +31 -4
- package/source/components/OfferDetailedSection/partials/PanelConfig.tsx +1 -1
- package/source/components/SearchFilters/filters/Power.tsx +1 -1
- package/source/components/Vehicle/VehicleFormattedPrice/VehicleFormattedPrice.tsx +3 -1
- package/source/components/VehicleDetailedSidebar/partials/PriceContent.styl +1 -1
- package/source/components/VehicleDetailedSidebar/partials/PriceContent.tsx +2 -0
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
2
2
|
import styles from './FormattedNumber.styl';
|
|
3
3
|
|
|
4
4
|
import classnames from 'classnames';
|
|
5
|
+
import _uniqueId from 'lodash/uniqueId';
|
|
5
6
|
|
|
6
7
|
export interface IFormattedPriceProps {
|
|
7
8
|
value: number;
|
|
@@ -12,15 +13,41 @@ export interface IFormattedPriceProps {
|
|
|
12
13
|
className?: string;
|
|
13
14
|
afterCommaClassName?: string;
|
|
14
15
|
beforeCommaClassName?: string;
|
|
16
|
+
fontSize?:number;
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
// const breakpointForRound = 10000;
|
|
18
20
|
const separatorCounter = 3;
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
+
const FormattedNumber: React.FunctionComponent<IFormattedPriceProps> = ({ className, value, disableFormatting, toRound, numbersAfterDot, beforeCommaClassName, afterCommaClassName, fontSize }) => {
|
|
22
|
+
const textRef = useRef(null);
|
|
23
|
+
const uniqueId = _uniqueId(className);
|
|
24
|
+
|
|
25
|
+
const [newFontSize, setFontSize] = useState(fontSize);
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
const priceElement = document.getElementById(uniqueId);
|
|
28
|
+
const resizeFont = () => {
|
|
29
|
+
const textWidth = priceElement.getBoundingClientRect().width;
|
|
30
|
+
let parentWidth = fontSize === 40 ? 150 : 100;
|
|
31
|
+
if (window.innerWidth < 720) {
|
|
32
|
+
parentWidth = fontSize === 40 ? 200 : 150;
|
|
33
|
+
}
|
|
34
|
+
if (fontSize && textWidth > 120) {
|
|
35
|
+
textRef.current.parentNode.style.maxWidth = `${parentWidth}px`;
|
|
36
|
+
const newFont = Math.floor(newFontSize * parentWidth / textWidth);
|
|
37
|
+
priceElement.style.fontSize = `${newFont}px`;
|
|
38
|
+
priceElement.style.verticalAlign = 'top';
|
|
39
|
+
textRef.current.parentNode.style.fontSize = `${newFont}px`;
|
|
40
|
+
setFontSize(newFont);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
resizeFont();
|
|
44
|
+
window.addEventListener('resize', resizeFont);
|
|
45
|
+
return () => window.removeEventListener('resize', resizeFont);
|
|
46
|
+
}, [uniqueId, newFontSize]);
|
|
21
47
|
|
|
22
48
|
function getFormattedNumber() {
|
|
23
49
|
// First we need to check if value is actual number;
|
|
50
|
+
|
|
24
51
|
const notFalsieValue = !!value ? value : 0;
|
|
25
52
|
|
|
26
53
|
const rounded = toRound ? Math.round(notFalsieValue) : notFalsieValue;
|
|
@@ -72,7 +99,7 @@ const FormattedNumber: React.FunctionComponent<IFormattedPriceProps> = ({ classN
|
|
|
72
99
|
|
|
73
100
|
return (
|
|
74
101
|
<span className={classnames(styles.formattedNumber, className)}>
|
|
75
|
-
<span className={styles.value}>{val}</span>
|
|
102
|
+
<span className={styles.value} ref={textRef} id={uniqueId}>{val}</span>
|
|
76
103
|
</span>
|
|
77
104
|
);
|
|
78
105
|
};
|
|
@@ -51,7 +51,6 @@ const PanelConfig: React.FunctionComponent<IPanelConfigProps> = ({
|
|
|
51
51
|
] : [];
|
|
52
52
|
|
|
53
53
|
const wrapperClassName = classnames(styles.wrapConfigDetails, { [styles.wrapConfigDetailsMobile]: mobileMode });
|
|
54
|
-
|
|
55
54
|
return (
|
|
56
55
|
<div className={wrapperClassName}>
|
|
57
56
|
<Hidden xs sm md>
|
|
@@ -66,6 +65,7 @@ const PanelConfig: React.FunctionComponent<IPanelConfigProps> = ({
|
|
|
66
65
|
postfix={postfix}
|
|
67
66
|
className={styles.detailsPrice}
|
|
68
67
|
unitClassName={styles.detailsUnit}
|
|
68
|
+
fontSize={40}
|
|
69
69
|
/>
|
|
70
70
|
</div>
|
|
71
71
|
</div>
|
|
@@ -23,6 +23,7 @@ export interface IVehiclePriceProps {
|
|
|
23
23
|
size?: 'small' | 'semimedium' | 'medium' | 'large';
|
|
24
24
|
disableStyles?: boolean;
|
|
25
25
|
disablePrice?: boolean;
|
|
26
|
+
fontSize?:number;
|
|
26
27
|
|
|
27
28
|
// FormattedNumber props
|
|
28
29
|
toRound?: boolean;
|
|
@@ -78,7 +79,7 @@ const VehicleFormattedPrice: React.FunctionComponent<IVehiclePriceProps> = (prop
|
|
|
78
79
|
// FormattedNumber props
|
|
79
80
|
const {
|
|
80
81
|
unit, sub, numbersAfterDot, toRound, numberContainerClassName,
|
|
81
|
-
afterCommaClassName, beforeCommaClassName, disableFormatting, disablePrice
|
|
82
|
+
afterCommaClassName, beforeCommaClassName, disableFormatting, disablePrice,fontSize
|
|
82
83
|
} = props;
|
|
83
84
|
|
|
84
85
|
const decimalsClass = classnames(afterCommaClassName, styles.decimals);
|
|
@@ -94,6 +95,7 @@ const VehicleFormattedPrice: React.FunctionComponent<IVehiclePriceProps> = (prop
|
|
|
94
95
|
disableFormatting,
|
|
95
96
|
numbersAfterDot,
|
|
96
97
|
toRound,
|
|
98
|
+
fontSize,
|
|
97
99
|
beforeCommaClassName,
|
|
98
100
|
value: price,
|
|
99
101
|
className: numberContainerClassName,
|
|
@@ -50,6 +50,7 @@ const PriceContent: React.FunctionComponent<IPriceContentProps> = ({
|
|
|
50
50
|
styles.tabContentPadding,
|
|
51
51
|
{ [styles.tabContentPaddingForBuy]: isBuy }
|
|
52
52
|
);
|
|
53
|
+
|
|
53
54
|
return (
|
|
54
55
|
<>
|
|
55
56
|
<div className={tabContentPaddingClassName}>
|
|
@@ -90,6 +91,7 @@ const PriceContent: React.FunctionComponent<IPriceContentProps> = ({
|
|
|
90
91
|
postfix={postfix}
|
|
91
92
|
numbersAfterDot={0}
|
|
92
93
|
size='large'
|
|
94
|
+
fontSize={tabContentPaddingClassName.includes('tabContentPaddingForBuy')?40:60}
|
|
93
95
|
/>
|
|
94
96
|
</div>
|
|
95
97
|
) : null}
|