1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-10 13:40:06 +00:00

use template outlet in button

This commit is contained in:
Bryan Cunningham
2026-01-15 10:15:17 -05:00
parent 2371546fc4
commit 8e071d3ead
2 changed files with 23 additions and 11 deletions

View File

@@ -2,17 +2,29 @@
@let leadIcon = startIcon();
@let tailIcon = endIcon();
<ng-template #content>
<ng-content></ng-content>
</ng-template>
<span class="tw-relative">
<span [class.tw-invisible]="showLoadingStyles">
<span [class]="leadIcon || tailIcon ? 'tw-flex tw-items-center tw-gap-2' : ''">
@if (leadIcon) {
<i class="{{ startIconClasses() }}"></i>
}
<ng-content></ng-content>
@if (tailIcon) {
<i class="{{ endIconClasses() }}"></i>
}
</span>
@if (leadIcon || tailIcon) {
<div class="tw-flex tw-items-center tw-gap-2">
@if (leadIcon) {
<i class="{{ startIconClasses() }}"></i>
}
<div>
<ng-container *ngTemplateOutlet="content"></ng-container>
</div>
@if (tailIcon) {
<i class="{{ endIconClasses() }}"></i>
}
</div>
} @else {
<div>
<ng-container *ngTemplateOutlet="content"></ng-container>
</div>
}
</span>
@if (showLoadingStyles) {
<span class="tw-absolute tw-inset-0 tw-flex tw-items-center tw-justify-center">

View File

@@ -1,4 +1,4 @@
import { NgClass } from "@angular/common";
import { NgClass, NgTemplateOutlet } from "@angular/common";
import {
input,
HostBinding,
@@ -72,7 +72,7 @@ const buttonStyles: Record<ButtonType, string[]> = {
selector: "button[bitButton], a[bitButton]",
templateUrl: "button.component.html",
providers: [{ provide: ButtonLikeAbstraction, useExisting: ButtonComponent }],
imports: [NgClass, SpinnerComponent],
imports: [NgClass, NgTemplateOutlet, SpinnerComponent],
hostDirectives: [AriaDisableDirective],
})
export class ButtonComponent implements ButtonLikeAbstraction {