Update Profile Featured tab to latest designs (#38616)

This commit is contained in:
diondiondion authored and GitHub committed 2026-04-09 09:15:05 +00:00
1 parent 34514f00da
commit 05bed6f3d8
18 files changed
+168 -125

No files matched your search

@@ -49,8 +49,14 @@ export const EmptyMessage: React.FC<EmptyMessageProps> = ({
image={image}
title={
<FormattedMessage
id='empty_column.account_featured_self.no_collections'
defaultMessage='No collections yet'
id='empty_column.account_featured_self.showcase_accounts'
defaultMessage='Showcase your favorite accounts'
/>
}
message={
<FormattedMessage
id='empty_column.account_featured_self.showcase_accounts_desc'
defaultMessage='Collections are curated lists of accounts to help others discover more of the Fediverse.'
/>
}
>
@@ -72,7 +78,7 @@ export const EmptyMessage: React.FC<EmptyMessageProps> = ({
message = (
<FormattedMessage
id='empty_column.account_featured_self.pre_collections_desc'
defaultMessage='Collections (coming in Mastodon 4.6) allows you to create your own curated lists of accounts to recommend to others.'
defaultMessage='Collections (coming in Mastodon 4.6) allow you to create your own curated lists of accounts to recommend to others.'
/>
);
}
@@ -93,47 +99,21 @@ export const EmptyMessage: React.FC<EmptyMessageProps> = ({
/>
);
} else {
// Standard other account empty state.
title = (
<FormattedMessage
id='empty_column.account_featured_other.title'
defaultMessage='Nothing to see here'
/>
);
if (hasCollections) {
if (acct) {
message = (
<FormattedMessage
id='empty_column.account_featured_other.no_collections_desc'
defaultMessage='{acct} hasn’t created any collections yet.'
values={{ acct }}
/>
);
} else {
message = (
<FormattedMessage
id='empty_column.account_featured_unknown.no_collections_desc'
defaultMessage='This account hasn’t created any collections yet.'
/>
);
}
if (acct) {
title = (
<FormattedMessage
id='empty_column.account_featured.other'
defaultMessage='{acct} has not featured anything yet.'
values={{ acct }}
/>
);
} else {
if (acct) {
message = (
<FormattedMessage
id='empty_column.account_featured.other'
defaultMessage='{acct} hasn’t featured anything yet.'
values={{ acct }}
/>
);
} else {
message = (
<FormattedMessage
id='empty_column.account_featured_unknown.other'
defaultMessage='This account hasn’t featured anything yet.'
/>
);
}
title = (
<FormattedMessage
id='empty_column.account_featured_unknown.other'
defaultMessage='This account has not featured anything yet.'
/>
);
}
}
@@ -0,0 +1,37 @@
.subheading {
box-sizing: border-box;
display: flex;
align-items: center;
justify-content: space-between;
min-height: 52px;
padding: 12px 16px;
font-size: 13px;
font-weight: 500;
text-transform: uppercase;
color: var(--color-text-primary);
background: var(--color-bg-secondary);
}
.link {
display: flex;
padding-block: 4px;
font-size: 13px;
font-weight: 500;
text-transform: none;
text-decoration: none;
color: inherit;
&:hover {
text-decoration: underline;
}
&:focus-visible {
outline: var(--outline-focus-default);
outline-offset: 2px;
}
:global(.icon) {
width: 18px;
height: 18px;
}
}
@@ -0,0 +1,42 @@
import type { ComponentPropsWithoutRef } from 'react';
import classNames from 'classnames';
import { Link } from 'react-router-dom';
import type { IconProp } from '@/mastodon/components/icon';
import { Icon } from '@/mastodon/components/icon';
import { polymorphicForwardRef } from '@/types/polymorphic';
import classes from './subheading.module.scss';
export const Subheading = polymorphicForwardRef<'h2'>(
({ as: Component = 'h2', children, className, ...props }, ref) => {
return (
<Component
ref={ref}
className={classNames(classes.subheading, className)}
{...props}
>
{children}
</Component>
);
},
);
interface SubheadingLinkProps extends ComponentPropsWithoutRef<typeof Link> {
icon: IconProp;
}
export const SubheadingLink: React.FC<SubheadingLinkProps> = ({
icon,
children,
className,
...props
}) => {
return (
<Link className={classNames(classes.link, className)} {...props}>
<Icon id='subheading-icon' icon={icon} />
{children}
</Link>
);
};
@@ -6,9 +6,10 @@ import { useHistory } from 'react-router';
import { List as ImmutableList } from 'immutable';
import { AccountListItem } from '@/mastodon/components/account_list_item';
import { useAccount } from '@/mastodon/hooks/useAccount';
import AddIcon from '@/material-icons/400-24px/add.svg?react';
import { fetchEndorsedAccounts } from 'mastodon/actions/accounts';
import { Account } from 'mastodon/components/account';
import { ColumnBackButton } from 'mastodon/components/column_back_button';
import { LoadingIndicator } from 'mastodon/components/loading_indicator';
import { RemoteHint } from 'mastodon/components/remote_hint';
@@ -28,10 +29,11 @@ import {
} from 'mastodon/reducers/slices/collections';
import { useAppDispatch, useAppSelector } from 'mastodon/store';
import { CollectionListItem } from '../collections/detail/collection_list_item';
import { CollectionListItem } from '../collections/components/collection_list_item';
import { areCollectionsEnabled } from '../collections/utils';
import { EmptyMessage } from './components/empty_message';
import { Subheading, SubheadingLink } from './components/subheading';
const AccountFeatured: React.FC<{ multiColumn: boolean }> = ({
multiColumn,
@@ -114,14 +116,44 @@ const AccountFeatured: React.FC<{ multiColumn: boolean }> = ({
{accountId && (
<AccountHeader accountId={accountId} hideTabs={forceEmptyState} />
)}
{!featuredAccountIds.isEmpty() && (
<>
<Subheading as='h2'>
<FormattedMessage
id='account.featured.accounts'
defaultMessage='Profiles'
/>
</Subheading>
<ItemList>
{featuredAccountIds.map((featuredAccountId, index) => (
<Article
focusable
key={featuredAccountId}
aria-posinset={index + 1}
aria-setsize={featuredAccountIds.size}
>
<AccountListItem accountId={featuredAccountId} />
</Article>
))}
</ItemList>
</>
)}
{listedCollections.length > 0 && status === 'idle' && (
<>
<h4 className='column-subheading'>
<FormattedMessage
id='account.featured.collections'
defaultMessage='Collections'
/>
</h4>
<Subheading as='header'>
<h2>
<FormattedMessage
id='account.featured.collections'
defaultMessage='Collections'
/>
</h2>
<SubheadingLink to='/collections/new' icon={AddIcon}>
<FormattedMessage
id='account.featured.new_collection'
defaultMessage='New collection'
/>
</SubheadingLink>
</Subheading>
<ItemList>
{listedCollections.map((item, index) => (
<CollectionListItem
@@ -136,28 +168,6 @@ const AccountFeatured: React.FC<{ multiColumn: boolean }> = ({
</ItemList>
</>
)}
{!featuredAccountIds.isEmpty() && (
<>
<h4 className='column-subheading'>
<FormattedMessage
id='account.featured.accounts'
defaultMessage='Profiles'
/>
</h4>
<ItemList>
{featuredAccountIds.map((featuredAccountId, index) => (
<Article
focusable
key={featuredAccountId}
aria-posinset={index + 1}
aria-setsize={featuredAccountIds.size}
>
<Account id={featuredAccountId} />
</Article>
))}
</ItemList>
</>
)}
<RemoteHint accountId={accountId} />
</Scrollable>
</Column>