Skip to content

Commit dc93876

Browse files
committed
feat: add border to media in media-block
1 parent dcffe83 commit dc93876

File tree

9 files changed

+68
-8
lines changed

9 files changed

+68
-8
lines changed

src/blocks/Media/Media.scss

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@import '../../../styles/mixins';
2+
3+
$block: '.#{$ns}media-block';
4+
5+
#{$block} {
6+
@include media-border();
7+
}

src/blocks/Media/Media.tsx

+14-4
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,29 @@ import Media from '../../components/Media/Media';
44
import MediaBase from '../../components/MediaBase/MediaBase';
55
import {useTheme} from '../../context/theme';
66
import {MediaBlockProps} from '../../models';
7-
import {getThemedValue} from '../../utils';
7+
import {block, getThemedValue} from '../../utils';
8+
9+
import './Media.scss';
10+
11+
const b = block('media-block');
812

913
export const MediaBlock = (props: MediaBlockProps) => {
10-
const {media} = props;
14+
const {media, border = 'shadow', disableShadow} = props;
15+
16+
const mediaBaseShadow = disableShadow || border !== 'shadow';
1117

1218
const [play, setPlay] = useState<boolean>(false);
1319
const theme = useTheme();
1420
const mediaThemed = getThemedValue(media, theme);
1521

1622
return (
17-
<MediaBase {...props} onScroll={() => setPlay(true)}>
23+
<MediaBase {...props} onScroll={() => setPlay(true)} disableShadow={mediaBaseShadow}>
1824
<MediaBase.Card>
19-
<Media {...mediaThemed} playVideo={play} />
25+
<Media
26+
{...mediaThemed}
27+
playVideo={play}
28+
className={b({border: disableShadow ? 'none' : border})}
29+
/>
2030
</MediaBase.Card>
2131
</MediaBase>
2232
);

src/blocks/Media/__stories__/Media.mdx

+3-1
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@ import * as MediaStories from './Media.stories.tsx';
2121

2222
`largeMedia?: boolean` — An image/video takes 8 columns.
2323

24-
`disableShadow?: boolean` — Disable shadow for the block.
24+
`disableShadow?: boolean` — Disable shadow for the block (Deprecated).
2525

2626
`additionalInfo?: string` — Gray text (with YFM support)
2727

2828
[`links?: Link[]` — An array with link objects](?path=/docs/documentation-types--docs#link)
2929

3030
[`buttons?: Button[]` — An array with button objects](?path=/docs/documentation-types--docs#button)
3131

32+
`border?: 'shadow' | 'line' | 'none'` — Image border
33+
3234
</StoryTemplate>

src/blocks/Media/__stories__/Media.stories.tsx

+13-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,9 @@ export const Video = VideoTemplate.bind({});
193193
export const DataLens = ImageSliderTemplate.bind({});
194194
export const Size = SizeTemplate.bind({});
195195
export const Direction = DirectionTemplate.bind({});
196+
export const WithoutShadowDeprecated = ImageSliderTemplate.bind({});
196197
export const WithoutShadow = ImageSliderTemplate.bind({});
198+
export const WithBorder = ImageSliderTemplate.bind({});
197199
export const Iframe = IframeTemplate.bind({});
198200

199201
const DefaultArgs = {
@@ -214,11 +216,21 @@ DataLens.args = {
214216
} as MediaBlockProps;
215217
Size.args = DefaultArgs as MediaBlockProps;
216218
Direction.args = DefaultArgs as MediaBlockProps;
217-
WithoutShadow.args = {
219+
WithoutShadowDeprecated.args = {
218220
...DefaultArgs,
219221
...data.withoutShadow.content,
220222
disableShadow: true,
221223
} as MediaBlockProps;
224+
WithoutShadow.args = {
225+
...DefaultArgs,
226+
...data.withoutShadow.content,
227+
border: 'none',
228+
} as MediaBlockProps;
229+
WithBorder.args = {
230+
...DefaultArgs,
231+
...data.withoutShadow.content,
232+
border: 'line',
233+
} as MediaBlockProps;
222234
Iframe.args = {
223235
...DefaultArgs,
224236
} as MediaBlockProps;

src/blocks/Media/schema.ts

+7
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,18 @@ export const MediaBlockBaseProps = {
4242
mediaOnly: {
4343
type: 'boolean',
4444
},
45+
/**
46+
* @deprecated use border='none' or border='line' instead
47+
*/
4548
disableShadow: {
4649
type: 'boolean',
4750
},
4851
button: ButtonBlock,
4952
mediaOnlyColSizes: containerSizesObject,
53+
border: {
54+
type: 'string',
55+
enum: ['shadow', 'line', 'none'],
56+
},
5057
};
5158

5259
export const MediaBlock = {

src/components/MediaBase/MediaBase.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ export const MediaBase = (props: MediaBaseProps) => {
2727
mobileDirection = 'content-media',
2828
animated,
2929
mediaOnly,
30+
/**
31+
* @deprecated use custom class for media-component
32+
*/
3033
disableShadow = false,
3134
onScroll,
3235
mediaOnlyColSizes = {all: 12, md: 8},

src/models/constructor-items/blocks.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import {
3434
ThemedMediaVideoProps,
3535
TitleItemBaseProps,
3636
TitleItemProps,
37+
WithBorder,
3738
YandexFormProps,
3839
} from './common';
3940
import {BannerCardProps, HubspotFormProps, SubBlock, SubBlockModels} from './sub-blocks';
@@ -234,7 +235,7 @@ export interface MediaContentProps
234235
button?: ButtonProps;
235236
}
236237

237-
export interface MediaBlockProps extends MediaBaseBlockProps {
238+
export interface MediaBlockProps extends MediaBaseBlockProps, WithBorder {
238239
media: ThemeSupporting<MediaProps>;
239240
}
240241

src/models/constructor-items/common.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,8 @@ export interface TitleItemBaseProps {
386386
}
387387

388388
// card
389-
export type CardBorder = 'shadow' | 'line' | 'none';
389+
export type MediaBorder = 'shadow' | 'line' | 'none';
390+
export type CardBorder = MediaBorder;
390391

391392
export interface CardBaseProps {
392393
border?: CardBorder;
@@ -476,3 +477,7 @@ export interface YandexFormProps extends AnalyticsEventsBase {
476477
metrikaGoals?: string | string[];
477478
pixelEvents?: string | string[] | PixelEvent | PixelEvent[];
478479
}
480+
481+
export interface WithBorder {
482+
border?: MediaBorder;
483+
}

styles/mixins.scss

+13
Original file line numberDiff line numberDiff line change
@@ -616,3 +616,16 @@ unpredictable css rules order in build */
616616
}
617617
}
618618
}
619+
620+
@mixin media-border() {
621+
&_border {
622+
&_shadow {
623+
@include image-shadow();
624+
}
625+
626+
&_line {
627+
border-radius: $borderRadius;
628+
border: 1px solid var(--g-color-line-generic);
629+
}
630+
}
631+
}

0 commit comments

Comments
 (0)