From 9f89c31bd334ece0e64eacf8764fb51daf11e6ed Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 11 May 2022 14:35:56 -0500 Subject: [PATCH] Create a logged-out call-to-action on threads --- app/soapbox/components/ui/card/card.tsx | 5 ++- .../status/components/thread-login-cta.tsx | 36 +++++++++++++++++++ app/soapbox/features/status/index.tsx | 31 +++++++++------- 3 files changed, 59 insertions(+), 13 deletions(-) create mode 100644 app/soapbox/features/status/components/thread-login-cta.tsx diff --git a/app/soapbox/components/ui/card/card.tsx b/app/soapbox/components/ui/card/card.tsx index 9dd22bebe..f8ed33c1e 100644 --- a/app/soapbox/components/ui/card/card.tsx +++ b/app/soapbox/components/ui/card/card.tsx @@ -47,7 +47,10 @@ interface ICardHeader { onBackClick?: (event: React.MouseEvent) => void } -/** Typically holds a CardTitle. */ +/** + * Card header container with back button. + * Typically holds a CardTitle. + */ const CardHeader: React.FC = ({ children, backHref, onBackClick }): JSX.Element => { const intl = useIntl(); diff --git a/app/soapbox/features/status/components/thread-login-cta.tsx b/app/soapbox/features/status/components/thread-login-cta.tsx new file mode 100644 index 000000000..2626aeb3c --- /dev/null +++ b/app/soapbox/features/status/components/thread-login-cta.tsx @@ -0,0 +1,36 @@ +import React from 'react'; +import { FormattedMessage } from 'react-intl'; + +import { Card, CardTitle, Text, Stack, Button } from 'soapbox/components/ui'; +import { useAppSelector } from 'soapbox/hooks'; + +/** Prompts logged-out users to log in when viewing a thread. */ +const ThreadLoginCta: React.FC = () => { + const siteTitle = useAppSelector(state => state.instance.title); + + return ( + + + } /> + + + + + + + + + + + ); +}; + +export default ThreadLoginCta; diff --git a/app/soapbox/features/status/index.tsx b/app/soapbox/features/status/index.tsx index 58d9c3b21..25247ac6f 100644 --- a/app/soapbox/features/status/index.tsx +++ b/app/soapbox/features/status/index.tsx @@ -19,7 +19,7 @@ import { getSettings } from 'soapbox/actions/settings'; import { getSoapboxConfig } from 'soapbox/actions/soapbox'; import ScrollableList from 'soapbox/components/scrollable_list'; import SubNavigation from 'soapbox/components/sub_navigation'; -import { Column } from 'soapbox/components/ui'; +import { Column, Stack } from 'soapbox/components/ui'; import PlaceholderStatus from 'soapbox/features/placeholder/components/placeholder_status'; import PendingStatus from 'soapbox/features/ui/components/pending_status'; @@ -60,6 +60,7 @@ import { attachFullscreenListener, detachFullscreenListener, isFullscreen } from import ActionBar from './components/action-bar'; import DetailedStatus from './components/detailed-status'; +import ThreadLoginCta from './components/thread-login-cta'; import ThreadStatus from './components/thread-status'; import type { AxiosError } from 'axios'; @@ -72,6 +73,7 @@ import type { Attachment as AttachmentEntity, Status as StatusEntity, } from 'soapbox/types/entities'; +import type { Me } from 'soapbox/types/soapbox'; const messages = defineMessages({ title: { id: 'status.title', defaultMessage: '@{username}\'s Post' }, @@ -181,6 +183,7 @@ interface IStatus extends RouteComponentProps, IntlComponentProps { allowedEmoji: ImmutableList, onOpenMedia: (media: ImmutableList, index: number) => void, onOpenVideo: (video: AttachmentEntity, time: number) => void, + me: Me, } interface IStatusState { @@ -669,7 +672,7 @@ class Status extends ImmutablePureComponent { } render() { - const { status, ancestorsIds, descendantsIds, intl } = this.props; + const { me, status, ancestorsIds, descendantsIds, intl } = this.props; const hasAncestors = ancestorsIds && ancestorsIds.size > 0; const hasDescendants = descendantsIds && descendantsIds.size > 0; @@ -782,16 +785,20 @@ class Status extends ImmutablePureComponent { -
- } - > - {children} - -
+ +
+ } + > + {children} + +
+ + {!me && } +
); }