diff --git a/src/components/ContentPreview/index.tsx b/src/components/ContentPreview/index.tsx index c0f34116..43019645 100644 --- a/src/components/ContentPreview/index.tsx +++ b/src/components/ContentPreview/index.tsx @@ -30,6 +30,7 @@ import ApplicationHandlerInfo from '../ApplicationHandlerInfo' import ApplicationHandlerRecommendation from '../ApplicationHandlerRecommendation' import FollowPackPreview from './FollowPackPreview' import ReactionEmojiDisplay from '../Note/ReactionEmojiDisplay' +import NoteKindLabel from '../Note/NoteKindLabel' /** Inert event so hooks can run before `event` is defined. */ const CONTENT_PREVIEW_HOOK_PLACEHOLDER = { @@ -42,6 +43,22 @@ const CONTENT_PREVIEW_HOOK_PLACEHOLDER = { sig: '' } as Event +/** Keep spacing/margins on the outer wrapper; put line-clamp on the preview body so it still clamps text. */ +function splitPreviewLayoutClasses(className?: string) { + if (!className?.trim()) return { outer: undefined, body: undefined } + const tokens = className.trim().split(/\s+/) + const body: string[] = [] + const outer: string[] = [] + for (const tok of tokens) { + if (tok.startsWith('line-clamp')) body.push(tok) + else outer.push(tok) + } + return { + outer: outer.length ? outer.join(' ') : undefined, + body: body.length ? body.join(' ') : undefined + } +} + export default function ContentPreview({ event, className @@ -85,6 +102,15 @@ export default function ContentPreview({ ) } + const { outer: previewOuter, body: previewBody } = splitPreviewLayoutClasses(className) + + const withKindRow = (node: React.ReactNode) => ( +
- {poll.pollType === POLL_TYPE.MULTIPLE_CHOICE && - t('Multiple choice (select one or more)')} -
+ {!isExpired && poll.pollType === POLL_TYPE.MULTIPLE_CHOICE && ( +{t('Multiple choice (select one or more)')}
+ )}{!!poll.endsAt && (isExpired @@ -168,36 +176,30 @@ export default function Poll({ event, className }: { event: Event; className?: s