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 1 commit
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 widht and height. Fit - media content has real sizes and locates in the middle
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typos in width word


</StoryTemplate>
3 changes: 2 additions & 1 deletion src/models/constructor-items/sub-blocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,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?: 'fit' | 'full';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are configuring object-fit, it can have the values 'contain', 'cover', etc. I think they should be used as values for this prop. And create modifiers for these values, in your case only contain

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but in header we are using the same format. I want to keep consistence view

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a lot of settings in the header besides "object-fit".

In the case of the header, I would suggest using "contain", etc. as a value ,but I have not reviewed this code before

@gorgeousvlad what do you think ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we wanna get it same in Header and Banner, suppose we should create type, type MediaView = 'fit' | 'full' to use for both and keep same values.
In case we want to make them different (use contain in Banner) lets name theme different

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added MediaView type

}

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