Skip to content
This repository has been archived by the owner on Oct 4, 2023. It is now read-only.

Commit

Permalink
Add fb share page (#3876)
Browse files Browse the repository at this point in the history
  • Loading branch information
raymondjacobson authored Aug 14, 2023
1 parent 46c33eb commit 49d1d05
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/web/src/pages/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ import { ChatPageProvider } from './chat-page/ChatPageProvider'
import { CollectiblesPlaylistPage } from './collectibles-playlist-page'
import { DeactivateAccountPage } from './deactivate-account-page/DeactivateAccountPage'
import ExploreCollectionsPage from './explore-page/ExploreCollectionsPage'
import { FbSharePage } from './fb-share-page/FbSharePage'
import FollowersPage from './followers-page/FollowersPage'
import FollowingPage from './following-page/FollowingPage'
import SettingsPage from './settings-page/SettingsPage'
Expand Down Expand Up @@ -489,6 +490,12 @@ class App extends Component {
/>
))}

<Route
exact
path={'/fb/share'}
render={(props) => <FbSharePage />}
/>

<Route
exact
path={SIGN_IN_PAGE}
Expand Down
10 changes: 10 additions & 0 deletions packages/web/src/pages/fb-share-page/FbSharePage.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.root {
background: var(--white);
border-radius: 8px;
padding: 16px;
margin: 80px;
}

.share {
margin-top: 16px;
}
48 changes: 48 additions & 0 deletions packages/web/src/pages/fb-share-page/FbSharePage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import React, { useEffect } from 'react'

import { accountSelectors } from '@audius/common'
import cn from 'classnames'

import { Text } from 'components/typography'
import { useSelector } from 'utils/reducer'

import styles from './FbSharePage.module.css'

const PUBLIC_HOSTNAME = process.env.REACT_APP_PUBLIC_HOSTNAME

const messages = {
share: 'Share your profile with your friends on Facebook!'
}

const injectScript = function () {
const scriptElement = document.createElement('script')
scriptElement.innerHTML = `(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v3.0";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));`
document.head.appendChild(scriptElement)
}

export const FbSharePage = () => {
useEffect(() => {
injectScript()
}, [])
const handle = useSelector(accountSelectors.getUserHandle)
return (
<div className={styles.root}>
<div id='fb-root'></div>
<Text>{messages.share}</Text>
{handle ? (
<div
className={cn('fb-share-button', styles.share)}
data-href={`https://${PUBLIC_HOSTNAME}/${handle}`}
data-layout='button'
data-size='large'
/>
) : null}
</div>
)
}

0 comments on commit 49d1d05

Please sign in to comment.