src/ui-shell/header/header-action.component.ts
Contained by HeaderGlobal
. Generally used to trigger Panel
s
selector | cds-header-action, ibm-header-action |
template |
|
Methods |
Inputs |
Outputs |
active | |
Type : boolean
|
|
Default value : false
|
|
Toggles the active state. May be used to toggle a |
ariaLabel | |
Type : string
|
|
Sets the aria label on the nav element. |
description | |
Type : string | TemplateRef<any>
|
|
Tooltip content to show on mouseenter |
align | |
Type : "top" | "top-left" | "top-right" | "bottom" | "bottom-left" | "bottom-right" | "left" | "left-bottom" | "left-top" | "right" | "right-bottom" | "right-top"
|
|
Default value : "bottom"
|
|
Inherited from
BaseIconButton
|
|
Defined in
BaseIconButton:32
|
|
Set popover alignment |
autoAlign | |
Type : boolean
|
|
Default value : false
|
|
Inherited from
BaseIconButton
|
|
Defined in
BaseIconButton:40
|
|
Experimental: Use floating-ui to position the tooltip This is not toggleable - should be assigned once |
caret | |
Type : boolean
|
|
Default value : true
|
|
Inherited from
BaseIconButton
|
|
Defined in
BaseIconButton:16
|
|
Set to |
dropShadow | |
Type : boolean
|
|
Default value : true
|
|
Inherited from
BaseIconButton
|
|
Defined in
BaseIconButton:20
|
|
Set to |
enterDelayMs | |
Type : number
|
|
Default value : 100
|
|
Inherited from
BaseIconButton
|
|
Defined in
BaseIconButton:44
|
|
Set delay before tooltip is shown |
highContrast | |
Type : boolean
|
|
Default value : true
|
|
Inherited from
BaseIconButton
|
|
Defined in
BaseIconButton:24
|
|
Set to |
isOpen | |
Type : boolean
|
|
Default value : false
|
|
Inherited from
BaseIconButton
|
|
Defined in
BaseIconButton:28
|
|
Set to |
leaveDelayMs | |
Type : number
|
|
Default value : 300
|
|
Inherited from
BaseIconButton
|
|
Defined in
BaseIconButton:48
|
|
Set delay when tooltip disappears |
activeChange | |
Type : EventEmitter
|
|
"Change" emitter to allow double binding to the |
selected | |
Type : EventEmitter
|
|
Emits when the action has been clicked. |
onClick |
onClick()
|
Returns :
void
|
import {
Component,
Input,
Output,
EventEmitter,
TemplateRef
} from "@angular/core";
import { BaseIconButton } from "carbon-components-angular/button";
/**
* Contained by `HeaderGlobal`. Generally used to trigger `Panel`s
*/
@Component({
selector: "cds-header-action, ibm-header-action",
template: `
<cds-icon-button
[buttonNgClass]="{
'cds--header__action': true,
'cds--header__action--active': active
}"
(click)="onClick()"
[align]="align"
[caret]="caret"
[dropShadow]="dropShadow"
[highContrast]="highContrast"
[isOpen]="isOpen"
[enterDelayMs]="enterDelayMs"
[leaveDelayMs]="leaveDelayMs"
[description]="description"
[buttonAttributes]="{
'aria-label': ariaLabel
}">
<ng-content></ng-content>
</cds-icon-button>
`
})
export class HeaderAction extends BaseIconButton {
/**
* Tooltip content to show on mouseenter
*/
@Input() description: string | TemplateRef<any>;
/**
* Sets the aria label on the nav element.
*/
@Input() ariaLabel: string;
/**
* Toggles the active state. May be used to toggle a `Panel`s active state.
*/
@Input() active = false;
/**
* "Change" emitter to allow double binding to the `active` Input.
*/
@Output() activeChange = new EventEmitter<boolean>();
/**
* Emits when the action has been clicked.
*/
@Output() selected = new EventEmitter<boolean>();
onClick() {
this.active = !this.active;
this.selected.emit(this.active);
this.activeChange.emit(this.active);
}
}