Steve Ruiz 4 роки тому
джерело
коміт
8a0f355e00
9 змінених файлів з 141 додано та 29 видалено
  1. 2
    2
      components/editor.tsx
  2. 1
    0
      package.json
  3. 1
    0
      pages/_app.tsx
  4. 18
    0
      pages/index.tsx
  5. 10
    0
      pages/signout.tsx
  6. 92
    27
      pages/sponsorware.tsx
  7. BIN
      public/flat.png
  8. 2
    0
      styles/stitches.config.ts
  9. 15
    0
      yarn.lock

+ 2
- 2
components/editor.tsx Переглянути файл

6
 import StylePanel from './style-panel/style-panel'
6
 import StylePanel from './style-panel/style-panel'
7
 import styled from 'styles'
7
 import styled from 'styles'
8
 import PagePanel from './page-panel/page-panel'
8
 import PagePanel from './page-panel/page-panel'
9
-import dynamic from 'next/dynamic'
10
-import ControlsPanel from './controls-panel/controls-panel'
9
+// import dynamic from 'next/dynamic'
10
+// import ControlsPanel from './controls-panel/controls-panel'
11
 // import { useSelector } from 'state'
11
 // import { useSelector } from 'state'
12
 // const CodePanel = dynamic(() => import('./code-panel/code-panel'))
12
 // const CodePanel = dynamic(() => import('./code-panel/code-panel'))
13
 
13
 

+ 1
- 0
package.json Переглянути файл

13
     "@radix-ui/react-context-menu": "^0.0.21",
13
     "@radix-ui/react-context-menu": "^0.0.21",
14
     "@radix-ui/react-dialog": "^0.0.18",
14
     "@radix-ui/react-dialog": "^0.0.18",
15
     "@radix-ui/react-dropdown-menu": "^0.0.20",
15
     "@radix-ui/react-dropdown-menu": "^0.0.20",
16
+    "@radix-ui/react-hover-card": "^0.0.3",
16
     "@radix-ui/react-icons": "^1.0.3",
17
     "@radix-ui/react-icons": "^1.0.3",
17
     "@radix-ui/react-radio-group": "^0.0.17",
18
     "@radix-ui/react-radio-group": "^0.0.17",
18
     "@radix-ui/react-tooltip": "^0.0.19",
19
     "@radix-ui/react-tooltip": "^0.0.19",

+ 1
- 0
pages/_app.tsx Переглянути файл

6
 
6
 
7
 function MyApp({ Component, pageProps }: AppProps) {
7
 function MyApp({ Component, pageProps }: AppProps) {
8
   globalStyles()
8
   globalStyles()
9
+
9
   useGtag()
10
   useGtag()
10
 
11
 
11
   return (
12
   return (

+ 18
- 0
pages/index.tsx Переглянути файл

1
 // import Editor from "components/editor"
1
 // import Editor from "components/editor"
2
 import Head from 'next/head'
2
 import Head from 'next/head'
3
 import dynamic from 'next/dynamic'
3
 import dynamic from 'next/dynamic'
4
+import { GetServerSideProps } from 'next'
5
+import { getSession } from 'next-auth/client'
6
+
4
 const Editor = dynamic(() => import('components/editor'), { ssr: false })
7
 const Editor = dynamic(() => import('components/editor'), { ssr: false })
5
 
8
 
6
 export default function Home() {
9
 export default function Home() {
13
     </>
16
     </>
14
   )
17
   )
15
 }
18
 }
19
+
20
+export const getServerSideProps: GetServerSideProps = async (context) => {
21
+  const session = await getSession(context)
22
+
23
+  if (!session?.user) {
24
+    context.res.setHeader('Location', `/sponsorware`)
25
+    context.res.statusCode = 307
26
+  }
27
+
28
+  return {
29
+    props: {
30
+      session,
31
+    },
32
+  }
33
+}

+ 10
- 0
pages/signout.tsx Переглянути файл

1
+import { GetServerSideProps, NextApiRequest, NextApiResponse } from 'next'
2
+import { signOut, signout } from 'next-auth/client'
3
+
4
+export default function SignOut() {
5
+  return (
6
+    <div>
7
+      <button onClick={() => signOut()}>Sign Out</button>
8
+    </div>
9
+  )
10
+}

+ 92
- 27
pages/sponsorware.tsx Переглянути файл

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

BIN
public/flat.png Переглянути файл


+ 2
- 0
styles/stitches.config.ts Переглянути файл

20
       inactive: '#cccccf',
20
       inactive: '#cccccf',
21
       hover: '#efefef',
21
       hover: '#efefef',
22
       text: '#333',
22
       text: '#333',
23
+      muted: '#777',
23
       input: '#f3f3f3',
24
       input: '#f3f3f3',
24
       inputBorder: '#ddd',
25
       inputBorder: '#ddd',
25
     },
26
     },
95
     overscrollBehavior: 'none',
96
     overscrollBehavior: 'none',
96
     fontFamily: '$ui',
97
     fontFamily: '$ui',
97
     fontSize: '$2',
98
     fontSize: '$2',
99
+    backgroundColor: '$canvas',
98
   },
100
   },
99
 })
101
 })
100
 
102
 

+ 15
- 0
yarn.lock Переглянути файл

1731
     "@radix-ui/react-primitive" "0.0.14"
1731
     "@radix-ui/react-primitive" "0.0.14"
1732
     "@radix-ui/react-use-callback-ref" "0.0.5"
1732
     "@radix-ui/react-use-callback-ref" "0.0.5"
1733
 
1733
 
1734
+"@radix-ui/react-hover-card@^0.0.3":
1735
+  version "0.0.3"
1736
+  resolved "https://registry.yarnpkg.com/@radix-ui/react-hover-card/-/react-hover-card-0.0.3.tgz#fb219ea72ddfa60fd3307820f025d353b5a0b8cd"
1737
+  integrity sha512-/bq0SuD0al81wMstd168Hx2UQFpGqaWeSIoKK38EOP78bRGmlXQYh3n608uBvK/eCZrCqgnUIUwFtKSqYVlyxQ==
1738
+  dependencies:
1739
+    "@babel/runtime" "^7.13.10"
1740
+    "@radix-ui/primitive" "0.0.5"
1741
+    "@radix-ui/react-context" "0.0.5"
1742
+    "@radix-ui/react-polymorphic" "0.0.12"
1743
+    "@radix-ui/react-popper" "0.0.17"
1744
+    "@radix-ui/react-portal" "0.0.14"
1745
+    "@radix-ui/react-presence" "0.0.14"
1746
+    "@radix-ui/react-primitive" "0.0.14"
1747
+    "@radix-ui/react-use-controllable-state" "0.0.6"
1748
+
1734
 "@radix-ui/react-icons@^1.0.3":
1749
 "@radix-ui/react-icons@^1.0.3":
1735
   version "1.0.3"
1750
   version "1.0.3"
1736
   resolved "https://registry.yarnpkg.com/@radix-ui/react-icons/-/react-icons-1.0.3.tgz#4ef61f1234f44991f7a19e108f77ca37032b4be2"
1751
   resolved "https://registry.yarnpkg.com/@radix-ui/react-icons/-/react-icons-1.0.3.tgz#4ef61f1234f44991f7a19e108f77ca37032b4be2"

Завантаження…
Відмінити
Зберегти