Make RSS button more visible
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
9a1f6a16ab
commit
0fea7460be
2 changed files with 29 additions and 3 deletions
|
@ -15,14 +15,18 @@ interface IIconButton extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
||||||
theme?: 'seamless' | 'outlined' | 'secondary' | 'transparent' | 'dark';
|
theme?: 'seamless' | 'outlined' | 'secondary' | 'transparent' | 'dark';
|
||||||
/** Override the data-testid */
|
/** Override the data-testid */
|
||||||
'data-testid'?: string;
|
'data-testid'?: string;
|
||||||
|
/** URL address */
|
||||||
|
href?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** A clickable icon. */
|
/** A clickable icon. */
|
||||||
const IconButton = React.forwardRef((props: IIconButton, ref: React.ForwardedRef<HTMLButtonElement>): JSX.Element => {
|
const IconButton = React.forwardRef((props: IIconButton, ref: React.ForwardedRef<HTMLButtonElement>): JSX.Element => {
|
||||||
const { src, className, iconClassName, text, theme = 'seamless', ...filteredProps } = props;
|
const { src, className, iconClassName, text, theme = 'seamless', ...filteredProps } = props;
|
||||||
|
|
||||||
|
const Component = (props.href ? 'a' : 'button') as 'button';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<button
|
<Component
|
||||||
ref={ref}
|
ref={ref}
|
||||||
type='button'
|
type='button'
|
||||||
className={clsx('flex items-center space-x-2 rounded-full p-1 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-2 dark:ring-offset-0', {
|
className={clsx('flex items-center space-x-2 rounded-full p-1 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-2 dark:ring-offset-0', {
|
||||||
|
@ -34,6 +38,7 @@ const IconButton = React.forwardRef((props: IIconButton, ref: React.ForwardedRef
|
||||||
}, className)}
|
}, className)}
|
||||||
{...filteredProps}
|
{...filteredProps}
|
||||||
data-testid={filteredProps['data-testid'] || 'icon-button'}
|
data-testid={filteredProps['data-testid'] || 'icon-button'}
|
||||||
|
{...(props.href ? { target: '_blank' } as any : {})}
|
||||||
>
|
>
|
||||||
<SvgIcon src={src} className={iconClassName} />
|
<SvgIcon src={src} className={iconClassName} />
|
||||||
|
|
||||||
|
@ -42,7 +47,7 @@ const IconButton = React.forwardRef((props: IIconButton, ref: React.ForwardedRef
|
||||||
{text}
|
{text}
|
||||||
</Text>
|
</Text>
|
||||||
) : null}
|
) : null}
|
||||||
</button>
|
</Component>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -284,7 +284,7 @@ const Header: React.FC<IHeader> = ({ account }) => {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (features.rssFeeds && account.local) {
|
if (!ownAccount && features.rssFeeds && account.local) {
|
||||||
menu.push({
|
menu.push({
|
||||||
text: intl.formatMessage(messages.subscribeFeed),
|
text: intl.formatMessage(messages.subscribeFeed),
|
||||||
icon: require('@tabler/icons/outline/rss.svg'),
|
icon: require('@tabler/icons/outline/rss.svg'),
|
||||||
|
@ -591,6 +591,25 @@ const Header: React.FC<IHeader> = ({ account }) => {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const renderRssButton = () => {
|
||||||
|
if (ownAccount || !features.rssFeeds || !account.local) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const href = software === MASTODON ? `${account.url}.rss` : `${account.url}/feed.rss`;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<IconButton
|
||||||
|
src={require('@tabler/icons/outline/rss.svg')}
|
||||||
|
href={href}
|
||||||
|
title={intl.formatMessage(messages.subscribeFeed)}
|
||||||
|
theme='outlined'
|
||||||
|
className='px-2'
|
||||||
|
iconClassName='h-4 w-4'
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const info = makeInfo();
|
const info = makeInfo();
|
||||||
const menu = makeMenu();
|
const menu = makeMenu();
|
||||||
|
|
||||||
|
@ -647,6 +666,8 @@ const Header: React.FC<IHeader> = ({ account }) => {
|
||||||
</DropdownMenu>
|
</DropdownMenu>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{renderRssButton()}
|
||||||
|
|
||||||
<ActionButton account={account} />
|
<ActionButton account={account} />
|
||||||
</HStack>
|
</HStack>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue