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:
@@ -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>
|
||||||
|
|||||||
@@ -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) {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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";
|
||||||
|
|||||||
2
libs/components/src/utils/index.ts
Normal file
2
libs/components/src/utils/index.ts
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
export * from "./function-to-observable";
|
||||||
|
export * from "./i18n-mock.service";
|
||||||
Reference in New Issue
Block a user