Skip to content

Commit

Permalink
Revert ":fire: Remove unnecessary UI files (#13)" (#15)
Browse files Browse the repository at this point in the history
This reverts commit f5e0976.
  • Loading branch information
realjoshuau committed Nov 18, 2023
1 parent f5e0976 commit 99bf3d7
Show file tree
Hide file tree
Showing 7 changed files with 373 additions and 0 deletions.
58 changes: 58 additions & 0 deletions apps/web/components/Code.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
'use client'

import { useState } from 'react'

const CopyIcon = () => (
<svg
xmlns="http://www.w3.org/2000/svg"
width="20"
height="20"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
>
<rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect>
<path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path>
</svg>
)

const CheckIcon = () => (
<svg
xmlns="http://www.w3.org/2000/svg"
width="20"
height="20"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
>
<polyline points="20 6 9 17 4 12"></polyline>
</svg>
)

export default function Code({ code }: { code: string }) {
const [icon, setIcon] = useState(CopyIcon)

const copy = async () => {
await navigator?.clipboard?.writeText(code)
setIcon(CheckIcon)
setTimeout(() => setIcon(CopyIcon), 2000)
}

return (
<pre className="bg-foreground/5 rounded-md p-8 my-8 relative">
<button
onClick={copy}
className="absolute top-4 right-4 p-2 rounded-md bg-foreground/5 hover:bg-foreground/10"
>
{icon}
</button>
<code>{code}</code>
</pre>
)
}
62 changes: 62 additions & 0 deletions apps/web/components/ConnectSupabaseSteps.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import Step from './Step'

export default function ConnectSupabaseSteps() {
return (
<ol className="flex flex-col gap-6">
<Step title="Create Supabase project">
<p>
Head over to{' '}
<a
href="https://app.supabase.com/project/_/settings/api"
target="_blank"
className="font-bold hover:underline text-foreground/80"
rel="noreferrer"
>
database.new
</a>{' '}
and create a new Supabase project.
</p>
</Step>

<Step title="Declare environment variables">
<p>
Rename the{' '}
<span className="px-2 py-1 rounded-md bg-foreground/20 text-foreground/80">
.env.example
</span>{' '}
file in your Next.js app to{' '}
<span className="px-2 py-1 rounded-md bg-foreground/20 text-foreground/80">
.env.local
</span>{' '}
and populate with values from{' '}
<a
href="https://app.supabase.com/project/_/settings/api"
target="_blank"
className="font-bold hover:underline text-foreground/80"
rel="noreferrer"
>
your Supabase project's API Settings
</a>
.
</p>
</Step>

<Step title="Restart your Next.js development server">
<p>
You may need to quit your Next.js development server and run{' '}
<span className="px-2 py-1 rounded-md bg-foreground/20 text-foreground/80">
npm run dev
</span>{' '}
again to load the new environment variables.
</p>
</Step>

<Step title="Refresh the page">
<p>
You may need to refresh the page for Next.js to load the new
environment variables.
</p>
</Step>
</ol>
)
}
23 changes: 23 additions & 0 deletions apps/web/components/DeployButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
export default function DeployButton() {
return (
<a
className="py-2 px-3 flex rounded-md no-underline hover:bg-btn-background-hover border"
href="https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fvercel%2Fnext.js%2Ftree%2Fcanary%2Fexamples%2Fwith-supabase&project-name=nextjs-with-supabase&repository-name=nextjs-with-supabase&demo-title=nextjs-with-supabase&demo-description=This%20starter%20configures%20Supabase%20Auth%20to%20use%20cookies%2C%20making%20the%20user's%20session%20available%20throughout%20the%20entire%20Next.js%20app%20-%20Client%20Components%2C%20Server%20Components%2C%20Route%20Handlers%2C%20Server%20Actions%20and%20Middleware.&demo-url=https%3A%2F%2Fdemo-nextjs-with-supabase.vercel.app%2F&external-id=https%3A%2F%2Fgithub.com%2Fvercel%2Fnext.js%2Ftree%2Fcanary%2Fexamples%2Fwith-supabase&demo-image=https%3A%2F%2Fdemo-nextjs-with-supabase.vercel.app%2Fopengraph-image.png&integration-ids=oac_VqOgBHqhEoFTPzGkPd7L0iH6"
target="_blank"
rel="noreferrer"
>
<svg
aria-label="Vercel logomark"
role="img"
viewBox="0 0 74 64"
className="h-4 w-4 mr-2"
>
<path
d="M37.5896 0.25L74.5396 64.25H0.639648L37.5896 0.25Z"
fill="currentColor"
></path>
</svg>
Deploy to Vercel
</a>
)
}
44 changes: 44 additions & 0 deletions apps/web/components/Header.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import NextLogo from './NextLogo'
import SupabaseLogo from './SupabaseLogo'

export default function Header() {
return (
<div className="flex flex-col gap-16 items-center">
<div className="flex gap-8 justify-center items-center">
<a
href="https://supabase.com/?utm_source=create-next-app&utm_medium=template&utm_term=nextjs"
target="_blank"
rel="noreferrer"
>
<SupabaseLogo />
</a>
<span className="border-l rotate-45 h-6" />
<a href="https://nextjs.org/" target="_blank" rel="noreferrer">
<NextLogo />
</a>
</div>
<h1 className="sr-only">Supabase and Next.js Starter Template</h1>
<p className="text-3xl lg:text-4xl !leading-tight mx-auto max-w-xl text-center">
The fastest way to build apps with{' '}
<a
href="https://supabase.com/?utm_source=create-next-app&utm_medium=template&utm_term=nextjs"
target="_blank"
className="font-bold hover:underline"
rel="noreferrer"
>
Supabase
</a>{' '}
and{' '}
<a
href="https://nextjs.org/"
target="_blank"
className="font-bold hover:underline"
rel="noreferrer"
>
Next.js
</a>
</p>
<div className="w-full p-[1px] bg-gradient-to-r from-transparent via-foreground/10 to-transparent my-8" />
</div>
)
}
46 changes: 46 additions & 0 deletions apps/web/components/NextLogo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
export default function NextLogo() {
return (
<svg
aria-label="Next.js logotype"
height="68"
role="img"
viewBox="0 0 394 79"
width="100"
>
<path
d="M261.919 0.0330722H330.547V12.7H303.323V79.339H289.71V12.7H261.919V0.0330722Z"
fill="currentColor"
/>
<path
d="M149.052 0.0330722V12.7H94.0421V33.0772H138.281V45.7441H94.0421V66.6721H149.052V79.339H80.43V12.7H80.4243V0.0330722H149.052Z"
fill="currentColor"
/>
<path
d="M183.32 0.0661486H165.506L229.312 79.3721H247.178L215.271 39.7464L247.127 0.126654L229.312 0.154184L206.352 28.6697L183.32 0.0661486Z"
fill="currentColor"
/>
<path
d="M201.6 56.7148L192.679 45.6229L165.455 79.4326H183.32L201.6 56.7148Z"
fill="currentColor"
/>
<path
clipRule="evenodd"
d="M80.907 79.339L17.0151 0H0V79.3059H13.6121V16.9516L63.8067 79.339H80.907Z"
fill="currentColor"
fillRule="evenodd"
/>
<path
d="M333.607 78.8546C332.61 78.8546 331.762 78.5093 331.052 77.8186C330.342 77.1279 329.991 76.2917 330 75.3011C329.991 74.3377 330.342 73.5106 331.052 72.8199C331.762 72.1292 332.61 71.7838 333.607 71.7838C334.566 71.7838 335.405 72.1292 336.115 72.8199C336.835 73.5106 337.194 74.3377 337.204 75.3011C337.194 75.9554 337.028 76.5552 336.696 77.0914C336.355 77.6368 335.922 78.064 335.377 78.373C334.842 78.6911 334.252 78.8546 333.607 78.8546Z"
fill="currentColor"
/>
<path
d="M356.84 45.4453H362.872V68.6846C362.863 70.8204 362.401 72.6472 361.498 74.1832C360.585 75.7191 359.321 76.8914 357.698 77.7185C356.084 78.5364 354.193 78.9546 352.044 78.9546C350.079 78.9546 348.318 78.6001 346.75 77.9094C345.182 77.2187 343.937 76.1826 343.024 74.8193C342.101 73.456 341.649 71.7565 341.649 69.7207H347.691C347.7 70.6114 347.903 71.3838 348.29 72.0291C348.677 72.6744 349.212 73.1651 349.895 73.5105C350.586 73.8559 351.38 74.0286 352.274 74.0286C353.243 74.0286 354.073 73.8286 354.746 73.4196C355.419 73.0197 355.936 72.4199 356.296 71.6201C356.646 70.8295 356.831 69.8479 356.84 68.6846V45.4453Z"
fill="currentColor"
/>
<path
d="M387.691 54.5338C387.544 53.1251 386.898 52.0254 385.773 51.2438C384.638 50.4531 383.172 50.0623 381.373 50.0623C380.11 50.0623 379.022 50.2532 378.118 50.6258C377.214 51.0075 376.513 51.5164 376.033 52.1617C375.554 52.807 375.314 53.5432 375.295 54.3703C375.295 55.061 375.461 55.6608 375.784 56.1607C376.107 56.6696 376.54 57.0968 377.103 57.4422C377.656 57.7966 378.274 58.0874 378.948 58.3237C379.63 58.56 380.313 58.76 380.995 58.9236L384.14 59.6961C385.404 59.9869 386.631 60.3778 387.802 60.8776C388.973 61.3684 390.034 61.9955 390.965 62.7498C391.897 63.5042 392.635 64.413 393.179 65.4764C393.723 66.5397 394 67.7848 394 69.2208C394 71.1566 393.502 72.8562 392.496 74.3285C391.491 75.7917 390.043 76.9369 388.143 77.764C386.252 78.582 383.965 79 381.272 79C378.671 79 376.402 78.6002 374.493 77.8004C372.575 77.0097 371.08 75.8463 370.001 74.3194C368.922 72.7926 368.341 70.9294 368.258 68.7391H374.235C374.318 69.8842 374.687 70.8386 375.314 71.6111C375.95 72.3745 376.78 72.938 377.795 73.3197C378.819 73.6923 379.962 73.8832 381.226 73.8832C382.545 73.8832 383.707 73.6832 384.712 73.2924C385.708 72.9016 386.492 72.3564 387.055 71.6475C387.627 70.9476 387.913 70.1206 387.922 69.1754C387.913 68.312 387.654 67.5939 387.156 67.0304C386.649 66.467 385.948 65.9944 385.053 65.6127C384.15 65.231 383.098 64.8856 381.899 64.5857L378.081 63.6223C375.323 62.9225 373.137 61.8592 371.541 60.4323C369.937 59.0054 369.143 57.115 369.143 54.7429C369.143 52.798 369.678 51.0894 370.758 49.6261C371.827 48.1629 373.294 47.0268 375.148 46.2179C377.011 45.4 379.114 45 381.456 45C383.836 45 385.92 45.4 387.719 46.2179C389.517 47.0268 390.929 48.1538 391.952 49.5897C392.976 51.0257 393.511 52.6707 393.539 54.5338H387.691Z"
fill="currentColor"
/>
</svg>
)
}
116 changes: 116 additions & 0 deletions apps/web/components/SignUpUserSteps.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
import Link from 'next/link'
import Step from './Step'
import Code from '@/components/Code'

const create = `
create table notes (
id serial primary key,
title text
);
insert into notes(title)
values
('Today I created a Supabase project.'),
('I added some data and queried it from Next.js.'),
('It was awesome!');
`.trim()

const server = `
import { createClient } from '@/utils/supabase/server'
import { cookies } from 'next/headers'
export default async function Page() {
const cookieStore = cookies()
const supabase = createClient(cookieStore)
const { data: notes } = await supabase.from('notes').select()
return <pre>{JSON.stringify(notes, null, 2)}</pre>
}
`.trim()

const client = `
'use client'
import { createClient } from '@/utils/supabase/client'
import { useEffect, useState } from 'react'
export default function Page() {
const [notes, setNotes] = useState<any[] | null>(null)
const supabase = createClient()
useEffect(() => {
const getData = async () => {
const { data } = await supabase.from('notes').select()
setNotes(data)
}
getData()
}, [])
return <pre>{JSON.stringify(notes, null, 2)}</pre>
}
`.trim()

export default function SignUpUserSteps() {
return (
<ol className="flex flex-col gap-6">
<Step title="Sign up your first user">
<p>
Head over to the{' '}
<Link
href="/login"
className="font-bold hover:underline text-foreground/80"
>
Login
</Link>{' '}
page and sign up your first user. It's okay if this is just you for
now. Your awesome idea will have plenty of users later!
</p>
</Step>

<Step title="Create some tables and insert some data">
<p>
Head over to the{' '}
<a
href="https://supabase.com/dashboard/project/_/editor"
className="font-bold hover:underline text-foreground/80"
target="_blank"
rel="noreferrer"
>
Table Editor
</a>{' '}
for your Supabase project to create a table and insert some example
data. If you're stuck for creativity, you can copy and paste the
following into the{' '}
<a
href="https://supabase.com/dashboard/project/_/sql/new"
className="font-bold hover:underline text-foreground/80"
target="_blank"
rel="noreferrer"
>
SQL Editor
</a>{' '}
and click RUN!
</p>
<Code code={create} />
</Step>

<Step title="Query Supabase data from Next.js">
<p>
To create a Supabase client and query data from an Async Server
Component, create a new page.tsx file at{' '}
<span className="px-2 py-1 rounded-md bg-foreground/20 text-foreground/80">
/app/notes/page.tsx
</span>{' '}
and add the following.
</p>
<Code code={server} />
<p>Alternatively, you can use a Client Component.</p>
<Code code={client} />
</Step>

<Step title="Build in a weekend and scale to millions!">
<p>You're ready to launch your product to the world! 🚀</p>
</Step>
</ol>
)
}
24 changes: 24 additions & 0 deletions apps/web/components/Step.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
export default function Step({
title,
children,
}: {
title: string
children: React.ReactNode
}) {
return (
<li className="mx-4">
<input type="checkbox" id={title} className={`mr-2 peer`} />
<label
htmlFor={title}
className={`text-lg text-foreground/90 peer-checked:line-through font-semibold hover:cursor-pointer`}
>
{title}
</label>
<div
className={`mx-6 text-foreground/80 text-sm peer-checked:line-through`}
>
{children}
</div>
</li>
)
}

0 comments on commit 99bf3d7

Please sign in to comment.