Refactor spacing of statuses
This commit is contained in:
parent
7599876e13
commit
6a864d126d
8 changed files with 62 additions and 111 deletions
|
@ -1,15 +1,17 @@
|
|||
import classNames from 'clsx';
|
||||
import React, { useState } from 'react';
|
||||
import { defineMessages, useIntl, FormattedMessage, FormattedList } from 'react-intl';
|
||||
import React, { MouseEventHandler, useState } from 'react';
|
||||
import { defineMessages, useIntl } from 'react-intl';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
|
||||
import StatusMedia from 'soapbox/components/status-media';
|
||||
import { Stack, Text } from 'soapbox/components/ui';
|
||||
import { Stack } from 'soapbox/components/ui';
|
||||
import AccountContainer from 'soapbox/containers/account_container';
|
||||
import { useSettings } from 'soapbox/hooks';
|
||||
import { defaultMediaVisibility } from 'soapbox/utils/status';
|
||||
|
||||
import OutlineBox from './outline-box';
|
||||
import StatusReplyMentions from './status-reply-mentions';
|
||||
import StatusContent from './status_content';
|
||||
import SensitiveContentOverlay from './statuses/sensitive-content-overlay';
|
||||
|
||||
import type { Account as AccountEntity, Status as StatusEntity } from 'soapbox/types/entities';
|
||||
|
@ -37,7 +39,7 @@ const QuotedStatus: React.FC<IQuotedStatus> = ({ status, onCancel, compose }) =>
|
|||
|
||||
const [showMedia, setShowMedia] = useState<boolean>(defaultMediaVisibility(status, displayMedia));
|
||||
|
||||
const handleExpandClick = (e: React.MouseEvent<HTMLDivElement>) => {
|
||||
const handleExpandClick: MouseEventHandler<HTMLDivElement> = (e) => {
|
||||
if (!status) return;
|
||||
const account = status.account as AccountEntity;
|
||||
|
||||
|
@ -58,57 +60,6 @@ const QuotedStatus: React.FC<IQuotedStatus> = ({ status, onCancel, compose }) =>
|
|||
setShowMedia(!showMedia);
|
||||
};
|
||||
|
||||
const renderReplyMentions = () => {
|
||||
if (!status?.in_reply_to_id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const account = status.account as AccountEntity;
|
||||
const to = status.mentions || [];
|
||||
|
||||
if (to.size === 0) {
|
||||
if (status.in_reply_to_account_id === account.id) {
|
||||
return (
|
||||
<div className='reply-mentions'>
|
||||
<FormattedMessage
|
||||
id='reply_mentions.reply'
|
||||
defaultMessage='Replying to {accounts}'
|
||||
values={{
|
||||
accounts: `@${account.username}`,
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
} else {
|
||||
return (
|
||||
<div className='reply-mentions'>
|
||||
<FormattedMessage id='reply_mentions.reply_empty' defaultMessage='Replying to post' />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const accounts = to.slice(0, 2).map(account => <>@{account.username}</>).toArray();
|
||||
|
||||
if (to.size > 2) {
|
||||
accounts.push(
|
||||
<FormattedMessage id='reply_mentions.more' defaultMessage='{count} more' values={{ count: to.size - 2 }} />,
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className='reply-mentions'>
|
||||
<FormattedMessage
|
||||
id='reply_mentions.reply'
|
||||
defaultMessage='Replying to {accounts}'
|
||||
values={{
|
||||
accounts: <FormattedList type='conjunction' value={accounts} />,
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
if (!status) {
|
||||
return null;
|
||||
}
|
||||
|
@ -128,7 +79,7 @@ const QuotedStatus: React.FC<IQuotedStatus> = ({ status, onCancel, compose }) =>
|
|||
return (
|
||||
<OutlineBox
|
||||
data-testid='quoted-status'
|
||||
className={classNames('cursor-pointer relative', {
|
||||
className={classNames('cursor-pointer', {
|
||||
'hover:bg-gray-100 dark:hover:bg-gray-800': !compose,
|
||||
})}
|
||||
>
|
||||
|
@ -145,16 +96,13 @@ const QuotedStatus: React.FC<IQuotedStatus> = ({ status, onCancel, compose }) =>
|
|||
withLinkToProfile={!compose}
|
||||
/>
|
||||
|
||||
{renderReplyMentions()}
|
||||
<StatusReplyMentions status={status} hoverable={false} />
|
||||
|
||||
<Text
|
||||
className='break-words status__content status__content--quote'
|
||||
size='sm'
|
||||
dangerouslySetInnerHTML={{ __html: status.contentHtml }}
|
||||
/>
|
||||
|
||||
<Stack>
|
||||
{status.hidden && (
|
||||
<Stack className={classNames('relative', {
|
||||
'min-h-[220px]': status.hidden,
|
||||
})}
|
||||
>
|
||||
{(status.hidden) && (
|
||||
<SensitiveContentOverlay
|
||||
status={status}
|
||||
visible={showMedia}
|
||||
|
@ -162,12 +110,21 @@ const QuotedStatus: React.FC<IQuotedStatus> = ({ status, onCancel, compose }) =>
|
|||
/>
|
||||
)}
|
||||
|
||||
<StatusMedia
|
||||
status={status}
|
||||
muted={compose}
|
||||
showMedia={showMedia}
|
||||
onToggleVisibility={handleToggleMediaVisibility}
|
||||
/>
|
||||
<Stack space={4}>
|
||||
<StatusContent
|
||||
status={status}
|
||||
collapsable
|
||||
/>
|
||||
|
||||
{(status.media_attachments.size > 0) && (
|
||||
<StatusMedia
|
||||
status={status}
|
||||
muted={compose}
|
||||
showMedia={showMedia}
|
||||
onToggleVisibility={handleToggleMediaVisibility}
|
||||
/>
|
||||
)}
|
||||
</Stack>
|
||||
</Stack>
|
||||
</Stack>
|
||||
</OutlineBox>
|
||||
|
|
Binary file not shown.
|
@ -65,7 +65,6 @@ const Status: React.FC<IStatus> = (props) => {
|
|||
hidden,
|
||||
featured,
|
||||
unread,
|
||||
group,
|
||||
hideActionBar,
|
||||
variant = 'rounded',
|
||||
withDismiss,
|
||||
|
@ -349,6 +348,8 @@ const Status: React.FC<IStatus> = (props) => {
|
|||
</div>
|
||||
|
||||
<div className='status__content-wrapper'>
|
||||
<StatusReplyMentions status={actualStatus} hoverable={hoverable} />
|
||||
|
||||
<Stack
|
||||
className={
|
||||
classNames('relative', {
|
||||
|
@ -364,32 +365,27 @@ const Status: React.FC<IStatus> = (props) => {
|
|||
/>
|
||||
)}
|
||||
|
||||
{!group && actualStatus.group && (
|
||||
<div className='status__meta'>
|
||||
Posted in <NavLink to={`/groups/${actualStatus.getIn(['group', 'id'])}`}>{String(actualStatus.getIn(['group', 'title']))}</NavLink>
|
||||
</div>
|
||||
)}
|
||||
<Stack space={4}>
|
||||
<StatusContent
|
||||
status={actualStatus}
|
||||
onClick={handleClick}
|
||||
collapsable
|
||||
/>
|
||||
|
||||
<StatusReplyMentions
|
||||
status={actualStatus}
|
||||
hoverable={hoverable}
|
||||
/>
|
||||
{(quote || actualStatus.media_attachments.size > 0) && (
|
||||
<Stack space={4}>
|
||||
<StatusMedia
|
||||
status={actualStatus}
|
||||
muted={muted}
|
||||
onClick={handleClick}
|
||||
showMedia={showMedia}
|
||||
onToggleVisibility={handleToggleMediaVisibility}
|
||||
/>
|
||||
|
||||
<StatusContent
|
||||
status={actualStatus}
|
||||
onClick={handleClick}
|
||||
collapsable
|
||||
/>
|
||||
|
||||
<StatusMedia
|
||||
status={actualStatus}
|
||||
muted={muted}
|
||||
onClick={handleClick}
|
||||
showMedia={showMedia}
|
||||
onToggleVisibility={handleToggleMediaVisibility}
|
||||
/>
|
||||
|
||||
{quote}
|
||||
{quote}
|
||||
</Stack>
|
||||
)}
|
||||
</Stack>
|
||||
</Stack>
|
||||
|
||||
{!hideActionBar && (
|
||||
|
|
|
@ -100,15 +100,21 @@ const DetailedStatus: React.FC<IDetailedStatus> = ({
|
|||
/>
|
||||
)}
|
||||
|
||||
<StatusContent status={actualStatus} />
|
||||
<Stack space={4}>
|
||||
<StatusContent status={actualStatus} />
|
||||
|
||||
<StatusMedia
|
||||
status={actualStatus}
|
||||
showMedia={showMedia}
|
||||
onToggleVisibility={onToggleMediaVisibility}
|
||||
/>
|
||||
{(quote || actualStatus.media_attachments.size > 0) && (
|
||||
<Stack space={4}>
|
||||
<StatusMedia
|
||||
status={actualStatus}
|
||||
showMedia={showMedia}
|
||||
onToggleVisibility={onToggleMediaVisibility}
|
||||
/>
|
||||
|
||||
{quote}
|
||||
{quote}
|
||||
</Stack>
|
||||
)}
|
||||
</Stack>
|
||||
</Stack>
|
||||
|
||||
<HStack justifyContent='between' alignItems='center' className='py-2' wrap>
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
.media-gallery {
|
||||
box-sizing: border-box;
|
||||
margin-top: 8px;
|
||||
overflow: hidden;
|
||||
border-radius: 10px;
|
||||
position: relative;
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
.detailed-status {
|
||||
.reply-mentions {
|
||||
display: block;
|
||||
margin: 4px 0 0 0;
|
||||
|
||||
span {
|
||||
cursor: pointer;
|
||||
|
|
|
@ -14,11 +14,6 @@
|
|||
opacity: 1;
|
||||
animation: fade 150ms linear;
|
||||
|
||||
.video-player,
|
||||
.audio-player {
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
&.light {
|
||||
.display-name {
|
||||
strong {
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
flex-direction: column;
|
||||
height: 100%;
|
||||
justify-content: center;
|
||||
margin-top: 8px;
|
||||
position: relative;
|
||||
text-align: center;
|
||||
z-index: 100;
|
||||
|
|
Loading…
Reference in a new issue