Skip to content

Commit d1a4ee7

Browse files
authored
feat: allow title text to be overridden using input prop (#2833)
Signed-off-by: Akshat Patel <akshat@live.ca>
1 parent 7eb80c7 commit d1a4ee7

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/ui-shell/header/hamburger.component.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,8 @@ import { I18n } from "carbon-components-angular/i18n";
1717
(click)="doClick()"
1818
[ngClass]="{'cds--header__action--active': active}"
1919
class="cds--header__menu-trigger cds--header__action cds--header__menu-toggle"
20-
[attr.aria-label]="active
21-
? (i18n.get('UI_SHELL.HEADER.CLOSE_MENU') | async)
22-
: (i18n.get('UI_SHELL.HEADER.OPEN_MENU') | async)"
23-
[attr.title]="active
24-
? (i18n.get('UI_SHELL.HEADER.CLOSE_MENU') | async)
25-
: (i18n.get('UI_SHELL.HEADER.OPEN_MENU') | async)">
20+
[attr.aria-label]="active ? activeTitle : inactiveTitle"
21+
[attr.title]="active ? activeTitle : inactiveTitle">
2622
<svg *ngIf="!active" cdsIcon="menu" size="20"></svg>
2723
<svg *ngIf="active" cdsIcon="close" size="20"></svg>
2824
</button>
@@ -34,12 +30,22 @@ export class Hamburger {
3430
*/
3531
@Input() active = false;
3632

33+
/**
34+
* Set the title text when the hamburger is active
35+
*/
36+
@Input() activeTitle = this.i18n.get().UI_SHELL.HEADER.CLOSE_MENU;
37+
38+
/**
39+
* Set the title text when the hamburger is inactive
40+
*/
41+
@Input() inactiveTitle = this.i18n.get().UI_SHELL.HEADER.OPEN_MENU;
42+
3743
/**
3844
* `EventEmitter` to notify parent components of menu click events.
3945
*/
4046
@Output() selected: EventEmitter<Object> = new EventEmitter<Object>();
4147

42-
constructor(public i18n: I18n) { }
48+
constructor(public i18n: I18n) {}
4349

4450
/**
4551
* Emit the Hamburger click event upwards.

0 commit comments

Comments
 (0)