Skip to content

Commit 36cb65f

Browse files
aleksey-shkadovbablos
andauthored
fix: button in banner block is optional (#1033)
* fix: button in banner block is optional * fix: button in banner block is optional --------- Co-authored-by: bablos <[email protected]>
1 parent 48ba404 commit 36cb65f

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

src/blocks/Banner/__stories__/Banner.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import * as BannerStories from './Banner.stories.tsx';
1919

2020
`color?: string` — Background color
2121

22-
`button: Button` — Button
22+
`button?: Button` — Button
2323

2424
`mediaView?: full | fit` — full is default value, the media content covers all width and height. Fit - media content has real sizes and locates in the middle
2525

src/models/constructor-items/sub-blocks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ export interface BannerCardProps {
162162
disableCompress?: boolean;
163163
color?: ThemeSupporting<string>;
164164
theme?: TextTheme;
165-
button: Pick<ButtonProps, 'text' | 'url' | 'target' | 'theme'>;
165+
button?: Pick<ButtonProps, 'text' | 'url' | 'target' | 'theme'>;
166166
mediaView?: MediaView;
167167
}
168168

src/sub-blocks/BannerCard/BannerCard.tsx

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const BannerCard = (props: BannerCardProps) => {
1313
const {
1414
title,
1515
subtitle,
16-
button: {url, text, target, theme: buttonTheme = 'raised'},
16+
button: {url, text, target, theme: buttonTheme = 'raised'} = {},
1717
color,
1818
theme: textTheme = 'light',
1919
image,
@@ -43,16 +43,19 @@ export const BannerCard = (props: BannerCardProps) => {
4343
/>
4444
)}
4545
</div>
46-
<RouterLink href={url}>
47-
<Button
48-
className={b('button')}
49-
theme={buttonTheme}
50-
size="xl"
51-
text={text}
52-
url={url}
53-
target={target}
54-
/>
55-
</RouterLink>
46+
47+
{url && (
48+
<RouterLink href={url}>
49+
<Button
50+
className={b('button')}
51+
theme={buttonTheme}
52+
size="xl"
53+
text={text ?? ''}
54+
url={url}
55+
target={target}
56+
/>
57+
</RouterLink>
58+
)}
5659
</div>
5760
<BackgroundImage
5861
className={b('image')}

0 commit comments

Comments
 (0)