Merge branch 'sensitive-overlay-height' into 'develop'
Fix 'Overly long content warning spills over the banner' Closes #1173 See merge request soapbox-pub/soapbox!1910
This commit is contained in:
commit
8ca1cd0345
|
@ -1,5 +1,5 @@
|
||||||
import classNames from 'clsx';
|
import classNames from 'clsx';
|
||||||
import React, { MouseEventHandler, useState } from 'react';
|
import React, { MouseEventHandler, useEffect, useRef, useState } from 'react';
|
||||||
import { defineMessages, useIntl } from 'react-intl';
|
import { defineMessages, useIntl } from 'react-intl';
|
||||||
import { useHistory } from 'react-router-dom';
|
import { useHistory } from 'react-router-dom';
|
||||||
|
|
||||||
|
@ -37,7 +37,16 @@ const QuotedStatus: React.FC<IQuotedStatus> = ({ status, onCancel, compose }) =>
|
||||||
const settings = useSettings();
|
const settings = useSettings();
|
||||||
const displayMedia = settings.get('displayMedia');
|
const displayMedia = settings.get('displayMedia');
|
||||||
|
|
||||||
|
const overlay = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
const [showMedia, setShowMedia] = useState<boolean>(defaultMediaVisibility(status, displayMedia));
|
const [showMedia, setShowMedia] = useState<boolean>(defaultMediaVisibility(status, displayMedia));
|
||||||
|
const [minHeight, setMinHeight] = useState(208);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (overlay.current) {
|
||||||
|
setMinHeight(overlay.current.getBoundingClientRect().height);
|
||||||
|
}
|
||||||
|
}, [overlay.current]);
|
||||||
|
|
||||||
const handleExpandClick: MouseEventHandler<HTMLDivElement> = (e) => {
|
const handleExpandClick: MouseEventHandler<HTMLDivElement> = (e) => {
|
||||||
if (!status) return;
|
if (!status) return;
|
||||||
|
@ -103,15 +112,16 @@ const QuotedStatus: React.FC<IQuotedStatus> = ({ status, onCancel, compose }) =>
|
||||||
|
|
||||||
<StatusReplyMentions status={status} hoverable={false} />
|
<StatusReplyMentions status={status} hoverable={false} />
|
||||||
|
|
||||||
<Stack className={classNames('relative z-0', {
|
<Stack
|
||||||
'min-h-[220px]': status.hidden,
|
className='relative z-0'
|
||||||
})}
|
style={{ minHeight: status.hidden ? Math.max(minHeight, 208) + 12 : undefined }}
|
||||||
>
|
>
|
||||||
{(status.hidden) && (
|
{(status.hidden) && (
|
||||||
<SensitiveContentOverlay
|
<SensitiveContentOverlay
|
||||||
status={status}
|
status={status}
|
||||||
visible={showMedia}
|
visible={showMedia}
|
||||||
onToggleVisibility={handleToggleMediaVisibility}
|
onToggleVisibility={handleToggleMediaVisibility}
|
||||||
|
ref={overlay}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ const StatusActionButton = React.forwardRef<HTMLButtonElement, IStatusActionButt
|
||||||
const renderIcon = () => {
|
const renderIcon = () => {
|
||||||
if (emoji) {
|
if (emoji) {
|
||||||
return (
|
return (
|
||||||
<span className='block w-6 h-6 flex items-center justify-center'>
|
<span className='flex w-6 h-6 items-center justify-center'>
|
||||||
<Emoji className='w-full h-full p-0.5' emoji={emoji} />
|
<Emoji className='w-full h-full p-0.5' emoji={emoji} />
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
|
|
|
@ -79,8 +79,10 @@ const Status: React.FC<IStatus> = (props) => {
|
||||||
const displayMedia = settings.get('displayMedia') as string;
|
const displayMedia = settings.get('displayMedia') as string;
|
||||||
const didShowCard = useRef(false);
|
const didShowCard = useRef(false);
|
||||||
const node = useRef<HTMLDivElement>(null);
|
const node = useRef<HTMLDivElement>(null);
|
||||||
|
const overlay = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
const [showMedia, setShowMedia] = useState<boolean>(defaultMediaVisibility(status, displayMedia));
|
const [showMedia, setShowMedia] = useState<boolean>(defaultMediaVisibility(status, displayMedia));
|
||||||
|
const [minHeight, setMinHeight] = useState(208);
|
||||||
|
|
||||||
const actualStatus = getActualStatus(status);
|
const actualStatus = getActualStatus(status);
|
||||||
|
|
||||||
|
@ -95,6 +97,12 @@ const Status: React.FC<IStatus> = (props) => {
|
||||||
setShowMedia(defaultMediaVisibility(status, displayMedia));
|
setShowMedia(defaultMediaVisibility(status, displayMedia));
|
||||||
}, [status.id]);
|
}, [status.id]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (overlay.current) {
|
||||||
|
setMinHeight(overlay.current.getBoundingClientRect().height);
|
||||||
|
}
|
||||||
|
}, [overlay.current]);
|
||||||
|
|
||||||
const handleToggleMediaVisibility = (): void => {
|
const handleToggleMediaVisibility = (): void => {
|
||||||
setShowMedia(!showMedia);
|
setShowMedia(!showMedia);
|
||||||
};
|
};
|
||||||
|
@ -358,17 +366,15 @@ const Status: React.FC<IStatus> = (props) => {
|
||||||
<StatusReplyMentions status={actualStatus} hoverable={hoverable} />
|
<StatusReplyMentions status={actualStatus} hoverable={hoverable} />
|
||||||
|
|
||||||
<Stack
|
<Stack
|
||||||
className={
|
className='relative z-0'
|
||||||
classNames('relative z-0', {
|
style={{ minHeight: isUnderReview || isSensitive ? Math.max(minHeight, 208) + 12 : undefined }}
|
||||||
'min-h-[220px]': isUnderReview || isSensitive,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
{(isUnderReview || isSensitive) && (
|
{(isUnderReview || isSensitive) && (
|
||||||
<SensitiveContentOverlay
|
<SensitiveContentOverlay
|
||||||
status={status}
|
status={status}
|
||||||
visible={showMedia}
|
visible={showMedia}
|
||||||
onToggleVisibility={handleToggleMediaVisibility}
|
onToggleVisibility={handleToggleMediaVisibility}
|
||||||
|
ref={overlay}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ interface ISensitiveContentOverlay {
|
||||||
visible?: boolean
|
visible?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
const SensitiveContentOverlay = (props: ISensitiveContentOverlay) => {
|
const SensitiveContentOverlay = React.forwardRef<HTMLDivElement, ISensitiveContentOverlay>((props, ref) => {
|
||||||
const { onToggleVisibility, status } = props;
|
const { onToggleVisibility, status } = props;
|
||||||
const isUnderReview = status.visibility === 'self';
|
const isUnderReview = status.visibility === 'self';
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ const SensitiveContentOverlay = (props: ISensitiveContentOverlay) => {
|
||||||
size='sm'
|
size='sm'
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<div className='text-center w-3/4 mx-auto space-y-4'>
|
<div className='text-center w-3/4 mx-auto space-y-4' ref={ref}>
|
||||||
<div className='space-y-1'>
|
<div className='space-y-1'>
|
||||||
<Text theme='white' weight='semibold'>
|
<Text theme='white' weight='semibold'>
|
||||||
{intl.formatMessage(isUnderReview ? messages.underReviewTitle : messages.sensitiveTitle)}
|
{intl.formatMessage(isUnderReview ? messages.underReviewTitle : messages.sensitiveTitle)}
|
||||||
|
@ -84,7 +84,7 @@ const SensitiveContentOverlay = (props: ISensitiveContentOverlay) => {
|
||||||
|
|
||||||
{status.spoiler_text && (
|
{status.spoiler_text && (
|
||||||
<div className='py-4 italic'>
|
<div className='py-4 italic'>
|
||||||
<Text theme='white' size='md' weight='medium'>
|
<Text className='line-clamp-6' theme='white' size='md' weight='medium'>
|
||||||
“<span dangerouslySetInnerHTML={{ __html: status.spoilerHtml }} />”
|
“<span dangerouslySetInnerHTML={{ __html: status.spoilerHtml }} />”
|
||||||
</Text>
|
</Text>
|
||||||
</div>
|
</div>
|
||||||
|
@ -127,6 +127,6 @@ const SensitiveContentOverlay = (props: ISensitiveContentOverlay) => {
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
});
|
||||||
|
|
||||||
export default SensitiveContentOverlay;
|
export default SensitiveContentOverlay;
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import classNames from 'clsx';
|
import React, { useEffect, useRef, useState } from 'react';
|
||||||
import React, { useRef } from 'react';
|
|
||||||
import { FormattedDate, FormattedMessage, useIntl } from 'react-intl';
|
import { FormattedDate, FormattedMessage, useIntl } from 'react-intl';
|
||||||
|
|
||||||
import Icon from 'soapbox/components/icon';
|
import Icon from 'soapbox/components/icon';
|
||||||
|
@ -35,7 +34,17 @@ const DetailedStatus: React.FC<IDetailedStatus> = ({
|
||||||
showMedia,
|
showMedia,
|
||||||
}) => {
|
}) => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
|
|
||||||
const node = useRef<HTMLDivElement>(null);
|
const node = useRef<HTMLDivElement>(null);
|
||||||
|
const overlay = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
|
const [minHeight, setMinHeight] = useState(208);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (overlay.current) {
|
||||||
|
setMinHeight(overlay.current.getBoundingClientRect().height);
|
||||||
|
}
|
||||||
|
}, [overlay.current]);
|
||||||
|
|
||||||
const handleOpenCompareHistoryModal = () => {
|
const handleOpenCompareHistoryModal = () => {
|
||||||
onOpenCompareHistoryModal(status);
|
onOpenCompareHistoryModal(status);
|
||||||
|
@ -87,17 +96,15 @@ const DetailedStatus: React.FC<IDetailedStatus> = ({
|
||||||
<StatusReplyMentions status={actualStatus} />
|
<StatusReplyMentions status={actualStatus} />
|
||||||
|
|
||||||
<Stack
|
<Stack
|
||||||
className={
|
className='relative z-0'
|
||||||
classNames('relative z-0', {
|
style={{ minHeight: isUnderReview || isSensitive ? Math.max(minHeight, 208) + 12 : undefined }}
|
||||||
'min-h-[220px]': isUnderReview || isSensitive,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
{(isUnderReview || isSensitive) && (
|
{(isUnderReview || isSensitive) && (
|
||||||
<SensitiveContentOverlay
|
<SensitiveContentOverlay
|
||||||
status={status}
|
status={status}
|
||||||
visible={showMedia}
|
visible={showMedia}
|
||||||
onToggleVisibility={onToggleMediaVisibility}
|
onToggleVisibility={onToggleMediaVisibility}
|
||||||
|
ref={overlay}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|
|
@ -68,6 +68,7 @@
|
||||||
"@sentry/tracing": "^7.11.1",
|
"@sentry/tracing": "^7.11.1",
|
||||||
"@tabler/icons": "^1.111.0",
|
"@tabler/icons": "^1.111.0",
|
||||||
"@tailwindcss/forms": "^0.5.3",
|
"@tailwindcss/forms": "^0.5.3",
|
||||||
|
"@tailwindcss/line-clamp": "^0.4.2",
|
||||||
"@tailwindcss/typography": "^0.5.7",
|
"@tailwindcss/typography": "^0.5.7",
|
||||||
"@tanstack/react-query": "^4.0.10",
|
"@tanstack/react-query": "^4.0.10",
|
||||||
"@testing-library/react": "^12.1.4",
|
"@testing-library/react": "^12.1.4",
|
||||||
|
|
|
@ -85,6 +85,7 @@ module.exports = {
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
require('@tailwindcss/forms'),
|
require('@tailwindcss/forms'),
|
||||||
|
require('@tailwindcss/line-clamp'),
|
||||||
require('@tailwindcss/typography'),
|
require('@tailwindcss/typography'),
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
|
@ -2272,6 +2272,11 @@
|
||||||
dependencies:
|
dependencies:
|
||||||
mini-svg-data-uri "^1.2.3"
|
mini-svg-data-uri "^1.2.3"
|
||||||
|
|
||||||
|
"@tailwindcss/line-clamp@^0.4.2":
|
||||||
|
version "0.4.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/@tailwindcss/line-clamp/-/line-clamp-0.4.2.tgz#f353c5a8ab2c939c6267ac5b907f012e5ee130f9"
|
||||||
|
integrity sha512-HFzAQuqYCjyy/SX9sLGB1lroPzmcnWv1FHkIpmypte10hptf4oPUfucryMKovZh2u0uiS9U5Ty3GghWfEJGwVw==
|
||||||
|
|
||||||
"@tailwindcss/typography@^0.5.7":
|
"@tailwindcss/typography@^0.5.7":
|
||||||
version "0.5.7"
|
version "0.5.7"
|
||||||
resolved "https://registry.yarnpkg.com/@tailwindcss/typography/-/typography-0.5.7.tgz#e0b95bea787ee14c5a34a74fc824e6fe86ea8855"
|
resolved "https://registry.yarnpkg.com/@tailwindcss/typography/-/typography-0.5.7.tgz#e0b95bea787ee14c5a34a74fc824e6fe86ea8855"
|
||||||
|
|
Loading…
Reference in New Issue