Skip to content

Instantly share code, notes, and snippets.

@riapacheco
Created March 20, 2021 19:14
Show Gist options
  • Save riapacheco/546f6132b92b03eb58d7028795df1abe to your computer and use it in GitHub Desktop.
Save riapacheco/546f6132b92b03eb58d7028795df1abe to your computer and use it in GitHub Desktop.
<a class="overlay-bg" (click)="overlayClicked($event)" [@overlayAnimation]="showsOverlay ? 'shows' : 'hides' ">
<ng-content select="[overlay-bg]"></ng-content>
</a>
.overlay-bg {
display: block;
background-color: #00000095;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
cursor: default;
overflow: hidden;
backdrop-filter: blur(4px);
}
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { animate, state, style, transition, trigger } from '@angular/animations';
@Component({
selector: 'app-overlay-bg',
templateUrl: './overlay-bg.component.html',
styleUrls: ['./overlay-bg.component.scss'],
animations: [
trigger('overlayAnimation', [
state('shows', style({ display: 'block' })),
state('hides', style({ display: 'none' })),
transition('shows <=> hides', [
animate('300ms ease-in-out')
])
])
]
})
export class OverlayBgComponent implements OnInit {
@Input() showsOverlay: boolean;
@Output() overlayClick = new EventEmitter();
constructor() { }
ngOnInit(): void {
}
overlayClicked(event): any {
this.overlayClick.emit(true);
}
}
/* --------------------------------- Z-INDEX -------------------------------- */
app-root,
router-outlet {
z-index: 1 !important;
}
.mobile-menu {
z-index: 4 !important;
}
app-navbar, .nav, .nav-lg,
app-mobile-nav {
z-index: 5;
}
app-overlay-bg, .overlay-bg { // Overlay added to global z-index to stay on top of nav elements (to ensure no scroll)
z-index: 6 !important;
}
app-toast, .toast {
z-index: 7 !important;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment