Skip to content

Commit d960ea0

Browse files
authored
feat: add border to media in media-block (#722)
1 parent d15f14b commit d960ea0

File tree

16 files changed

+140
-23
lines changed

16 files changed

+140
-23
lines changed

src/blocks/Map/Map.scss

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

src/blocks/Map/Map.tsx

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,26 @@ import React from 'react';
33
import Map from '../../components/Map/Map';
44
import MediaBase from '../../components/MediaBase/MediaBase';
55
import {MapBlockProps} from '../../models';
6+
import {block} from '../../utils';
7+
import {getMediaBorder} from '../../utils/borderSelector';
68

7-
export const MapBlock = ({map, ...props}: MapBlockProps) => (
8-
<MediaBase {...props}>
9-
<MediaBase.Card>
10-
<Map {...map} />
11-
</MediaBase.Card>
12-
</MediaBase>
13-
);
9+
import './Map.scss';
10+
11+
const b = block('map-block');
12+
13+
export const MapBlock = ({map, border, disableShadow, ...props}: MapBlockProps) => {
14+
const borderSelected = getMediaBorder({
15+
border,
16+
disableShadow,
17+
});
18+
19+
return (
20+
<MediaBase {...props}>
21+
<MediaBase.Card>
22+
<Map {...map} className={b({border: borderSelected})} />
23+
</MediaBase.Card>
24+
</MediaBase>
25+
);
26+
};
1427

1528
export default MapBlock;

src/blocks/Map/__stories__/Map.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import * as MapStories from './Map.stories.tsx';
2424

2525
`largeMedia?: boolean` — An image/video takes 8 columns.
2626

27-
`disableShadow?: boolean`Disable shadow for the block.
27+
`border?: 'shadow' | 'line' | 'none`Select border of the block.
2828

2929
`additionalInfo?: string` — Gray text (with YFM support)
3030

src/blocks/Media/Media.scss

Lines changed: 7 additions & 0 deletions
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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,19 @@ 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+
import {getMediaBorder} from '../../utils/borderSelector';
9+
10+
import './Media.scss';
11+
12+
const b = block('media-block');
813

914
export const MediaBlock = (props: MediaBlockProps) => {
10-
const {media} = props;
15+
const {media, border, disableShadow} = props;
16+
const borderSelected = getMediaBorder({
17+
border,
18+
disableShadow,
19+
});
1120

1221
const [play, setPlay] = useState<boolean>(false);
1322
const theme = useTheme();
@@ -16,7 +25,7 @@ export const MediaBlock = (props: MediaBlockProps) => {
1625
return (
1726
<MediaBase {...props} onScroll={() => setPlay(true)}>
1827
<MediaBase.Card>
19-
<Media {...mediaThemed} playVideo={play} />
28+
<Media {...mediaThemed} playVideo={play} className={b({border: borderSelected})} />
2029
</MediaBase.Card>
2130
</MediaBase>
2231
);

src/blocks/Media/__stories__/Media.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ 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+
`border?: 'shadow' | 'line' | 'none`Select border of the block.
2525

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

@@ -33,4 +33,6 @@ import * as MediaStories from './Media.stories.tsx';
3333

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

36+
`border?: 'shadow' | 'line' | 'none'` — Image border
37+
3638
</StoryTemplate>

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

Lines changed: 13 additions & 1 deletion
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

Lines changed: 7 additions & 0 deletions
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/Map/GoogleMap.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function getScriptSrc(params: GoogleMapLinkParams) {
3030
}
3131

3232
const GoogleMap: React.FC<GMapProps> = (props) => {
33-
const {address, zoom} = props;
33+
const {address, zoom, className} = props;
3434
const {apiKey, scriptSrc} = useContext(MapsContext);
3535
const {lang = Lang.Ru} = useContext(LocaleContext);
3636
const isMobile = useContext(MobileContext);
@@ -63,7 +63,7 @@ const GoogleMap: React.FC<GMapProps> = (props) => {
6363

6464
return (
6565
<iframe
66-
className={b()}
66+
className={b(null, className)}
6767
ref={ref}
6868
style={{
6969
height,

src/components/Map/YMap/YandexMap.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const DEFAULT_ZOOM = 9;
2424
const INITIAL_CENTER = [0, 0];
2525

2626
const YandexMap: React.FC<YMapProps> = (props) => {
27-
const {markers, zoom, id} = props;
27+
const {markers, zoom, id, className} = props;
2828
const {apiKey, scriptSrc, nonce} = useContext(MapsContext);
2929
const isMobile = useContext(MobileContext);
3030

@@ -108,7 +108,12 @@ const YandexMap: React.FC<YMapProps> = (props) => {
108108
>
109109
<div className={b('wrapper')}>
110110
{/* hidden - to show the map after calculating the center */}
111-
<div id={containerId} className={b({hidden: !ready})} ref={ref} style={{height}} />
111+
<div
112+
id={containerId}
113+
className={b({hidden: !ready}, className)}
114+
ref={ref}
115+
style={{height}}
116+
/>
112117
{loading ? <Spin size="xl" className={b('spinner')} /> : null}
113118
</div>
114119
</ErrorWrapper>

0 commit comments

Comments
 (0)