Skip to content

Commit 852af58

Browse files
committed
Added new mobile image position prop with default at center (#1323)
1 parent 9fb326c commit 852af58

File tree

3 files changed

+50
-1
lines changed

3 files changed

+50
-1
lines changed

stories/Components/UIcomponents/Hero/PageHero/PageHeroOption.jsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@ export function PageHeroOption({
1717
imgalt,
1818
videosrc,
1919
cta,
20+
mobileImagePosition = 'center',
2021
...args
2122
}) {
2223
const CtaEnabledClass = args.CTA == 'On' ? 'has-cta' : '';
24+
const mobilePositionClass = `mobile-position-${mobileImagePosition}`;
2325
return (
2426
<div className={['pagehero-tall', CtaEnabledClass].join(' ')}>
2527
<div className="grid-x">
@@ -39,7 +41,9 @@ export function PageHeroOption({
3941
) : (
4042
<picture>
4143
<source media="(min-width: 767px)" srcSet={imgsrc} />
42-
<img src={imgsrc2} alt={imgalt} />
44+
<img
45+
className={mobilePositionClass}
46+
src={imgsrc2} alt={imgalt} />
4347
</picture>
4448
)}
4549
</div>

stories/Components/UIcomponents/Hero/PageHero/PageHeroOption.stories.mdx

+7
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,18 @@ export const getCaptionForLocale = (locale) => {
141141
options: ["On", "Off"],
142142
control: { type: "inline-radio" },
143143
},
144+
MobileImagePosition: {
145+
name: "Mobile Image Position",
146+
options: ["left", "center", "right"],
147+
control: { type: "inline-radio" },
148+
},
144149
}}
145150
args={{
146151
Variant: "Image",
147152
CTA: "Off",
148153
Overline: "Off",
149154
Subtitle: "Off",
155+
MobileImagePosition: "center",
150156
}}
151157
/>
152158

@@ -200,6 +206,7 @@ There are two states in the Tall Image Page- Default and Mobile.
200206
imgalt={caption.imgalt}
201207
videosrc={caption.videosrc}
202208
cta={cta}
209+
mobileImagePosition={args.MobileImagePosition}
203210
{...args}
204211
></PageHeroOption>
205212
);

stories/Components/UIcomponents/Hero/PageHero/page-hero.scss

+38
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,26 @@
7474
margin-bottom: 0;
7575
}
7676
}
77+
78+
.homepage-hero-image {
79+
img,
80+
video {
81+
@extend %img-cover;
82+
83+
// styles for mobile image positioning
84+
&.mobile-position-left {
85+
object-position: left;
86+
}
87+
88+
&.mobile-position-center {
89+
object-position: center;
90+
}
91+
92+
&.mobile-position-right {
93+
object-position: right;
94+
}
95+
}
96+
}
7797
}
7898

7999
&-content {
@@ -212,6 +232,24 @@
212232
margin: 2rem 0 1rem;
213233
display: none;
214234
}
235+
236+
img,
237+
video {
238+
@extend %img-cover;
239+
240+
// Add styles for mobile image positioning
241+
&.mobile-position-left {
242+
object-position: left;
243+
}
244+
245+
&.mobile-position-center {
246+
object-position: center;
247+
}
248+
249+
&.mobile-position-right {
250+
object-position: right;
251+
}
252+
}
215253
}
216254

217255
.breadcrumb {

0 commit comments

Comments
 (0)