Primeng TabView add content after tabs - html

I need to have 2/3 tabs, but in the end and on the same line, I need to add buttons, custom component etc etc ...
I didn't found a way to do it, and there is no responses when googling :-o
<p-tabView>
<p-tabPanel header="Header 1">
Content 1
</p-tabPanel>
<p-tabPanel header="Header 2">
Content 2
</p-tabPanel>
<p-tabPanel header="Header 3">
Content 3
</p-tabPanel>
<!-- here start my custom html - without tabs content -->
<p-tabPanel>
<button></button>
<app-my-custom-component></app-my-custom-component>
</p-tabPanel>
</p-tabView>
Here an example of what I need.
On the same line, I want to add custom html, and when I click on it, there is no tab, but other actions ... like dialog for example

Try this:
<p-tabView>
<p-tabPanel header="Header 1"> Content 1 </p-tabPanel>
<p-tabPanel header="Header 2"> Content 2 </p-tabPanel>
<p-tabPanel header="Header 3"> Content 3 </p-tabPanel>
<!-- here start my custom html - without tabs content -->
<p-tabPanel>
<ng-template pTemplate="header">
<p-button icon="pi pi-chevron-up" (click)="openPrev()">
</p-button>
</ng-template>
</p-tabPanel>
<p-tabPanel>
<ng-template pTemplate="header">
<app-my-custom-component></app-my-custom-component>
</ng-template>
</p-tabPanel>
</p-tabView>

In addition to this answer.
To prevent the content from opening and only trigger the button action, try this:
Add $event.stopPropagation() to the button (click) method:
<button pButton type="button" label="Action button"
(click)="performRequiredAction();$event.stopPropagation();" >
</button>
Using CSS, disable clicking on the parent element, which is the tab, and enable it for the child button:
:host ::ng-deep {
.p-tabview-nav-link:has(button){
pointer-events: none;
button {
pointer-events: all;
}
/* Additional styling for a better button look */
border: none !important;
padding: 0 4px !important;
height: 100%;
align-items: center;
}
}

Related

How can I stick button to a mat-drawer?

I have a mat drawer to the right of the screen and I am trying to stick a button to it, so the overall design is clear.
Example
How can I manage to do this action? So far I have tried adding the button inside of the drawer and giving it a negative left: -10px in order to overlay the drawer.
<mat-drawer-container class="example-container" [hasBackdrop]="false">
<mat-drawer style="width: 600px;" position="end" #drawer2 [mode]="over">
<button style="left: -10px; z-index: 1000;" mat-raised-button (click)="drawer2.toggle()">Side Nav</button> HERE
<mat-tab-group>
<mat-tab>
<ng-template mat-tab-label>
<mat-icon> layers</mat-icon>
<span>Componenti</span>
</ng-template>
<components [itemCategoryAreas]="itemCategoryAreas"></components>
</mat-tab>
<mat-tab>
<ng-template mat-tab-label>
<mat-icon>wallpaper</mat-icon>
<span>Disegno</span>
</ng-template>
Content 1
</mat-tab>
<mat-tab>
<ng-template mat-tab-label>
<mat-icon>list</mat-icon>
<span>Checklist</span>
</ng-template>
Content 1
</mat-tab>
</mat-tab-group>
</mat-drawer>
🚂 Might help! Try something like this:
.app-toolbar {
position: sticky;
position: -webkit-sticky; /* For macOS/iOS Safari */
top: 0; /* Sets the sticky toolbar to be on top */
z-index: 1000; /*app's content doesn't overlap the toolbar */
}
don't forget to change the classname though, Hope it helps :)
Then,
If you want your button to stick permanent to its position, you should use
position: fixed;
instead of
position: sticky;

Making collapse with slider in angular

I am working on angular project. I am trying to make a collapse. My code is as follows
<div class="myClass">
<mat-accordion>
<mat-expansion-panel>
<mat-expansion-panel-header>
<mat-panel-title>
</mat-panel-title>
<mat-panel-description>
Description
</mat-panel-description>
</mat-expansion-panel-header>
</mat-expansion-panel>
</mat-accordion>
</div>
.myClass {
display: flex;
flex-direction: column;
margin-top: auto;
}
.mat-expansion-panel-header {
width: 99.7vw;
}
.mat-expansion-panel-header-description {
flex-grow: 1;
}
Reason for using margin-top:auto because I want this collapse at end of page. Once I click on collapse icon my collapse should open and it should look like as shown in image
Once my collapse open I want to have these types of card with my data and on opening of this collapse I want to 4-5 boxes/cards in row as shown but in case if more data is present then I want to slide using ">>" and show these box/cards. If I click "<<" on left hand side then it should move in that direction. How can I do that?
This is called a carousel. Not the easiest of things to do if you're new to angular. I would recommend just using owl carousel. There's an angular wrapper you can use. Or if you want to make a carousel on your own you can follow this guide.
For the collapsing of the carousel, you'd have to make a button that switches collapse state. Something like this-
<button (click)="collapsed = !collapsed"></button>
<div *ngIf="!collapsed" >
<carousel-component></carousel-component>
<div>

