@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bytebrand/fe-ui-core",
3
- "version": "4.2.115",
3
+ "version": "4.2.117",
4
4
  "description": "UI components for the auto.de project",
5
5
  "main": "index.ts",
6
6
  "module": "dist/common.js",
@@ -1,7 +1,8 @@
1
- import * as React from 'react';
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 FormattedNumber: React.FunctionComponent<IFormattedPriceProps> = ({ className, value, disableFormatting, toRound, numbersAfterDot, beforeCommaClassName, afterCommaClassName }) => {
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>
@@ -27,7 +27,7 @@ class Power extends React.Component<IPowerProps, ITypeState> {
27
27
 
28
28
  this.name = 'POWER';
29
29
  this.state = {
30
- type: 'PS'
30
+ type: props.controls.type
31
31
  };
32
32
  }
33
33
 
@@ -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,
@@ -22,7 +22,7 @@
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
28
  .tabContentPadding
@@ -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}