From f67af96f74dbc9202661ab0fb40c31402224e30d Mon Sep 17 00:00:00 2001 From: danidfra Date: Tue, 19 Nov 2024 18:33:20 -0300 Subject: [PATCH] Refactor: remove "withLabels" and "text" props to simplify component --- src/components/status-action-bar.tsx | 8 -------- src/components/status-action-button.tsx | 15 +++------------ 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/src/components/status-action-bar.tsx b/src/components/status-action-bar.tsx index 3878cd43d..c86b4783b 100644 --- a/src/components/status-action-bar.tsx +++ b/src/components/status-action-bar.tsx @@ -146,7 +146,6 @@ const messages = defineMessages({ interface IStatusActionBar { status: Status; - withLabels?: boolean; expandable?: boolean; space?: 'sm' | 'md' | 'lg'; statusActionButtonTheme?: 'default' | 'inverse'; @@ -155,7 +154,6 @@ interface IStatusActionBar { const StatusActionBar: React.FC = ({ status, - withLabels = false, expandable = true, space = 'sm', statusActionButtonTheme = 'default', @@ -740,7 +738,6 @@ const StatusActionBar: React.FC = ({ active={status.reblogged} onClick={handleReblogClick} count={reblogCount} - text={withLabels ? intl.formatMessage(messages.reblog) : undefined} theme={statusActionButtonTheme} /> ); @@ -780,7 +777,6 @@ const StatusActionBar: React.FC = ({ icon={messageCircleIcon} onClick={handleReplyClick} count={replyCount} - text={withLabels ? intl.formatMessage(messages.reply) : undefined} disabled={replyDisabled} theme={statusActionButtonTheme} /> @@ -808,7 +804,6 @@ const StatusActionBar: React.FC = ({ active={Boolean(meEmojiName)} count={emojiReactCount} emoji={meEmojiReact} - text={withLabels ? meEmojiTitle : undefined} theme={statusActionButtonTheme} /> @@ -821,7 +816,6 @@ const StatusActionBar: React.FC = ({ onClick={handleFavouriteClick} active={Boolean(meEmojiName)} count={favouriteCount} - text={withLabels ? meEmojiTitle : undefined} theme={statusActionButtonTheme} /> )} @@ -835,7 +829,6 @@ const StatusActionBar: React.FC = ({ onClick={handleDislikeClick} active={status.disliked} count={status.dislikes_count} - text={withLabels ? intl.formatMessage(messages.disfavourite) : undefined} theme={statusActionButtonTheme} /> )} @@ -848,7 +841,6 @@ const StatusActionBar: React.FC = ({ filled onClick={handleZapClick} active={status.zapped} - text={withLabels ? intl.formatMessage(messages.zap) : undefined} theme={statusActionButtonTheme} count={status?.zaps_amount ? status.zaps_amount / 1000 : 0} /> diff --git a/src/components/status-action-button.tsx b/src/components/status-action-button.tsx index 2819adaa3..314889e90 100644 --- a/src/components/status-action-button.tsx +++ b/src/components/status-action-button.tsx @@ -36,12 +36,11 @@ interface IStatusActionButton extends React.ButtonHTMLAttributes((props, ref): JSX.Element => { - const { icon, className, iconClassName, active, color, filled = false, count = 0, emoji, text, theme = 'default', ...filteredProps } = props; + const { icon, className, iconClassName, active, color, filled = false, count = 0, emoji, theme = 'default', ...filteredProps } = props; const renderIcon = () => { if (emoji) { @@ -70,13 +69,7 @@ const StatusActionButton = forwardRef((p }; const renderText = () => { - if (text) { - return ( - - {text} - - ); - } else if (count) { + if (count) { return ( ); @@ -88,7 +81,7 @@ const StatusActionButton = forwardRef((p ref={ref} type='button' className={clsx( - 'flex items-center rounded-full p-1 rtl:space-x-reverse', + 'flex items-center space-x-1 rounded-full p-1 rtl:space-x-reverse', 'focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-2 dark:ring-offset-0', { 'text-gray-600 hover:text-gray-600 dark:hover:text-white bg-white dark:bg-transparent': theme === 'default', @@ -97,8 +90,6 @@ const StatusActionButton = forwardRef((p 'hover:text-gray-600 dark:hover:text-white': !filteredProps.disabled, 'text-accent-300 hover:text-accent-300 dark:hover:text-accent-300': active && !emoji && color === COLORS.accent, 'text-success-600 hover:text-success-600 dark:hover:text-success-600': active && !emoji && color === COLORS.success, - 'space-x-1': !text, - 'space-x-2': text, }, className, )}