1 Commits

3 changed files with 40 additions and 12 deletions

View File

@@ -1,5 +1,8 @@
<div class="hero-banner-container"> <div class="hero-banner-container">
<div class="hero-banner position-relative rounded"> <div
class="hero-banner position-relative rounded"
[class.hero-banner--with-media]="desktopImageUrl"
>
@if (desktopImageUrl) { @if (desktopImageUrl) {
<picture class="hero-media" aria-hidden="true"> <picture class="hero-media" aria-hidden="true">
@if (mobileImageUrl) { @if (mobileImageUrl) {

View File

@@ -7,23 +7,23 @@
min-height: 400px; min-height: 400px;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
&--with-media {
min-height: 0;
}
} }
.hero-media { .hero-media {
position: absolute; position: relative;
inset: 0;
display: block; display: block;
width: 100%;
overflow: hidden; overflow: hidden;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
border-radius: inherit; border-radius: inherit;
img { img {
display: block; display: block;
width: 100%; width: 100%;
height: 100%; height: auto;
object-fit: cover;
} }
&::after { &::after {
@@ -52,6 +52,11 @@
flex-grow: 1; flex-grow: 1;
} }
.hero-banner--with-media .hero-content {
position: absolute;
inset: 0;
}
::ng-deep .hero-title, ::ng-deep .hero-title,
.hero-title { .hero-title {
color: #666666; color: #666666;
@@ -179,24 +184,29 @@
inset: auto; inset: auto;
flex: 0 0 auto; flex: 0 0 auto;
width: 100%; width: 100%;
height: clamp(8.75rem, 44vw, 211px); overflow: visible;
background-position: center center;
background-size: 140% auto;
border-radius: 0; border-radius: 0;
} }
.hero-media::after { .hero-media::after {
top: auto; top: auto;
height: 48%; bottom: -2px;
height: calc(48% + 2px);
background: linear-gradient( background: linear-gradient(
to bottom, to bottom,
rgba(245, 245, 245, 0) 0%, rgba(245, 245, 245, 0) 0%,
rgba(245, 245, 245, 0.78) 55%, rgba(245, 245, 245, 0.78) 55%,
#f5f5f5 96%,
#f5f5f5 100% #f5f5f5 100%
); );
border-radius: 0; border-radius: 0;
} }
.hero-banner--with-media .hero-content {
position: relative;
inset: auto;
}
.hero-content { .hero-content {
justify-content: center !important; justify-content: center !important;
height: auto !important; height: auto !important;

View File

@@ -22,6 +22,21 @@ describe('HeroBannerComponent', () => {
expect(element.querySelector('img')?.getAttribute('src')).toBe( expect(element.querySelector('img')?.getAttribute('src')).toBe(
'https://example.com/desktop.jpg', 'https://example.com/desktop.jpg',
); );
expect(element.querySelector('.hero-banner')?.classList).toContain(
'hero-banner--with-media',
);
});
it('keeps the fallback banner sizing when there is no image', async () => {
await TestBed.configureTestingModule({ imports: [HeroBannerComponent] }).compileComponents();
const fixture = TestBed.createComponent(HeroBannerComponent);
fixture.componentRef.setInput('heroConfig', { title_html: 'Banner sin imagen' });
fixture.detectChanges();
const banner = (fixture.nativeElement as HTMLElement).querySelector('.hero-banner');
expect(banner?.classList).not.toContain('hero-banner--with-media');
}); });
it('expands and collapses the event schedules', async () => { it('expands and collapses the event schedules', async () => {