Refactor ComposeButton, FAB, and sidebar nav spacing

This commit is contained in:
Alex Gleason 2022-12-23 15:22:41 -06:00
parent 7a6126b978
commit ab7ec4babd
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
5 changed files with 31 additions and 15 deletions

View file

@ -1,6 +1,7 @@
import React from 'react'; import React from 'react';
import { defineMessages, FormattedMessage, useIntl } from 'react-intl'; import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
import { Stack } from 'soapbox/components/ui';
import DropdownMenu from 'soapbox/containers/dropdown-menu-container'; import DropdownMenu from 'soapbox/containers/dropdown-menu-container';
import { useStatContext } from 'soapbox/contexts/stat-context'; import { useStatContext } from 'soapbox/contexts/stat-context';
import ComposeButton from 'soapbox/features/ui/components/compose-button'; import ComposeButton from 'soapbox/features/ui/components/compose-button';
@ -109,8 +110,8 @@ const SidebarNavigation = () => {
}; };
return ( return (
<div> <Stack space={4}>
<div className='flex flex-col space-y-2'> <Stack space={2}>
<SidebarNavigationLink <SidebarNavigationLink
to='/' to='/'
icon={require('@tabler/icons/home.svg')} icon={require('@tabler/icons/home.svg')}
@ -183,12 +184,12 @@ const SidebarNavigation = () => {
/> />
</DropdownMenu> </DropdownMenu>
)} )}
</div> </Stack>
{account && ( {account && (
<ComposeButton /> <ComposeButton />
)} )}
</div> </Stack>
); );
}; };

View file

@ -49,6 +49,8 @@ const Button = React.forwardRef<HTMLButtonElement, IButton>((props, ref): JSX.El
className, className,
} = props; } = props;
const body = text || children;
const themeClass = useButtonStyles({ const themeClass = useButtonStyles({
theme, theme,
block, block,
@ -61,7 +63,7 @@ const Button = React.forwardRef<HTMLButtonElement, IButton>((props, ref): JSX.El
return null; return null;
} }
return <Icon src={icon} className='mr-2 w-4 h-4' />; return <Icon src={icon} className='w-4 h-4' />;
}; };
const handleClick = React.useCallback((event) => { const handleClick = React.useCallback((event) => {
@ -72,7 +74,7 @@ const Button = React.forwardRef<HTMLButtonElement, IButton>((props, ref): JSX.El
const renderButton = () => ( const renderButton = () => (
<button <button
className={classNames(themeClass, className)} className={classNames('space-x-2 rtl:space-x-reverse', themeClass, className)}
disabled={disabled} disabled={disabled}
onClick={handleClick} onClick={handleClick}
ref={ref} ref={ref}
@ -80,7 +82,10 @@ const Button = React.forwardRef<HTMLButtonElement, IButton>((props, ref): JSX.El
data-testid='button' data-testid='button'
> >
{renderIcon()} {renderIcon()}
{text || children}
{body && (
<span>{body}</span>
)}
</button> </button>
); );

View file

@ -10,11 +10,15 @@ const ComposeButton = () => {
const onOpenCompose = () => dispatch(openModal('COMPOSE')); const onOpenCompose = () => dispatch(openModal('COMPOSE'));
return ( return (
<div className='mt-4'> <Button
<Button theme='accent' icon={require('@tabler/icons/pencil-plus.svg')} block size='lg' onClick={onOpenCompose}> theme='accent'
<span><FormattedMessage id='navigation.compose' defaultMessage='Compose' /></span> icon={require('@tabler/icons/pencil-plus.svg')}
</Button> size='lg'
</div> onClick={onOpenCompose}
block
>
<FormattedMessage id='navigation.compose' defaultMessage='Compose' />
</Button>
); );
}; };

View file

@ -1,3 +1,4 @@
import clsx from 'clsx';
import React from 'react'; import React from 'react';
import { defineMessages, useIntl } from 'react-intl'; import { defineMessages, useIntl } from 'react-intl';
@ -24,12 +25,15 @@ const FloatingActionButton: React.FC<IFloatingActionButton> = () => {
return ( return (
<button <button
onClick={handleOpenComposeModal} onClick={handleOpenComposeModal}
className='z-40 lg:hidden transition-all fixed bottom-24 right-4 p-4 text-white bg-accent-300 hover:bg-accent-500 rounded-full' className={clsx(
'p-4 inline-flex items-center border font-medium rounded-full focus:outline-none focus:ring-2 focus:ring-offset-2 appearance-none transition-all',
'bg-primary-500 hover:bg-primary-400 dark:hover:bg-primary-600 border-transparent focus:bg-primary-500 text-gray-100 focus:ring-primary-300',
)}
aria-label={intl.formatMessage(messages.publish)} aria-label={intl.formatMessage(messages.publish)}
> >
<Icon <Icon
src={require('@tabler/icons/pencil-plus.svg')} src={require('@tabler/icons/pencil-plus.svg')}
className='w-6 h-6 stroke-[1.5px]' className='w-6 h-6'
/> />
</button> </button>
); );

View file

@ -641,7 +641,9 @@ const UI: React.FC = ({ children }) => {
</Layout> </Layout>
{(me && !shouldHideFAB()) && ( {(me && !shouldHideFAB()) && (
<FloatingActionButton /> <div className='z-40 lg:hidden transition-all fixed bottom-24 right-4'>
<FloatingActionButton />
</div>
)} )}
<BundleContainer fetchComponent={UploadArea}> <BundleContainer fetchComponent={UploadArea}>