Skip to content

Commit df42e8b

Browse files
authored
Merge pull request #1388 from prezly/feature/dev-22109-layuout-bug-in-new-preview
[DEV-22109] Fix - Preview bug on categories page
2 parents a8163b8 + 1b3cade commit df42e8b

3 files changed

Lines changed: 19 additions & 4 deletions

File tree

src/components/StoryCards/PlaceholderStoryCard.module.scss

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,17 @@ $image-height: 400px;
4444
justify-content: center;
4545
background-color: var(--prezly-background-color-intermediate);
4646
border: 1px solid var(--prezly-border-color);
47-
min-width: $image-width;
4847
height: $image-height;
4948
flex-shrink: 0;
5049
color: var(--prezly-text-color);
50+
51+
&.isCategoryPage {
52+
min-width: $image-width;
53+
}
54+
55+
&:not(.isCategoryPage) {
56+
max-width: $image-width;
57+
}
5158
}
5259

5360
.content {

src/components/StoryCards/PlaceholderStoryCard.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@ import styles from './PlaceholderStoryCard.module.scss';
1010
interface Props {
1111
title: string;
1212
description: string;
13+
isCategoryPage?: boolean;
1314
isHighlight?: boolean;
1415
hasStories?: boolean;
1516
}
1617

1718
export function PlaceholderStoryCard({
1819
title,
1920
description,
21+
isCategoryPage = false,
2022
isHighlight = false,
2123
hasStories = false,
2224
}: Props) {
@@ -25,7 +27,10 @@ export function PlaceholderStoryCard({
2527

2628
return (
2729
<a
28-
className={classNames(styles.wrapper, { [styles.highlight]: isHighlight })}
30+
className={classNames(styles.wrapper, {
31+
[styles.highlight]: isHighlight,
32+
[styles.categoryPage]: isCategoryPage,
33+
})}
2934
href={storiesUrl}
3035
onClick={() => analytics.track(PREVIEW.CREATE_STORY_CLICKED)}
3136
rel="noopener noreferrer"

src/modules/InfiniteStories/StoriesList.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,10 @@ export function StoriesList({
8080
const hasCategories = categories.length > 0;
8181
const hasStories = stories.length > 0;
8282
const isPreview = isPreviewActive();
83+
const totalStories = newsrooms.reduce((total, newsroom) => newsroom.stories_number + total, 0);
8384

8485
const [highlightedStories, restStories] = useMemo(() => {
85-
if (isPreview && stories.length < 3) {
86+
if (isPreview && totalStories < 3) {
8687
if (isCategoryList) {
8788
const placeholders = PLACEHOLDER_STORIES
8889
// Do not show the "Write your first Prezly story" placeholder in this case.
@@ -123,7 +124,7 @@ export function StoriesList({
123124
}
124125

125126
return [stories.slice(0, 1), stories.slice(1)];
126-
}, [hasCategories, isCategoryList, stories, isPreview]);
127+
}, [hasCategories, isCategoryList, stories, isPreview, totalStories]);
127128

128129
const getStoryCardSize = useStoryCardLayout(isCategoryList);
129130

@@ -209,6 +210,7 @@ export function StoriesList({
209210
description={story.description}
210211
title={story.title}
211212
hasStories={hasStories}
213+
isCategoryPage={isCategoryList}
212214
/>
213215
);
214216
}
@@ -263,6 +265,7 @@ export function StoriesList({
263265
description={story.description}
264266
title={story.title}
265267
hasStories={hasStories}
268+
isCategoryPage={isCategoryList}
266269
/>
267270
);
268271
}

0 commit comments

Comments
 (0)