Sidenav angular materials trying to be side to side with other component - html

The Problem: In an angular project I have a single component for the sidenav menu and I'm trying to put other component sided with the sidenav, but since the sidenav element has full height the other component just goes to the bottom of the page. I tried to use display flex, but still goes to the bottom of the page.
Sidenav - html
<mat-drawer-container class="container" autosize>
<mat-drawer #drawer class="p-5" mode="side">
<!-- Content for side menu -->
<!-- Title -->
<h2 class="mt-5">Menu</h2>
<!-- Menu options-->
<button mat-button class="m-2" [matMenuTriggerFor]="workexperience">Experiência
Profissional</button>
<button mat-button class="m-2" [matMenuTriggerFor]="studies">Educação</button>
<button mat-button class="m-2" [matMenuTriggerFor]="skills">Habilidades</button>
<...>
<!-- Option work experience-->
<mat-menu #workexperience="matMenu">
<button mat-menu-item>text</button>
<button mat-menu-item>text</button>
</mat-menu>
<...>
</mat-drawer>
</mat-drawer-container>
<nav class="navbar navbar-light cyan darken-3 text-white fixed-top">
<button type="button" mat-button (click)="drawer.toggle()">
<mat-icon class="mx-2">menu</mat-icon>
<p class="mr-4 d-inline">Menu</p>
</button>
<button type="button" routerLink="/home" routerLinkActive="active" mat-raised-button>
<mat-icon class="d-inline mx-2" aria-label="Example home icon">home</mat-icon>
<p class="mr-4 d-inline">Home</p>
</button>
<a class="navbar-brand d-inline mx-5" routerLink="/bio">
<img class="rounded-circle z-depth-2" alt="80x80" height="35" src="https://mdbootstrap.com/img/Photos/Avatars/img%20(31).jpg"
data-holder-rendered="true">
<p class="d-inline mx-3 text-white">text</p>
</a>
</nav>
Sidenav- css
.container {
display: inline-block;
height: 100%;
background-color: white;
}
The other component that I want to be on the rigth of the navside.
The other component html
<mat-grid-list cols="4" rowHeight="500" class="m-5 sidenav-content">
<mat-grid-tile
*ngFor="let tile of tiles"
[colspan]="tile.cols"
[rowspan]="tile.rows"
[style.background]="tile.color">
{{tile.text}}
</mat-grid-tile>
</mat-grid-list>
The other component css
.sidenav-content{
display: flex;
height: 100%;
}

Related

Have Bootstrap 5 modal and backdrop take up the parent container width and height and not the full screen

