From 3f8eabb91fb7945e01b217cbd311f7b198d4db65 Mon Sep 17 00:00:00 2001 From: Bryan Cunningham Date: Mon, 31 Aug 2026 13:26:40 -0400 Subject: [PATCH] [CL-1236] Extension header changes (#22484) --- .storybook/preview.tsx | 11 +- .../current-account.component.html | 6 +- .../current-account.component.ts | 29 +- ...ult-password-manager-prompt.component.html | 8 +- ...-password-manager-prompt.component.spec.ts | 2 + ...fault-password-manager-prompt.component.ts | 14 + .../popup/components/pop-out.component.html | 1 + .../popup/components/pop-out.component.ts | 30 +- .../popup/layout/popup-footer.component.html | 2 +- .../popup/layout/popup-header.component.html | 123 +++-- .../layout/popup-header.component.spec.ts | 365 +++++++++++++++ .../popup/layout/popup-header.component.ts | 262 +++++++++-- .../platform/popup/layout/popup-layout.mdx | 137 +++++- .../popup/layout/popup-layout.stories.ts | 425 ++++++++++++++++-- .../popup/layout/popup-page.component.html | 24 +- .../popup/layout/popup-page.component.spec.ts | 95 ++++ .../popup/layout/popup-page.component.ts | 2 + ...tension-anon-layout-wrapper.component.html | 2 + .../extension-anon-layout-wrapper.stories.ts | 7 - .../vault-generator-dialog.component.spec.ts | 4 +- .../src/layout/scroll-layout.directive.ts | 6 +- libs/components/src/utils/index.ts | 1 + .../src/utils/scroll-direction.spec.ts | 176 ++++++++ libs/components/src/utils/scroll-direction.ts | 112 +++++ .../src/addons/feature-flags/constants.ts | 25 +- .../src/addons/feature-flags/panel.tsx | 40 +- 26 files changed, 1758 insertions(+), 151 deletions(-) create mode 100644 apps/browser/src/platform/popup/layout/popup-header.component.spec.ts create mode 100644 apps/browser/src/platform/popup/layout/popup-page.component.spec.ts create mode 100644 libs/components/src/utils/scroll-direction.spec.ts create mode 100644 libs/components/src/utils/scroll-direction.ts diff --git a/.storybook/preview.tsx b/.storybook/preview.tsx index 1a37f2659c1..decd781fe97 100644 --- a/.storybook/preview.tsx +++ b/.storybook/preview.tsx @@ -7,8 +7,8 @@ import type { Preview } from "@storybook/angular"; import { featureFlagDecorator, FEATURE_FLAG_CATALOG, - FEATURE_FLAGS_CATALOG_GLOBAL, FEATURE_FLAGS_GLOBAL, + FEATURE_FLAGS_PARAM, } from "@bitwarden/storybook"; import docJson from "../documentation.json"; @@ -66,13 +66,14 @@ const preview: Preview = { backgrounds: { disabled: true, }, + // Published here (the preview can read the enum) so the manager's Feature + // Flags panel can render the catalog without importing `@bitwarden/*`. + // A parameter rather than a global: parameters are never diffed or written + // to the URL, so this array survives the boundary intact. + [FEATURE_FLAGS_PARAM]: { catalog: FEATURE_FLAG_CATALOG }, }, initialGlobals: { [FEATURE_FLAGS_GLOBAL]: [], - // Seeded here (preview can read the enum) so the manager panel can read the - // catalog from globals without importing `@bitwarden/*`. Unchanged globals - // stay out of the URL, so this large value never bloats story links. - [FEATURE_FLAGS_CATALOG_GLOBAL]: FEATURE_FLAG_CATALOG, }, tags: ["autodocs"], }; diff --git a/apps/browser/src/auth/popup/account-switching/current-account.component.html b/apps/browser/src/auth/popup/account-switching/current-account.component.html index 8b3c9aabdda..5ab32b252d2 100644 --- a/apps/browser/src/auth/popup/account-switching/current-account.component.html +++ b/apps/browser/src/auth/popup/account-switching/current-account.component.html @@ -1,4 +1,4 @@ -
+
@@ -20,9 +22,11 @@ class="tw-rounded-full hover:tw-outline hover:tw-outline-1 hover:tw-outline-offset-1" > {{ "switchAccounts" | i18n }} + diff --git a/apps/browser/src/auth/popup/account-switching/current-account.component.ts b/apps/browser/src/auth/popup/account-switching/current-account.component.ts index 2dde3b5a266..98d58e8f17c 100644 --- a/apps/browser/src/auth/popup/account-switching/current-account.component.ts +++ b/apps/browser/src/auth/popup/account-switching/current-account.component.ts @@ -1,15 +1,18 @@ // FIXME: Update this file to be type safe and remove this and next line // @ts-strict-ignore import { CommonModule, Location } from "@angular/common"; -import { Component } from "@angular/core"; +import { Component, computed, inject } from "@angular/core"; +import { toSignal } from "@angular/core/rxjs-interop"; import { ActivatedRoute, Router, RouterModule } from "@angular/router"; -import { Observable, combineLatest, switchMap } from "rxjs"; +import { Observable, combineLatest, of, switchMap } from "rxjs"; import { JslibModule } from "@bitwarden/angular/jslib.module"; import { AccountService } from "@bitwarden/common/auth/abstractions/account.service"; import { AuthService } from "@bitwarden/common/auth/abstractions/auth.service"; import { AvatarService } from "@bitwarden/common/auth/abstractions/avatar.service"; import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status"; +import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum"; +import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service"; import { UserId } from "@bitwarden/common/types/guid"; import { AvatarModule } from "@bitwarden/components"; @@ -31,6 +34,28 @@ export type CurrentAccount = { export class CurrentAccountComponent { currentAccount$: Observable; + /** + * TODO: remove with the VFO1Foundation flag. + * + * Optional so that reading the flag doesn't force a `ConfigService` stub into every spec that + * renders a page header. Always present in the running extension. + */ + private readonly configService = inject(ConfigService, { optional: true }); + + /** TODO: remove with the VFO1Foundation flag. */ + protected readonly vfo1Enabled = toSignal( + this.configService?.getFeatureFlag$(FeatureFlag.VFO1Foundation) ?? of(false), + { initialValue: false }, + ); + + /** + * TODO: remove with the VFO1Foundation flag, along with the `[class]` binding it feeds. + * + * The legacy header under-pads its trailing edge for icon buttons; the avatar isn't one, so it + * offsets itself. The app bar pads and centers the row itself. + */ + protected readonly wrapperClasses = computed(() => (this.vfo1Enabled() ? "" : "tw-me-2 tw-mt-1")); + constructor( private accountService: AccountService, private avatarService: AvatarService, diff --git a/apps/browser/src/autofill/popup/default-password-manager/default-password-manager-prompt.component.html b/apps/browser/src/autofill/popup/default-password-manager/default-password-manager-prompt.component.html index 2088ccb665f..726598461ca 100644 --- a/apps/browser/src/autofill/popup/default-password-manager/default-password-manager-prompt.component.html +++ b/apps/browser/src/autofill/popup/default-password-manager/default-password-manager-prompt.component.html @@ -5,11 +5,17 @@ > +
diff --git a/apps/browser/src/autofill/popup/default-password-manager/default-password-manager-prompt.component.spec.ts b/apps/browser/src/autofill/popup/default-password-manager/default-password-manager-prompt.component.spec.ts index d98289ba48d..3ac3f5ed7fd 100644 --- a/apps/browser/src/autofill/popup/default-password-manager/default-password-manager-prompt.component.spec.ts +++ b/apps/browser/src/autofill/popup/default-password-manager/default-password-manager-prompt.component.spec.ts @@ -5,6 +5,7 @@ import { mock, MockProxy } from "jest-mock-extended"; import { of } from "rxjs"; import { AbstractThemingService } from "@bitwarden/angular/platform/services/theming/theming.service.abstraction"; +import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service"; import { ThemeTypes } from "@bitwarden/common/platform/enums"; import { DialogService } from "@bitwarden/components"; @@ -100,6 +101,7 @@ describe("DefaultPasswordManagerPromptComponent", () => { provide: AbstractThemingService, useValue: { theme$: of(ThemeTypes.Light) }, }, + { provide: ConfigService, useValue: { getFeatureFlag$: () => of(false) } }, ], }) .overrideComponent(DefaultPasswordManagerPromptComponent, { diff --git a/apps/browser/src/autofill/popup/default-password-manager/default-password-manager-prompt.component.ts b/apps/browser/src/autofill/popup/default-password-manager/default-password-manager-prompt.component.ts index cb0bfb83940..b51160d1239 100644 --- a/apps/browser/src/autofill/popup/default-password-manager/default-password-manager-prompt.component.ts +++ b/apps/browser/src/autofill/popup/default-password-manager/default-password-manager-prompt.component.ts @@ -13,6 +13,8 @@ import { firstValueFrom, map } from "rxjs"; import { AbstractThemingService } from "@bitwarden/angular/platform/services/theming/theming.service.abstraction"; import { BitwardenLogo } from "@bitwarden/assets/svg"; import { BrowserClientVendors } from "@bitwarden/common/autofill/constants"; +import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum"; +import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service"; import { ThemeTypes } from "@bitwarden/common/platform/enums"; import { BaseCardComponent, @@ -69,6 +71,7 @@ export class DefaultPasswordManagerPromptComponent implements OnInit { ); private readonly introCarouselService = inject(IntroCarouselService); private readonly autofillBrowserSettingsService = inject(AutofillBrowserSettingsService); + private readonly configService = inject(ConfigService); private readonly privacyPermissionIsGranted = signal(false); @@ -77,6 +80,17 @@ export class DefaultPasswordManagerPromptComponent implements OnInit { { initialValue: false }, ); + /** + * TODO: remove with the VFO1Foundation flag, along with the header class override it gates. + * + * The two-bar header paints and pads its own bars, so the `[&_header]:` overrides that reach into + * the one-bar header have nothing to correct there. + */ + protected readonly vfo1Enabled = toSignal( + this.configService.getFeatureFlag$(FeatureFlag.VFO1Foundation), + { initialValue: false }, + ); + protected readonly logo = BitwardenLogo; protected readonly backgroundIllustration = computed(() => this.isDarkTheme() ? DefaultPasswordBackgroundDark : DefaultPasswordBackgroundLight, diff --git a/apps/browser/src/platform/popup/components/pop-out.component.html b/apps/browser/src/platform/popup/components/pop-out.component.html index b66f636b635..a8b68692d05 100644 --- a/apps/browser/src/platform/popup/components/pop-out.component.html +++ b/apps/browser/src/platform/popup/components/pop-out.component.html @@ -3,6 +3,7 @@ bitIconButton="bwi-popout" size="small" type="button" + [buttonType]="buttonType()" label="{{ 'popOutNewWindow' | i18n }}" [title]="'popOutNewWindow' | i18n" (click)="expand()" diff --git a/apps/browser/src/platform/popup/components/pop-out.component.ts b/apps/browser/src/platform/popup/components/pop-out.component.ts index fd2acbd8aa7..477b5c852e0 100644 --- a/apps/browser/src/platform/popup/components/pop-out.component.ts +++ b/apps/browser/src/platform/popup/components/pop-out.component.ts @@ -1,9 +1,13 @@ import { CommonModule } from "@angular/common"; -import { Component, Input, OnInit } from "@angular/core"; +import { Component, Input, OnInit, computed, inject } from "@angular/core"; +import { toSignal } from "@angular/core/rxjs-interop"; +import { of } from "rxjs"; import { JslibModule } from "@bitwarden/angular/jslib.module"; +import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum"; +import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service"; import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service"; -import { IconButtonModule } from "@bitwarden/components"; +import { ButtonType, IconButtonModule } from "@bitwarden/components"; import BrowserPopupUtils from "../../browser/browser-popup-utils"; @@ -19,6 +23,28 @@ export class PopOutComponent implements OnInit { // eslint-disable-next-line @angular-eslint/prefer-signals @Input() show = true; + /** + * TODO: remove with the VFO1Foundation flag. + * + * Optional so that reading the flag doesn't force a `ConfigService` stub into every spec that + * renders a page header. Always present in the running extension. + */ + private readonly configService = inject(ConfigService, { optional: true }); + + /** TODO: remove with the VFO1Foundation flag. */ + private readonly vfo1Enabled = toSignal( + this.configService?.getFeatureFlag$(FeatureFlag.VFO1Foundation) ?? of(false), + { initialValue: false }, + ); + + /** + * Every usage projects into the header's `end` slot, which the flag moves onto the dark app bar. + * Only `side-nav` is legible against that background. + */ + protected readonly buttonType = computed(() => + this.vfo1Enabled() ? "side-nav" : "primaryGhost", + ); + constructor(private platformUtilsService: PlatformUtilsService) {} async ngOnInit() { diff --git a/apps/browser/src/platform/popup/layout/popup-footer.component.html b/apps/browser/src/platform/popup/layout/popup-footer.component.html index 50ad535c891..1f9955edef2 100644 --- a/apps/browser/src/platform/popup/layout/popup-footer.component.html +++ b/apps/browser/src/platform/popup/layout/popup-footer.component.html @@ -1,5 +1,5 @@