您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

sponsorware.tsx 3.6KB

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