1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-12 14:23:32 +00:00

[CL-319] custom back action in popup header component (#9829)

* expose FunctionReturningAwaitable from CL lib

* expose backAction as input on popup header component
This commit is contained in:
Will Martin
2024-06-25 15:55:49 -04:00
committed by GitHub
parent 00801f95ce
commit 8df054cf51
4 changed files with 21 additions and 8 deletions

View File

@@ -9,7 +9,7 @@
*ngIf="showBackButton" *ngIf="showBackButton"
[title]="'back' | i18n" [title]="'back' | i18n"
[ariaLabel]="'back' | i18n" [ariaLabel]="'back' | i18n"
(click)="back()" [bitAction]="backAction"
></button> ></button>
<h1 bitTypography="h3" class="!tw-mb-0.5 tw-text-headers">{{ pageTitle }}</h1> <h1 bitTypography="h3" class="!tw-mb-0.5 tw-text-headers">{{ pageTitle }}</h1>
</div> </div>

View File

@@ -3,13 +3,18 @@ import { CommonModule, Location } from "@angular/common";
import { Component, Input } from "@angular/core"; import { Component, Input } from "@angular/core";
import { JslibModule } from "@bitwarden/angular/jslib.module"; import { JslibModule } from "@bitwarden/angular/jslib.module";
import { IconButtonModule, TypographyModule } from "@bitwarden/components"; import {
AsyncActionsModule,
FunctionReturningAwaitable,
IconButtonModule,
TypographyModule,
} from "@bitwarden/components";
@Component({ @Component({
selector: "popup-header", selector: "popup-header",
templateUrl: "popup-header.component.html", templateUrl: "popup-header.component.html",
standalone: true, standalone: true,
imports: [TypographyModule, CommonModule, IconButtonModule, JslibModule], imports: [TypographyModule, CommonModule, IconButtonModule, JslibModule, AsyncActionsModule],
}) })
export class PopupHeaderComponent { export class PopupHeaderComponent {
/** Display the back button, which uses Location.back() to go back one page in history */ /** Display the back button, which uses Location.back() to go back one page in history */
@@ -26,9 +31,15 @@ export class PopupHeaderComponent {
/** Title string that will be inserted as an h1 */ /** Title string that will be inserted as an h1 */
@Input({ required: true }) pageTitle: string; @Input({ required: true }) pageTitle: string;
constructor(private location: Location) {} /**
* Async action that occurs when clicking the back button
back() { *
* If unset, will call `location.back()`
**/
@Input()
backAction: FunctionReturningAwaitable = async () => {
this.location.back(); this.location.back();
} };
constructor(private location: Location) {}
} }

View File

@@ -35,4 +35,4 @@ export * from "./tabs";
export * from "./toast"; export * from "./toast";
export * from "./toggle-group"; export * from "./toggle-group";
export * from "./typography"; export * from "./typography";
export * from "./utils/i18n-mock.service"; export * from "./utils";

View File

@@ -0,0 +1,2 @@
export * from "./function-to-observable";
export * from "./i18n-mock.service";