diff --git a/app/soapbox/components/quoted-status.tsx b/app/soapbox/components/quoted-status.tsx index 8b358158b..2c976bf86 100644 --- a/app/soapbox/components/quoted-status.tsx +++ b/app/soapbox/components/quoted-status.tsx @@ -1,5 +1,5 @@ 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 { useHistory } from 'react-router-dom'; @@ -37,7 +37,16 @@ const QuotedStatus: React.FC = ({ status, onCancel, compose }) => const settings = useSettings(); const displayMedia = settings.get('displayMedia'); + const overlay = useRef(null); + const [showMedia, setShowMedia] = useState(defaultMediaVisibility(status, displayMedia)); + const [minHeight, setMinHeight] = useState(208); + + useEffect(() => { + if (overlay.current) { + setMinHeight(overlay.current.getBoundingClientRect().height); + } + }, [overlay.current]); const handleExpandClick: MouseEventHandler = (e) => { if (!status) return; @@ -103,15 +112,16 @@ const QuotedStatus: React.FC = ({ status, onCancel, compose }) => - {(status.hidden) && ( )} diff --git a/app/soapbox/components/status-action-button.tsx b/app/soapbox/components/status-action-button.tsx index aacda516f..2f355211b 100644 --- a/app/soapbox/components/status-action-button.tsx +++ b/app/soapbox/components/status-action-button.tsx @@ -41,7 +41,7 @@ const StatusActionButton = React.forwardRef { if (emoji) { return ( - + ); diff --git a/app/soapbox/components/status.tsx b/app/soapbox/components/status.tsx index fab25ea92..812d915ea 100644 --- a/app/soapbox/components/status.tsx +++ b/app/soapbox/components/status.tsx @@ -79,8 +79,10 @@ const Status: React.FC = (props) => { const displayMedia = settings.get('displayMedia') as string; const didShowCard = useRef(false); const node = useRef(null); + const overlay = useRef(null); const [showMedia, setShowMedia] = useState(defaultMediaVisibility(status, displayMedia)); + const [minHeight, setMinHeight] = useState(208); const actualStatus = getActualStatus(status); @@ -95,6 +97,12 @@ const Status: React.FC = (props) => { setShowMedia(defaultMediaVisibility(status, displayMedia)); }, [status.id]); + useEffect(() => { + if (overlay.current) { + setMinHeight(overlay.current.getBoundingClientRect().height); + } + }, [overlay.current]); + const handleToggleMediaVisibility = (): void => { setShowMedia(!showMedia); }; @@ -358,17 +366,15 @@ const Status: React.FC = (props) => { {(isUnderReview || isSensitive) && ( )} diff --git a/app/soapbox/components/statuses/sensitive-content-overlay.tsx b/app/soapbox/components/statuses/sensitive-content-overlay.tsx index 5239192fc..59faef161 100644 --- a/app/soapbox/components/statuses/sensitive-content-overlay.tsx +++ b/app/soapbox/components/statuses/sensitive-content-overlay.tsx @@ -25,7 +25,7 @@ interface ISensitiveContentOverlay { visible?: boolean } -const SensitiveContentOverlay = (props: ISensitiveContentOverlay) => { +const SensitiveContentOverlay = React.forwardRef((props, ref) => { const { onToggleVisibility, status } = props; const isUnderReview = status.visibility === 'self'; @@ -72,7 +72,7 @@ const SensitiveContentOverlay = (props: ISensitiveContentOverlay) => { size='sm' /> ) : ( -
+
{intl.formatMessage(isUnderReview ? messages.underReviewTitle : messages.sensitiveTitle)} @@ -84,7 +84,7 @@ const SensitiveContentOverlay = (props: ISensitiveContentOverlay) => { {status.spoiler_text && (
- +
@@ -127,6 +127,6 @@ const SensitiveContentOverlay = (props: ISensitiveContentOverlay) => { )}
); -}; +}); -export default SensitiveContentOverlay; \ No newline at end of file +export default SensitiveContentOverlay; diff --git a/app/soapbox/features/status/components/detailed-status.tsx b/app/soapbox/features/status/components/detailed-status.tsx index 80ab50022..a1fdc5434 100644 --- a/app/soapbox/features/status/components/detailed-status.tsx +++ b/app/soapbox/features/status/components/detailed-status.tsx @@ -1,5 +1,4 @@ -import classNames from 'clsx'; -import React, { useRef } from 'react'; +import React, { useEffect, useRef, useState } from 'react'; import { FormattedDate, FormattedMessage, useIntl } from 'react-intl'; import Icon from 'soapbox/components/icon'; @@ -35,7 +34,17 @@ const DetailedStatus: React.FC = ({ showMedia, }) => { const intl = useIntl(); + const node = useRef(null); + const overlay = useRef(null); + + const [minHeight, setMinHeight] = useState(208); + + useEffect(() => { + if (overlay.current) { + setMinHeight(overlay.current.getBoundingClientRect().height); + } + }, [overlay.current]); const handleOpenCompareHistoryModal = () => { onOpenCompareHistoryModal(status); @@ -87,17 +96,15 @@ const DetailedStatus: React.FC = ({ {(isUnderReview || isSensitive) && ( )} diff --git a/package.json b/package.json index afad054f8..6faed0629 100644 --- a/package.json +++ b/package.json @@ -68,6 +68,7 @@ "@sentry/tracing": "^7.11.1", "@tabler/icons": "^1.111.0", "@tailwindcss/forms": "^0.5.3", + "@tailwindcss/line-clamp": "^0.4.2", "@tailwindcss/typography": "^0.5.7", "@tanstack/react-query": "^4.0.10", "@testing-library/react": "^12.1.4", diff --git a/tailwind.config.js b/tailwind.config.js index ab0b64525..7d562327b 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -85,6 +85,7 @@ module.exports = { }, plugins: [ require('@tailwindcss/forms'), + require('@tailwindcss/line-clamp'), require('@tailwindcss/typography'), ], }; diff --git a/yarn.lock b/yarn.lock index 803003924..a0ef339e9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2272,6 +2272,11 @@ dependencies: 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": version "0.5.7" resolved "https://registry.yarnpkg.com/@tailwindcss/typography/-/typography-0.5.7.tgz#e0b95bea787ee14c5a34a74fc824e6fe86ea8855"