@bytebrand/fe-ui-core 4.2.117 → 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 +30 -28
- package/source/components/OfferDetailedSection/partials/PanelConfig.tsx +0 -1
- package/source/components/Vehicle/VehicleFormattedPrice/VehicleFormattedPrice.tsx +17 -5
- package/source/components/VehicleDetailedSidebar/partials/PriceContent.styl +17 -0
- package/source/components/VehicleDetailedSidebar/partials/PriceContent.tsx +5 -2
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import styles from './FormattedNumber.styl';
|
|
3
3
|
|
|
4
4
|
import classnames from 'classnames';
|
|
@@ -13,37 +13,39 @@ export interface IFormattedPriceProps {
|
|
|
13
13
|
className?: string;
|
|
14
14
|
afterCommaClassName?: string;
|
|
15
15
|
beforeCommaClassName?: string;
|
|
16
|
-
fontSize?:
|
|
16
|
+
fontSize?:string;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
// const breakpointForRound = 10000;
|
|
20
20
|
const separatorCounter = 3;
|
|
21
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
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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]);
|
|
47
49
|
|
|
48
50
|
function getFormattedNumber() {
|
|
49
51
|
// First we need to check if value is actual number;
|
|
@@ -99,7 +101,7 @@ const FormattedNumber: React.FunctionComponent<IFormattedPriceProps> = ({ classN
|
|
|
99
101
|
|
|
100
102
|
return (
|
|
101
103
|
<span className={classnames(styles.formattedNumber, className)}>
|
|
102
|
-
<span className={styles.value}
|
|
104
|
+
<span className={styles.value} >{val}</span>
|
|
103
105
|
</span>
|
|
104
106
|
);
|
|
105
107
|
};
|
|
@@ -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,7 +24,7 @@ export interface IVehiclePriceProps {
|
|
|
23
24
|
size?: 'small' | 'semimedium' | 'medium' | 'large';
|
|
24
25
|
disableStyles?: boolean;
|
|
25
26
|
disablePrice?: boolean;
|
|
26
|
-
fontSize?:
|
|
27
|
+
fontSize?:string;
|
|
27
28
|
|
|
28
29
|
// FormattedNumber props
|
|
29
30
|
toRound?: boolean;
|
|
@@ -35,11 +36,22 @@ export interface IVehiclePriceProps {
|
|
|
35
36
|
}
|
|
36
37
|
|
|
37
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
|
+
|
|
38
50
|
function renderUnit(): React.ReactNode {
|
|
39
51
|
const { postfix, unit, unitClassName } = props;
|
|
40
52
|
return (
|
|
41
53
|
<span className={classnames(styles.unit, unitClassName)}>
|
|
42
|
-
|
|
54
|
+
{fontSize === 'small' ? unit : '\u00A0' + unit}
|
|
43
55
|
{postfix ? renderPostfix() : ''}
|
|
44
56
|
</span>);
|
|
45
57
|
}
|
|
@@ -79,7 +91,7 @@ const VehicleFormattedPrice: React.FunctionComponent<IVehiclePriceProps> = (prop
|
|
|
79
91
|
// FormattedNumber props
|
|
80
92
|
const {
|
|
81
93
|
unit, sub, numbersAfterDot, toRound, numberContainerClassName,
|
|
82
|
-
afterCommaClassName, beforeCommaClassName, disableFormatting, disablePrice,fontSize
|
|
94
|
+
afterCommaClassName, beforeCommaClassName, disableFormatting, disablePrice, fontSize
|
|
83
95
|
} = props;
|
|
84
96
|
|
|
85
97
|
const decimalsClass = classnames(afterCommaClassName, styles.decimals);
|
|
@@ -103,7 +115,7 @@ const VehicleFormattedPrice: React.FunctionComponent<IVehiclePriceProps> = (prop
|
|
|
103
115
|
};
|
|
104
116
|
|
|
105
117
|
return (
|
|
106
|
-
<span className={containerClass}>
|
|
118
|
+
<span className={containerClass} ref={textRef} id={uniqueId}>
|
|
107
119
|
{<FormattedNumber {...formattedNumberProps} />}
|
|
108
120
|
{(unit && !monthly) && renderUnit()}
|
|
109
121
|
{(monthly && unit) && renderUnitMonthly()}
|
|
@@ -25,6 +25,9 @@
|
|
|
25
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,10 +46,12 @@ 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
|
);
|
|
53
56
|
|
|
54
57
|
return (
|
|
@@ -91,7 +94,7 @@ const PriceContent: React.FunctionComponent<IPriceContentProps> = ({
|
|
|
91
94
|
postfix={postfix}
|
|
92
95
|
numbersAfterDot={0}
|
|
93
96
|
size='large'
|
|
94
|
-
fontSize={
|
|
97
|
+
fontSize={priceFontSize}
|
|
95
98
|
/>
|
|
96
99
|
</div>
|
|
97
100
|
) : null}
|