From 873c30dc8ada7a891dc23aa3da4b9d45311bdd67 Mon Sep 17 00:00:00 2001 From: OpenStaxClaude Date: Mon, 31 Aug 2026 13:09:37 +0000 Subject: [PATCH 1/4] CORE-2006: Migrate ProfileMenu and HelpMenu to plain CSS Replaces the styled-components definitions in ProfileMenu/index.tsx and HelpMenu/index.tsx with plain CSS files, following the hybrid approach used by the other components in this migration: theme values stay in JavaScript and are bound to CSS custom properties on the element, with the palette hex as a fallback in the CSS. No test changes: the snapshot flake this branch originally worked around is gone from main, CORE-2715 (#138) and CORE-2716 (#139) having replaced both component snapshots with targeted assertions. Those specs pass against the migrated components unchanged. Co-Authored-By: Claude Opus 5 (1M context) --- src/components/HelpMenu/HelpMenu.css | 70 ++++++++++++ src/components/HelpMenu/index.tsx | 119 +++++++++------------ src/components/ProfileMenu/ProfileMenu.css | 44 ++++++++ src/components/ProfileMenu/index.tsx | 90 +++++++++------- 4 files changed, 220 insertions(+), 103 deletions(-) create mode 100644 src/components/HelpMenu/HelpMenu.css create mode 100644 src/components/ProfileMenu/ProfileMenu.css diff --git a/src/components/HelpMenu/HelpMenu.css b/src/components/HelpMenu/HelpMenu.css new file mode 100644 index 000000000..2af02f2b1 --- /dev/null +++ b/src/components/HelpMenu/HelpMenu.css @@ -0,0 +1,70 @@ +/* HelpMenu trigger button */ +.help-menu-button { + color: var(--help-menu-button-color, #5e5e5e); + font-size: 1.4rem; +} + +/* HelpMenu menu item */ +.help-menu-item { + color: var(--help-menu-item-color, #424242); + text-decoration: none; +} + +/* The compound selector keeps the override of .navbar-menu-item:focus-visible + independent of stylesheet order */ +.navbar-menu-item.help-menu-item:focus-visible { + outline: 0; + background: var(--help-menu-item-focus-bg, #f1f1f1); +} + +.help-menu-item:hover { + color: var(--help-menu-item-color, #424242); + text-decoration: none; +} + +/* Contact form iframe, portaled to the body */ +.help-menu-iframe-wrapper { + background-color: var(--help-menu-iframe-wrapper-bg, #f5f5f5); + position: absolute; + width: 100%; + top: 4rem; + left: 0; + bottom: 0; + z-index: 20; +} + +.help-menu-iframe { + border: 0; + width: 100%; + height: calc(100% - 5rem); +} + +/* Bar with the "Back" button that puts the contact form away */ +.help-menu-put-away { + border-top: 0.1rem solid var(--help-menu-put-away-border-color, #d5d5d5); + width: 100%; + height: 5.6rem; + display: flex; + align-items: center; + background-color: var(--help-menu-put-away-bg, #f5f5f5); + padding-left: 1.5rem; + position: fixed; + bottom: 0; + left: 0; + z-index: 20; +} + +@media (min-width: 56em) { + .help-menu-put-away { + padding: 0 calc(50vw - 43rem); + } +} + +.help-menu-put-away button { + height: 3rem; + background-color: var(--help-menu-put-away-button-bg, #ffffff); + border: 1px solid var(--help-menu-put-away-button-border-color, #d5d5d5); + box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.2); + width: 9rem; + border-radius: 0.5rem; +} diff --git a/src/components/HelpMenu/index.tsx b/src/components/HelpMenu/index.tsx index c4ad9c382..15a07e166 100644 --- a/src/components/HelpMenu/index.tsx +++ b/src/components/HelpMenu/index.tsx @@ -1,48 +1,62 @@ import React from 'react'; -import { NavBarMenuButton, NavBarMenuItem } from '../NavBarMenuButtons'; +import classNames from 'classnames'; +import { NavBarBaseButtonProps, NavBarMenuButton, NavBarMenuItem } from '../NavBarMenuButtons'; import { colors } from '../../theme'; -import styled from 'styled-components'; import { BodyPortal } from '../BodyPortal'; +import { CSSPropertiesWithVariables } from '../../types'; import { ChatConfiguration, getPreChatFields, useChatController, useHoursRange } from './hooks'; +import './HelpMenu.css'; -export const HelpMenuButton = styled(NavBarMenuButton)` - color: ${colors.palette.gray}; - font-size: 1.4rem; -`; +export const HelpMenuButton = ({ className, style, ...props }: NavBarBaseButtonProps) => { + const buttonStyle: CSSPropertiesWithVariables = { + '--help-menu-button-color': colors.palette.gray, + ...style + }; -export const HelpMenuItem = styled(NavBarMenuItem)` - color: ${colors.palette.neutralDarker}; - text-decoration: none; + return ( + + ); +}; - :focus-visible { - outline: 0; - background: ${colors.palette.neutralLighter}; - } - :hover { - color: ${colors.palette.neutralDarker}; - text-decoration: none; - } -`; - -const IframeWrapper = styled(BodyPortal)` - background-color: ${colors.palette.neutralBright}; - position: absolute; - width: 100%; - top: 4rem; - left: 0; - bottom: 0; - z-index: 20; -`; - -const Iframe = styled.iframe` - border: 0; - width: 100%; - height: calc(100% - 5rem); -`; +export const HelpMenuItem = React.forwardRef< + HTMLDivElement, + React.ComponentProps +>(({ className, style, ...props }, ref) => { + const menuItemStyle: CSSPropertiesWithVariables = { + '--help-menu-item-color': colors.palette.neutralDarker, + '--help-menu-item-focus-bg': colors.palette.neutralLighter, + ...style + }; + + return ( + + ); +}); +HelpMenuItem.displayName = 'HelpMenuItem'; + +const iframeWrapperStyle: CSSPropertiesWithVariables = { + '--help-menu-iframe-wrapper-bg': colors.palette.neutralBright, +}; + +const putAwayStyle: CSSPropertiesWithVariables = { + '--help-menu-put-away-border-color': colors.palette.pale, + '--help-menu-put-away-bg': colors.palette.neutralBright, + '--help-menu-put-away-button-bg': colors.palette.white, + '--help-menu-put-away-button-border-color': colors.palette.pale, +}; function PutAway({onClick, className}: {onClick: () => void; className?: string}) { return ( -
+
@@ -50,33 +64,6 @@ function PutAway({onClick, className}: {onClick: () => void; className?: string} ); } -const StyledPutAway = styled(PutAway)` - border-top: 0.1rem solid ${colors.palette.pale}; - width: 100%; - height: 5.6rem; - display: flex; - align-items: center; - background-color: ${colors.palette.neutralBright}; - padding-left: 1.5rem; - position: fixed; - bottom: 0; - left: 0; - z-index: 20; - - @media(min-width: 56em) { - padding: 0 calc(50vw - 43rem); - } - - button { - height: 3rem; - background-color: ${colors.palette.white}; - border: 1px solid ${colors.palette.pale}; - box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.2); - width: 9rem; - border-radius: 0.5rem; - } -`; - /** * SVG icon representing a "new tab" indicator * Used to visually indicate when a link or action will open in a new tab/window @@ -162,10 +149,10 @@ export const HelpMenu: React.FC = ({ contactFormParams, chatConfi {showIframe && ( - -