Skip to content

Commit df2a392

Browse files
committed
fixup! feat: add border to media in media-block and refactor it in layout-items
1 parent fff5479 commit df2a392

File tree

11 files changed

+87
-62
lines changed

11 files changed

+87
-62
lines changed

src/blocks/Media/Media.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ export const MediaBlock = (props: MediaBlockProps) => {
1414
const mediaThemed = getThemedValue(media, theme);
1515

1616
return (
17-
<MediaBase {...props} onScroll={() => setPlay(true)}>
17+
<MediaBase {...props} onScroll={() => setPlay(true)} border={border}>
1818
<MediaBase.Card>
19-
<Media {...mediaThemed} playVideo={play} border={border} rounded />
19+
<Media {...mediaThemed} playVideo={play} />
2020
</MediaBase.Card>
2121
</MediaBase>
2222
);

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -219,12 +219,13 @@ WithoutShadow.args = {
219219
...DefaultArgs,
220220
...data.withoutShadow.content,
221221
disableShadow: true,
222+
border: 'none',
222223
} as MediaBlockProps;
223224
WithBorder.args = {
224225
...DefaultArgs,
225226
...data.withoutShadow.content,
226227
disableShadow: true,
227-
border: true,
228+
border: 'line',
228229
} as MediaBlockProps;
229230
Iframe.args = {
230231
...DefaultArgs,

src/components/Media/Media.scss

+4-5
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@ $block: '.#{$ns}Media';
1515
}
1616

1717
&_border {
18-
border: 1px solid var(--g-color-line-generic);
19-
}
20-
21-
&_rounded {
22-
border-radius: $borderRadius;
18+
&_line {
19+
border-radius: $borderRadius;
20+
border: 1px solid var(--g-color-line-generic);
21+
}
2322
}
2423
}

src/components/Media/Media.tsx

+2-7
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ export const Media = (props: MediaAllProps) => {
5353
onImageLoad,
5454
iframe,
5555
margins,
56-
border = false,
57-
rounded = false,
56+
border = 'shadow',
5857
} = props;
5958

6059
const [hasVideoFallback, setHasVideoFallback] = useState(false);
@@ -160,11 +159,7 @@ export const Media = (props: MediaAllProps) => {
160159
]);
161160

162161
return (
163-
<div
164-
className={b({border, rounded}, className)}
165-
style={{backgroundColor: color}}
166-
data-qa={qa}
167-
>
162+
<div className={b({border}, className)} style={{backgroundColor: color}} data-qa={qa}>
168163
{content}
169164
</div>
170165
);

src/components/MediaBase/MediaBase.scss

+9-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,15 @@ $block: '.#{$ns}media-base';
1818
border-radius: $borderRadius; // special for safari
1919
}
2020

21-
&_shadow {
22-
@include image-shadow();
21+
&_border {
22+
&_shadow {
23+
@include image-shadow();
24+
}
25+
26+
&_line {
27+
border-radius: $borderRadius;
28+
border: 1px solid var(--g-color-line-generic);
29+
}
2330
}
2431
}
2532

src/components/MediaBase/MediaBase.tsx

+9-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export const MediaBase = (props: MediaBaseProps) => {
2929
mediaOnly,
3030
disableShadow = false,
3131
onScroll,
32+
// border, // uncomment on major
3233
...mediaContentProps
3334
} = props;
3435
const {title, description} = mediaContentProps;
@@ -68,7 +69,14 @@ export const MediaBase = (props: MediaBaseProps) => {
6869
</Col>
6970
{card ? (
7071
<Col sizes={mediaSizes}>
71-
<div className={b('card', {shadow: !disableShadow})}>{card}</div>
72+
<div
73+
className={b('card', {
74+
// border, // uncomment on major
75+
border: disableShadow ? 'none' : 'shadow', // remove on major
76+
})}
77+
>
78+
{card}
79+
</div>
7280
</Col>
7381
) : null}
7482
</Row>

src/models/constructor-items/blocks.ts

+3
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,9 @@ export interface MediaBaseBlockProps extends Animatable, MediaContentProps, With
223223
mobileDirection?: MediaDirection;
224224
largeMedia?: boolean;
225225
mediaOnly?: boolean;
226+
/**
227+
* @deprecated use border='none' or border='line' instead
228+
*/
226229
disableShadow?: boolean;
227230
}
228231

src/models/constructor-items/common.ts

