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,8 +6,8 @@ import ToolsPanel from './tools-panel/tools-panel'
6 6
 import StylePanel from './style-panel/style-panel'
7 7
 import styled from 'styles'
8 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 11
 // import { useSelector } from 'state'
12 12
 // const CodePanel = dynamic(() => import('./code-panel/code-panel'))
13 13
 

+ 1
- 0
package.json Прегледај датотеку

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

+ 1
- 0
pages/_app.tsx Прегледај датотеку

@@ -6,6 +6,7 @@ import { Provider } from 'next-auth/client'
6 6
 
7 7
 function MyApp({ Component, pageProps }: AppProps) {
8 8
   globalStyles()
9
+
9 10
   useGtag()
10 11
 
11 12
   return (

+ 18
- 0
pages/index.tsx Прегледај датотеку

@@ -1,6 +1,9 @@
1 1
 // import Editor from "components/editor"
2 2
 import Head from 'next/head'
3 3
 import dynamic from 'next/dynamic'
4
+import { GetServerSideProps } from 'next'
5
+import { getSession } from 'next-auth/client'
6
+
4 7
 const Editor = dynamic(() => import('components/editor'), { ssr: false })
5 8
 
6 9
 export default function Home() {
@@ -13,3 +16,18 @@ 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 Прегледај датотеку

@@ -0,0 +1,10 @@
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,26 +1,25 @@
1 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 6
 export default function Sponsorware() {
5 7
   const [session, loading] = useSession()
6 8
 
7 9
   return (
8 10
     <Content>
9
-      <h1>tldraw is sponsorware</h1>
10
-      <video src="images/hello.mp4" autoPlay muted loop />
11
+      <h1>tldraw (is sponsorware)</h1>
11 12
       <p>
12 13
         Hey, thanks for visiting <a href="https://tldraw.com/">tldraw</a>, a
13 14
         tiny little drawing app by{' '}
14 15
         <a href="https://twitter.com/steveruizok">steveruizok</a>.
15 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 23
       <p>
25 24
         If you'd like to try it out,{' '}
26 25
         <a
@@ -32,23 +31,61 @@ export default function Sponsorware() {
32 31
         </a>{' '}
33 32
         (at $1 or more) and sign in below.
34 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 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 76
 const Content = styled('div', {
43 77
   width: '720px',
44 78
   maxWidth: 'calc(100% - 16px)',
45 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 84
   overflow: 'hidden',
51 85
   color: '$text',
86
+  fontSize: '$3',
87
+  fontFamily: '$body',
88
+  lineHeight: 1.5,
52 89
 
53 90
   '& a': {
54 91
     color: '$bounds',
@@ -58,32 +95,60 @@ const Content = styled('div', {
58 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 100
   '& video': {
68 101
     maxWidth: '100%',
69
-    boxShadow: '0px 2px 4px rgba(0,0,0,.2)',
102
+    border: '1px solid $overlay',
70 103
     borderRadius: '4px',
71 104
     overflow: 'hidden',
72 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 126
 const Button = styled('button', {
127
+  cursor: 'pointer',
77 128
   width: '100%',
78 129
   padding: '12px 0',
79 130
   display: 'flex',
80 131
   alignItems: 'center',
81 132
   justifyContent: 'center',
82 133
   font: '$ui',
83
-  fontWeight: 'bold',
84 134
   fontSize: '$3',
85
-  background: '$bounds',
86 135
   color: '$panel',
87 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
 })


+ 2
- 0
styles/stitches.config.ts Прегледај датотеку

@@ -20,6 +20,7 @@ const { styled, global, css, theme, getCssString } = createCss({
20 20
       inactive: '#cccccf',
21 21
       hover: '#efefef',
22 22
       text: '#333',
23
+      muted: '#777',
23 24
       input: '#f3f3f3',
24 25
       inputBorder: '#ddd',
25 26
     },
@@ -95,6 +96,7 @@ const globalStyles = global({
95 96
     overscrollBehavior: 'none',
96 97
     fontFamily: '$ui',
97 98
     fontSize: '$2',
99
+    backgroundColor: '$canvas',
98 100
   },
99 101
 })
100 102
 

+ 15
- 0
yarn.lock Прегледај датотеку

@@ -1731,6 +1731,21 @@
1731 1731
     "@radix-ui/react-primitive" "0.0.14"
1732 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 1749
 "@radix-ui/react-icons@^1.0.3":
1735 1750
   version "1.0.3"
1736 1751
   resolved "https://registry.yarnpkg.com/@radix-ui/react-icons/-/react-icons-1.0.3.tgz#4ef61f1234f44991f7a19e108f77ca37032b4be2"

Loading…
Откажи
Сачувај