From ac42186eaf29ec86c68695e6cda33475defeeb50 Mon Sep 17 00:00:00 2001 From: diondiondion Date: Fri, 18 Sep 2026 09:06:58 +0000 Subject: [PATCH] Redesign: Update account menu trigger in main navigation (#40573) --- .../mastodon/components/list_item/index.tsx | 117 ++++++++++-------- .../components/list_item/styles.module.scss | 7 +- .../account_card_and_menu.module.scss | 42 ++++--- .../redesign/account_card_and_menu.tsx | 63 ++++++---- 4 files changed, 128 insertions(+), 101 deletions(-) diff --git a/app/javascript/mastodon/components/list_item/index.tsx b/app/javascript/mastodon/components/list_item/index.tsx index 377196542ea..74b0a54e788 100644 --- a/app/javascript/mastodon/components/list_item/index.tsx +++ b/app/javascript/mastodon/components/list_item/index.tsx @@ -1,7 +1,7 @@ import classNames from 'classnames'; import { Link } from 'react-router-dom'; -import { polymorphicForwardRef } from '@/types/polymorphic'; +import type { PolymorphicProps } from '@/types/polymorphic'; import classes from './styles.module.scss'; @@ -43,66 +43,73 @@ interface ContentProps { subtitleId?: string; } -export const ListItemContent = polymorphicForwardRef<'h3', ContentProps>( - ( - { as: Component = 'h3', subtitle, subtitleId, children, ...otherProps }, - ref, - ) => { - return ( - <> - - {children} - - {subtitle && ( -
- {subtitle} -
- )} - - ); - }, -); +export const ListItemContent = ({ + as, + subtitle, + subtitleId, + children, + ...otherProps +}: PolymorphicProps) => { + const Component = as ?? 'h3'; + return ( + <> + + {children} + + {subtitle && ( +
+ {subtitle} +
+ )} + + ); +}; interface LinkProps extends React.ComponentPropsWithoutRef, ContentProps {} -export const ListItemLink = polymorphicForwardRef<'h3', LinkProps>( - ({ as, subtitle, subtitleId, children, className, ...otherProps }, ref) => { - return ( - - - {children} - - - ); - }, -); +export const ListItemLink = ({ + as, + subtitle, + subtitleId, + children, + className, + ...otherProps +}: PolymorphicProps) => { + return ( + + + {children} + + + ); +}; interface ButtonProps extends React.ComponentPropsWithoutRef<'button'>, ContentProps {} -export const ListItemButton = polymorphicForwardRef<'h3', ButtonProps>( - ({ as, subtitle, subtitleId, children, className, ...otherProps }, ref) => { - return ( - ({ + as, + subtitle, + subtitleId, + children, + className, + ...otherProps +}: PolymorphicProps) => { + const Comp = as ?? 'h3'; + return ( + + - - ); - }, -); + {children} + + + ); +}; diff --git a/app/javascript/mastodon/components/list_item/styles.module.scss b/app/javascript/mastodon/components/list_item/styles.module.scss index 26840e6738d..dc1c893e4a5 100644 --- a/app/javascript/mastodon/components/list_item/styles.module.scss +++ b/app/javascript/mastodon/components/list_item/styles.module.scss @@ -1,3 +1,5 @@ +@use '@/styles/mastodon/mixins'; + .wrapper { --list-item-padding: 16px; --list-item-padding-block: var(--list-item-padding); @@ -20,7 +22,7 @@ } .title { - font-weight: 500; + @include mixins.type-label; :any-link, button { @@ -44,7 +46,8 @@ } .subtitle { - font-size: 13px; + @include mixins.type-caption; + color: var(--color-text-secondary); } diff --git a/app/javascript/mastodon/features/navigation_panel/redesign/account_card_and_menu.module.scss b/app/javascript/mastodon/features/navigation_panel/redesign/account_card_and_menu.module.scss index 7094e9a9862..c25ed861b19 100644 --- a/app/javascript/mastodon/features/navigation_panel/redesign/account_card_and_menu.module.scss +++ b/app/javascript/mastodon/features/navigation_panel/redesign/account_card_and_menu.module.scss @@ -1,31 +1,39 @@ .root { - display: flex; - align-items: center; - padding: var(--space-2); + --list-item-padding: var(--space-2); + --list-item-gap: var(--space-2); + border: 1px solid var(--color-border-primary); border-radius: var(--radius-3); + transition: background-color 200ms; - & > :global(.account) { - flex-grow: 1; - overflow: hidden; - - --account-outer-spacing: 0; - --avatar-border-radius: var(--radius-round); - --account-name-color: var(--color-text-primary); - --account-name-size: var(--fs-14); - --account-handle-color: var(--color-text-secondary); - --account-handle-size: var(--fs-12); + &:hover { + background-color: var(--color-bg-highlight); } - & :global(.display-name) { - // Allow display name to wrap instead of truncating with ellipsis - white-space: normal; + &:has(button:focus-visible) { + outline: var(--outline-focus-default); + background-color: var(--color-bg-highlight); } + + // Disable default styles for LockupButton component + & button { + &:hover { + text-decoration: none; + } + + &:focus-visible { + outline: none; + } + } +} + +.dotsIcon { + padding: var(--space-2); } .profileMenuItem { --list-item-padding: 0; - --list-item-gap: 8px; + --list-item-gap: var(--space-2); color: inherit; } diff --git a/app/javascript/mastodon/features/navigation_panel/redesign/account_card_and_menu.tsx b/app/javascript/mastodon/features/navigation_panel/redesign/account_card_and_menu.tsx index dcbbb58d51a..401d18d59b1 100644 --- a/app/javascript/mastodon/features/navigation_panel/redesign/account_card_and_menu.tsx +++ b/app/javascript/mastodon/features/navigation_panel/redesign/account_card_and_menu.tsx @@ -17,12 +17,11 @@ import { } from '@phosphor-icons/react'; import { openModal } from '@/mastodon/actions/modal'; -import { Account } from '@/mastodon/components/account'; import { Avatar } from '@/mastodon/components/avatar'; -import { IconButton } from '@/mastodon/components/button/redesign'; import { DisplayName } from '@/mastodon/components/display_name'; import { useAccountHandle } from '@/mastodon/components/display_name/default'; import { + ListItemButton, ListItemContent, ListItemWrapper, } from '@/mastodon/components/list_item'; @@ -52,31 +51,41 @@ export const NavigationAccountCardAndMenu: React.FC = () => { } return ( -
- - - - - - - - - -
+ + + + + + + + + ); +}; + +const AccountMenuTrigger: React.FC> = ( + props, +) => { + const { accountId } = useIdentity(); + const account = useAccount(accountId); + const handle = useAccountHandle(account); + + return ( + } + sideContent={} + className={classes.root} + > + + + + ); };