pl-fe: use consistent margins in compose form

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak 2024-09-15 11:59:59 +02:00
parent bf01ca26ae
commit 9bddccd1b3
2 changed files with 10 additions and 5 deletions

View file

@ -183,11 +183,12 @@ const ComposeForm = <ID extends string>({ id, shouldCondense, autoFocus, clickab
</HStack> </HStack>
), [features, id, anyMedia]); ), [features, id, anyMedia]);
const composeModifiers = !condensed && ( const showModifiers = !condensed && (compose.media_attachments.size || compose.is_uploading || compose.poll?.options.size || compose.schedule);
const composeModifiers = showModifiers && (
<Stack space={4} className='font-[inherit] text-sm text-gray-900'> <Stack space={4} className='font-[inherit] text-sm text-gray-900'>
<UploadForm composeId={id} onSubmit={handleSubmit} /> <UploadForm composeId={id} onSubmit={handleSubmit} />
<PollForm composeId={id} /> <PollForm composeId={id} />
<ScheduleForm composeId={id} /> <ScheduleForm composeId={id} />
</Stack> </Stack>
); );
@ -228,7 +229,7 @@ const ComposeForm = <ID extends string>({ id, shouldCondense, autoFocus, clickab
{!shouldCondense && !event && !group && <ReplyMentions composeId={id} />} {!shouldCondense && !event && !group && <ReplyMentions composeId={id} />}
{!!selectButtons && ( {!!selectButtons && (
<HStack space={2} wrap className='-mb-2'> <HStack space={2} wrap className={clsx(transparent && '-mb-2')}>
{selectButtons} {selectButtons}
</HStack> </HStack>
)} )}

View file

@ -16,7 +16,9 @@ interface IUploadForm {
const UploadForm: React.FC<IUploadForm> = ({ composeId, onSubmit }) => { const UploadForm: React.FC<IUploadForm> = ({ composeId, onSubmit }) => {
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
const mediaIds = useCompose(composeId).media_attachments.map((item) => item.id); const { is_uploading: isUploading, media_attachments: mediaAttachments } = useCompose(composeId);
const mediaIds = mediaAttachments.map((item) => item.id);
const dragItem = useRef<string | null>(); const dragItem = useRef<string | null>();
const dragOverItem = useRef<string | null>(); const dragOverItem = useRef<string | null>();
@ -35,11 +37,13 @@ const UploadForm: React.FC<IUploadForm> = ({ composeId, onSubmit }) => {
dragOverItem.current = null; dragOverItem.current = null;
}, [dragItem, dragOverItem]); }, [dragItem, dragOverItem]);
if (!isUploading && mediaIds.isEmpty()) return null;
return ( return (
<div className='overflow-hidden'> <div className='overflow-hidden'>
<UploadProgress composeId={composeId} /> <UploadProgress composeId={composeId} />
<HStack wrap className={clsx('overflow-hidden', mediaIds.size !== 0 && 'p-1')}> <HStack wrap className={clsx('overflow-hidden', mediaIds.size !== 0 && 'm-[-5px]')}>
{mediaIds.map((id: string) => ( {mediaIds.map((id: string) => (
<Upload <Upload
id={id} id={id}