-
Notifications
You must be signed in to change notification settings - Fork 293
Expand file tree
/
Copy pathBasePostContent.tsx
More file actions
73 lines (68 loc) · 1.94 KB
/
BasePostContent.tsx
File metadata and controls
73 lines (68 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import dynamic from 'next/dynamic';
import type { ReactElement } from 'react';
import React from 'react';
import classNames from 'classnames';
import PostEngagements from './PostEngagements';
import type { BasePostContentProps } from './common';
import { PostHeaderActions } from './PostHeaderActions';
import { ButtonSize } from '../buttons/common';
import { PostBottomAction } from './PostBottomAction';
const Custom404 = dynamic(
() => import(/* webpackChunkName: "custom404" */ '../Custom404'),
);
const GoBackHeaderMobile = dynamic(
() =>
import(/* webpackChunkName: "goBackHeaderMobile" */ './GoBackHeaderMobile'),
{
ssr: false,
loading: () => (
<div className="-mx-4 h-12 border-b border-border-subtlest-tertiary laptop:hidden" />
),
},
);
export function BasePostContent({
post,
isFallback,
origin,
children,
className = {},
navigationProps,
engagementProps,
shouldOnboardAuthor,
isPostPage,
}: BasePostContentProps): ReactElement {
const { id } = post ?? {};
const { onCopyPostLink } = engagementProps ?? {};
if (!id && !isFallback) {
return <Custom404 />;
}
return (
<>
{isPostPage && (
<GoBackHeaderMobile
className={classNames(className.header, '-mx-4 bg-background-subtle')}
>
<PostHeaderActions
post={post}
className="ml-auto"
contextMenuId="post-page-header-actions"
onReadArticle={navigationProps.onReadArticle}
buttonSize={ButtonSize.Small}
/>
</GoBackHeaderMobile>
)}
{children}
{!!engagementProps && (
<PostEngagements
post={post}
onCopyLinkClick={onCopyPostLink}
logOrigin={origin}
shouldOnboardAuthor={shouldOnboardAuthor}
/>
)}
{!isPostPage && !!navigationProps?.onClose && (
<PostBottomAction onAction={() => navigationProps.onClose?.(null as any)} />
)}
</>
);
}