@bytebrand/fe-ui-core 4.2.116 → 4.2.118
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 +33 -4
- package/source/components/OfferDetailedSection/partials/PanelConfig.tsx +0 -1
- package/source/components/Vehicle/VehicleFormattedPrice/VehicleFormattedPrice.tsx +18 -4
- package/source/components/VehicleDetailedSidebar/partials/PriceContent.styl +18 -1
- package/source/components/VehicleDetailedSidebar/partials/PriceContent.tsx +6 -1
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React 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,43 @@ export interface IFormattedPriceProps {
|
|
|
12
13
|
className?: string;
|
|
13
14
|
afterCommaClassName?: string;
|
|
14
15
|
beforeCommaClassName?: string;
|
|
16
|
+
fontSize?:string;
|
|
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 && value.toString().length>4) {
|
|
35
|
+
// // textRef.current.parentNode.style.maxWidth = `${parentWidth}px`;
|
|
36
|
+
// // const newFont = Math.floor(newFontSize * parentWidth / textWidth);
|
|
37
|
+
// // priceElement.style.fontSize = `45px`;
|
|
38
|
+
// // priceElement.style.verticalAlign = 'top';
|
|
39
|
+
// textRef.current.parentNode.style.fontSize = `45px`;
|
|
40
|
+
// // setFontSize(newFont);
|
|
41
|
+
// }
|
|
42
|
+
// // };
|
|
43
|
+
// // resizeFont();
|
|
44
|
+
// // window.addEventListener('resize', resizeFont);
|
|
45
|
+
// // return () => window.removeEventListener('resize', resizeFont);
|
|
46
|
+
// // if(fontSize && )
|
|
47
|
+
// console.log('value',value.toString().length);
|
|
48
|
+
// }, [uniqueId]);
|
|
21
49
|
|
|
22
50
|
function getFormattedNumber() {
|
|
23
51
|
// First we need to check if value is actual number;
|
|
52
|
+
|
|
24
53
|
const notFalsieValue = !!value ? value : 0;
|
|
25
54
|
|
|
26
55
|
const rounded = toRound ? Math.round(notFalsieValue) : notFalsieValue;
|
|
@@ -72,7 +101,7 @@ const FormattedNumber: React.FunctionComponent<IFormattedPriceProps> = ({ classN
|
|
|
72
101
|
|
|
73
102
|
return (
|
|
74
103
|
<span className={classnames(styles.formattedNumber, className)}>
|
|
75
|
-
<span className={styles.value}>{val}</span>
|
|
104
|
+
<span className={styles.value} >{val}</span>
|
|
76
105
|
</span>
|
|
77
106
|
);
|
|
78
107
|
};
|
|
@@ -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>
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React, { useEffect, useRef } from 'react';
|
|
2
2
|
import classnames from 'classnames';
|
|
3
3
|
import FormattedNumber from '../../FormattedNumber/FormattedNumber';
|
|
4
4
|
import styles from './VehicleFormattedPrice.styl';
|
|
5
|
+
import _uniqueId from 'lodash/uniqueId';
|
|
5
6
|
|
|
6
7
|
export interface IVehiclePriceProps {
|
|
7
8
|
price: number;
|
|
@@ -23,6 +24,7 @@ export interface IVehiclePriceProps {
|
|
|
23
24
|
size?: 'small' | 'semimedium' | 'medium' | 'large';
|
|
24
25
|
disableStyles?: boolean;
|
|
25
26
|
disablePrice?: boolean;
|
|
27
|
+
fontSize?:string;
|
|
26
28
|
|
|
27
29
|
// FormattedNumber props
|
|
28
30
|
toRound?: boolean;
|
|
@@ -34,11 +36,22 @@ export interface IVehiclePriceProps {
|
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
const VehicleFormattedPrice: React.FunctionComponent<IVehiclePriceProps> = (props) => {
|
|
39
|
+
const textRef = useRef(null);
|
|
40
|
+
const uniqueId = _uniqueId(props.className);
|
|
41
|
+
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
const priceElement = document.getElementById(uniqueId);
|
|
44
|
+
if (fontSize === 'small') {
|
|
45
|
+
priceElement.style.fontSize = `45px`;
|
|
46
|
+
priceElement.style.margin = `9px 0px 0px 4px`;
|
|
47
|
+
}
|
|
48
|
+
}, [uniqueId]);
|
|
49
|
+
|
|
37
50
|
function renderUnit(): React.ReactNode {
|
|
38
51
|
const { postfix, unit, unitClassName } = props;
|
|
39
52
|
return (
|
|
40
53
|
<span className={classnames(styles.unit, unitClassName)}>
|
|
41
|
-
|
|
54
|
+
{fontSize === 'small' ? unit : '\u00A0' + unit}
|
|
42
55
|
{postfix ? renderPostfix() : ''}
|
|
43
56
|
</span>);
|
|
44
57
|
}
|
|
@@ -78,7 +91,7 @@ const VehicleFormattedPrice: React.FunctionComponent<IVehiclePriceProps> = (prop
|
|
|
78
91
|
// FormattedNumber props
|
|
79
92
|
const {
|
|
80
93
|
unit, sub, numbersAfterDot, toRound, numberContainerClassName,
|
|
81
|
-
afterCommaClassName, beforeCommaClassName, disableFormatting, disablePrice
|
|
94
|
+
afterCommaClassName, beforeCommaClassName, disableFormatting, disablePrice, fontSize
|
|
82
95
|
} = props;
|
|
83
96
|
|
|
84
97
|
const decimalsClass = classnames(afterCommaClassName, styles.decimals);
|
|
@@ -94,6 +107,7 @@ const VehicleFormattedPrice: React.FunctionComponent<IVehiclePriceProps> = (prop
|
|
|
94
107
|
disableFormatting,
|
|
95
108
|
numbersAfterDot,
|
|
96
109
|
toRound,
|
|
110
|
+
fontSize,
|
|
97
111
|
beforeCommaClassName,
|
|
98
112
|
value: price,
|
|
99
113
|
className: numberContainerClassName,
|
|
@@ -101,7 +115,7 @@ const VehicleFormattedPrice: React.FunctionComponent<IVehiclePriceProps> = (prop
|
|
|
101
115
|
};
|
|
102
116
|
|
|
103
117
|
return (
|
|
104
|
-
<span className={containerClass}>
|
|
118
|
+
<span className={containerClass} ref={textRef} id={uniqueId}>
|
|
105
119
|
{<FormattedNumber {...formattedNumberProps} />}
|
|
106
120
|
{(unit && !monthly) && renderUnit()}
|
|
107
121
|
{(monthly && unit) && renderUnitMonthly()}
|
|
@@ -22,9 +22,12 @@
|
|
|
22
22
|
margin-left: 0;
|
|
23
23
|
+media-phone-only()
|
|
24
24
|
[class*="VehicleFormattedPrice__large"]
|
|
25
|
-
font-size: 45px;
|
|
25
|
+
font-size: 45px!important;
|
|
26
26
|
margin-left: 3px;
|
|
27
27
|
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
28
31
|
.tabContentPadding
|
|
29
32
|
padding: 10px 10px 10px 10px;
|
|
30
33
|
flex-direction: row
|
|
@@ -112,3 +115,17 @@
|
|
|
112
115
|
.wrapper
|
|
113
116
|
+media-tablet-landscape-up()
|
|
114
117
|
padding-right: 15px;
|
|
118
|
+
|
|
119
|
+
.priceFontSizeSmall
|
|
120
|
+
.financingPriceItem
|
|
121
|
+
display: block;
|
|
122
|
+
.priceInfoLabel
|
|
123
|
+
margin-top:8px!important
|
|
124
|
+
.wrapper
|
|
125
|
+
+media-tablet-landscape-up()
|
|
126
|
+
padding-right: 0px;
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
.tabContentPaddingForBuy.priceFontSizeSmall
|
|
130
|
+
.financingPriceItem
|
|
131
|
+
display: flex;
|
|
@@ -7,6 +7,7 @@ import styles from './PriceContent.styl';
|
|
|
7
7
|
import VehicleFormattedPrice from '../../Vehicle/VehicleFormattedPrice/VehicleFormattedPrice';
|
|
8
8
|
import PriceRating from '../../PriceRating/PriceRating';
|
|
9
9
|
import RequestOffer from '../../_common/OfferRequestButtonWrapper/OfferRequestButtonWrapper';
|
|
10
|
+
import { getFormattedPrice } from '../../../../utils';
|
|
10
11
|
|
|
11
12
|
const PriceContent: React.FunctionComponent<IPriceContentProps> = ({
|
|
12
13
|
t,
|
|
@@ -45,11 +46,14 @@ const PriceContent: React.FunctionComponent<IPriceContentProps> = ({
|
|
|
45
46
|
isAdditionalOption: true,
|
|
46
47
|
onShowOfferDetails: offerBlockProps.onShowOfferDetails
|
|
47
48
|
};
|
|
49
|
+
const priceFontSize:string = monthlyInstallment ? (getFormattedPrice(monthlyInstallment)?.toString().match(/\d/g).length >= 4 ? 'small' :'large') :'';
|
|
48
50
|
|
|
49
51
|
const tabContentPaddingClassName = classnames(
|
|
50
52
|
styles.tabContentPadding,
|
|
51
|
-
{ [styles.tabContentPaddingForBuy]: isBuy }
|
|
53
|
+
{ [styles.tabContentPaddingForBuy]: isBuy },
|
|
54
|
+
{ [styles.priceFontSizeSmall]: priceFontSize === 'small' }
|
|
52
55
|
);
|
|
56
|
+
|
|
53
57
|
return (
|
|
54
58
|
<>
|
|
55
59
|
<div className={tabContentPaddingClassName}>
|
|
@@ -90,6 +94,7 @@ const PriceContent: React.FunctionComponent<IPriceContentProps> = ({
|
|
|
90
94
|
postfix={postfix}
|
|
91
95
|
numbersAfterDot={0}
|
|
92
96
|
size='large'
|
|
97
|
+
fontSize={priceFontSize}
|
|
93
98
|
/>
|
|
94
99
|
</div>
|
|
95
100
|
) : null}
|