Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. import styled from 'styles'
  2. import { getSession, signin, signout, useSession } from 'next-auth/client'
  3. import { GetServerSideProps } from 'next'
  4. import React from 'react'
  5. export default function Sponsorware(): JSX.Element {
  6. const [session, loading] = useSession()
  7. return (
  8. <Content
  9. size={{
  10. '@sm': 'small',
  11. }}
  12. >
  13. <h1>tldraw (is sponsorware)</h1>
  14. <p>
  15. Hey, thanks for visiting <a href="https://tldraw.com/">tldraw</a>, a
  16. tiny little drawing app by{' '}
  17. <a href="https://twitter.com/steveruizok">steveruizok</a>.
  18. </p>
  19. <video autoPlay muted playsInline onClick={(e) => e.currentTarget.play()}>
  20. <source src="images/hello.mp4" type="video/mp4" />
  21. </video>
  22. <p>This project is currently: </p>
  23. <ul>
  24. <li>in development</li>
  25. <li>only available for my sponsors</li>
  26. </ul>
  27. <p>
  28. If you&apos;d like to try it out,{' '}
  29. <a
  30. href="https://github.com/sponsors/steveruizok"
  31. target="_blank"
  32. rel="noopener noreferrer"
  33. >
  34. sponsor me on Github
  35. </a>{' '}
  36. (at $1 or more) and sign in below.
  37. </p>
  38. <ButtonGroup>
  39. {session ? (
  40. <>
  41. <Button onClick={() => signout()} variant={'secondary'}>
  42. Sign Out
  43. </Button>
  44. <Detail>
  45. Signed in as {session?.user?.name} ({session?.user?.email}), but
  46. it looks like you&apos;re not yet a sponsor.
  47. <br />
  48. Something wrong? Try <a href="/">reloading the page</a> or DM me
  49. on <a href="https://twitter.com/steveruizok">Twitter</a>.
  50. </Detail>
  51. </>
  52. ) : (
  53. <>
  54. <Button onClick={() => signin('github')} variant={'primary'}>
  55. {loading ? 'Loading...' : 'Sign in With Github'}
  56. </Button>
  57. <Detail>Already a sponsor? Just sign in to visit the app.</Detail>
  58. </>
  59. )}
  60. </ButtonGroup>
  61. </Content>
  62. )
  63. }
  64. export const getServerSideProps: GetServerSideProps = async (context) => {
  65. const session = await getSession(context)
  66. if (session?.user) {
  67. context.res.setHeader('Location', `/`)
  68. context.res.statusCode = 307
  69. }
  70. return {
  71. props: {
  72. session,
  73. },
  74. }
  75. }
  76. const Content = styled('div', {
  77. width: '720px',
  78. maxWidth: '100%',
  79. backgroundColor: '$panel',
  80. margin: '32px auto',
  81. borderRadius: '0px',
  82. boxShadow: '0px 2px 24px rgba(0,0,0,.08), 0px 2px 4px rgba(0,0,0,.16)',
  83. padding: '16px',
  84. overflow: 'hidden',
  85. color: '$text',
  86. fontSize: '$2',
  87. fontFamily: '$body',
  88. lineHeight: 1.5,
  89. '& a': {
  90. color: '$bounds',
  91. backgroundColor: '$boundsBg',
  92. padding: '2px 4px',
  93. margin: '0 -3px',
  94. borderRadius: '2px',
  95. },
  96. '& p': {
  97. borderRadius: '8px',
  98. },
  99. '& video': {
  100. maxWidth: '100%',
  101. border: '1px solid $overlay',
  102. borderRadius: '4px',
  103. overflow: 'hidden',
  104. margin: '16px 0',
  105. },
  106. '& iframe': {
  107. border: 'none',
  108. backgroundColor: 'none',
  109. background: 'none',
  110. },
  111. variants: {
  112. size: {
  113. small: {
  114. fontSize: '$3',
  115. padding: '32px',
  116. },
  117. },
  118. },
  119. })
  120. const ButtonGroup = styled('div', {
  121. display: 'grid',
  122. gap: '16px',
  123. margin: '40px 0 32px 0',
  124. })
  125. const Detail = styled('p', {
  126. fontSize: '$2',
  127. textAlign: 'center',
  128. })
  129. const Button = styled('button', {
  130. cursor: 'pointer',
  131. width: '100%',
  132. padding: '12px 0',
  133. display: 'flex',
  134. alignItems: 'center',
  135. justifyContent: 'center',
  136. font: '$ui',
  137. fontSize: '$3',
  138. color: '$panel',
  139. border: 'none',
  140. borderRadius: '4px',
  141. variants: {
  142. variant: {
  143. primary: {
  144. fontWeight: 'bold',
  145. background: '$bounds',
  146. color: '$panel',
  147. boxShadow: '0px 2px 4px rgba(0,0,0,.2)',
  148. },
  149. secondary: {
  150. border: '1px solid $overlay',
  151. background: 'transparent',
  152. color: '$muted',
  153. },
  154. },
  155. },
  156. })