Skip to content

Commit da8db36

Browse files
committed
feat: Introduce mediaMaw prop to MediaBlock, Hero, and FeatureSplit components for setting media maximum width.
1 parent 4ea5e33 commit da8db36

File tree

4 files changed

+43
-30
lines changed

4 files changed

+43
-30
lines changed

demo/src/Demo.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ export function Demo() {
290290
icon: <IconArrowRight size={20} />,
291291
}}
292292
image="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/react/react-original.svg"
293+
mediaMaw={400}
293294
/>
294295

295296
<SocialProof

src/components/FeatureSplit.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ import { CTAButton } from '../primitives/CTAButton.jsx'
1010
* @param {object} cta - { label, href, icon, size, variant, color }
1111
* @param {object} video - { src, width, filter }
1212
* @param {string} image - image src (alternative to video)
13+
* @param {string|number} mediaMaw - max-width for the media element
1314
*/
14-
export function FeatureSplit({ id, subtitle, title, description, featuresList, cta, video, image, reverse = false, background = 'white' }) {
15+
export function FeatureSplit({ id, subtitle, title, description, featuresList, cta, video, image, reverse = false, background = 'white', mediaMaw }) {
1516
const listComponent = featuresList && featuresList.length > 0 && (
1617
<List
1718
spacing="md"
@@ -73,6 +74,7 @@ export function FeatureSplit({ id, subtitle, title, description, featuresList, c
7374
video={video}
7475
image={image}
7576
width="80%"
77+
maw={mediaMaw}
7678
/>
7779
)
7880

src/components/Hero.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ import { CTAButton } from '../primitives/CTAButton.jsx'
1212
* @param {object} cta - { label, href, size, icon, variant, color, px }
1313
* @param {object} video - { src, filter, width }
1414
* @param {string} image - image src (alternative to video)
15+
* @param {string|number} mediaMaw - max-width for the media element
1516
*/
16-
export function Hero({ subtitle, title, description, cta, video, image, background = 'white' }) {
17+
export function Hero({ subtitle, title, description, cta, video, image, background = 'white', mediaMaw }) {
1718
return (
1819
<Box
1920
py={{ base: 80, sm: 100, md: 140 }}
@@ -76,6 +77,7 @@ export function Hero({ subtitle, title, description, cta, video, image, backgrou
7677
<MediaBlock
7778
video={video}
7879
image={image}
80+
maw={mediaMaw}
7981
alt="Demonstração do produto"
8082
/>
8183
</SimpleGrid>

src/primitives/MediaBlock.jsx

Lines changed: 36 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,48 @@
1-
import { Box, Center } from "@mantine/core";
1+
import { Box, Center } from '@mantine/core'
22

33
/**
44
* MediaBlock - Renders a video or image with consistent styling.
55
*
66
* @param {object} video - { src, width, filter }
77
* @param {string} image - Image src (fallback when no video)
88
* @param {string} width - Default width for the media element
9+
* @param {string|number} maw - Max-width for the media element
910
* @param {string} alt - Alt text for images / aria-label for videos
1011
*/
11-
export function MediaBlock({ video, image, width = "100%", alt }) {
12-
if (video) {
13-
return (
14-
<Center>
15-
<Box
16-
component="video"
17-
src={video.src}
18-
autoPlay
19-
loop
20-
muted
21-
playsInline
22-
aria-label={alt || "Demonstração em vídeo"}
23-
w={video.width || width}
24-
h="auto"
25-
style={{ filter: video.filter || "none" }}
26-
/>
27-
</Center>
28-
);
29-
}
12+
export function MediaBlock({ video, image, width = '100%', maw, alt }) {
13+
if (video) {
14+
return (
15+
<Center>
16+
<Box
17+
component="video"
18+
src={video.src}
19+
autoPlay
20+
loop
21+
muted
22+
playsInline
23+
aria-label={alt || 'Demonstração em vídeo'}
24+
w={video.width || width}
25+
h="auto"
26+
style={{ filter: video.filter || 'none' }}
27+
/>
28+
</Center>
29+
)
30+
}
3031

31-
if (image) {
32-
return (
33-
<Center>
34-
<Box component="img" src={image} alt={alt || ""} w={width} h="auto" />
35-
</Center>
36-
);
37-
}
32+
if (image) {
33+
return (
34+
<Center>
35+
<Box
36+
component="img"
37+
src={image}
38+
alt={alt || ''}
39+
w={width}
40+
h="auto"
41+
maw={maw}
42+
/>
43+
</Center>
44+
)
45+
}
3846

39-
return null;
47+
return null
4048
}

0 commit comments

Comments
 (0)