I am currently working on a mega menu and have the following code snippet:
<button mat-button [matMenuTriggerFor]="objectmenu">Objects</button>
<mat-menu #objectmenu="matMenu" >
<div class="menu-content" [style.backgroundColor]="getUnSelectedRandomColor()" style="height: 550px;">
<div fxFlex="100" fxFlex.gt-sm="30" fxFlex.sm="45" class="dropdown-menu-items">
<div class="dropdown-menu-btns" *ngFor="let parent of (objectList$ | async)"
(mouseover)="openCategory($event,
parent)"
[style.background-color] = "this.selectedColor === (parent.categoryId * 100) ? getSelectedRandomColor() : getUnSelectedRandomColor()"
>{{parent.name}}</div>
</div>
<div class="theme-container">
<div class="theme-container" style=" padding-bottom: 0px !important; padding-top: 7px !important;">
<div fxLayout="column" fxLayout.gt-sm="row wrap" fxLayoutAlign="center center" class="content border-lighter">
<div fxFlex="100" fxFlex.gt-sm="100" fxLayout="column" fxLayoutAlign="center center">
<h2 *ngIf="this.selectedCategory" class="uppercase">{{this.selectedCategory.name}}</h2>
</div>
</div>
<div class="content border-lighter" [style.backgroundColor]="getSelectedRandomColor()" style="height: 380px;">
<div fxLayout="row wrap" fxLayoutAlign="space-between">
<div fxFlex="100" fxFlex.gt-sm="70" fxFlex.sm="45" style="column-count: 2;">
<ul class="ht-dropdown megamenu-two d-flex"
*ngFor="let parent of (childCategories$ | async)" style="list-style: none;">
<label [routerLink]="['/products']" [queryParams]="{categories: parent.categoryId}"
routerLinkActive="router-link-active">{{parent.name}}</label>
<li *ngFor="let child of parent.childrenCategories"
[routerLink]="['/products']" [queryParams]="{categories: child.categoryId}"
routerLinkActive="router-link-active">
{{child.name}}
</li>
</ul>
</div>
<div fxFlex="100" fxFlex.gt-sm="30" ngClass.lt-md="pt-5" style="background-size: contain !important;"
[style.background]="selectedCategoryUrl">
</div>
</div>
</div>
</div>
<div fxLayout="row" fxLayout.xs="column" fxLayoutAlign="space-between center" >
<img *ngFor="let brand of (relatedBrandsList$ | async)" [src]=" brand.thumbnail | safeHtml" style="width: 110px; height: 110px; border-radius: 50%;"/>
</div>
</div>
</div>
</mat-menu>
After applying this code, I noticed that the top and bottom edges of the menu panel are not reflecting the dynamic background color generated by my Angular code using the getUnSelectedRandomColor() method. The getUnSelectedRandomColor() function is defined as follows:
openCategory(evt, category: Category) {
this.selectedCategory = category;
this.selectedCategoryUrl = `url('../../assets/categories/${category.categoryId}.webp')`;
this.childCategories$ = this.store.pipe(select(getChildCategories(category.categoryId)));
this.relatedBrandsList$ = this.store.pipe(select(getRelatedBrands(category.categoryId)));
this.selectedColor = category.categoryId * 100;
}
getSelectedRandomColor() {
const color = 'hsl(' + this.selectedColor + ', 30%, 75%)';
return color;
}
getUnSelectedRandomColor() {
const color = 'hsl(' + this.selectedColor + ', 30%, 86%)';
return color;
}
What steps can I take to ensure that the dynamic background colors are applied to all parts of the menu panel?