From 37ffeb269fc7b09baed9d4cae70c6e1e718248d4 Mon Sep 17 00:00:00 2001 From: Miles Blackwood Date: Mon, 12 May 2025 19:18:31 -0400 Subject: [PATCH] [WIP] Minimize impact of sharing CSS. --- .../notification/confirmation/body.ts | 1 - .../notification/confirmation/container.ts | 9 ++- .../notification/confirmation/footer.ts | 32 ++++++++- .../notification/confirmation/message.ts | 66 +++++++++++-------- 4 files changed, 76 insertions(+), 32 deletions(-) diff --git a/apps/browser/src/autofill/content/components/notification/confirmation/body.ts b/apps/browser/src/autofill/content/components/notification/confirmation/body.ts index f3dc1117209..c23eb36583d 100644 --- a/apps/browser/src/autofill/content/components/notification/confirmation/body.ts +++ b/apps/browser/src/autofill/content/components/notification/confirmation/body.ts @@ -59,7 +59,6 @@ export function NotificationConfirmationBody({ `; } -// Allow sharing of styles between notifications (@TODO isolate structural/presentational component layer) export const iconContainerStyles = (error?: string | boolean) => css` > svg { width: ${!error ? "50px" : "40px"}; diff --git a/apps/browser/src/autofill/content/components/notification/confirmation/container.ts b/apps/browser/src/autofill/content/components/notification/confirmation/container.ts index b824d88a994..61b8ad9cd1e 100644 --- a/apps/browser/src/autofill/content/components/notification/confirmation/container.ts +++ b/apps/browser/src/autofill/content/components/notification/confirmation/container.ts @@ -113,9 +113,14 @@ function getConfirmationMessage(i18n: I18n, type?: NotificationType, error?: str if (error) { return i18n.saveFailureDetails; } + + /* @TODO This partial string return and later concatenation with the cipher name is needed + * to handle cipher name overflow cases, but is risky for i18n concerns. Fix concatenation + * with cipher name overflow when a tag replacement solution is available. + */ return type === NotificationTypes.Add - ? i18n.loginSaveConfirmation - : i18n.loginUpdatedConfirmation; + ? i18n.notificationLoginSaveConfirmation + : i18n.notificationLoginUpdatedConfirmation; } function getHeaderMessage(i18n: I18n, type?: NotificationType, error?: string) { diff --git a/apps/browser/src/autofill/content/components/notification/confirmation/footer.ts b/apps/browser/src/autofill/content/components/notification/confirmation/footer.ts index fe65c61a63d..bd2e9480d56 100644 --- a/apps/browser/src/autofill/content/components/notification/confirmation/footer.ts +++ b/apps/browser/src/autofill/content/components/notification/confirmation/footer.ts @@ -4,9 +4,9 @@ import { html } from "lit"; import { Theme } from "@bitwarden/common/platform/enums"; import { ActionButton } from "../../buttons/action-button"; -import { AdditionalTasksButtonContent } from "../../buttons/additional-tasks/button-content"; import { I18n } from "../../common-types"; -import { notificationFooterStyles } from "../footer"; +import { spacing, themes } from "../../constants/styles"; +import { ExternalLink } from "../../icons"; export type NotificationConfirmationFooterProps = { i18n: I18n; @@ -22,7 +22,7 @@ export function NotificationConfirmationFooter({ const primaryButtonText = i18n.nextSecurityTaskAction; return html` -
+
${ActionButton({ handleClick: handleButtonClick, buttonText: AdditionalTasksButtonContent({ buttonText: primaryButtonText, theme }), @@ -35,3 +35,29 @@ export function NotificationConfirmationFooter({ const maxWidthMinContent = css` max-width: min-content; `; + +const notificationConfirmationFooterStyles = ({ theme }: { theme: Theme }) => css` + background-color: ${themes[theme].background.alt}; + padding: 0 ${spacing[3]} ${spacing[3]} ${spacing[3]}; + + :last-child { + border-radius: 0 0 ${spacing["4"]} ${spacing["4"]}; + padding-bottom: ${spacing[4]}; + } +`; + +function AdditionalTasksButtonContent({ buttonText, theme }: { buttonText: string; theme: Theme }) { + return html` +
+ ${buttonText} + ${ExternalLink({ theme, color: themes[theme].text.contrast })} +
+ `; +} + +const additionalTasksButtonContentStyles = ({ theme }: { theme: Theme }) => css` + gap: ${spacing[2]}; + display: flex; + align-items: center; + white-space: nowrap; +`; diff --git a/apps/browser/src/autofill/content/components/notification/confirmation/message.ts b/apps/browser/src/autofill/content/components/notification/confirmation/message.ts index 4e42aa3efea..6dc0a1e0f7c 100644 --- a/apps/browser/src/autofill/content/components/notification/confirmation/message.ts +++ b/apps/browser/src/autofill/content/components/notification/confirmation/message.ts @@ -28,28 +28,31 @@ export function NotificationConfirmationMessage({
${message || buttonText ? html` - ${itemName} - - ${message || nothing} - ${buttonText - ? html` - handleButtonKeyDown(e, () => handleClick(e))} - aria-label=${buttonAria} - tabindex="0" - role="button" - > - ${buttonText} - - ` - : nothing} - +
+ ${itemName} + + ${message || nothing} + ${buttonText + ? html` + + handleButtonKeyDown(e, () => handleClick(e))} + aria-label=${buttonAria} + tabindex="0" + role="button" + > + ${buttonText} + + ` + : nothing} + +
` : nothing} ${messageDetails @@ -61,14 +64,18 @@ export function NotificationConfirmationMessage({ const containerStyles = css` display: flex; - flex-wrap: wrap; - align-items: center; + flex-direction: column; gap: ${spacing[1]}; width: 100%; `; -export const baseTextStyles = css` - flex-grow: 1; +const singleLineWrapperStyles = css` + display: inline; + white-space: normal; + word-break: break-word; +`; + +const baseTextStyles = css` overflow-x: hidden; text-align: left; text-overflow: ellipsis; @@ -82,6 +89,9 @@ export const notificationConfirmationMessageStyles = (theme: Theme) => css` color: ${themes[theme].text.main}; font-weight: 400; + white-space: normal; + word-break: break-word; + display: inline; `; const itemNameStyles = (theme: Theme) => css` @@ -91,6 +101,10 @@ const itemNameStyles = (theme: Theme) => css` font-weight: 400; white-space: nowrap; max-width: 300px; + overflow: hidden; + text-overflow: ellipsis; + display: inline-block; + vertical-align: bottom; `; export const notificationConfirmationButtonTextStyles = (theme: Theme) => css`