Adding footer to Vuetify's list/menu/combobox

I am trying to insert footer to the Vuetify's list or menu or combobox. They all are pretty same. I tried every possibe css solution I could without solution.
This is what I want but I want the bottom button to be statically visible at the bottom even if scrolling:
Regular fixed css solution do not work no matter on what element I do apply styles.
This is the combobox I am trying to implement it to:
<v-combobox
style="min-width: 260px;"
dense
:value="item.description"
:items="products"
item-text="name"
item-value="id"
:error-messages="item.description_error"
:filter="filter_products"
#input="product_selected"
ref="description">
<template
slot="item"
slot-scope="{ index, item, parent }">
<v-list-tile-content v-if="!item.footer">{{ item.name }}</v-list-tile-content>
<v-btn v-else flat dark small style="padding-left:0!important;margin-left:0!important;display:table-row;width:100%"
color="primary"
depressed
:ripple="false"
#click.stop="add_new_product"><v-icon left>add_box</v-icon>{{ item.footer }}</v-btn>
</template>
</v-combobox>
Also tried using v-menu and v-list
<v-menu max-height="250px">
<v-text-field label="Hello" slot="activator"></v-text-field>
<v-list>
<v-list-tile v-for="item in 10">hello</v-list-tile>
</v-list>
<p style="position: fixed; bottom: 0;">IUWHEGIuiHWEGIUHGIWUEHGIUWHEGIUHWEIUG</p>
</v-menu>
Codepen
We need to add max-height and overflow: auto to the v-list element so that we can scroll the list, and not the whole menu.
Add "footer" to the bottom of the v-menu and it should work as expected.
And just wrap it inside the v-card for example so that menu is not transparent.
<v-menu v-model="menu" offset-y>
<v-btn slot="activator">Menu</v-btn>
<v-card>
<v-list class="custom-list">
<v-list-tile v-for="item in items"></v-list-tile>
</v-list>
<v-divider></v-divider>
<div class="pa-1" #click.stop="">
<v-btn flat dark small color="primary" depressed :ripple="false">
<v-icon left>add_box</v-icon>
footer button
</v-btn>
</div>
</v-card>
</v-menu>
css
.custom-list {
max-height:200px;
overflow: auto;
}
We can use #click.stop="" to prevent it from closing the menu.

Angular - Primeng's confirmDialog is shown behind the ng-bootstrap's modal

I'm using the primeng and ng-bootstrap components to make a website with angular.
To capture information I use a form within an ng-bootstrap modal. When clicking on the "save" button of that modal The primeng confirmDialog should appear. The problem is that it appears behind the modal.
How can I fix it?
Here's some of my HTML:
<p-confirmDialog header="Confirmation" icon="pi pi-exclamation-triangle" width="425" appendTo="body"></p-confirmDialog>
<ng-template #modalFormOrder let-c="close" let-d="dismiss" id="modalFormOrder">
<div class="modal-header">
...
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-light" (click)="c('Close click')">Close</button>
<button type="button" class="btn m-btn--pill m-btn--air btn-success" (click)="SaveEditLoadOrder()">Save</button>
</div>
</ng-template>
I'm somehow sure that both dialogs use z-index CSS property
Override the z-index CSS property with a bigger number for the element that you want to appears first, example z-index: 1001;
If you want to override Css for PrimeNG I suggest you write it on /src/styles.css . Following Example is overriding calendar CSS
.ui-calendar {
width: 100%;
height: 100%;
}
On PrimeNG documentation you can find the CSS classes to override for each component

"cursor: pointer" just not working at all

This is my angular template code:
<!-- Modal -->
<ng-template #levelsmodal let-c="close" let-d="dismiss">
<div class="modal-header">
Select the levels you want to show in the table and chart
</div>
<div id="segments-modal" class="modal-body">
<div class="row margin" *ngFor="let level of config?.data?.groups; let i = index" (click)="selectLevel(level)">
<div class="colorspan" [style.backgroundColor]="level.active ? colors[i] : 'gray'" class="colorspan">
</div>
<span class="level-labels pointer-cursor" [innerHTML]="getLabel(level)" ></span>
</div>
</div>
<div class="modal-footer">
<button class="btn btn-success" (click)="c()">Close</button>
</div>
</ng-template>
The class "pointer-cursor" is plain simple:
.pointer-cursor{
cursor: pointer !important;
z-index: 500;
}
The z-index was only added for trying if it could make some difference, but it doesn't. I also tried applying this class to other parts like the wrapper div and so, but it's just not working. I keep seeing the normal "text cursor" instead of the pointer one...
Does anybody know why this happens?
Try that
::ng-deep .pointer-cursor{
cursor: pointer !important;
z-index: 500;
}
Edit
The ::ng-deep combinator (https://angular.io/guide/component-styles#deprecated-deep--and-ng-deep) ensures that the defined style applies to all child elements of the component, not only elements directly created by the component.
Since the element you want to style in inside a ng-template tag (so it does not belong directly to the component), you need to use this to style its elements