From 8c43232558ab9e278fc8bd98bc75c00c54211ee5 Mon Sep 17 00:00:00 2001 From: Jonathan Prusik Date: Wed, 7 May 2025 09:47:04 -0400 Subject: [PATCH] [PM-21211] Update Lit component stories (#14657) * replace string with message catalog representation * add I18n type * update components * update and add stories and mock data * mock chrome.i18n.getMessage for lit stories that require it * set a max-width for the header component story * move i18n to bottom of story controls --- .../components/buttons/action-button.ts | 14 +- .../components/buttons/badge-button.ts | 14 +- .../components/buttons/close-button.ts | 9 +- .../content/components/buttons/edit-button.ts | 11 +- .../components/cipher/cipher-action.ts | 15 +- .../content/components/cipher/cipher-icon.ts | 19 +- .../cipher/cipher-indicator-icons.ts | 10 +- .../content/components/cipher/cipher-info.ts | 4 +- .../content/components/cipher/cipher-item.ts | 17 +- .../content/components/common-types.ts | 4 + .../buttons/action-button.lit-stories.ts | 17 +- .../buttons/badge-button.lit-stories.ts | 17 +- .../buttons/close-button.lit-stories.ts | 14 +- .../buttons/edit-button.lit-stories.ts | 20 +-- .../option-selection-button.lit-stories.ts | 38 ++++ .../ciphers/cipher-action.lit-stories.ts | 22 +-- .../ciphers/cipher-icon.lit-stories.ts | 17 +- .../cipher-indicator-icons.lit-stories.ts | 25 ++- .../ciphers/cipher-info.lit-stories.ts | 23 +++ .../ciphers/cipher-item.lit-stories.ts | 32 ++++ .../lit-stories/icons/icons.lit-stories.ts | 12 +- .../illustrations.lit-stories.ts | 8 +- .../components/lit-stories/mock-data.ts | 167 +++++++++++++++--- .../notification/body.lit-stories.ts | 49 ++--- .../confirmation/body.lit-stories.ts | 4 + .../confirmation/container.lit-stories.ts | 33 ++-- .../confirmation/footer.lit-stories.ts | 7 +- .../confirmation/message.lit-stories.ts | 2 + .../notification/container.lit-stories.ts | 19 +- .../notification/footer.lit-stories.ts | 17 +- .../notification/header.lit-stories.ts | 19 +- .../option-selection.lit-stories.ts | 4 +- .../rows/action-row.lit-stories.ts | 16 +- .../lit-stories/rows/item-row.lit-stories.ts | 16 +- .../content/components/notification/body.ts | 18 +- .../components/notification/button-row.ts | 6 +- .../notification/confirmation/body.ts | 6 +- .../notification/confirmation/container.ts | 16 +- .../notification/confirmation/footer.ts | 3 +- .../notification/confirmation/message.ts | 6 +- .../components/notification/container.ts | 6 +- .../content/components/notification/footer.ts | 4 +- .../content/components/notification/header.ts | 14 +- .../option-selection/option-item.ts | 12 +- .../option-selection/option-items.ts | 16 +- .../content/components/rows/action-row.ts | 10 +- .../content/components/rows/item-row.ts | 9 +- apps/browser/src/autofill/notification/bar.ts | 6 +- 48 files changed, 484 insertions(+), 363 deletions(-) create mode 100644 apps/browser/src/autofill/content/components/lit-stories/buttons/option-selection-button.lit-stories.ts create mode 100644 apps/browser/src/autofill/content/components/lit-stories/ciphers/cipher-info.lit-stories.ts create mode 100644 apps/browser/src/autofill/content/components/lit-stories/ciphers/cipher-item.lit-stories.ts diff --git a/apps/browser/src/autofill/content/components/buttons/action-button.ts b/apps/browser/src/autofill/content/components/buttons/action-button.ts index 881b44b4785..41d92a0449d 100644 --- a/apps/browser/src/autofill/content/components/buttons/action-button.ts +++ b/apps/browser/src/autofill/content/components/buttons/action-button.ts @@ -5,17 +5,19 @@ import { Theme } from "@bitwarden/common/platform/enums"; import { border, themes, typography, spacing } from "../constants/styles"; +export type ActionButtonProps = { + buttonText: string | TemplateResult; + disabled?: boolean; + theme: Theme; + handleClick: (e: Event) => void; +}; + export function ActionButton({ buttonText, disabled = false, theme, handleClick, -}: { - buttonText: string | TemplateResult; - disabled?: boolean; - theme: Theme; - handleClick: (e: Event) => void; -}) { +}: ActionButtonProps) { const handleButtonClick = (event: Event) => { if (!disabled) { handleClick(event); diff --git a/apps/browser/src/autofill/content/components/buttons/badge-button.ts b/apps/browser/src/autofill/content/components/buttons/badge-button.ts index 3b3b84f8166..9852c07d47b 100644 --- a/apps/browser/src/autofill/content/components/buttons/badge-button.ts +++ b/apps/browser/src/autofill/content/components/buttons/badge-button.ts @@ -5,17 +5,19 @@ import { Theme } from "@bitwarden/common/platform/enums"; import { border, themes, typography, spacing } from "../constants/styles"; +export type BadgeButtonProps = { + buttonAction: (e: Event) => void; + buttonText: string; + disabled?: boolean; + theme: Theme; +}; + export function BadgeButton({ buttonAction, buttonText, disabled = false, theme, -}: { - buttonAction: (e: Event) => void; - buttonText: string; - disabled?: boolean; - theme: Theme; -}) { +}: BadgeButtonProps) { const handleButtonClick = (event: Event) => { if (!disabled) { buttonAction(event); diff --git a/apps/browser/src/autofill/content/components/buttons/close-button.ts b/apps/browser/src/autofill/content/components/buttons/close-button.ts index 05a12d4f453..71743c3992a 100644 --- a/apps/browser/src/autofill/content/components/buttons/close-button.ts +++ b/apps/browser/src/autofill/content/components/buttons/close-button.ts @@ -6,13 +6,12 @@ import { Theme } from "@bitwarden/common/platform/enums"; import { spacing, themes } from "../constants/styles"; import { Close as CloseIcon } from "../icons"; -export function CloseButton({ - handleCloseNotification, - theme, -}: { +export type CloseButtonProps = { handleCloseNotification: (e: Event) => void; theme: Theme; -}) { +}; + +export function CloseButton({ handleCloseNotification, theme }: CloseButtonProps) { return html`