Merge branch 'update-component-status-action-bar' into 'main'
Update action bar in status component See merge request soapbox-pub/soapbox!3271
This commit is contained in:
commit
fe7ffe48f7
|
@ -146,7 +146,6 @@ const messages = defineMessages({
|
||||||
|
|
||||||
interface IStatusActionBar {
|
interface IStatusActionBar {
|
||||||
status: Status;
|
status: Status;
|
||||||
withLabels?: boolean;
|
|
||||||
expandable?: boolean;
|
expandable?: boolean;
|
||||||
space?: 'sm' | 'md' | 'lg';
|
space?: 'sm' | 'md' | 'lg';
|
||||||
statusActionButtonTheme?: 'default' | 'inverse';
|
statusActionButtonTheme?: 'default' | 'inverse';
|
||||||
|
@ -155,7 +154,6 @@ interface IStatusActionBar {
|
||||||
|
|
||||||
const StatusActionBar: React.FC<IStatusActionBar> = ({
|
const StatusActionBar: React.FC<IStatusActionBar> = ({
|
||||||
status,
|
status,
|
||||||
withLabels = false,
|
|
||||||
expandable = true,
|
expandable = true,
|
||||||
space = 'sm',
|
space = 'sm',
|
||||||
statusActionButtonTheme = 'default',
|
statusActionButtonTheme = 'default',
|
||||||
|
@ -740,7 +738,6 @@ const StatusActionBar: React.FC<IStatusActionBar> = ({
|
||||||
active={status.reblogged}
|
active={status.reblogged}
|
||||||
onClick={handleReblogClick}
|
onClick={handleReblogClick}
|
||||||
count={reblogCount}
|
count={reblogCount}
|
||||||
text={withLabels ? intl.formatMessage(messages.reblog) : undefined}
|
|
||||||
theme={statusActionButtonTheme}
|
theme={statusActionButtonTheme}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
@ -780,7 +777,6 @@ const StatusActionBar: React.FC<IStatusActionBar> = ({
|
||||||
icon={messageCircleIcon}
|
icon={messageCircleIcon}
|
||||||
onClick={handleReplyClick}
|
onClick={handleReplyClick}
|
||||||
count={replyCount}
|
count={replyCount}
|
||||||
text={withLabels ? intl.formatMessage(messages.reply) : undefined}
|
|
||||||
disabled={replyDisabled}
|
disabled={replyDisabled}
|
||||||
theme={statusActionButtonTheme}
|
theme={statusActionButtonTheme}
|
||||||
/>
|
/>
|
||||||
|
@ -808,7 +804,6 @@ const StatusActionBar: React.FC<IStatusActionBar> = ({
|
||||||
active={Boolean(meEmojiName)}
|
active={Boolean(meEmojiName)}
|
||||||
count={emojiReactCount}
|
count={emojiReactCount}
|
||||||
emoji={meEmojiReact}
|
emoji={meEmojiReact}
|
||||||
text={withLabels ? meEmojiTitle : undefined}
|
|
||||||
theme={statusActionButtonTheme}
|
theme={statusActionButtonTheme}
|
||||||
/>
|
/>
|
||||||
</StatusReactionWrapper>
|
</StatusReactionWrapper>
|
||||||
|
@ -821,7 +816,6 @@ const StatusActionBar: React.FC<IStatusActionBar> = ({
|
||||||
onClick={handleFavouriteClick}
|
onClick={handleFavouriteClick}
|
||||||
active={Boolean(meEmojiName)}
|
active={Boolean(meEmojiName)}
|
||||||
count={favouriteCount}
|
count={favouriteCount}
|
||||||
text={withLabels ? meEmojiTitle : undefined}
|
|
||||||
theme={statusActionButtonTheme}
|
theme={statusActionButtonTheme}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
@ -835,7 +829,6 @@ const StatusActionBar: React.FC<IStatusActionBar> = ({
|
||||||
onClick={handleDislikeClick}
|
onClick={handleDislikeClick}
|
||||||
active={status.disliked}
|
active={status.disliked}
|
||||||
count={status.dislikes_count}
|
count={status.dislikes_count}
|
||||||
text={withLabels ? intl.formatMessage(messages.disfavourite) : undefined}
|
|
||||||
theme={statusActionButtonTheme}
|
theme={statusActionButtonTheme}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
@ -848,7 +841,6 @@ const StatusActionBar: React.FC<IStatusActionBar> = ({
|
||||||
filled
|
filled
|
||||||
onClick={handleZapClick}
|
onClick={handleZapClick}
|
||||||
active={status.zapped}
|
active={status.zapped}
|
||||||
text={withLabels ? intl.formatMessage(messages.zap) : undefined}
|
|
||||||
theme={statusActionButtonTheme}
|
theme={statusActionButtonTheme}
|
||||||
count={status?.zaps_amount ? status.zaps_amount / 1000 : 0}
|
count={status?.zaps_amount ? status.zaps_amount / 1000 : 0}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -36,12 +36,11 @@ interface IStatusActionButton extends React.ButtonHTMLAttributes<HTMLButtonEleme
|
||||||
color?: Color;
|
color?: Color;
|
||||||
filled?: boolean;
|
filled?: boolean;
|
||||||
emoji?: EmojiReaction;
|
emoji?: EmojiReaction;
|
||||||
text?: React.ReactNode;
|
|
||||||
theme?: 'default' | 'inverse';
|
theme?: 'default' | 'inverse';
|
||||||
}
|
}
|
||||||
|
|
||||||
const StatusActionButton = forwardRef<HTMLButtonElement, IStatusActionButton>((props, ref): JSX.Element => {
|
const StatusActionButton = forwardRef<HTMLButtonElement, IStatusActionButton>((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 = () => {
|
const renderIcon = () => {
|
||||||
if (emoji) {
|
if (emoji) {
|
||||||
|
@ -70,13 +69,7 @@ const StatusActionButton = forwardRef<HTMLButtonElement, IStatusActionButton>((p
|
||||||
};
|
};
|
||||||
|
|
||||||
const renderText = () => {
|
const renderText = () => {
|
||||||
if (text) {
|
if (count) {
|
||||||
return (
|
|
||||||
<Text tag='span' theme='inherit' size='sm'>
|
|
||||||
{text}
|
|
||||||
</Text>
|
|
||||||
);
|
|
||||||
} else if (count) {
|
|
||||||
return (
|
return (
|
||||||
<StatusActionCounter count={count} />
|
<StatusActionCounter count={count} />
|
||||||
);
|
);
|
||||||
|
@ -88,7 +81,7 @@ const StatusActionButton = forwardRef<HTMLButtonElement, IStatusActionButton>((p
|
||||||
ref={ref}
|
ref={ref}
|
||||||
type='button'
|
type='button'
|
||||||
className={clsx(
|
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',
|
'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',
|
'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<HTMLButtonElement, IStatusActionButton>((p
|
||||||
'hover:text-gray-600 dark:hover:text-white': !filteredProps.disabled,
|
'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-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,
|
'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,
|
className,
|
||||||
)}
|
)}
|
||||||
|
|
Loading…
Reference in New Issue