From 7960323c0a4c25f4e6da57b33f6d65c593461ae0 Mon Sep 17 00:00:00 2001 From: vchikalkin Date: Wed, 20 Aug 2025 17:31:15 +0300 Subject: [PATCH] fix(service-card): improve expand button visibility logic for service description - Added logic to determine when to show the expand button based on description length and line breaks. - Enhanced user experience by ensuring the button appears only when necessary, improving readability of service descriptions. --- apps/web/components/shared/service-card.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/web/components/shared/service-card.tsx b/apps/web/components/shared/service-card.tsx index aa30484..09e8237 100644 --- a/apps/web/components/shared/service-card.tsx +++ b/apps/web/components/shared/service-card.tsx @@ -19,6 +19,12 @@ export function ServiceCard({ }: Readonly) { const [isDescriptionExpanded, setIsDescriptionExpanded] = useState(false); + const shouldShowExpandButton = + description && + (description.length > 120 || + description.split('\n').length > 2 || + (description.length > 80 && description.includes('\n'))); + return (
{description}
- {description.length > 100 && ( + + {shouldShowExpandButton && (
{ event.preventDefault();