From 12eb83b5646e04044857f9cc28841ada96a12411 Mon Sep 17 00:00:00 2001 From: Echo Date: Thu, 10 Sep 2026 17:40:25 +0000 Subject: [PATCH] Composer redesign: Swap pepper to flag icon (#40456) --- app/javascript/mastodon/components/icon.tsx | 28 ++++++++++++++++++- .../mastodon/components/status/action_bar.tsx | 26 ++++------------- .../features/compose/redesign/index.tsx | 8 ++++-- 3 files changed, 38 insertions(+), 24 deletions(-) diff --git a/app/javascript/mastodon/components/icon.tsx b/app/javascript/mastodon/components/icon.tsx index 0a801e7af7d..8bc34749306 100644 --- a/app/javascript/mastodon/components/icon.tsx +++ b/app/javascript/mastodon/components/icon.tsx @@ -1,6 +1,8 @@ +import { useCallback } from 'react'; + import classNames from 'classnames'; -import type { IconWeight } from '@phosphor-icons/react'; +import type { IconWeight, Icon as PhosphorIcon } from '@phosphor-icons/react'; import CheckBoxOutlineBlankIcon from '@/material-icons/400-24px/check_box_outline_blank.svg?react'; import { isProduction } from 'mastodon/utils/environment'; @@ -61,3 +63,27 @@ export const Icon: React.FC = ({ /> ); }; + +type MaybeWeight = IconWeight | false | null; + +export const iconWeight = ( + Icon: PhosphorIcon, + weight?: MaybeWeight, +): React.FC => { + const IconWeight = (props: SVGPropsWithTitle) => ( + + ); + return IconWeight; +}; + +export function useIconWeight( + Icon: PhosphorIcon, + weight?: MaybeWeight, +): React.FC { + return useCallback( + (props: SVGPropsWithTitle) => ( + + ), + [Icon, weight], + ); +} diff --git a/app/javascript/mastodon/components/status/action_bar.tsx b/app/javascript/mastodon/components/status/action_bar.tsx index 74de8ee5ba8..afebb037400 100644 --- a/app/javascript/mastodon/components/status/action_bar.tsx +++ b/app/javascript/mastodon/components/status/action_bar.tsx @@ -60,6 +60,7 @@ import { ToggleButton, ToggleIconButton, } from '../button/redesign'; +import { iconWeight, useIconWeight } from '../icon'; import { Menu, MenuItem, @@ -191,23 +192,10 @@ export const StatusActionBar: React.FC = ({ const intl = useIntl(); - const favouriteIcon = useCallback( - (props: React.SVGProps) => - status?.favourited ? ( - - ) : ( - - ), - [status?.favourited], - ); - const bookmarkIcon = useCallback( - (props: React.SVGProps) => - status?.bookmarked ? ( - - ) : ( - - ), - [status?.bookmarked], + const favouriteIcon = useIconWeight(HeartIcon, status?.favourited && 'fill'); + const bookmarkIcon = useIconWeight( + BookmarkSimpleIcon, + status?.bookmarked && 'fill', ); if (!status) { @@ -368,9 +356,7 @@ const StatusReblogButton: React.FC<{ ); }; -const QuotesFilledIcon = (props: React.SVGProps) => ( - -); +const QuotesFilledIcon = iconWeight(QuotesIcon, 'fill'); const StatusActionMenu: React.FC<{ dismissQuoteHint: () => void; diff --git a/app/javascript/mastodon/features/compose/redesign/index.tsx b/app/javascript/mastodon/features/compose/redesign/index.tsx index f153f1721b2..139f5944441 100644 --- a/app/javascript/mastodon/features/compose/redesign/index.tsx +++ b/app/javascript/mastodon/features/compose/redesign/index.tsx @@ -5,7 +5,7 @@ import { defineMessages, FormattedMessage, useIntl } from 'react-intl'; import classNames from 'classnames'; -import { LockSimpleOpenIcon, PepperIcon } from '@phosphor-icons/react'; +import { FlagIcon, LockSimpleOpenIcon } from '@phosphor-icons/react'; import { changeComposeSpoilerness, @@ -14,7 +14,7 @@ import { } from '@/mastodon/actions/compose'; import { ToggleButton } from '@/mastodon/components/button/redesign'; import { TextInputField } from '@/mastodon/components/form_fields/redesign'; -import { Icon } from '@/mastodon/components/icon'; +import { Icon, useIconWeight } from '@/mastodon/components/icon'; import { getComposerTextarea, requestComposerFocus, @@ -64,6 +64,8 @@ export const RedesignComposeForm: React.FC< const intl = useIntl(); const titleId = useId(); + const sensitiveIcon = useIconWeight(FlagIcon, sensitive && 'fill'); + return (