From 89a9e73c8a0486ae4d6a57484202f405f3bc2786 Mon Sep 17 00:00:00 2001 From: Nhan Nguyen Date: Thu, 25 Dec 2025 13:53:55 -0500 Subject: [PATCH] refactor(frontend): replace Temp components with design system components (#12158) --- .../features/user/user-context-menu.tsx | 66 ++++++-------- frontend/src/routes/manage-org.tsx | 85 ++++--------------- frontend/src/ui/credits-chip.tsx | 30 +++++++ frontend/src/ui/interactive-chip.tsx | 33 +++++++ 4 files changed, 105 insertions(+), 109 deletions(-) create mode 100644 frontend/src/ui/credits-chip.tsx create mode 100644 frontend/src/ui/interactive-chip.tsx diff --git a/frontend/src/components/features/user/user-context-menu.tsx b/frontend/src/components/features/user/user-context-menu.tsx index d62c8d4029..8b287dc68e 100644 --- a/frontend/src/components/features/user/user-context-menu.tsx +++ b/frontend/src/components/features/user/user-context-menu.tsx @@ -19,32 +19,14 @@ import { SettingsDropdownInput } from "../settings/settings-dropdown-input"; import { I18nKey } from "#/i18n/declaration"; import { useSettingsNavItems } from "#/hooks/use-settings-nav-items"; import DocumentIcon from "#/icons/document.svg?react"; +import { Divider } from "#/ui/divider"; +import { ContextMenuListItem } from "../context-menu/context-menu-list-item"; -interface TempButtonProps { - start: React.ReactNode; - onClick: () => void; -} - -function TempButton({ - start, - children, - onClick, -}: React.PropsWithChildren) { - return ( - - ); -} - -function TempDivider() { - return
; -} +// Shared className for context menu list items in the user context menu +// Removes default padding and hover background to match the simpler text-hover style +const contextMenuListItemClassName = cn( + "flex items-center p-0 h-auto hover:bg-transparent hover:text-white gap-1", +); interface UserContextMenuProps { type: OrganizationUserRole; @@ -140,31 +122,34 @@ export function UserContextMenu({ type, onClose }: UserContextMenuProps) { {!isUser && ( <> - } + className={contextMenuListItemClassName} > + {t(I18nKey.ORG$INVITE_ORGANIZATION_MEMBER)} - + - + - } + className={contextMenuListItemClassName} > + {t(I18nKey.ORG$MANAGE_ACCOUNT)} - - + } + className={contextMenuListItemClassName} > + {t(I18nKey.ORG$MANAGE_ORGANIZATION_MEMBERS)} - + )} - + {navItems.map((item) => ( ))} - + - } + className={contextMenuListItemClassName} > + {t(I18nKey.ACCOUNT_SETTINGS$LOGOUT)} - +
); diff --git a/frontend/src/routes/manage-org.tsx b/frontend/src/routes/manage-org.tsx index 42ad9a4daa..546d7f161c 100644 --- a/frontend/src/routes/manage-org.tsx +++ b/frontend/src/routes/manage-org.tsx @@ -21,66 +21,8 @@ import { I18nKey } from "#/i18n/declaration"; import { amountIsValid } from "#/utils/amount-is-valid"; import { useUpdateOrganization } from "#/hooks/mutation/use-update-organization"; import { useDeleteOrganization } from "#/hooks/mutation/use-delete-organization"; - -function TempChip({ - children, - ...props -}: React.PropsWithChildren<{ "data-testid": string }>) { - return ( -
- {children} -
- ); -} - -interface TempInteractiveChipProps { - onClick: () => void; -} - -function TempInteractiveChip({ - children, - onClick, -}: React.PropsWithChildren) { - return ( -
- {children} -
- ); -} - -function TempButton({ - children, - onClick, - type, - variant = "primary", -}: React.PropsWithChildren<{ - onClick?: () => void; - type: "button" | "submit"; - variant?: "primary" | "secondary"; -}>) { - return ( - - ); -} +import { CreditsChip } from "#/ui/credits-chip"; +import { InteractiveChip } from "#/ui/interactive-chip"; interface ChangeOrgNameModalProps { onClose: () => void; @@ -252,10 +194,17 @@ function AddCreditsModal({ onClose }: AddCreditsModalProps) {
- {t(I18nKey.ORG$NEXT)} - + + {t(I18nKey.ORG$NEXT)} + + {t(I18nKey.BUTTON$CANCEL)} - +
@@ -323,15 +272,13 @@ function ManageOrg() { {t(I18nKey.ORG$CREDITS)}
- + {organization?.credits} - + {canAddCredits && ( - setAddCreditsFormVisible(true)} - > + setAddCreditsFormVisible(true)}> {t(I18nKey.ORG$ADD)} - + )}
diff --git a/frontend/src/ui/credits-chip.tsx b/frontend/src/ui/credits-chip.tsx new file mode 100644 index 0000000000..a27b6513b3 --- /dev/null +++ b/frontend/src/ui/credits-chip.tsx @@ -0,0 +1,30 @@ +import { cn } from "#/utils/utils"; + +interface CreditsChipProps { + testId?: string; + className?: string; +} + +/** + * Chip component for displaying credits amount + * Uses yellow background with black text for visibility + */ +export function CreditsChip({ + children, + testId, + className, +}: React.PropsWithChildren) { + return ( +
+ {children} +
+ ); +} diff --git a/frontend/src/ui/interactive-chip.tsx b/frontend/src/ui/interactive-chip.tsx new file mode 100644 index 0000000000..224e98d7d8 --- /dev/null +++ b/frontend/src/ui/interactive-chip.tsx @@ -0,0 +1,33 @@ +import { cn } from "#/utils/utils"; + +interface InteractiveChipProps { + onClick: () => void; + testId?: string; + className?: string; +} + +/** + * Small clickable chip component for actions like "Add" + * Uses gray background with black text + */ +export function InteractiveChip({ + children, + onClick, + testId, + className, +}: React.PropsWithChildren) { + return ( + + ); +}