tldraw/pages/sponsorware.tsx

172 lines
3.9 KiB
TypeScript
Raw Normal View History

2021-06-20 10:56:43 +00:00
import styled from 'styles'
2021-06-20 12:35:47 +00:00
import { getSession, signin, signout, useSession } from 'next-auth/client'
import { GetServerSideProps } from 'next'
import React from 'react'
2021-06-20 10:56:43 +00:00
2021-06-21 21:35:28 +00:00
export default function Sponsorware(): JSX.Element {
2021-06-20 10:56:43 +00:00
const [session, loading] = useSession()
2021-06-19 20:18:14 +00:00
return (
2021-06-20 12:48:10 +00:00
<Content
size={{
'@sm': 'small',
}}
>
2021-06-20 12:35:47 +00:00
<h1>tldraw (is sponsorware)</h1>
2021-06-20 10:56:43 +00:00
<p>
Hey, thanks for visiting <a href="https://tldraw.com/">tldraw</a>, a
tiny little drawing app by{' '}
<a href="https://twitter.com/steveruizok">steveruizok</a>.
</p>
2021-06-20 12:48:10 +00:00
<video autoPlay muted playsInline onClick={(e) => e.currentTarget.play()}>
<source src="images/hello.mp4" type="video/mp4" />
</video>
2021-06-20 12:35:47 +00:00
<p>This project is currently: </p>
<ul>
<li>in development</li>
<li>only available for my sponsors</li>
</ul>
2021-06-20 10:56:43 +00:00
<p>
2021-06-21 21:35:28 +00:00
If you&apos;d like to try it out,{' '}
2021-06-20 10:56:43 +00:00
<a
href="https://github.com/sponsors/steveruizok"
target="_blank"
rel="noopener noreferrer"
>
sponsor me on Github
</a>{' '}
(at $1 or more) and sign in below.
</p>
2021-06-20 12:35:47 +00:00
<ButtonGroup>
{session ? (
<>
<Button onClick={() => signout()} variant={'secondary'}>
Sign Out
</Button>
<Detail>
Signed in as {session?.user?.name} ({session?.user?.email}), but
2021-06-21 21:35:28 +00:00
it looks like you&apos;re not yet a sponsor.
2021-06-20 12:35:47 +00:00
<br />
Something wrong? Try <a href="/">reloading the page</a> or DM me
on <a href="https://twitter.com/steveruizok">Twitter</a>.
</Detail>
</>
) : (
<>
<Button onClick={() => signin('github')} variant={'primary'}>
{loading ? 'Loading...' : 'Sign in With Github'}
</Button>
<Detail>Already a sponsor? Just sign in to visit the app.</Detail>
</>
)}
</ButtonGroup>
2021-06-20 10:56:43 +00:00
</Content>
2021-06-19 20:18:14 +00:00
)
}
2021-06-20 10:56:43 +00:00
2021-06-20 12:35:47 +00:00
export const getServerSideProps: GetServerSideProps = async (context) => {
const session = await getSession(context)
2021-06-21 21:35:28 +00:00
if (session?.user) {
context.res.setHeader('Location', `/`)
context.res.statusCode = 307
}
2021-06-20 12:35:47 +00:00
return {
props: {
session,
},
}
}
2021-06-20 10:56:43 +00:00
const Content = styled('div', {
width: '720px',
2021-06-20 12:48:10 +00:00
maxWidth: '100%',
2021-06-20 10:56:43 +00:00
backgroundColor: '$panel',
2021-06-20 12:35:47 +00:00
margin: '32px auto',
2021-06-20 12:48:10 +00:00
borderRadius: '0px',
2021-06-20 12:35:47 +00:00
boxShadow: '0px 2px 24px rgba(0,0,0,.08), 0px 2px 4px rgba(0,0,0,.16)',
2021-06-20 12:48:10 +00:00
padding: '16px',
2021-06-20 10:56:43 +00:00
overflow: 'hidden',
color: '$text',
2021-06-20 12:48:10 +00:00
fontSize: '$2',
2021-06-20 12:35:47 +00:00
fontFamily: '$body',
lineHeight: 1.5,
2021-06-20 10:56:43 +00:00
'& a': {
color: '$bounds',
backgroundColor: '$boundsBg',
padding: '2px 4px',
margin: '0 -3px',
borderRadius: '2px',
},
2021-06-20 12:48:10 +00:00
'& p': {
borderRadius: '8px',
},
2021-06-20 10:56:43 +00:00
'& video': {
maxWidth: '100%',
2021-06-20 12:35:47 +00:00
border: '1px solid $overlay',
2021-06-20 10:56:43 +00:00
borderRadius: '4px',
overflow: 'hidden',
margin: '16px 0',
},
2021-06-20 12:35:47 +00:00
'& iframe': {
border: 'none',
backgroundColor: 'none',
background: 'none',
},
2021-06-20 12:48:10 +00:00
variants: {
size: {
small: {
fontSize: '$3',
padding: '32px',
},
},
},
2021-06-20 12:35:47 +00:00
})
const ButtonGroup = styled('div', {
display: 'grid',
gap: '16px',
margin: '40px 0 32px 0',
})
const Detail = styled('p', {
fontSize: '$2',
textAlign: 'center',
2021-06-20 10:56:43 +00:00
})
const Button = styled('button', {
2021-06-20 12:35:47 +00:00
cursor: 'pointer',
2021-06-20 10:56:43 +00:00
width: '100%',
padding: '12px 0',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
font: '$ui',
fontSize: '$3',
color: '$panel',
border: 'none',
2021-06-20 12:35:47 +00:00
borderRadius: '4px',
variants: {
variant: {
primary: {
fontWeight: 'bold',
background: '$bounds',
color: '$panel',
boxShadow: '0px 2px 4px rgba(0,0,0,.2)',
},
secondary: {
border: '1px solid $overlay',
background: 'transparent',
color: '$muted',
},
},
},
2021-06-20 10:56:43 +00:00
})