projects/tl-elements/src/lib/tl-dropdown-menu/tl-dropdown-menu-section/tl-dropdown-menu-section.component.ts
changeDetection | ChangeDetectionStrategy.Default |
selector | tl-dropdown-menu-section-component |
styleUrls | ./tl-dropdown-menu-section.component.scss |
templateUrl | ./tl-dropdown-menu-section.component.html |
Properties |
Methods |
Inputs |
HostBindings |
constructor(injector: Injector)
|
||||||
Parameters :
|
inheritFontStyle | |
Type : "true" | "false"
|
|
Inherited from
TamuAbstractBaseComponent
|
|
Defined in
TamuAbstractBaseComponent:14
|
class.mobile-layout |
Type : any
|
Default value : this.isMobileLayout
|
Toggles the mobile-layout class on the root element. |
style.--wvr-nav-list-component-max-height |
Type : string
|
Allows for the override of the --tl-mobile-display-wvr-nav-list-component-max-height variable. |
style.--tl-font-family-sans-serif |
Type : string
|
Default value : 'var(--tl-default-font-family-sans-serif)'
|
Inherited from
TamuAbstractBaseComponent
|
Defined in
TamuAbstractBaseComponent:12
|
Allows for the override of the --tl-font-family-sans-serif css variable. |
style.--tl-font-size |
Type : string
|
Default value : 'var(--tl-default-font-size)'
|
Inherited from
TamuAbstractBaseComponent
|
Defined in
TamuAbstractBaseComponent:9
|
Allows for the override of the --tl-default-font-size css variable. |
getElementHeight |
getElementHeight()
|
Get the clientHeight of the element.
Returns :
number
the height of the element, in pixels. |
ngAfterContentInit |
ngAfterContentInit()
|
Perform after-initialization operations. This will add the section to the parent's component.
Returns :
void
|
ngOnInit |
ngOnInit()
|
Perform initialization operations. This will identify the parent element.
Returns :
void
|
mobileLayout |
Default value : this.isMobileLayout
|
Decorators :
@HostBinding('class.mobile-layout')
|
Toggles the mobile-layout class on the root element. |
Private parent |
Type : TlDropDownMenuComponent
|
wvrNavListComponentMaxHeight |
Type : string
|
Decorators :
@HostBinding('style.--wvr-nav-list-component-max-height')
|
Allows for the override of the --tl-mobile-display-wvr-nav-list-component-max-height variable. |
_fontFamily |
Type : string
|
Default value : 'var(--tl-default-font-family-sans-serif)'
|
Decorators :
@HostBinding('style.--tl-font-family-sans-serif')
|
Inherited from
TamuAbstractBaseComponent
|
Defined in
TamuAbstractBaseComponent:12
|
Allows for the override of the --tl-font-family-sans-serif css variable. |
_fontSize |
Type : string
|
Default value : 'var(--tl-default-font-size)'
|
Decorators :
@HostBinding('style.--tl-font-size')
|
Inherited from
TamuAbstractBaseComponent
|
Defined in
TamuAbstractBaseComponent:9
|
Allows for the override of the --tl-default-font-size css variable. |
import { AfterContentInit, ChangeDetectionStrategy, Component, HostBinding, Injector, OnInit } from '@angular/core';
import { TamuAbstractBaseComponent } from '../../shared/tl-abstract-base.component';
import { TlDropDownMenuComponent } from '../tl-dropdown-menu.component';
@Component({
selector: 'tl-dropdown-menu-section-component',
templateUrl: './tl-dropdown-menu-section.component.html',
styleUrls: ['./tl-dropdown-menu-section.component.scss'],
changeDetection: ChangeDetectionStrategy.Default
})
export class TlDropDownMenuSectionComponent extends TamuAbstractBaseComponent implements AfterContentInit, OnInit {
private parent: TlDropDownMenuComponent;
/** Toggles the mobile-layout class on the root element. */
@HostBinding('class.mobile-layout') mobileLayout = this.isMobileLayout;
/** Allows for the override of the --tl-mobile-display-wvr-nav-list-component-max-height variable. */
@HostBinding('style.--wvr-nav-list-component-max-height') wvrNavListComponentMaxHeight: string;
// tslint:disable-next-line:unnecessary-constructor
constructor(injector: Injector) {
super(injector);
}
/**
* Perform initialization operations.
*
* This will identify the parent element.
*/
ngOnInit(): void {
super.ngOnInit();
const elem = this.eRef.nativeElement as HTMLElement;
const parentElem = elem.closest('tl-dropdown-menu');
if (parentElem) {
this.parent = this.componentRegistry.getComponentByElement(parentElem as HTMLElement) as TlDropDownMenuComponent;
} else {
console.warn(`TlDropDownMenuSectionComponent (${this.id}) is not within a TlDropDownMenuComponent`);
}
}
/**
* Perform after-initialization operations.
*
* This will add the section to the parent's component.
*/
ngAfterContentInit(): void {
super.ngAfterContentInit();
setTimeout(() => {
this.parent.addSection(this);
}, 1500);
}
/**
* Get the clientHeight of the element.
*
* @returns the height of the element, in pixels.
*/
getElementHeight(): number {
return (this.eRef.nativeElement as HTMLElement).clientHeight;
}
}
<wvr-nav-list-component vertical="true" class="section-content" [ngClass]="{ 'mobile-layout': isMobileLayout }">
<template nav-list-items>
<ng-content select="tl-nav-li, tl-dropdown-menu-custom" ngProjectAs="wvr-nav-li"></ng-content>
</template>
</wvr-nav-list-component>
./tl-dropdown-menu-section.component.scss
@import "../../shared/styles/tl-variables.scss";
:host {
width: 27%;
padding-bottom: 35px;
wvr-nav-list-component.mobile-layout {
display: inline-block;
overflow: hidden;
transition: max-height 0.25s ease-in-out;
}
wvr-nav-list-component.mobile-layout.active {
max-height: var(--wvr-nav-list-component-max-height);
transition: max-height 1s ease-in-out;
}
p {
margin-bottom: 3px;
}
wvr-nav-list-component {
::ng-deep {
[role=menu] {
height: auto;
}
tl-nav-li {
padding: 4px 0px 6px 25px;
margin-bottom: 2px;
color: var(--tl-deep-grey);
font-weight: lighter;
width: 100%;
display: block;
> a {
padding: 0px;
margin-bottom: 0x;
color: inherit;
font-weight: inherit;
width: 100%;
display: block;
}
> a:hover {
font-weight: inherit;
color: inherit;
background: inherit;
text-decoration: none;
}
}
tl-nav-li:hover {
font-weight: bolder;
color: var(--tl-white);
background: var(--tl-deep-grey);
text-decoration: none;
}
}
}
}