@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bytebrand/fe-ui-core",
3
- "version": "4.2.117",
3
+ "version": "4.2.118",
4
4
  "description": "UI components for the auto.de project",
5
5
  "main": "index.ts",
6
6
  "module": "dist/common.js",
@@ -1,4 +1,4 @@
1
- import React, { useEffect, useRef, useState } from '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?:number;
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
- 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]);
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} ref={textRef} id={uniqueId}>{val}</span>
104
+ <span className={styles.value} >{val}</span>
103
105
  </span>
104
106
  );
105
107
  };
@@ -65,7 +65,6 @@ const PanelConfig: React.FunctionComponent<IPanelConfigProps> = ({
65
65
  postfix={postfix}
66
66
  className={styles.detailsPrice}
67
67
  unitClassName={styles.detailsUnit}
68
- fontSize={40}
69
68
  />
70
69
  </div>
71
70
  </div>
@@ -1,7 +1,8 @@
1
- import * as React from 'react';
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?:number;
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
- &nbsp;{unit}
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={tabContentPaddingClassName.includes('tabContentPaddingForBuy')?40:60}
97
+ fontSize={priceFontSize}
95
98
  />
96
99
  </div>
97
100
  ) : null}