From af07af9b7540b208f0e0c9884ead021fd8c2aae3 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Thu, 28 Apr 2022 13:05:00 -0500 Subject: [PATCH] HomePage: convert to TSX --- app/soapbox/components/ui/card/card.tsx | 3 +- app/soapbox/pages/home_page.js | 123 ------------------------ app/soapbox/pages/home_page.tsx | 106 ++++++++++++++++++++ 3 files changed, 108 insertions(+), 124 deletions(-) delete mode 100644 app/soapbox/pages/home_page.js create mode 100644 app/soapbox/pages/home_page.tsx diff --git a/app/soapbox/components/ui/card/card.tsx b/app/soapbox/components/ui/card/card.tsx index 412c1985b..1c72c4841 100644 --- a/app/soapbox/components/ui/card/card.tsx +++ b/app/soapbox/components/ui/card/card.tsx @@ -20,9 +20,10 @@ interface ICard { variant?: 'rounded', size?: 'md' | 'lg' | 'xl', className?: string, + children: React.ReactNode, } -const Card: React.FC = React.forwardRef(({ children, variant, size = 'md', className, ...filteredProps }, ref: React.ForwardedRef): JSX.Element => ( +const Card = React.forwardRef(({ children, variant, size = 'md', className, ...filteredProps }, ref): JSX.Element => (
{ - const me = state.get('me'); - const soapbox = getSoapboxConfig(state); - const hasPatron = soapbox.getIn(['extensions', 'patron', 'enabled']); - const hasCrypto = typeof soapbox.getIn(['cryptoAddresses', 0, 'ticker']) === 'string'; - const cryptoLimit = soapbox.getIn(['cryptoDonatePanel', 'limit']); - const features = getFeatures(state.get('instance')); - - return { - me, - account: state.getIn(['accounts', me]), - hasPatron, - hasCrypto, - cryptoLimit, - features, - }; -}; - -export default @connect(mapStateToProps) -class HomePage extends ImmutablePureComponent { - - constructor(props) { - super(props); - this.composeBlock = React.createRef(); - } - - render() { - const { me, children, account, features, hasPatron, hasCrypto, cryptoLimit } = this.props; - - const acct = account ? account.get('acct') : ''; - - return ( - - - - - - - {me && - -
- - - - - -
-
-
} - - {children} -
- - - {!me && ( - - {Component => } - - )} - {features.trends && ( - - {Component => } - - )} - {hasPatron && ( - - {Component => } - - )} - {hasCrypto && cryptoLimit > 0 && ( - - {Component => } - - )} - - {Component => } - - {features.birthdays && ( - - {Component => } - - )} - {features.suggestions && ( - - {Component => } - - )} - - -
- ); - } - -} diff --git a/app/soapbox/pages/home_page.tsx b/app/soapbox/pages/home_page.tsx new file mode 100644 index 000000000..31b26b657 --- /dev/null +++ b/app/soapbox/pages/home_page.tsx @@ -0,0 +1,106 @@ +import React, { useRef } from 'react'; +import { Link } from 'react-router-dom'; + +import SidebarNavigation from 'soapbox/components/sidebar-navigation'; +import LinkFooter from 'soapbox/features/ui/components/link_footer'; +import { + WhoToFollowPanel, + TrendsPanel, + SignUpPanel, + PromoPanel, + FundingPanel, + CryptoDonatePanel, + BirthdayPanel, +} from 'soapbox/features/ui/util/async-components'; +import { useAppSelector, useOwnAccount, useFeatures, useSoapboxConfig } from 'soapbox/hooks'; + +import Avatar from '../components/avatar'; +import { Card, CardBody, Layout } from '../components/ui'; +import ComposeFormContainer from '../features/compose/containers/compose_form_container'; +import BundleContainer from '../features/ui/containers/bundle_container'; +// import GroupSidebarPanel from '../features/groups/sidebar_panel'; + +const HomePage: React.FC = ({ children }) => { + const me = useAppSelector(state => state.me); + const account = useOwnAccount(); + const features = useFeatures(); + const soapboxConfig = useSoapboxConfig(); + + const composeBlock = useRef(null); + + const hasPatron = soapboxConfig.extensions.getIn(['patron', 'enabled']) === true; + const hasCrypto = typeof soapboxConfig.cryptoAddresses.getIn([0, 'ticker']) === 'string'; + const cryptoLimit = soapboxConfig.cryptoDonatePanel.get('limit'); + + const acct = account ? account.acct : ''; + + return ( + + + + + + + {me && ( + + +
+ + + + + +
+
+
+ )} + + {children} +
+ + + {!me && ( + + {Component => } + + )} + {features.trends && ( + + {Component => } + + )} + {hasPatron && ( + + {Component => } + + )} + {hasCrypto && cryptoLimit && cryptoLimit > 0 && ( + + {Component => } + + )} + + {Component => } + + {features.birthdays && ( + + {Component => } + + )} + {features.suggestions && ( + + {Component => } + + )} + + +
+ ); +}; + +export default HomePage;