From 763ae2073cac680c616c837df05fe6fd61530b2f Mon Sep 17 00:00:00 2001 From: SemenStruchev Date: Thu, 20 Jul 2023 17:16:14 +0300 Subject: [PATCH] fully reworked --- src/components/Breakdown.jsx | 62 +++++++------------------- src/stories/Other/Breakdown.stories.js | 10 ++--- 2 files changed, 20 insertions(+), 52 deletions(-) diff --git a/src/components/Breakdown.jsx b/src/components/Breakdown.jsx index 7201a1571..b8298e095 100644 --- a/src/components/Breakdown.jsx +++ b/src/components/Breakdown.jsx @@ -43,57 +43,25 @@ const BreakdownItem = ({ color = "default", ...rest }) => { - const containerRef = useRef(null); - const textRef = useRef(null); - const [rowWidthExceeds20Percent, setRowWidthExceeds20Percent] = useState(false); - const dateOrInfoExist = !!date || !!info; const currency = useContext(CurrencyContext); - useEffect(() => { - const containerElement = containerRef.current; - const containerRect = containerElement.getBoundingClientRect(); - const containerWidth = containerRect.width; - - const textElement = textRef.current; - const textRect = textElement.getBoundingClientRect(); - const textWidth = textRect.width; - - const percentage = (textWidth / containerWidth) * 100; - if (!rowWidthExceeds20Percent) { - setRowWidthExceeds20Percent(percentage > 20); - } - }, [info, date]); - return ( - - {methodIcon} - - {children} - - - {secondary && {secondary}} - {rowWidthExceeds20Percent && dateOrInfoExist ? ( -

- {info && ( - - {info} - - )} - - {date && {date}} -

- ) : ( - <> - {info && ( - - {info} - - )} - {date && {date}} - - )} -
+ +
+ + {methodIcon} + {children} + + + {secondary && {secondary}} + {info && ( + + {info} + + )} + +
diff --git a/src/stories/Other/Breakdown.stories.js b/src/stories/Other/Breakdown.stories.js index a9b9c4391..bc3076a5e 100644 --- a/src/stories/Other/Breakdown.stories.js +++ b/src/stories/Other/Breakdown.stories.js @@ -22,7 +22,7 @@ export const Default = () => { Line item caption - Children + Very long really Children Adults @@ -42,16 +42,16 @@ export const Default = () => { - }> + }> Payment - }> + }> Return Payment - } value={0} methodIcon={}> - This is a really long message that should wrap somehow + } value={0} methodIcon={}> + This is a really long message that should wrap somehow more long