Skip to content

Commit 9868fc0

Browse files
committed
Rename isExternal prop to external
1 parent c1d491e commit 9868fc0

File tree

10 files changed

+38
-47
lines changed

10 files changed

+38
-47
lines changed

src/components/CategoriesList/CategoriesList.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import styles from './CategoriesList.module.scss';
1313
type Props = {
1414
categories: TranslatedCategory[];
1515
className?: string;
16-
isExternal: ExternalNewsroomUrl;
16+
external: ExternalNewsroomUrl;
1717
isStatic?: boolean;
1818
showAllCategories?: boolean;
1919
withBadges?: boolean;
@@ -24,7 +24,7 @@ const MAX_CATEGORIES_CHARACTER_LENGTH = 50;
2424
export function CategoriesList({
2525
categories,
2626
className,
27-
isExternal,
27+
external,
2828
isStatic,
2929
showAllCategories = false,
3030
withBadges = false,
@@ -72,7 +72,7 @@ export function CategoriesList({
7272
<CategoryLink
7373
category={category}
7474
className={styles.categoryLink}
75-
isExternal={isExternal}
75+
external={external}
7676
withBadge={withBadges}
7777
/>
7878
</Fragment>

src/components/CategoryLink/CategoryLink.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ import styles from './CategoryLink.module.scss';
1212
type Props = {
1313
category: TranslatedCategory;
1414
className?: string;
15-
isExternal: ExternalNewsroomUrl;
15+
external: ExternalNewsroomUrl;
1616
withBadge?: boolean;
1717
};
1818

19-
export function CategoryLink({ category, className, isExternal, withBadge = false }: Props) {
19+
export function CategoryLink({ category, className, external, withBadge = false }: Props) {
2020
const content = withBadge ? (
2121
<Badge variant="outline" size="small">
2222
{category.name}
@@ -25,8 +25,8 @@ export function CategoryLink({ category, className, isExternal, withBadge = fals
2525
<span>{category.name}</span>
2626
);
2727

28-
const href = isExternal
29-
? `${ensureTrailingSlash(isExternal.newsroomUrl)}${category.locale}/category/${category.slug}`
28+
const href = external
29+
? `${ensureTrailingSlash(external.newsroomUrl)}${category.locale}/category/${category.slug}`
3030
: ({
3131
routeName: 'category',
3232
params: { slug: category.slug, localeCode: category.locale },

src/components/StoryCards/HighlightedStoryCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ export function HighlightedStoryCard({
107107
return (
108108
<StoryCard
109109
key={story.uuid}
110+
external={false}
110111
fallback={fallback}
111-
isExternal={false}
112112
layout="horizontal"
113113
placeholder={{}}
114114
publishedAt={story.published_at}

src/components/StoryCards/StoryCard.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ import styles from './StoryCard.module.scss';
1313

1414
type Props = {
1515
className?: string;
16+
external: ExternalStoryUrl;
1617
fallback: StoryImage.Props['fallback'];
1718
forceAspectRatio?: boolean;
18-
isExternal: ExternalStoryUrl;
1919
layout: 'horizontal' | 'vertical';
2020
placeholder: StoryImage.Props['placeholder'];
2121
publishedAt: string | null;
@@ -34,9 +34,9 @@ type Props = {
3434

3535
export function StoryCard({
3636
className,
37+
external,
3738
fallback,
3839
forceAspectRatio,
39-
isExternal,
4040
layout,
4141
placeholder,
4242
publishedAt,
@@ -55,8 +55,8 @@ export function StoryCard({
5555
const hasCategories = translatedCategories.length > 0;
5656
const HeadingTag = size === 'small' ? 'h3' : 'h2';
5757

58-
const href = isExternal
59-
? isExternal.storyUrl
58+
const href = external
59+
? external.storyUrl
6060
: ({ routeName: 'story', params: { slug } } satisfies Link.Props['href']);
6161

6262
return (
@@ -88,7 +88,7 @@ export function StoryCard({
8888
{hasCategories && (
8989
<CategoriesList
9090
categories={translatedCategories}
91-
isExternal={isExternal}
91+
external={external}
9292
isStatic
9393
showAllCategories
9494
withBadges={variant === 'boxed'}

src/modules/Header/ui/SearchWidget/components/SearchHit.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ import { getNewsroomPlaceholderColors } from '@/utils';
1212
import styles from './SearchHit.module.scss';
1313

1414
interface Props {
15+
external: ExternalStoryUrl;
1516
hit: Hit<{ attributes: Search.IndexedStory; _tags: string[] }>;
16-
isExternal: ExternalStoryUrl;
1717
newsroom: Newsroom | undefined;
1818
onClick?: (event: MouseEvent<HTMLAnchorElement>) => void;
1919
}
2020

21-
export function SearchHit({ hit, isExternal, newsroom, onClick }: Props) {
21+
export function SearchHit({ external, hit, newsroom, onClick }: Props) {
2222
const { attributes: story } = hit;
2323

24-
const href = isExternal
25-
? isExternal.storyUrl
24+
const href = external
25+
? external.storyUrl
2626
: ({ routeName: 'story', params: story } satisfies Link.Props['href']);
2727

2828
return (

src/modules/Header/ui/SearchWidget/components/SearchResults.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export function SearchResults({
4242
const storyNewsroomUuid = getNewsroomUuidFromHitTags(hit._tags);
4343
const newsroom = newsrooms.find((newsroom) => newsroom.uuid === storyNewsroomUuid);
4444

45-
const isExternal =
45+
const external =
4646
newsroom && newsroom.uuid !== newsroomUuid
4747
? ({
4848
newsroomUrl: newsroom.url,
@@ -53,7 +53,7 @@ export function SearchResults({
5353

5454
return (
5555
<SearchHit
56-
isExternal={isExternal}
56+
external={external}
5757
newsroom={newsroom}
5858
onClick={onPlainLeftClick(onClose)}
5959
hit={hit}

src/modules/InfiniteStories/StoriesList.tsx

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -125,27 +125,26 @@ export function StoriesList({
125125
})}
126126
>
127127
{restStories.map((story, index) => {
128-
const isExternal = story.newsroom.uuid !== newsroomUuid;
129128
const newsroom = newsrooms.find(
130129
(newsroom) => newsroom.uuid === story.newsroom.uuid,
131130
);
132131

133132
return (
134133
<StoryCard
135134
key={story.uuid}
136-
fallback={{
137-
image: newsroom?.newsroom_logo ?? null,
138-
text: newsroom?.name ?? '',
139-
}}
140-
forceAspectRatio
141-
isExternal={
142-
isExternal
135+
external={
136+
story.newsroom.uuid !== newsroomUuid
143137
? {
144138
newsroomUrl: story.newsroom.url,
145139
storyUrl: story.links.newsroom_view!,
146140
}
147141
: false
148142
}
143+
fallback={{
144+
image: newsroom?.newsroom_logo ?? null,
145+
text: newsroom?.name ?? '',
146+
}}
147+
forceAspectRatio
149148
layout="vertical"
150149
placeholder={getNewsroomPlaceholderColors(newsroom)}
151150
publishedAt={story.published_at}
@@ -170,7 +169,6 @@ export function StoriesList({
170169
{restStories.length > 0 && layout === 'masonry' && (
171170
<StaggeredLayout className={styles.staggered}>
172171
{restStories.map((story) => {
173-
const isExternal = story.newsroom.uuid !== newsroomUuid;
174172
const newsroom = newsrooms.find(
175173
(newsroom) => newsroom.uuid === story.newsroom.uuid,
176174
);
@@ -179,18 +177,18 @@ export function StoriesList({
179177
<StoryCard
180178
key={story.uuid}
181179
className={styles.card}
182-
fallback={{
183-
image: newsroom?.newsroom_logo ?? null,
184-
text: newsroom?.name ?? '',
185-
}}
186-
isExternal={
187-
isExternal
180+
external={
181+
story.newsroom.uuid !== newsroomUuid
188182
? {
189183
newsroomUrl: story.newsroom.url,
190184
storyUrl: story.links.newsroom_view!,
191185
}
192186
: false
193187
}
188+
fallback={{
189+
image: newsroom?.newsroom_logo ?? null,
190+
text: newsroom?.name ?? '',
191+
}}
194192
layout="vertical"
195193
placeholder={getNewsroomPlaceholderColors(newsroom)}
196194
publishedAt={story.published_at}

src/modules/Search/components/Hit.tsx

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,15 @@ import type { ExternalStoryUrl } from '@/types';
1313
import { getNewsroomPlaceholderColors } from '@/utils';
1414

1515
export interface Props {
16+
external: ExternalStoryUrl;
1617
hit: HitType<{ attributes: Search.IndexedStory; _tags: string[] }>;
17-
isExternal: ExternalStoryUrl;
1818
newsroom: Newsroom;
1919
showDate: boolean;
2020
showSubtitle: boolean;
2121
storyCardVariant: ThemeSettings['story_card_variant'];
2222
}
2323

24-
export function Hit({
25-
hit,
26-
isExternal,
27-
newsroom,
28-
showDate,
29-
showSubtitle,
30-
storyCardVariant,
31-
}: Props) {
24+
export function Hit({ external, hit, newsroom, showDate, showSubtitle, storyCardVariant }: Props) {
3225
const { attributes: story } = hit;
3326
const { categories } = story;
3427
const localeCode = useLocale();
@@ -50,11 +43,11 @@ export function Hit({
5043

5144
return (
5245
<StoryCard
46+
external={external}
5347
fallback={{
5448
image: newsroom.newsroom_logo,
5549
text: newsroom.name,
5650
}}
57-
isExternal={isExternal}
5851
layout="horizontal"
5952
placeholder={getNewsroomPlaceholderColors(newsroom)}
6053
publishedAt={new Date(story.published_at * 1000).toISOString()}

src/modules/Search/components/Results.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export const Results = connectInfiniteHits(
6666
return null;
6767
}
6868

69-
const isExternal =
69+
const external =
7070
newsroom.uuid !== newsroomUuid
7171
? ({
7272
newsroomUrl: newsroom.url,
@@ -78,8 +78,8 @@ export const Results = connectInfiniteHits(
7878
return (
7979
<Hit
8080
key={hit.objectID}
81+
external={external}
8182
hit={hit}
82-
isExternal={isExternal}
8383
newsroom={newsroom}
8484
showDate={showDate}
8585
showSubtitle={showSubtitle}

src/modules/Story/Story.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export async function Story({
7171
{categories.length > 0 && (
7272
<CategoriesList
7373
categories={categories}
74-
isExternal={false}
74+
external={false}
7575
showAllCategories
7676
withBadges={withBadges}
7777
/>

0 commit comments

Comments
 (0)