From cf76bbcaa8f51890a31cdc270e61d59e994c4c17 Mon Sep 17 00:00:00 2001 From: Tomas Chlebek Date: Tue, 17 Dec 2024 09:26:45 +0100 Subject: [PATCH] fixed product slider on article page --- .../Basic/UserText/GrapesJsProducts.tsx | 15 +++++++++++---- .../components/Blocks/Product/ProductsSlider.tsx | 5 ++++- .../Pages/Article/ArticleDetailContent.tsx | 3 ++- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/storefront/components/Basic/UserText/GrapesJsProducts.tsx b/storefront/components/Basic/UserText/GrapesJsProducts.tsx index 3585ee98e7..36f14a09dd 100644 --- a/storefront/components/Basic/UserText/GrapesJsProducts.tsx +++ b/storefront/components/Basic/UserText/GrapesJsProducts.tsx @@ -1,4 +1,8 @@ -import { ProductsSlider, VISIBLE_SLIDER_ITEMS_BLOG } from 'components/Blocks/Product/ProductsSlider'; +import { + ProductsSlider, + VISIBLE_SLIDER_ITEMS_ARTICLE, + VISIBLE_SLIDER_ITEMS_BLOG, +} from 'components/Blocks/Product/ProductsSlider'; import { SkeletonModuleProductListItem } from 'components/Blocks/Skeleton/SkeletonModuleProductListItem'; import { TypeProductsByCatnums } from 'graphql/requests/products/queries/ProductsByCatnumsQuery.generated'; import { GtmMessageOriginType } from 'gtm/enums/GtmMessageOriginType'; @@ -48,19 +52,22 @@ export const GrapesJsProducts: FC = ({ return null; } + const isBlog = visibleSliderItems === VISIBLE_SLIDER_ITEMS_BLOG; + const isArticle = visibleSliderItems === VISIBLE_SLIDER_ITEMS_ARTICLE; + return (
3 ? 'xl:my-9' : '', - visibleSliderItems !== VISIBLE_SLIDER_ITEMS_BLOG && products.length > 4 ? 'vl:my-9' : '', + isBlog && products.length > VISIBLE_SLIDER_ITEMS_BLOG ? 'xl:my-9' : '', + isArticle && products.length > VISIBLE_SLIDER_ITEMS_ARTICLE ? 'vl:my-9' : '', )} >
diff --git a/storefront/components/Blocks/Product/ProductsSlider.tsx b/storefront/components/Blocks/Product/ProductsSlider.tsx index 9bd46b3b18..531230babb 100644 --- a/storefront/components/Blocks/Product/ProductsSlider.tsx +++ b/storefront/components/Blocks/Product/ProductsSlider.tsx @@ -17,9 +17,10 @@ import { wait } from 'utils/wait'; export const VISIBLE_SLIDER_ITEMS = 5; export const VISIBLE_SLIDER_ITEMS_LAST_VISITED = 8; export const VISIBLE_SLIDER_ITEMS_BLOG = 3; +export const VISIBLE_SLIDER_ITEMS_ARTICLE = 4; export const VISIBLE_SLIDER_ITEMS_AUTOCOMPLETE = 5; -type ProductsSliderVariant = 'default' | 'blog' | 'lastVisited' | 'autocomplete'; +type ProductsSliderVariant = 'default' | 'blog' | 'article' | 'lastVisited' | 'autocomplete'; export type ProductsSliderProps = { products: TypeListedProductFragment[]; gtmProductListName: GtmProductListNameType; @@ -118,6 +119,8 @@ export const ProductsSlider: FC = ({ return 'auto-cols-[225px] sm:auto-cols-[60%] md:auto-cols-[45%] lg:auto-cols-[30%] vl:auto-cols-[25%] xl:auto-cols-[20%]'; case 'blog': return 'auto-cols-[80%] lg:auto-cols-[45%] xl:auto-cols-[33.33%]'; + case 'article': + return 'auto-cols-[80%] sm:auto-cols-[60%] md:auto-cols-[45%] lg:auto-cols-[31%] vl:auto-cols-[33.33%] xl:auto-cols-[25%]'; case 'lastVisited': return 'auto-cols-[140px] sm:auto-cols-[30%] lg:auto-cols-[19.5%] vl:auto-cols-[14.5%] xl:auto-cols-[12.5%]'; case 'autocomplete': diff --git a/storefront/components/Pages/Article/ArticleDetailContent.tsx b/storefront/components/Pages/Article/ArticleDetailContent.tsx index 6e85655ff2..becbe46d27 100644 --- a/storefront/components/Pages/Article/ArticleDetailContent.tsx +++ b/storefront/components/Pages/Article/ArticleDetailContent.tsx @@ -1,5 +1,6 @@ import { ArticleTitle } from './ArticleTitle'; import { GrapesJsParser } from 'components/Basic/UserText/GrapesJsParser'; +import { VISIBLE_SLIDER_ITEMS_ARTICLE } from 'components/Blocks/Product/ProductsSlider'; import { Webline } from 'components/Layout/Webline/Webline'; import { TypeArticleDetailFragment } from 'graphql/requests/articlesInterface/articles/fragments/ArticleDetailFragment.generated'; import { useFormatDate } from 'utils/formatting/useFormatDate'; @@ -19,7 +20,7 @@ export const ArticleDetailContent: FC = ({ article })

{article.text !== null && (
- +
)}