feat: create and style mobile-nav in ContactDetailComponent
This commit is contained in:
parent
4061076ff1
commit
dc9585c4c1
3 changed files with 75 additions and 14 deletions
|
|
@ -112,7 +112,23 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
} @if (showMobileNavbar) {
|
||||
<!-- TODO -->
|
||||
} @if (isMobileNavbarVisible) {
|
||||
<div class="mobile-nav">
|
||||
@if(selectedUser!.isContactOnly || currentUser && selectedUser!.id ===
|
||||
currentUser.id) {
|
||||
<div class="link" (click)="editContact(selectedUser!)">
|
||||
<span>
|
||||
{{ "contacts.btnEdit1" | translate }}
|
||||
</span>
|
||||
</div>
|
||||
} @if (selectedUser!.isContactOnly || currentUser && selectedUser!.id !==
|
||||
currentUser.id) {
|
||||
<div class="link" (click)="deleteContact(selectedUserId!)">
|
||||
<span>
|
||||
{{ "contacts.btnDelete1" | translate }}
|
||||
</span>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</section>
|
||||
|
|
|
|||
|
|
@ -181,6 +181,44 @@
|
|||
display: none;
|
||||
}
|
||||
|
||||
.mobile-nav {
|
||||
position: fixed;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
bottom: 120px;
|
||||
right: 80px;
|
||||
width: 100px;
|
||||
height: fit-content;
|
||||
background-color: var(--bgSidebar);
|
||||
border-radius: 20px 20px 0 20px;
|
||||
box-shadow: 0px 0px 4px 0px rgba(0, 0, 0, 0.1);
|
||||
padding: 10px;
|
||||
z-index: 5;
|
||||
}
|
||||
|
||||
.link {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
height: 46px;
|
||||
padding: 8px 16px;
|
||||
border-radius: 8px;
|
||||
color: var(--white);
|
||||
cursor: pointer;
|
||||
span {
|
||||
width: 118px;
|
||||
text-align: center;
|
||||
word-wrap: break-word;
|
||||
overflow-wrap: break-word;
|
||||
white-space: normal;
|
||||
}
|
||||
&:hover {
|
||||
background-color: var(--very-dark-blue);
|
||||
span {
|
||||
color: var(--light-blue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*------------- ANIMATION -------------*/
|
||||
|
||||
.animation-coming-in {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import {
|
||||
Component,
|
||||
EventEmitter,
|
||||
HostListener,
|
||||
Input,
|
||||
OnChanges,
|
||||
OnDestroy,
|
||||
|
|
@ -31,8 +32,7 @@ export class ContactDetailComponent implements OnChanges, OnDestroy {
|
|||
|
||||
selectedUser: User | null = null;
|
||||
isLoading = false;
|
||||
showMobileNavbar = false;
|
||||
showConfirmDialog = false;
|
||||
isMobileNavbarVisible = false;
|
||||
|
||||
private destroy$ = new Subject<void>();
|
||||
|
||||
|
|
@ -102,15 +102,7 @@ export class ContactDetailComponent implements OnChanges, OnDestroy {
|
|||
* Toggles the visibility of the mobile contact details navbar.
|
||||
*/
|
||||
toggleNav(): void {
|
||||
this.showMobileNavbar = !this.showMobileNavbar;
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggles the visibility of the confirmation dialog.
|
||||
* This method switches the `showConfirmDialog` boolean state.
|
||||
*/
|
||||
toggleConfirmDialog(): void {
|
||||
this.showConfirmDialog = !this.showConfirmDialog;
|
||||
this.isMobileNavbarVisible = !this.isMobileNavbarVisible;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -121,7 +113,7 @@ export class ContactDetailComponent implements OnChanges, OnDestroy {
|
|||
*/
|
||||
editContact(userData: User) {
|
||||
this.overlayService.setOverlayData('contactOverlay', userData);
|
||||
this.showMobileNavbar = false;
|
||||
this.isMobileNavbarVisible = false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -138,4 +130,19 @@ export class ContactDetailComponent implements OnChanges, OnDestroy {
|
|||
console.error(error);
|
||||
}
|
||||
}
|
||||
|
||||
@HostListener('document:click', ['$event'])
|
||||
/**
|
||||
* Closes the mobile navbar if the user clicks outside of it.
|
||||
* @param event - A MouseEvent from the document.
|
||||
*/
|
||||
closeNavbarOnOutsideClick(event: MouseEvent): void {
|
||||
const clickedElement = event.target as HTMLElement;
|
||||
if (
|
||||
!clickedElement.closest('mobile-nav') &&
|
||||
!clickedElement.closest('.btn-mobile')
|
||||
) {
|
||||
this.isMobileNavbarVisible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue