From 96d40ae5c0cfd3391d88ee739a80ad1bbbad70bc Mon Sep 17 00:00:00 2001 From: Mick Letofsky Date: Thu, 16 Oct 2025 10:08:13 +0200 Subject: [PATCH] [PM-21807] Migrate fido components to tailwind (#16645) * Update CSS class & refactor to use control flow instead of *ngIf directives * Migrate to Tailwind classes for styling on the use-browser-link component * Refactor if directive - use control flow instead * Refactor to leverage Tailwind CSS --- .../fido2/fido2-cipher-row.component.html | 16 +- .../fido2-use-browser-link.component.html | 64 ++-- .../fido2/fido2-use-browser-link.component.ts | 51 +--- .../autofill/popup/fido2/fido2.component.html | 276 +++++++++--------- 4 files changed, 168 insertions(+), 239 deletions(-) diff --git a/apps/browser/src/autofill/popup/fido2/fido2-cipher-row.component.html b/apps/browser/src/autofill/popup/fido2/fido2-cipher-row.component.html index 46a03acaedb..165416f63a5 100644 --- a/apps/browser/src/autofill/popup/fido2/fido2-cipher-row.component.html +++ b/apps/browser/src/autofill/popup/fido2/fido2-cipher-row.component.html @@ -9,15 +9,17 @@ {{ cipher.name }} - + @if (cipher.organizationId) { + + } -
{{ getSubName(cipher) }}
-
{{ cipher.subTitle }}
+ @if (getSubName(cipher)) { +
{{ getSubName(cipher) }}
+ } + @if (cipher.subTitle) { +
{{ cipher.subTitle }}
+ }
diff --git a/apps/browser/src/autofill/popup/fido2/fido2-use-browser-link.component.html b/apps/browser/src/autofill/popup/fido2/fido2-use-browser-link.component.html index 45c0612af44..0d0d2bb017d 100644 --- a/apps/browser/src/autofill/popup/fido2/fido2-use-browser-link.component.html +++ b/apps/browser/src/autofill/popup/fido2/fido2-use-browser-link.component.html @@ -1,52 +1,24 @@ - - - -
- -
-
- -
-
+ @if (showOverlay) { +
+ } +} diff --git a/apps/browser/src/autofill/popup/fido2/fido2-use-browser-link.component.ts b/apps/browser/src/autofill/popup/fido2/fido2-use-browser-link.component.ts index 27fe88130de..b8b49f993e3 100644 --- a/apps/browser/src/autofill/popup/fido2/fido2-use-browser-link.component.ts +++ b/apps/browser/src/autofill/popup/fido2/fido2-use-browser-link.component.ts @@ -1,8 +1,5 @@ // FIXME: Update this file to be type safe and remove this and next line // @ts-strict-ignore -import { animate, state, style, transition, trigger } from "@angular/animations"; -import { A11yModule } from "@angular/cdk/a11y"; -import { ConnectedPosition, CdkOverlayOrigin, CdkConnectedOverlay } from "@angular/cdk/overlay"; import { CommonModule } from "@angular/common"; import { Component } from "@angular/core"; import { firstValueFrom } from "rxjs"; @@ -13,6 +10,7 @@ import { NeverDomains } from "@bitwarden/common/models/domain/domain-service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service"; import { Utils } from "@bitwarden/common/platform/misc/utils"; +import { MenuModule } from "@bitwarden/components"; import { fido2PopoutSessionData$ } from "../../../vault/popup/utils/fido2-popout-session-data"; import { BrowserFido2UserInterfaceSession } from "../../fido2/services/browser-fido2-user-interface.service"; @@ -20,63 +18,24 @@ import { BrowserFido2UserInterfaceSession } from "../../fido2/services/browser-f @Component({ selector: "app-fido2-use-browser-link", templateUrl: "fido2-use-browser-link.component.html", - imports: [A11yModule, CdkConnectedOverlay, CdkOverlayOrigin, CommonModule, JslibModule], - animations: [ - trigger("transformPanel", [ - state( - "void", - style({ - opacity: 0, - }), - ), - transition( - "void => open", - animate( - "100ms linear", - style({ - opacity: 1, - }), - ), - ), - transition("* => void", animate("100ms linear", style({ opacity: 0 }))), - ]), - ], + imports: [CommonModule, JslibModule, MenuModule], }) export class Fido2UseBrowserLinkComponent { showOverlay = false; - isOpen = false; - overlayPosition: ConnectedPosition[] = [ - { - originX: "start", - originY: "bottom", - overlayX: "start", - overlayY: "top", - offsetY: 5, - }, - ]; protected fido2PopoutSessionData$ = fido2PopoutSessionData$(); constructor( - private domainSettingsService: DomainSettingsService, - private platformUtilsService: PlatformUtilsService, - private i18nService: I18nService, + private readonly domainSettingsService: DomainSettingsService, + private readonly platformUtilsService: PlatformUtilsService, + private readonly i18nService: I18nService, ) {} - toggle() { - this.isOpen = !this.isOpen; - } - - close() { - this.isOpen = false; - } - /** * Aborts the current FIDO2 session and fallsback to the browser. * @param excludeDomain - Identifies if the domain should be excluded from future FIDO2 prompts. */ protected async abort(excludeDomain = true) { - this.close(); const sessionData = await firstValueFrom(this.fido2PopoutSessionData$); if (!excludeDomain) { diff --git a/apps/browser/src/autofill/popup/fido2/fido2.component.html b/apps/browser/src/autofill/popup/fido2/fido2.component.html index 8d8394641e9..ed851af234e 100644 --- a/apps/browser/src/autofill/popup/fido2/fido2.component.html +++ b/apps/browser/src/autofill/popup/fido2/fido2.component.html @@ -1,144 +1,140 @@ - - - - + @if (showNewPasskeyButton) { + + } + -
- - - +
+ @if (passkeyAction === PasskeyActions.Register) { + + + + } - - - - - -

{{ "chooseCipherForPasskeySave" | i18n }}

-
- -
+ @switch (data.message.type) { + @case (BrowserFido2MessageTypes.ConfirmNewCredentialRequest) { + + @if (displayedCiphers.length > 0) { + +

{{ "chooseCipherForPasskeySave" | i18n }}

+
+ @for (cipherItem of displayedCiphers; track cipherItem.id) { + + } + } + @if (!displayedCiphers.length) { + + {{ + (hasSearched ? "noItemsMatchSearch" : "noMatchingLoginsForSite") | i18n + }} + {{ + (hasSearched ? "searchSavePasskeyNewLogin" : "clearFiltersOrTryAnother") | i18n + }} - - - - {{ - (hasSearched ? "noItemsMatchSearch" : "noMatchingLoginsForSite") | i18n - }} - {{ - (hasSearched ? "searchSavePasskeyNewLogin" : "clearFiltersOrTryAnother") | i18n - }} - - - - -
- - - -
-

{{ "passkeyAlreadyExists" | i18n }}

-
-
- -
-
-
-
- - - - - - {{ "chooseCipherForPasskeyAuth" | i18n }} - - - - - - - {{ - (hasSearched ? "noItemsMatchSearch" : "noMatchingLoginsForSite") | i18n - }} - {{ - (hasSearched ? "searchSavePasskeyNewLogin" : "clearFiltersOrTryAnother") | i18n - }} - - - - - - - - -
-

{{ "noPasskeysFoundForThisApplication" | i18n }}

-
- -
- - -
- + + + } + + } + @case (BrowserFido2MessageTypes.InformExcludedCredentialRequest) { + +
+

{{ "passkeyAlreadyExists" | i18n }}

+
+ @for (cipherItem of displayedCiphers; track cipherItem.id) { + + } +
+
+
+ } + @case (BrowserFido2MessageTypes.PickCredentialRequest) { + + @if (displayedCiphers.length > 0) { + {{ "chooseCipherForPasskeyAuth" | i18n }} + @for (cipherItem of displayedCiphers; track cipherItem.id) { + + } + } @else { + + {{ + (hasSearched ? "noItemsMatchSearch" : "noMatchingLoginsForSite") | i18n + }} + {{ + (hasSearched ? "searchSavePasskeyNewLogin" : "clearFiltersOrTryAnother") | i18n + }} + + + } + + } + @case (BrowserFido2MessageTypes.InformCredentialNotFoundRequest) { + +
+

{{ "noPasskeysFoundForThisApplication" | i18n }}

+
+ +
+ } + } + +
+
+}