Is there a way to limit the size of bootstrap 5 modal dialog and backdrop?
The example below is occupying 100% of the screen, is it possible to make it cover only the parent main container?
<main class="container-fluid pt-4 px-4" style="height: 400px">
<!-- Button trigger modal -->
<button
type="button"
class="btn btn-primary"
data-bs-toggle="modal"
data-bs-target="#exampleModal"
>
Launch demo modal
</button>
<!-- Modal -->
<div
class="modal fade hide"
data-backdrop="false"
id="exampleModal"
tabindex="-1"
aria-labelledby="exampleModalLabel"
aria-hidden="true"
>
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5
class="modal-title"
id="exampleModalLabel"
>
Modal title
</h5>
<button
type="button"
class="btn-close"
data-bs-dismiss="modal"
aria-label="Close"
></button>
</div>
<div class="modal-body">...</div>
<div class="modal-footer">
<button
type="button"
class="btn btn-secondary"
data-bs-dismiss="modal"
>
Close
</button>
<button
type="button"
class="btn btn-primary"
>
Save changes
</button>
</div>
</div>
</div>
</div>
</main>
I added the CSS below but not working.
.modal-dialog, .modal-backdrop {
/* supposed to take the height and width of parent container */
height: 100% !important;
width: 100% !important;
}
How it works:
What I want (or expected behavior):
The modal component adds a the backdrop element (outside the .modal's parent) automatically, so if you want the modal to be completely contained inside the parent, start by disabling the backdrop with data-bs-backdrop="false".
By default the .modal has position: fixed so it gets rendered relative to the viewport without regards to its parent element(s). This behavior can be overridden by giving the (main) parent position: relative; and give the .modal child position: absolute;. You can also give the .modal an rgba() background-color to simulate an encapsulated, static backdrop within the parent only (clicking on a static backdrop does not close the modal).
To have the modal centered within the parent add .modal-dialog-centered to the .modal-dialog.
In the snippet below I have given both main and .modal a background to more clearly demonstrate:
main {
position: relative;
background: #EEE;
}
main .modal {
position: absolute;
background: rgba(0, 100, 0, 0.35);
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.2.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
<div class="container-fluid">
<div class="row">
<div class="col-2">
sidebar
</div>
<div class="col-10">
<div class="row">
<nav class="navbar bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="#">Navbar</a>
</div>
</nav>
</div>
<div class="row">
<main class="container-fluid pt-4 px-4" style="height: 400px">
<!-- Button trigger modal -->
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#exampleModal">
Launch demo modal
</button>
<!-- Modal -->
<div class="modal fade hide" data-bs-backdrop="false" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">
Modal title
</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body flex-grow-1">...</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">
Close
</button>
<button type="button" class="btn btn-primary">
Save changes
</button>
</div>
</div>
</div>
</div>
</main>
</div>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.2.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4" crossorigin="anonymous"></script>

The data is not rendering in the mat-menu

I been trying to create a navbar with a submenu. The nav bar data is rendered successfully but the submenu is not working, I am very new to this. Please let me know where is the problem.
<mat-nav-list class="navigation relative">
<div *ngFor="let link of navLinks; let i=index" style="padding-bottom: 14px;">
<div class="card">
<mat-list-item appAccordionlinks routerLinkActive="active-link" (click)="onClick(link.name)">
<a mat-button [matMenuTriggerFor]="submenu" *ngIf="link?.submenu?.length > 0" appAccordiontoggle
class="relative main-active">
<mat-icon *ngIf="link.icon">{{link.icon}}</mat-icon>
<img class="menu-img" *ngIf="link.img" [src]="link.img" alt="">
<app-menu-icon *ngIf="link.img" [name]="'employee'"></app-menu-icon>
<span>{{link.name}}</span><span fxFlex></span>
</a>
<a *ngIf="!(link?.submenu?.length > 0)" [routerLink]="link.path" appAccordiontoggle
class="relative main-active" mat-ripple fxLayout="row">
<mat-icon *ngIf="link.icon">{{link.icon}}</mat-icon>
<app-menu-icon *ngIf="link.img" [name]="link.name" [color]="link.color"></app-menu-icon>
<!-- <img class="menu-img" *ngIf="link.img" [src]="link.img" alt=""> this is need to mark as comment -->
<span>{{link.name}}</span>
</a>
</mat-list-item>
</div>
</div>
</mat-nav-list>
<mat-menu #submenu>
<ng-container *ngFor="let sublink of link?.submenu">
<ng-container *ngIf="link?.submenu?.length > 0">
<button mat-menu-item>
<img class="menu-img" *ngIf="sublink.img" [src]="sublink.img">
<span>{{sublink.name}}</span>
</button>
</ng-container>
</ng-container>
</mat-menu>
The mat-menu element is out of the scope of link variable. You need to include it (mat-menu) in the div you are dynamically rendering the links, i.e. within link's scope:
<div *ngFor="let link of navLinks; let i = index"...>
<--! card html -->
<mat-menu #submenu>
<--! submenu child elements... -->
</mat-menu>
</div>

how to make a RTL Menu in angular

Hi i am Learning Angular
I just Made an angular Panel But I want It To Be Rtl But I do not Know How To do That
This Is My Panel
this Is My Html Code
<mat-toolbar color="primary">
<mat-toolbar-row>
<button mat-icon-button >
<mat-icon>menu</mat-icon>
</button>
<span> Admin Panel </span>
<div fxFlex fxLayout="row" fxLayoutAlign="flex-end">
<ul fxLayout="row" fxLayoutGap="20px">
<li>
<button mat-icon-button>
<mat-icon>settings</mat-icon>
</button>
</li>
<li>
<button mat-icon-button>
<mat-icon>help_outline</mat-icon>
</button>
</li>
</ul>
</div>
</mat-toolbar-row>
</mat-toolbar>
This Is My css
ul li{
list-style: none;
}
Do you mean something like that?
Code:
<mat-toolbar color="primary">
<mat-toolbar-row fxLayout="row-reverse">
<button mat-icon-button (click)="sidenav.toggle()">
<mat-icon>menu</mat-icon>
</button>
<span> Admin Panel </span>
<span fxFlex="1 1"></span>
<button mat-icon-button>
<mat-icon>settings</mat-icon>
</button>
<button mat-icon-button>
<mat-icon>help_outline</mat-icon>
</button>
</mat-toolbar-row>
</mat-toolbar>
<mat-sidenav-container>
<mat-sidenav #sidenav position="end">
Sidenav content
</mat-sidenav>
<mat-sidenav-content>
Sidenav content
</mat-sidenav-content>
</mat-sidenav-container>
Using the fxLayout="row-reverse"-property in your <mat-toolbar-row>
Here is a stackblitz: https://stackblitz.com/angular/kgnvebakmpj
fyi if you only have one toolbar row, you can leave out the <mat-toolbar-row>.

How to apply width to specific child ngx-bootstrap Modal from parent component CSS

I am using the following CSS code in parent component CSS file to change the width of a child modal (I am using NGX bootstrap modals).
Parent CSS:
::ng-deep .modal-dialog {
min-width: 1000px;
}
Parent HTML:
<!-- Modal -->
<div class="modal-header" style="padding-bottom: 0px">
<h2 class="modal-title" id="exampleModalLabel">Modification History</h2>
<button type="button" class="close" data-dismiss="modal" (click)="bsModalRef.hide()" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<app-mod-logs [searchInput]="searchInput"></app-mod-logs>
</div>
Child HTML:
<div class="modal-dialog filter">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">
Advanced Filter
</h5>
<button type="button"
class="close"
data-dismiss="modal"
(click)="bsModalRef.hide()"
aria-label="Close">
<span aria-hidden="true">
×
</span>
</button>
</div>
<div class="modal-body">
<div class="row">
<div class="col-md-4 py-3 px-lg-1 border bg-light column1">
<div class="heading">
<b>Available Objects</b>
</div>
<ul class="list-group container1">
<li class="list-group-item list-group-item-action"
[ngStyle]="{width: objectWidth}"
[class.active]="active === i"
(click)='loadKeyItems(object.KeyObject); activated(i);'
*ngFor="let object of availableObjects; let i = index;">
{{object.SourceObject}}
</li>
</ul>
</div>
<div class="col-md-4 py-3 px-lg-1 border bg-light column2">
<div class="heading">
<b>Available Items</b>
</div>
<ul class="list-group container2">
<ngx-spinner name="boxSpinner"
[fullScreen]="false"
type="ball-spin-clockwise"
size="small">
</ngx-spinner>
<li [ngStyle]="{width: availableWidth}"
class="list-group-item list-group-item-action"
(dblclick)='pushToSelected(keyItem.Id)'
(mousedown)="disableTextSelection($event)"
*ngFor="let keyItem of KeyItems">
{{keyItem.Caption}}
</li>
</ul>
</div>
<div class="col-md-4 py-3 px-lg-1 border bg-light column3">
<div class="heading">
<b>Selected Items</b>
</div>
<ul class="list-group container3">
<li [ngStyle]="{width: selectedWidth}"
class="list-group-item list-group-item-action"
(dblclick)='pushToAvailable(select.Id)'
(mousedown)="disableTextSelection($event)"
*ngFor='let select of selectedItemArray'>
{{select.Caption}}
</li>
</ul>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button"
class="btn btn-secondary"
(click)='clear()'
[disabled]='buttonDisabled'>
Clear
</button>
<button type="button"
class="btn btn-secondary"
[disabled]='buttonDisabled'>
Apply Filters
</button>
</div>
</div>
but this code applies the width of 1000px to all the children. I want this on a specific modal. And as the modal-dialog class is a parent bootstrap class of modals, I can not access it from children, so I have written the CSS in the parent. I have tried to add css class of my that specific child but it is not working as expected. (See the following code). (PS - I haven't applied any css related to this in the child CSS).
Parent modified CSS:
::ng-deep .modal-dialog .filter {
min-width: 1000px;
}
I was using modal-lg class for that specific modal so therefore I used following CSS in the Parent component.
::ng-deep .modal-lg {
min-width: 1000px !important;
}

How to set background image in div-element in Angular Material app?

I know this has been asked, but none of the solutions work.
I have following html and I can get the image displayed if I use the commented img-element
<img src="assets/utgmap.jpg">
and comment away the following div-element. However I would like to have background image for the div instead and it's not working. CSS definition is in the end of the file and there's no 404 error for the image so it can be fetched but is is not displayed.
HTML:
<mat-sidenav-container class="sidenav-container">
<mat-sidenav #drawer class="sidenav" fixedInViewport="true"
[attr.role]="(isHandset$ | async) ? 'dialog' : 'navigation'"
[mode]="(isHandset$ | async) ? 'over' : 'side'"
[opened]="!(isHandset$ | async)">
<mat-toolbar>Menu</mat-toolbar>
<mat-nav-list>
<a mat-list-item href="#">Link 1</a>
<a mat-list-item href="#">Link 2</a>
<a mat-list-item href="#">Link 3</a>
</mat-nav-list>
</mat-sidenav>
<mat-sidenav-content>
<mat-toolbar color="primary">
<mat-toolbar-row>
<button mat-icon-button (click)="toggleSidenav.emit()">
<mat-icon>menu</mat-icon>
</button>
<span>webgisproto</span>
<button mat-icon-button>
<mat-icon>settings</mat-icon>
</button>
<button mat-icon-button>
<mat-icon>help_outline</mat-icon>
</button>
<button mat-icon-button [matMenuTriggerFor]="menu">
<mat-icon>exit_to_app</mat-icon>
</button>
<mat-menu #menu="matMenu">
<button mat-menu-item (click)="logout()">
<mat-icon>exit_to_app</mat-icon>
<span>Sign out</span>
</button>
</mat-menu>
</mat-toolbar-row>
</mat-toolbar>
<app-menu></app-menu>
<!-- THIS WORKS!!
<img src="assets/utgmap.jpg">
IF I UNCOMMENT THIS AND COMMENT OUT THE FOLLOWING DIV -->
<div class="bgimg">
<div class="testclass">
<mat-list color="primary">
<mat-list-item>
<button mat-icon-button>
<mat-icon>settings</mat-icon>
</button>
</mat-list-item>
<mat-list-item>
<button mat-icon-button>
<mat-icon>help_outline</mat-icon>
</button>
</mat-list-item>
</mat-list>
</div>
</div>
</mat-sidenav-content>
CSS:
.testclass {
float: right;
}
.bgimg {
background: url('../../assets/utgmap.jpg') no-repeat center center fixed;
}
If I change the path above there will be error.
You need to set a dimension to your div. The following code will display the image in full screen.
html, body {
height: 100%;
}
.bgimg {
display:block;
width:100%;
height:100%;
background: url('../../assets/utgmap.jpg') no-repeat center center fixed;
}