src/app/core/layout/navbar/navbar-user/navbar-user.component.ts
OnInit
selector | bgui-navbar-user |
standalone | true |
imports |
CommonModule
MatIconModule
MatDividerModule
MatRippleModule
ClickOutsideDirective
MatButtonModule
RouterLink
|
styleUrls | ./navbar-user.component.scss |
templateUrl | ./navbar-user.component.html |
Properties |
Methods |
constructor()
|
ngOnInit |
ngOnInit()
|
Returns :
void
|
onClickOutside |
onClickOutside()
|
Returns :
void
|
toggleDropdown |
toggleDropdown()
|
Returns :
void
|
isOpen |
Type : boolean
|
import { Component, OnInit } from '@angular/core';
import { CommonModule } from '@angular/common';
import { MatIconModule } from '@angular/material/icon';
import { MatDividerModule } from '@angular/material/divider';
import { MatRippleModule } from '@angular/material/core';
import { ClickOutsideDirective } from '../../../../shared/click-outside/click-outside.directive';
import { MatButtonModule } from '@angular/material/button';
import { RouterLink } from '@angular/router';
@Component({
selector: 'bgui-navbar-user',
standalone: true,
imports: [
CommonModule,
MatIconModule,
MatDividerModule,
MatRippleModule,
ClickOutsideDirective,
MatButtonModule,
RouterLink,
],
templateUrl: './navbar-user.component.html',
styleUrls: ['./navbar-user.component.scss'],
})
export class NavbarUserComponent implements OnInit {
isOpen!: boolean;
constructor() {}
ngOnInit() {}
toggleDropdown() {
this.isOpen = !this.isOpen;
}
onClickOutside() {
this.isOpen = false;
}
}
./navbar-user.component.scss
@use 'sass:math';
.toolbar-user {
position: relative;
display: flex;
.button {
min-width: 64px;
border-radius: 0;
.avatar {
width: 40px;
height: 40px;
border-radius: 50%;
}
.name {
margin: 0 8px 0 10px;
}
.icon {
width: 16px;
height: 16px;
font-size: 16px;
transform: rotate(0);
transition: transform .25s cubic-bezier(.25,.8,.25,1);
}
&.open {
background: rgba(0, 0, 0, .05);
.icon {
transform: rotate(-180deg);
}
}
}
.dropdown {
position: absolute;
top: 64px;
right: 0;
width: 100%;
min-width: 160px;
z-index: -1;
transform: translateY(-110%);
visibility: hidden;
transition: transform .4s cubic-bezier(.25,.8,.25,1), visibility .4s cubic-bezier(.25,.8,.25,1);
border-bottom-left-radius: 16px;
border-bottom-right-radius: 16px;
background: white;
box-shadow: 0px 0px 0px 0px rgba(0, 0, 0, 0.2), 0px 0px 0px 0px rgba(0, 0, 0, 0.14), 0px 0px 0px 0px rgba(0, 0, 0, 0.12);
.list {
padding-top: math.div(24px, 3);
.list-item {
display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: center;
align-content: center;
height: 48px;
padding: 0 math.div(24px, 1.5);
position: relative;
cursor: pointer;
outline: none;
.list-item-icon {
padding-right: math.div(24px, 1.5);
}
}
}
&.open {
transform: translateY(0);
visibility: visible;
}
}
}
nav{
position: absolute;
top: 200%;
left: 50%;
transform: translate(-50%, -50%);
}
nav .drop-btn{
width: 400px;
background: #242526;
color: #b0b3b8;
line-height: 50px;
padding: 0 20px;
border-radius: 5px;
font-size: 20px;
font-weight: 500;
}
nav .drop-btn span {
float: right;
line-height: 50px;
font-size: 28px;
cursor: pointer;
}
nav .wrapper {
position: absolute;
top: 65px;
display: flex;
width: 400px;
background: #242526;
border-radius: 5px;
}
nav .wrapper ul {
list-style: none;
width: 400px;
padding: 10px;
}
nav .wrapper ul li {
line-height: 55px;
}
nav .wrapper ul li a {
position: relative;
text-decoration: none;
color: #b0b3b8;
display: flex;
font-size: 18px;
font-weight: 500;
padding: 0 10px;
align-items: center;
border-radius: 8px;
}
nav .wrapper ul li:hover a{
background: #3A3b3c;
}
.wrapper ul li a .icon {
height: 40px;
width: 40px;
margin-right: 13px;
background: #ffffff1a;
display: flex;
align-items: center;
justify-content: center;
text-align: center;
border-radius: 50px;
}
.wrapper ul li a i {
position: absolute;
right: 10px;
font-size: 25px;
pointer-events: none;
}