projects/tl-elements/src/lib/tl-dropdown/tl-dropdown.component.ts
changeDetection | ChangeDetectionStrategy.Default |
selector | tl-dropdown-component |
styleUrls | ./tl-dropdown.component.scss |
templateUrl | ./tl-dropdown.component.html |
Properties |
Inputs |
HostBindings |
Accessors |
constructor(injector: Injector)
|
||||||
Parameters :
|
btnBorderRadius | |
Type : any
|
|
Used to override the border radius of button in a dropdown |
btnBoxShadowFocus | |
Type : any
|
|
btnFontFamily | |
Type : any
|
|
Used to override the button font family in a drop down |
btnFontSize | |
Type : any
|
|
Used to override the button font size in a drop down |
btnHref | |
Type : any
|
|
Used to convert the dropdown menu button into a link. |
btnLineHeight | |
Type : any
|
|
Used to override the line height of button in a drop down |
btnTextAlign | |
Type : any
|
|
Used to override the text alignment of button in a drop down |
menuBackground | |
Type : any
|
|
Used to define the drop down menu background. |
menuBorder | |
Type : any
|
|
Used to define the drop down menu border. |
menuBorderDisplay | |
Type : any
|
|
Used to define the drop-down menu border display |
menuBorderRadius | |
Type : any
|
|
Used to define the drop down menu-border-radius. |
menuBoxShadow | |
Type : any
|
|
Used to define the drop down menu box shadow. |
menuFlexDirection | |
Type : any
|
|
Used to define the drop-down |
menuItemMargin | |
Type : any
|
|
Used to define the item margin in drop-down menu. |
menuPadding | |
Type : any
|
|
Used to define the drop-down menu padding |
menuWidth | |
Type : any
|
|
Used to define the drop-down menu width |
menuXOffset | |
Type : any
|
|
Used to define the drop-down menu x offset. |
menuYOffset | |
Type : string
|
|
Default value : '-6px'
|
|
Used to define the drop-down menu x offset. |
toggleOn | |
Type : string
|
|
Default value : 'click'
|
|
Used to define the event type which will display the dropdown menu. |
inheritFontStyle | |
Type : "true" | "false"
|
|
Inherited from
TamuAbstractBaseComponent
|
|
Defined in
TamuAbstractBaseComponent:14
|
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. |
isOpen |
Default value : false
|
Used to define the boolean value for the drop down |
_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. |
btnBackground |
getbtnBackground()
|
Used to override the button background in a drop down
Returns :
string
|
btnBackgroundActive |
getbtnBackgroundActive()
|
Used to override the button background active state in a drop down
Returns :
string
|
btnBackgroundHover |
getbtnBackgroundHover()
|
Used to override the button background hover state in a drop down
Returns :
string
|
btnBorderColor |
getbtnBorderColor()
|
Used to override the button border in a drop down
Returns :
string
|
btnBorderActive |
getbtnBorderActive()
|
Used to override the button active state border in a drop down
Returns :
string
|
btnBorderFocus |
getbtnBorderFocus()
|
Used to override the button focus state border in a drop down
Returns :
string
|
btnBorderHover |
getbtnBorderHover()
|
Used to override the button active state border in a drop down
Returns :
string
|
btnColor |
getbtnColor()
|
Used to override the button color in a drop down
Returns :
string
|
btnColorActive |
getbtnColorActive()
|
Used to override the button color active state in a drop down
Returns :
string
|
btnColorHover |
getbtnColorHover()
|
Used to override the button color hover state in a drop down
Returns :
string
|
btnTextDecoration |
getbtnTextDecoration()
|
Used to override the text decoration property of button in a drop down
Returns :
string
|
btnTextDecorationActive |
getbtnTextDecorationActive()
|
Used to override the active state of button text decoration property in a drop down
Returns :
string
|
btnTextDecorationFocus |
getbtnTextDecorationFocus()
|
Used to override the focus state of button text decoration property in a drop down
Returns :
string
|
btnTextDecorationHover |
getbtnTextDecorationHover()
|
Used to override the hover state of button text decoration property in a drop down
Returns :
string
|
import { ChangeDetectionStrategy, Component, HostBinding, Injector, Input } from '@angular/core';
import { TamuAbstractBaseComponent } from '../shared/tl-abstract-base.component';
@Component({
selector: 'tl-dropdown-component',
templateUrl: './tl-dropdown.component.html',
styleUrls: ['./tl-dropdown.component.scss'],
changeDetection: ChangeDetectionStrategy.Default
})
export class TlDropDownComponent extends TamuAbstractBaseComponent {
/** Used to convert the dropdown menu button into a link. */
@Input() btnHref;
/** Used to define the drop down menu background. */
@HostBinding('style.--tl-dropdown-menu-background') @Input() menuBackground;
/** Used to define the drop down menu border. */
@HostBinding('style.--tl-dropdown-menu-border') @Input() menuBorder;
/** Used to define the drop-down menu border display */
@HostBinding('style.--tl-dropdown-menu-border-display') @Input() menuBorderDisplay;
/** Used to define the drop down menu-border-radius. */
@HostBinding('style.--tl-dropdown-menu-border-radius') @Input() menuBorderRadius;
/** Used to define the drop down menu box shadow. */
@HostBinding('style.--tl-dropdown-menu-box-shadow') @Input() menuBoxShadow;
/** Used to define the drop-down `menu-border-flexDirection` */
@HostBinding('style.--tl-dropdown-menu-flex-direction') @Input() menuFlexDirection;
/** Used to define the item margin in drop-down menu. */
@HostBinding('style.--tl-dropdown-menu-item-margin') @Input() menuItemMargin;
/** Used to define the drop-down menu padding */
@HostBinding('style.--tl-dropdown-menu-padding') @Input() menuPadding;
/** Used to define the drop-down menu width */
@HostBinding('style.--tl-dropdown-menu-width') @Input() menuWidth;
/** Used to define the drop-down menu x offset. */
@HostBinding('style.--tl-dropdown-menu-x-offset') @Input() menuXOffset;
/** Used to define the drop-down menu x offset. */
@HostBinding('style.--tl-dropdown-menu-y-offset') @Input() menuYOffset = '-6px';
/** Used to define the event type which will display the dropdown menu. */
@Input() toggleOn = 'click';
/** Used to define the boolean value for the drop down */
isOpen = false;
/** Used to override the button background in a drop down */
get btnBackground(): string {
return `var(--tl-btn-${this.themeVariant}-background)`;
}
/** Used to override the button background active state in a drop down */
get btnBackgroundActive(): string {
return `var(--tl-btn-${this.themeVariant}-active-background)`;
}
/** Used to override the button background hover state in a drop down */
get btnBackgroundHover(): string {
return `var(--tl-btn-${this.themeVariant}-hover-background)`;
}
/** Used to override the button border in a drop down */
get btnBorderColor(): string {
return `var(--tl-btn-${this.themeVariant}-border)`;
}
/** Used to override the button active state border in a drop down */
get btnBorderActive(): string {
return `var(--tl-btn-${this.themeVariant}-active-border)`;
}
/** Used to override the button focus state border in a drop down */
get btnBorderFocus(): string {
return `var(--tl-btn-${this.themeVariant}-focus-border)`;
}
/** Used to override the button active state border in a drop down */
get btnBorderHover(): string {
return `var(--tl-btn-${this.themeVariant}-hover-border)`;
}
/** Used to override the border radius of button in a dropdown */
@HostBinding('style.--tl-btn-border-radius') @Input() btnBorderRadius;
@HostBinding('style.--tl-btn-focus-box-shadow') @Input() btnBoxShadowFocus;
/** Used to override the button color in a drop down */
get btnColor(): string {
return `var(--tl-btn-${this.themeVariant}-color)`;
}
/** Used to override the button color active state in a drop down */
get btnColorActive(): string {
return `var(--tl-btn-${this.themeVariant}-active-color)`;
}
/** Used to override the button color hover state in a drop down */
get btnColorHover(): string {
return `var(--tl-btn-${this.themeVariant}-hover-color)`;
}
/** Used to override the button font family in a drop down */
@HostBinding('style.--tl-font-family-sans-serif') @Input() btnFontFamily;
/** Used to override the button font size in a drop down */
@HostBinding('style.--tl-btn-font-size') @Input() btnFontSize;
/** Used to override the line height of button in a drop down */
@HostBinding('style.--tl-btn-line-height') @Input() btnLineHeight;
/** Used to override the text alignment of button in a drop down */
@HostBinding('style.--tl-btn-text-align') @Input() btnTextAlign;
/** Used to override the text decoration property of button in a drop down */
get btnTextDecoration(): string {
return `var(--tl-btn-${this.themeVariant}-hover-color)`;
}
/** Used to override the active state of button text decoration property in a drop down */
get btnTextDecorationActive(): string {
return `var(--tl-btn-${this.themeVariant}-hover-color)`;
}
/** Used to override the focus state of button text decoration property in a drop down */
get btnTextDecorationFocus(): string {
return `var(--tl-btn-${this.themeVariant}-hover-color)`;
}
/** Used to override the hover state of button text decoration property in a drop down */
get btnTextDecorationHover(): string {
return `var(--tl-btn-${this.themeVariant}-hover-color)`;
}
// tslint:disable-next-line:unnecessary-constructor
constructor(injector: Injector) {
super(injector);
}
}
<wvr-dropdown-component
[btnHref]="btnHref"
[toggleOn]="toggleOn"
[themeVariant]="themeVariant"
[menuBackground]="'var(--tl-dropdown-menu-background)'"
[menuBorder]="'var(--tl-dropdown-menu-border)'"
[menuBorderRadius]="'var(--tl-dropdown-menu-border-radius)'"
[menuBorderDisplay]="'var(--tl-dropdown-menu-border-display)'"
[menuFlexDirection]="'var(--tl-dropdown-menu-flex-direction)'"
[menuPadding]="'var(--tl-dropdown-menu-padding)'"
[menuWidth]="'var(--tl-dropdown-menu-width)'"
[menuXOffset]="'var(--tl-dropdown-menu-x-offset)'"
[menuYOffset]="'var(--tl-dropdown-menu-y-offset)'"
[menuItemMargin]="'var(--tl-dropdown-menu-item-margin)'"
[backgroundActive]="btnBackgroundActive"
[btnBorderColor]="btnBorderColor"
[btnBorderActive]="btnBorderActive"
[btnBorderFocus]="btnBorderFocus"
[btnBorderRadius]="'var(--tl-btn-border-radius)'"
[btnBoxShadowFocus]="'var(--tl-btn-focus-box-shadow)'"
[btnColorActive]="btnColorActive"
[fontFamily]="'var(--tl-font-family-sans-serif)'"
[fontSize]="'var(--tl-btn-font-size)'"
[lineHeight]="'var(--tl-btn-line-height)'"
[textAlign]="'var(--tl-btn-text-align)'"
[textDecoration]="btnTextDecoration"
[textDecorationActive]="btnTextDecorationActive"
[textDecorationFocus]="btnTextDecorationFocus"
[dropdownMenuDisplay]="'static'"
ngbDropdownAnchor>
<ng-content select="template[dropdown-button]" ngProjectAs="template[dropdown-button]"></ng-content>
<ng-content select="template[dropdown-menu]" ngProjectAs="template[dropdown-menu]"></ng-content>
</wvr-dropdown-component>
./tl-dropdown.component.scss
@import "../shared/styles/tl-variables.scss";
:host {
// dropdown menu properties
--tl-dropdown-menu-width: fit-content;
--tl-dropdown-menu-height: fit-content;
--tl-dropdown-menu-background: var(--tl-white);
--tl-dropdown-menu-border: 1px solid rgb(204, 204, 204);
--tl-dropdown-menu-box-shadow: 0px 6px 12px 0px rgba(0, 0, 0, 0.17);
--tl-dropdown-menu-border-radius: 4px;
// drop down button properties
--tl-dropdown-button-width: 124px;
--tl-dropdown-button-height: 48px;
--tl-dropdown-button-border-radius: 4px;
// tl-dropdown properties
--tl-dropdown-menu-animation-speed: var(--wvr-dropdown-menu-animation-speed);
--tl-dropdown-menu-border-radius: 4px;
--tl-dropdown-menu-display: var(--wvr-dropdown-menu-display);
--tl-dropdown-menu-flex-direction: var(--wvr-dropdown-menu-flex-direction);
--tl-dropdown-menu-padding: var(--wvr-dropdown-menu-padding);
--tl-dropdown-menu-width: var(--wvr-dropdown-menu-width);
--tl-dropdown-menu-padding: var(--wvr-dropdown-menu-padding);
--tl-dropdown-menu-x-offset: var(--wvr-dropdown-menu-x-offset);
--tl-dropdown-menu-y-offset: var(--wvr-dropdown-menu-y-offset);
--tl-dropdown-menu-item-margin: var(--wvr-dropdown-menu-item-margin);
wvr-dropdown-component {
::ng-deep {
wvr-dropdown-menu, .dropdown-menu {
box-shadow: var(--tl-dropdown-menu-box-shadow);
width: var(--tl-dropdown-menu-width);
height: var(--tl-dropdown-menu-height);
background: var(--tl-dropdown-menu-background);
border: var(--tl-dropdown-menu-border);
}
.dropdown-menu > * {
box-shadow: none;
border: none;
}
.dropdown-menu wvr-dropdown-menu-item {
display: block;
padding: 10px;
}
.dropdown-menu wvr-dropdown-menu-item:hover {
background: var(--tl-grey);
}
}
}
}