Skip to content

Commit

Permalink
lint fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed Jun 29, 2023
1 parent f887a3d commit 2f0bfb8
Show file tree
Hide file tree
Showing 7 changed files with 220 additions and 99 deletions.
6 changes: 3 additions & 3 deletions examples/with-supabase/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
@keyframes animateIn {
from {
opacity: 0;
transform: translateY(10px)
transform: translateY(10px);
}
to {
opacity: 1;
transform: translateY(0)
transform: translateY(0);
}
}
}
11 changes: 8 additions & 3 deletions examples/with-supabase/app/login/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ export default function Login() {

return (
<div className="flex-1 flex flex-col w-full px-8 sm:max-w-md justify-center gap-2">
<Link href="/" className='absolute left-8 top-8 py-2 px-4 rounded-md no-underline text-foreground bg-btn-background hover:bg-btn-background-hover flex items-center group text-sm'>
<Link
href="/"
className="absolute left-8 top-8 py-2 px-4 rounded-md no-underline text-foreground bg-btn-background hover:bg-btn-background-hover flex items-center group text-sm"
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
Expand All @@ -50,11 +53,13 @@ export default function Login() {
className="mr-2 h-4 w-4 transition-transform group-hover:-translate-x-1"
>
<polyline points="15 18 9 12 15 6" />
</svg> Back
</svg>{' '}
Back
</Link>
{view === 'check-email' ? (
<p className="text-center text-foreground">
Check <span className="font-bold">{email}</span> to continue signing up
Check <span className="font-bold">{email}</span> to continue signing
up
</p>
) : (
<form
Expand Down
118 changes: 67 additions & 51 deletions examples/with-supabase/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,39 @@ import LogoutButton from '../components/LogoutButton'
import SupabaseLogo from '../components/SupabaseLogo'
import NextJsLogo from '../components/NextJsLogo'

const resources = [
{
title: 'Cookie-based Auth and the Next.js App Router',
subtitle:
'This free course by Jon Meyers, shows you how to configure Supabase Auth to use cookies, and steps through some common patterns.',
url: 'https://youtube.com/playlist?list=PL5S4mPUpp4OtMhpnp93EFSo42iQ40XjbF',
icon: 'M7 4V20M17 4V20M3 8H7M17 8H21M3 12H21M3 16H7M17 16H21M4 20H20C20.5523 20 21 19.5523 21 19V5C21 4.44772 20.5523 4 20 4H4C3.44772 4 3 4.44772 3 5V19C3 19.5523 3.44772 20 4 20Z',
},
{
title: 'Supabase Next.js App Router Example',
subtitle:
'Want to see a code example containing some common patterns with Next.js and Supabase? Check out this repo!',
url: 'https://github.com/supabase/supabase/tree/master/examples/auth/nextjs',
icon: 'M10 20L14 4M18 8L22 12L18 16M6 16L2 12L6 8',
},
{
title: 'Supabase Auth Helpers Docs',
subtitle:
'This template has configured Supabase Auth to use cookies for you, but the docs are a great place to learn more.',
url: 'https://supabase.com/docs/guides/auth/auth-helpers/nextjs',
icon: 'M12 6.25278V19.2528M12 6.25278C10.8321 5.47686 9.24649 5 7.5 5C5.75351 5 4.16789 5.47686 3 6.25278V19.2528C4.16789 18.4769 5.75351 18 7.5 18C9.24649 18 10.8321 18.4769 12 19.2528M12 6.25278C13.1679 5.47686 14.7535 5 16.5 5C18.2465 5 19.8321 5.47686 21 6.25278V19.2528C19.8321 18.4769 18.2465 18 16.5 18C14.7535 18 13.1679 18.4769 12 19.2528',
},
]

const examples = [
{ type: 'Client Components', src: 'app/_examples/client-component/page.tsx' },
{ type: 'Server Components', src: 'app/_examples/server-component/page.tsx' },
{ type: 'Server Actions', src: 'app/_examples/server-action/page.tsx' },
{ type: 'Route Handlers', src: 'app/_examples/route-handler.ts' },
{ type: 'Middleware', src: 'app/middleware.ts' },
{ type: 'Protected Routes', src: 'app/_examples/protected/page.tsx' },
]

export default async function Index() {
const supabase = createServerComponentClient({ cookies })

Expand All @@ -15,7 +48,7 @@ export default async function Index() {
return (
<div className="w-full flex flex-col items-center">
<nav className="w-full flex justify-center border-b border-b-foreground/10 h-16">
<div className='w-full max-w-4xl flex justify-between items-center p-3 text-sm text-foreground'>
<div className="w-full max-w-4xl flex justify-between items-center p-3 text-sm text-foreground">
<div />
<div>
{user ? (
Expand All @@ -24,7 +57,10 @@ export default async function Index() {
<LogoutButton />
</div>
) : (
<Link href="/login" className="py-2 px-4 rounded-md no-underline bg-btn-background hover:bg-btn-background-hover">
<Link
href="/login"
className="py-2 px-4 rounded-md no-underline bg-btn-background hover:bg-btn-background-hover"
>
Login
</Link>
)}
Expand All @@ -33,7 +69,7 @@ export default async function Index() {
</nav>

<div className="animate-in flex flex-col gap-14 opacity-0 max-w-4xl px-3 py-16 lg:py-24 text-foreground">
<div className='flex flex-col items-center mb-4 lg:mb-12'>
<div className="flex flex-col items-center mb-4 lg:mb-12">
<div className="flex gap-8 justify-center items-center">
<Link href="https://supabase.com/" target="_blank">
<SupabaseLogo />
Expand All @@ -53,7 +89,7 @@ export default async function Index() {

<div className="w-full p-[1px] bg-gradient-to-r from-transparent via-foreground/10 to-transparent" />

<div className='flex flex-col gap-8 text-foreground'>
<div className="flex flex-col gap-8 text-foreground">
<h2 className="text-lg font-bold text-center">
Everything you need to get started
</h2>
Expand All @@ -63,23 +99,30 @@ export default async function Index() {
key={title}
className="relative flex flex-col group rounded-lg border p-6 hover:border-foreground"
href={url}
target='_blank'
target="_blank"
rel="noreferrer"
>
<h3 className="font-bold mb-2 min-h-[40px] lg:min-h-[60px]">
{title}
</h3>
<div className="flex flex-col grow gap-4 justify-between">
<p className="text-sm opacity-70">{subtitle}</p>
<div className='flex justify-between items-center'>
<div className="flex justify-between items-center">
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
className='opacity-80 group-hover:opacity-100'
className="opacity-80 group-hover:opacity-100"
>
<path d={icon} stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
<path
d={icon}
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
/>
</svg>

<svg
Expand All @@ -91,7 +134,7 @@ export default async function Index() {
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
strokeLinejoin="round"
className="ml-2 h-4 w-4 opacity-0 -translate-x-2 group-hover:translate-x-0 group-hover:opacity-100 transition-all"
>
<polyline points="9 18 15 12 9 6" />
Expand All @@ -103,19 +146,20 @@ export default async function Index() {
</div>
</div>

<div className='flex flex-col gap-8 text-foreground'>
<div className="flex flex-col gap-8 text-foreground">
<div className="grid gap-2 justify-center mx-auto text-center">
<h2 className="text-lg font-bold text-center">
Examples
</h2>
<h2 className="text-lg font-bold text-center">Examples</h2>
<p className="text-sm">
Look in the <code>_examples</code> folder to see how to create a
Supabase client in all the different contexts.
</p>
</div>
<div className="w-full justify-center border rounded-lg overflow-hidden">
{examples.map(({ type, src }) => (
<div key={type} className="w-full grid grid-cols-3 border-b last:border-b-0 text-sm">
<div
key={type}
className="w-full grid grid-cols-3 border-b last:border-b-0 text-sm"
>
<div className="flex items-center font-bold p-4 min-h-12 w-full">
{type}
</div>
Expand All @@ -128,46 +172,18 @@ export default async function Index() {
</div>

<div className="flex justify-center text-center text-xs">
<p>Powered by <Link href="https://supabase.com/" target="_blank" className='font-bold'>
<p>
Powered by{' '}
<Link
href="https://supabase.com/"
target="_blank"
className="font-bold"
>
Supabase
</Link></p>
</Link>
</p>
</div>

</div>
</div>
)
}

const resources = [
{
title: 'Cookie-based Auth and the Next.js App Router',
subtitle:
'This free course by Jon Meyers, shows you how to configure Supabase Auth to use cookies, and steps through some common patterns.',
url: 'https://youtube.com/playlist?list=PL5S4mPUpp4OtMhpnp93EFSo42iQ40XjbF',
icon: 'M7 4V20M17 4V20M3 8H7M17 8H21M3 12H21M3 16H7M17 16H21M4 20H20C20.5523 20 21 19.5523 21 19V5C21 4.44772 20.5523 4 20 4H4C3.44772 4 3 4.44772 3 5V19C3 19.5523 3.44772 20 4 20Z',
},
{
title: 'Supabase Next.js App Router Example',
subtitle:
'Want to see a code example containing some common patterns with Next.js and Supabase? Check out this repo!',
url: 'https://github.com/supabase/supabase/tree/master/examples/auth/nextjs',
icon: 'M10 20L14 4M18 8L22 12L18 16M6 16L2 12L6 8',
},
{
title: 'Supabase Auth Helpers Docs',
subtitle:
'This template has configured Supabase Auth to use cookies for you, but the docs are a great place to learn more.',
url: 'https://supabase.com/docs/guides/auth/auth-helpers/nextjs',
icon: 'M12 6.25278V19.2528M12 6.25278C10.8321 5.47686 9.24649 5 7.5 5C5.75351 5 4.16789 5.47686 3 6.25278V19.2528C4.16789 18.4769 5.75351 18 7.5 18C9.24649 18 10.8321 18.4769 12 19.2528M12 6.25278C13.1679 5.47686 14.7535 5 16.5 5C18.2465 5 19.8321 5.47686 21 6.25278V19.2528C19.8321 18.4769 18.2465 18 16.5 18C14.7535 18 13.1679 18.4769 12 19.2528',
},
]


const examples = [
{ type: 'Client Components', src: 'app/_examples/client-component/page.tsx' },
{ type: 'Server Components', src: 'app/_examples/server-component/page.tsx' },
{ type: 'Server Actions', src: 'app/_examples/server-action/page.tsx' },
{ type: 'Route Handlers', src: 'app/_examples/route-handler.ts' },
{ type: 'Middleware', src: 'app/middleware.ts' },
{ type: 'Protected Routes', src: 'app/_examples/protected/page.tsx' },
]
5 changes: 4 additions & 1 deletion examples/with-supabase/components/LogoutButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ export default function LogoutButton() {
}

return (
<button className="py-2 px-4 rounded-md no-underline bg-btn-background hover:bg-btn-background-hover" onClick={signOut}>
<button
className="py-2 px-4 rounded-md no-underline bg-btn-background hover:bg-btn-background-hover"
onClick={signOut}
>
Logout
</button>
)
Expand Down
50 changes: 41 additions & 9 deletions examples/with-supabase/components/NextJsLogo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,47 @@ import React from 'react'

export default function NextJsLogo() {
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
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>
)
}

0 comments on commit 2f0bfb8

Please sign in to comment.