From 90ed8636b8468f5e59d2f962a6a40e9c026e5987 Mon Sep 17 00:00:00 2001 From: Alexander Petkov Date: Fri, 17 May 2024 12:46:54 +0300 Subject: [PATCH] fix(campaign-news): Adjust initial article height with font's lineHeight This way the See more, See less buttons wont be visible if text is just around the height limit --- .../client/campaign-news/CampaignNewsList.tsx | 10 +++++++--- .../client/campaigns/CampaignNewsSection.tsx | 11 +++++++---- src/components/common/QuillStyleWrapper.tsx | 2 +- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/components/client/campaign-news/CampaignNewsList.tsx b/src/components/client/campaign-news/CampaignNewsList.tsx index 3d2a5277d..06453c79f 100644 --- a/src/components/client/campaign-news/CampaignNewsList.tsx +++ b/src/components/client/campaign-news/CampaignNewsList.tsx @@ -81,7 +81,9 @@ type Props = { export default function CampaignNewsList({ articles }: Props) { const { t, i18n } = useTranslation('news') - const INITIAL_HEIGHT_LIMIT = 400 + + const LINE_HEIGHT = theme.typography.body1.lineHeight + const INITIAL_HEIGHT_LIMIT = 400 * Number(LINE_HEIGHT) const [isExpanded, expandContent] = useShowMoreContent() return ( <> @@ -131,10 +133,12 @@ export default function CampaignNewsList({ articles }: Props) { maxWidth: 1200, }}> - {article.title} + + {article.title} + ({ padding: 0, }, - [`div.${classes.articleDescription} > p`]: { + [`article.${classes.articleDescription} > p`]: { margin: 0, }, @@ -162,7 +162,8 @@ export default function CampaignNewsSection({ campaign, canCreateArticle }: Prop const { t, i18n } = useTranslation('news') const { small }: { small: boolean } = useMobile() - const INITIAL_HEIGHT_LIMIT = 200 + const LINE_HEIGHT = theme.typography.body1.lineHeight + const INITIAL_HEIGHT_LIMIT = 200 * Number(LINE_HEIGHT) const [isExpanded, expandContent] = useShowMoreContent() return ( @@ -249,7 +250,9 @@ export default function CampaignNewsSection({ campaign, canCreateArticle }: Prop )} - {article.title} + + {article.title} + ({ }, ['p']: { - fontSize: theme.spacing(2), + fontSize: theme.typography.pxToRem(16), fontWeight: 400, lineHeight: theme.spacing(2.85), },