Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added mediaView for image and theme for button in banner block #794

Merged
merged 3 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/blocks/Banner/__stories__/Banner.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@ import * as BannerStories from './Banner.stories.tsx';
`color?: string` — Background color

`button: Button` — Button

`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

</StoryTemplate>
2 changes: 1 addition & 1 deletion src/blocks/Header/__stories__/Header.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ There could be only one one Header block on the page.
`verticalOffset?: '0' | 's' | 'm' | 'l' | 'xl'` — Top and bottom offsets from the text. (Values: '0' - 0px, 's' - 48px, 'm' - 80px, 'l' - 112px, 'xl' - 144px.)
</StoryTemplate>

`mediaView?: full | fit` — full is default value, the media content covers all widht and height. Fit - media content has real sizes and locates in the middle
`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
3 changes: 2 additions & 1 deletion src/models/constructor-items/blocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
MapProps,
MediaDirection,
MediaProps,
MediaView,
TextSize,
TextTheme,
ThemedImage,
Expand Down Expand Up @@ -159,7 +160,7 @@ export interface HeaderBlockProps {
offset?: HeaderOffset;
image?: ThemedImage;
video?: ThemedMediaVideoProps;
mediaView?: 'fit' | 'full';
mediaView?: MediaView;
background?: ThemedHeaderBlockBackground;
theme?: 'light' | 'dark';
verticalOffset?: '0' | 's' | 'm' | 'l' | 'xl';
Expand Down
2 changes: 2 additions & 0 deletions src/models/constructor-items/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,8 @@ export interface TitleItemBaseProps {
onClick?: () => void;
}

export type MediaView = 'fit' | 'full';

// card
export type MediaBorder = 'shadow' | 'line' | 'none';
export type CardBorder = MediaBorder;
Expand Down
4 changes: 3 additions & 1 deletion src/models/constructor-items/sub-blocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
ImageProps,
LinkProps,
MediaProps,
MediaView,
PriceDetailedProps,
TextTheme,
Themable,
Expand Down Expand Up @@ -143,7 +144,8 @@ export interface BannerCardProps {
disableCompress?: boolean;
color?: ThemeSupporting<string>;
theme?: TextTheme;
button: Pick<ButtonProps, 'text' | 'url' | 'target'>;
button: Pick<ButtonProps, 'text' | 'url' | 'target' | 'theme'>;
mediaView?: MediaView;
}

export interface MediaCardProps extends MediaProps, AnalyticsEventsBase, CardBaseProps {}
Expand Down
8 changes: 8 additions & 0 deletions src/sub-blocks/BannerCard/BannerCard.scss
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ $block: '.#{$ns}banner-card';
}
}

&_media-view_fit {
#{$block}__image {
img {
object-fit: contain;
}
}
}

@media (max-width: map-get($gridBreakpoints, 'sm') - 1) {
&__image {
display: none;
Expand Down
7 changes: 4 additions & 3 deletions src/sub-blocks/BannerCard/BannerCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ export const BannerCard = (props: BannerCardProps) => {
const {
title,
subtitle,
button: {url, text, target},
button: {url, text, target, theme: buttonTheme = 'raised'},
color,
theme: textTheme = 'light',
image,
disableCompress,
mediaView = 'full',
} = props;
const theme = useTheme();
const contentStyle: Record<string, string> = {};
Expand All @@ -27,7 +28,7 @@ export const BannerCard = (props: BannerCardProps) => {
}

return (
<div className={b({theme: textTheme})}>
<div className={b({theme: textTheme, ['media-view']: mediaView})}>
<div className={b('content')} style={contentStyle}>
<div className={b('info')}>
<div className={b('text')}>
Expand All @@ -45,7 +46,7 @@ export const BannerCard = (props: BannerCardProps) => {
<RouterLink href={url}>
<Button
className={b('button')}
theme="raised"
theme={buttonTheme}
size="xl"
text={text}
url={url}
Expand Down
Loading