Skip to content

Commit 5cd19b8

Browse files
authored
feat(BackgroundMedia): add fullWidthMedia for BackgroundMedia (#281)
1 parent f0189a7 commit 5cd19b8

File tree

7 files changed

+80
-63
lines changed

7 files changed

+80
-63
lines changed

src/components/BackgroundMedia/BackgroundMedia.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@ $block: '.#{$ns}BackgroundMedia';
1616
max-width: 1440px;
1717
text-align: center;
1818
height: 100%;
19+
20+
&_full-width-media {
21+
max-width: none;
22+
23+
#{$class}__video video {
24+
height: 100%;
25+
width: 100%;
26+
object-fit: cover;
27+
}
28+
}
1929
}
2030

2131
&__image {

src/components/BackgroundMedia/BackgroundMedia.tsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, {useContext} from 'react';
22

33
import {MobileContext} from '../../context/mobileContext';
4-
import {Animatable, MediaProps} from '../../models';
4+
import {BackgroundMediaProps} from '../../models';
55
import {block} from '../../utils';
66
import AnimateBlock from '../AnimateBlock/AnimateBlock';
77
import Media from '../Media/Media';
@@ -10,20 +10,16 @@ import './BackgroundMedia.scss';
1010

1111
const b = block('BackgroundMedia');
1212

13-
export interface FullProps extends MediaProps, Animatable {
14-
className?: string;
15-
mediaClassName?: string;
16-
}
17-
1813
const BackgroundMedia = ({
1914
className,
2015
color,
2116
animated,
2217
parallax = true,
2318
video,
2419
mediaClassName,
20+
fullWidthMedia,
2521
...props
26-
}: FullProps) => {
22+
}: BackgroundMediaProps) => {
2723
const isMobile = useContext(MobileContext);
2824

2925
return (
@@ -33,7 +29,7 @@ const BackgroundMedia = ({
3329
animate={animated}
3430
>
3531
<Media
36-
className={b('media', mediaClassName)}
32+
className={b('media', {'full-width-media': fullWidthMedia}, mediaClassName)}
3733
imageClassName={b('image')}
3834
videoClassName={b('video')}
3935
isBackground={true}

src/components/BackgroundMedia/__stories__/BackgroundMedia.stories.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import React from 'react';
33
import {Meta, Story} from '@storybook/react/types-6-0';
44

55
import {COMPONENTS, MEDIA} from '../../../demo/constants';
6-
import BackgroundMedia, {FullProps} from '../BackgroundMedia';
6+
import {BackgroundMediaProps} from '../../../models';
7+
import BackgroundMedia from '../BackgroundMedia';
78

89
import data from './data.json';
910

@@ -17,7 +18,7 @@ export default {
1718
},
1819
} as Meta;
1920

20-
const DefaultTemplate: Story<FullProps> = (args) => (
21+
const DefaultTemplate: Story<BackgroundMediaProps> = (args) => (
2122
<div style={{maxWidth: '1400px', position: 'relative'}}>
2223
<BackgroundMedia {...args} />
2324
</div>

src/containers/PageConstructor/__stories__/PageConstructor.stories.tsx

Lines changed: 26 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ import React from 'react';
33
import {Meta, Story} from '@storybook/react/types-6-0';
44

55
import {CONTAINERS} from '../../../demo/constants';
6-
import {HeaderBlockModel, NavigationData} from '../../../models';
7-
import {PageConstructor} from '../PageConstructor';
6+
import {PageConstructor, PageConstructorProps} from '../PageConstructor';
87

98
import data from './data.json';
109

@@ -13,51 +12,37 @@ export default {
1312
component: PageConstructor,
1413
} as Meta;
1514

16-
interface TemplateProps {
17-
items: HeaderBlockModel[];
18-
navigation?: NavigationData;
19-
}
20-
21-
const DefaultTemplate: Story<TemplateProps> = (args) => (
22-
<PageConstructor
23-
content={{
24-
blocks: args.items,
25-
background: data.default.background,
26-
}}
27-
/>
28-
);
15+
const DefaultTemplate: Story<PageConstructorProps> = (args) => <PageConstructor {...args} />;
2916

30-
const WithFootnotesTemplate: Story<TemplateProps> = (args) => (
31-
<PageConstructor
32-
content={{
33-
blocks: args.items,
34-
background: data.default.background,
35-
footnotes: data.withFootnotes.footnotes,
36-
}}
37-
/>
38-
);
17+
const WithFootnotesTemplate: Story<PageConstructorProps> = (args) => <PageConstructor {...args} />;
18+
19+
const NavigationTemplate: Story<PageConstructorProps> = (args) => <PageConstructor {...args} />;
3920

40-
const NavigationTemplate: Story<TemplateProps> = (args) => (
41-
<PageConstructor
42-
content={{
43-
blocks: args.items,
44-
}}
45-
navigation={args.navigation}
46-
/>
21+
const WithFullWidthBackgroundMediaTemplate: Story<PageConstructorProps> = (args) => (
22+
<PageConstructor {...args} />
4723
);
4824

4925
export const Default = DefaultTemplate.bind({});
5026
export const WithFootnotes = WithFootnotesTemplate.bind({});
5127
export const Navigation = NavigationTemplate.bind({});
52-
53-
interface PageConstructorStoryProps {
54-
items: HeaderBlockModel[];
55-
navigation?: NavigationData;
56-
}
57-
58-
Default.args = data.default.content as PageConstructorStoryProps;
59-
WithFootnotes.args = data.default.content as PageConstructorStoryProps;
28+
export const WithFullWidthBackgroundMedia = WithFullWidthBackgroundMediaTemplate.bind({});
29+
30+
Default.args = data.default as PageConstructorProps;
31+
WithFootnotes.args = {
32+
content: {
33+
...data.default.content,
34+
footnotes: data.withFootnotes.footnotes,
35+
},
36+
} as PageConstructorProps;
6037
Navigation.args = {
61-
items: data.default.content.items,
38+
content: {
39+
blocks: data.default.content.blocks,
40+
},
6241
navigation: data.navigation,
63-
} as PageConstructorStoryProps;
42+
} as PageConstructorProps;
43+
WithFullWidthBackgroundMedia.args = {
44+
content: {
45+
blocks: data.default.content.blocks,
46+
background: data.withFullWidthBackgroundMedia.background,
47+
},
48+
} as PageConstructorProps;

src/containers/PageConstructor/__stories__/data.json

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"<p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat</p>"
66
],
77
"content": {
8-
"items": [
8+
"blocks": [
99
{
1010
"type": "header-block",
1111
"title": "Lorem ipsum dolor sit amet, consectetur adipiscing elit",
@@ -29,18 +29,18 @@
2929
}
3030
},
3131
"default": {
32-
"background": {
33-
"light": {
34-
"image": "https://storage.yandexcloud.net/cloud-www-assets/constructor/storybook/images/header-bg-video_light.png",
35-
"color": "#EFF2F8"
36-
},
37-
"dark": {
38-
"image": "https://storage.yandexcloud.net/cloud-www-assets/constructor/storybook/images/header-bg-video_dark.png",
39-
"color": "#262626"
40-
}
41-
},
4232
"content": {
43-
"items": [
33+
"background": {
34+
"light": {
35+
"image": "https://storage.yandexcloud.net/cloud-www-assets/constructor/storybook/images/header-bg-video_light.png",
36+
"color": "#EFF2F8"
37+
},
38+
"dark": {
39+
"image": "https://storage.yandexcloud.net/cloud-www-assets/constructor/storybook/images/header-bg-video_dark.png",
40+
"color": "#262626"
41+
}
42+
},
43+
"blocks": [
4444
{
4545
"type": "header-block",
4646
"title": "Lorem ipsum dolor sit amet, consectetur adipiscing elit",
@@ -345,5 +345,21 @@
345345
}
346346
]
347347
}
348+
},
349+
"withFullWidthBackgroundMedia": {
350+
"background": {
351+
"light": {
352+
"image": "https://storage.yandexcloud.net/cloud-www-assets/constructor/storybook/images/header-bg-video_light.png",
353+
"color": "#EFF2F8",
354+
"fullWidthMedia": true,
355+
"parallax": false
356+
},
357+
"dark": {
358+
"image": "https://storage.yandexcloud.net/cloud-www-assets/constructor/storybook/images/header-bg-video_dark.png",
359+
"color": "#262626",
360+
"fullWidthMedia": true,
361+
"parallax": false
362+
}
363+
}
348364
}
349365
}

src/models/constructor-items/common.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,12 @@ export interface MediaProps
251251
color?: string;
252252
}
253253

254+
export interface BackgroundMediaProps extends MediaProps, Animatable {
255+
fullWidthMedia?: boolean;
256+
className?: string;
257+
mediaClassName?: string;
258+
}
259+
254260
export type Coordinate = number[];
255261

256262
export interface MapBaseProps {

src/schema/validators/common.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,9 @@ export const BackgroundProps = {
178178
parallax: {
179179
type: 'boolean',
180180
},
181+
fullWidthMedia: {
182+
type: 'boolean',
183+
},
181184
},
182185
};
183186

0 commit comments

Comments
 (0)