+3-3
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;
@@ -477,6 +478,5 @@ export interface YandexFormProps extends AnalyticsEventsBase {
477478
}
478479

479480
export interface WithBorder {
480-
border?: boolean;
481-
rounded?: boolean;
481+
border?: MediaBorder | boolean;
482482
}

src/sub-blocks/LayoutItem/LayoutItem.scss

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ $block: '.#{$ns}layout-item';
77
&__media {
88
width: 100%;
99
display: block;
10+
border-radius: $borderRadius;
1011
}
1112

1213
&__meta-info {

src/sub-blocks/LayoutItem/LayoutItem.tsx

+45-40
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22

33
import {Content} from '..';
44
import {FullscreenMedia, Media, MetaInfo} from '../../components';
5-
import {LayoutItemProps} from '../../models';
5+
import {LayoutItemProps, MediaBorder} from '../../models';
66
import {block} from '../../utils';
77

88
import {getLayoutItemLinks, hasFullscreen, showFullscreenIcon} from './utils';
@@ -15,48 +15,53 @@ const LayoutItem = ({
1515
content: {links, ...content},
1616
metaInfo,
1717
media,
18-
border,
18+
border = 'none',
1919
fullscreen,
2020
className,
2121
analyticsEvents,
22-
}: LayoutItemProps) => (
23-
<div className={b(null, className)}>
24-
{fullscreen && hasFullscreen(media) ? (
25-
<FullscreenMedia showFullscreenIcon={showFullscreenIcon(media)}>
26-
{({
27-
className: mediaClassName,
28-
fullscreen: _fullscreen,
29-
...fullscreenMediaProps
30-
} = {}) => (
31-
<Media
32-
{...media}
33-
{...fullscreenMediaProps}
34-
className={b('media', mediaClassName)}
35-
analyticsEvents={analyticsEvents}
36-
border={border}
37-
rounded
38-
/>
39-
)}
40-
</FullscreenMedia>
41-
) : (
42-
<Media
43-
{...media}
44-
className={b('media')}
45-
analyticsEvents={analyticsEvents}
46-
border={border}
47-
rounded
48-
/>
49-
)}
50-
{metaInfo && <MetaInfo items={metaInfo} className={b('meta-info')} />}
51-
<div className={b('content')}>
52-
<Content
53-
{...content}
54-
links={getLayoutItemLinks(links)}
55-
size="s"
56-
colSizes={{all: 12, md: 12}}
57-
/>
22+
}: LayoutItemProps) => {
23+
let tempBorder: MediaBorder = 'none';
24+
if (typeof border === 'boolean' && border) {
25+
tempBorder = 'line';
26+
}
27+
28+
return (
29+
<div className={b(null, className)}>
30+
{fullscreen && hasFullscreen(media) ? (
31+
<FullscreenMedia showFullscreenIcon={showFullscreenIcon(media)}>
32+
{({
33+
className: mediaClassName,
34+
fullscreen: _fullscreen,
35+
...fullscreenMediaProps
36+
} = {}) => (
37+
<Media
38+
{...media}
39+
{...fullscreenMediaProps}
40+
className={b('media', mediaClassName)}
41+
analyticsEvents={analyticsEvents}
42+
border={tempBorder}
43+
/>
44+
)}
45+
</FullscreenMedia>
46+
) : (
47+
<Media
48+
{...media}
49+
className={b('media')}
50+
analyticsEvents={analyticsEvents}
51+
border={tempBorder}
52+
/>
53+
)}
54+
{metaInfo && <MetaInfo items={metaInfo} className={b('meta-info')} />}
55+
<div className={b('content')}>
56+
<Content
57+
{...content}
58+
links={getLayoutItemLinks(links)}
59+
size="s"
60+
colSizes={{all: 12, md: 12}}
61+
/>
62+
</div>
5863
</div>
59-
</div>
60-
);
64+
);
65+
};
6166

6267
export default LayoutItem;

src/sub-blocks/LayoutItem/schema.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@ export const LayoutItem = {
1515
content: omit(ContentBase, ['colSize', 'size', 'centered']),
1616
metaInfo: metaInfo,
1717
border: {
18-
type: 'boolean',
18+
oneOf: [
19+
{
20+
type: 'string',
21+
enum: ['shadow', 'line', 'none'],
22+
},
23+
{type: 'boolean'},
24+
],
1925
},
2026
fullscreen: {
2127
type: 'boolean',

0 commit comments

Comments
 (0)