initial
35
.gitignore
vendored
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||||
|
|
||||||
|
# dependencies
|
||||||
|
/node_modules
|
||||||
|
/.pnp
|
||||||
|
.pnp.js
|
||||||
|
|
||||||
|
# testing
|
||||||
|
/coverage
|
||||||
|
|
||||||
|
# next.js
|
||||||
|
/.next/
|
||||||
|
/out/
|
||||||
|
|
||||||
|
# production
|
||||||
|
/build
|
||||||
|
|
||||||
|
# misc
|
||||||
|
.DS_Store
|
||||||
|
*.pem
|
||||||
|
|
||||||
|
# debug
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
|
||||||
|
# local env files
|
||||||
|
.env*.local
|
||||||
|
|
||||||
|
# vercel
|
||||||
|
.vercel
|
||||||
|
|
||||||
|
# typescript
|
||||||
|
*.tsbuildinfo
|
||||||
|
next-env.d.ts
|
22
.storybook/main.ts
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
import type { StorybookConfig } from "@storybook/react-vite";
|
||||||
|
|
||||||
|
const config: StorybookConfig = {
|
||||||
|
stories: [
|
||||||
|
"../stories/**/*.mdx",
|
||||||
|
"../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)",
|
||||||
|
],
|
||||||
|
addons: [
|
||||||
|
"@storybook/addon-links",
|
||||||
|
"@storybook/addon-essentials",
|
||||||
|
"@storybook/addon-onboarding",
|
||||||
|
"@storybook/addon-interactions",
|
||||||
|
],
|
||||||
|
framework: {
|
||||||
|
name: "@storybook/react-vite",
|
||||||
|
options: {},
|
||||||
|
},
|
||||||
|
docs: {
|
||||||
|
autodocs: "tag",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
export default config;
|
15
.storybook/preview.ts
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
import type { Preview } from "@storybook/react";
|
||||||
|
|
||||||
|
const preview: Preview = {
|
||||||
|
parameters: {
|
||||||
|
actions: { argTypesRegex: "^on[A-Z].*" },
|
||||||
|
controls: {
|
||||||
|
matchers: {
|
||||||
|
color: /(background|color)$/i,
|
||||||
|
date: /Date$/,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default preview;
|
48
README.md
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
# Supabase Starter
|
||||||
|
|
||||||
|
This starter configures Supabase Auth to use cookies, making the user's session available throughout the entire Next.js app - Client Components, Server Components, Route Handlers, Server Actions and Middleware.
|
||||||
|
|
||||||
|
## Deploy your own
|
||||||
|
|
||||||
|
The Vercel deployment will guide you through creating a Supabase account and project. After installation of the Supabase integration, all relevant environment variables will be set up so that the project is usable immediately after deployment 🚀
|
||||||
|
|
||||||
|
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https://github.com/vercel/next.js/tree/canary/examples/with-supabase&project-name=nextjs-with-supabase&repository-name=nextjs-with-supabase&integration-ids=oac_jUduyjQgOyzev1fjrW83NYOv)
|
||||||
|
|
||||||
|
## How to use
|
||||||
|
|
||||||
|
1. Create a [new Supabase project](https://database.new)
|
||||||
|
1. Run `npx create-next-app -e with-supabase` to create a Next.js app using the Supabase Starter template
|
||||||
|
1. Use `cd` to change into the app's directory
|
||||||
|
1. Run `npm install` to install dependencies
|
||||||
|
1. Rename `.env.local.example` to `.env.local` and update the values for `NEXT_PUBLIC_SUPABASE_URL` and `NEXT_PUBLIC_SUPABASE_ANON_KEY` from [your Supabase project's API settings](https://app.supabase.com/project/_/settings/api)
|
||||||
|
1. Run `npm run dev` to start the local development server
|
||||||
|
|
||||||
|
> Check out [the docs for Local Development](https://supabase.com/docs/guides/getting-started/local-development) to also run Supabase locally.
|
||||||
|
|
||||||
|
### Create a Supabase client
|
||||||
|
|
||||||
|
Check out the [`/app/_examples`](./app/_examples/) folder for an example of creating a Supabase client in:
|
||||||
|
|
||||||
|
- [Client Components](./app/_examples/client-component/page.tsx)
|
||||||
|
- [Server Components](./app/_examples/server-component/page.tsx)
|
||||||
|
- [Route Handlers](./app/_examples/route-handler/route.ts)
|
||||||
|
- [Server Actions](./app/_examples/server-action/page.tsx)
|
||||||
|
|
||||||
|
### Create `todo` table and seed with data (optional)
|
||||||
|
|
||||||
|
Navigate to [your project's SQL Editor](https://app.supabase.com/project/_/sql), click `New query`, paste the contents of the [init.sql](./supabase/migrations/20230618024722_init.sql) file and click `RUN`.
|
||||||
|
|
||||||
|
This will create a basic `todos` table, enable Row Level Security (RLS), and write RLS policies enabling `select` and `insert` actions for `authenticated` users.
|
||||||
|
|
||||||
|
To seed your `todos` table with some dummy data, run the contents of the [seed.sql](./supabase/seed.sql) file.
|
||||||
|
|
||||||
|
## Feedback and issues
|
||||||
|
|
||||||
|
Please file feedback and issues over on the [Supabase GitHub org](https://github.com/supabase/supabase/issues/new/choose).
|
||||||
|
|
||||||
|
## More Supabase examples
|
||||||
|
|
||||||
|
- [Next.js Subscription Payments Starter](https://github.com/vercel/nextjs-subscription-payments)
|
||||||
|
- [Cookie-based Auth and the Next.js 13 App Router (free course)](https://youtube.com/playlist?list=PL5S4mPUpp4OtMhpnp93EFSo42iQ40XjbF)
|
||||||
|
- [Supabase Auth and the Next.js App Router](https://github.com/supabase/supabase/tree/master/examples/auth/nextjs)
|
||||||
|
- [Next.js Auth Helpers Docs](https://supabase.com/docs/guides/auth/auth-helpers/nextjs)
|
29
app/_examples/client-component/page.tsx
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
'use client'
|
||||||
|
|
||||||
|
// TODO: Duplicate or move this file outside the `_examples` folder to make it a route
|
||||||
|
|
||||||
|
import { createClientComponentClient } from '@supabase/auth-helpers-nextjs'
|
||||||
|
import { useEffect, useState } from 'react'
|
||||||
|
|
||||||
|
export default function ClientComponent() {
|
||||||
|
const [todos, setTodos] = useState<any[]>([])
|
||||||
|
|
||||||
|
// Create a Supabase client configured to use cookies
|
||||||
|
const supabase = createClientComponentClient()
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const getTodos = async () => {
|
||||||
|
// This assumes you have a `todos` table in Supabase. Check out
|
||||||
|
// the `Create Table and seed with data` section of the README 👇
|
||||||
|
// https://github.com/vercel/next.js/blob/canary/examples/with-supabase/README.md
|
||||||
|
const { data } = await supabase.from('todos').select()
|
||||||
|
if (data) {
|
||||||
|
setTodos(data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getTodos()
|
||||||
|
}, [supabase, setTodos])
|
||||||
|
|
||||||
|
return <pre>{JSON.stringify(todos, null, 2)}</pre>
|
||||||
|
}
|
83
app/_examples/protected-route/page.tsx
Normal file
|
@ -0,0 +1,83 @@
|
||||||
|
// TODO: Duplicate or move this file outside the `_examples` folder to make it a route
|
||||||
|
|
||||||
|
import {
|
||||||
|
createServerActionClient,
|
||||||
|
createServerComponentClient,
|
||||||
|
} from '@supabase/auth-helpers-nextjs'
|
||||||
|
import { cookies } from 'next/headers'
|
||||||
|
import Image from 'next/image'
|
||||||
|
import { redirect } from 'next/navigation'
|
||||||
|
|
||||||
|
export const dynamic = 'force-dynamic'
|
||||||
|
|
||||||
|
export default async function ProtectedRoute() {
|
||||||
|
const supabase = createServerComponentClient({ cookies })
|
||||||
|
|
||||||
|
const {
|
||||||
|
data: { user },
|
||||||
|
} = await supabase.auth.getUser()
|
||||||
|
|
||||||
|
if (!user) {
|
||||||
|
// This route can only be accessed by authenticated users.
|
||||||
|
// Unauthenticated users will be redirected to the `/login` route.
|
||||||
|
redirect('/login')
|
||||||
|
}
|
||||||
|
|
||||||
|
const signOut = async () => {
|
||||||
|
'use server'
|
||||||
|
const supabase = createServerActionClient({ cookies })
|
||||||
|
await supabase.auth.signOut()
|
||||||
|
redirect('/login')
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="flex-1 flex flex-col max-w-3xl mt-24">
|
||||||
|
<h1 className="text-2xl mb-2 flex justify-between">
|
||||||
|
<span className="sr-only">Supabase and Next.js Starter Template</span>
|
||||||
|
</h1>
|
||||||
|
|
||||||
|
<div className="flex border-b py-3 text-sm text-neutral-100">
|
||||||
|
<div className="flex items-center justify-between w-full">
|
||||||
|
<code className="bg-neutral-700 px-3 py-1 rounded-lg text-sm">
|
||||||
|
Protected page
|
||||||
|
</code>
|
||||||
|
<span className="flex gap-4">
|
||||||
|
Hey, {user.email}! <span className="border-r"></span>{' '}
|
||||||
|
<form action={signOut}>
|
||||||
|
<button className="text-neutral-100">Logout</button>
|
||||||
|
</form>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex gap-8 justify-center mt-12">
|
||||||
|
<Image
|
||||||
|
src="/supabase.svg"
|
||||||
|
alt="Supabase Logo"
|
||||||
|
width={225}
|
||||||
|
height={45}
|
||||||
|
priority
|
||||||
|
/>
|
||||||
|
<div className="border-l rotate-45 h-10"></div>
|
||||||
|
<Image
|
||||||
|
src="/next.svg"
|
||||||
|
alt="Vercel Logo"
|
||||||
|
width={150}
|
||||||
|
height={36}
|
||||||
|
priority
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p className="text-3xl mx-auto max-w-2xl text-center mt-8 text-white">
|
||||||
|
The fastest way to get started building apps with{' '}
|
||||||
|
<strong>Supabase</strong> and <strong>Next.js</strong>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div className="flex justify-center mt-12">
|
||||||
|
<span className="bg-neutral-100 py-3 px-6 rounded-lg font-mono text-sm text-neutral-900">
|
||||||
|
Get started by editing <strong>app/page.tsx</strong>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
19
app/_examples/route-handler/route.ts
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
// TODO: Duplicate or move this file outside the `_examples` folder to make it a route
|
||||||
|
|
||||||
|
import { createRouteHandlerClient } from '@supabase/auth-helpers-nextjs'
|
||||||
|
import { cookies } from 'next/headers'
|
||||||
|
import { NextResponse } from 'next/server'
|
||||||
|
|
||||||
|
export const dynamic = 'force-dynamic'
|
||||||
|
|
||||||
|
export async function GET() {
|
||||||
|
// Create a Supabase client configured to use cookies
|
||||||
|
const supabase = createRouteHandlerClient({ cookies })
|
||||||
|
|
||||||
|
// This assumes you have a `todos` table in Supabase. Check out
|
||||||
|
// the `Create Table and seed with data` section of the README 👇
|
||||||
|
// https://github.com/vercel/next.js/blob/canary/examples/with-supabase/README.md
|
||||||
|
const { data: todos } = await supabase.from('todos').select()
|
||||||
|
|
||||||
|
return NextResponse.json(todos)
|
||||||
|
}
|
31
app/_examples/server-action/page.tsx
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
// TODO: Duplicate or move this file outside the `_examples` folder to make it a route
|
||||||
|
|
||||||
|
import { createServerActionClient } from '@supabase/auth-helpers-nextjs'
|
||||||
|
import { revalidatePath } from 'next/cache'
|
||||||
|
import { cookies } from 'next/headers'
|
||||||
|
|
||||||
|
export const dynamic = 'force-dynamic'
|
||||||
|
|
||||||
|
export default async function ServerAction() {
|
||||||
|
const addTodo = async (formData: FormData) => {
|
||||||
|
'use server'
|
||||||
|
const title = formData.get('title')
|
||||||
|
|
||||||
|
if (title) {
|
||||||
|
// Create a Supabase client configured to use cookies
|
||||||
|
const supabase = createServerActionClient({ cookies })
|
||||||
|
|
||||||
|
// This assumes you have a `todos` table in Supabase. Check out
|
||||||
|
// the `Create Table and seed with data` section of the README 👇
|
||||||
|
// https://github.com/vercel/next.js/blob/canary/examples/with-supabase/README.md
|
||||||
|
await supabase.from('todos').insert({ title })
|
||||||
|
revalidatePath('/server-action-example')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<form action={addTodo}>
|
||||||
|
<input name="title" />
|
||||||
|
</form>
|
||||||
|
)
|
||||||
|
}
|
18
app/_examples/server-component/page.tsx
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
// TODO: Duplicate or move this file outside the `_examples` folder to make it a route
|
||||||
|
|
||||||
|
import { createServerComponentClient } from '@supabase/auth-helpers-nextjs'
|
||||||
|
import { cookies } from 'next/headers'
|
||||||
|
|
||||||
|
export const dynamic = 'force-dynamic'
|
||||||
|
|
||||||
|
export default async function ServerComponent() {
|
||||||
|
// Create a Supabase client configured to use cookies
|
||||||
|
const supabase = createServerComponentClient({ cookies })
|
||||||
|
|
||||||
|
// This assumes you have a `todos` table in Supabase. Check out
|
||||||
|
// the `Create Table and seed with data` section of the README 👇
|
||||||
|
// https://github.com/vercel/next.js/blob/canary/examples/with-supabase/README.md
|
||||||
|
const { data: todos } = await supabase.from('todos').select()
|
||||||
|
|
||||||
|
return <pre>{JSON.stringify(todos, null, 2)}</pre>
|
||||||
|
}
|
21
app/auth/callback/route.ts
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
import { createRouteHandlerClient } from '@supabase/auth-helpers-nextjs'
|
||||||
|
import { cookies } from 'next/headers'
|
||||||
|
import { NextResponse } from 'next/server'
|
||||||
|
|
||||||
|
export const dynamic = 'force-dynamic'
|
||||||
|
|
||||||
|
export async function GET(request: Request) {
|
||||||
|
// The `/auth/callback` route is required for the server-side auth flow implemented
|
||||||
|
// by the Auth Helpers package. It exchanges an auth code for the user's session.
|
||||||
|
// https://supabase.com/docs/guides/auth/auth-helpers/nextjs#managing-sign-in-with-code-exchange
|
||||||
|
const requestUrl = new URL(request.url)
|
||||||
|
const code = requestUrl.searchParams.get('code')
|
||||||
|
|
||||||
|
if (code) {
|
||||||
|
const supabase = createRouteHandlerClient({ cookies })
|
||||||
|
await supabase.auth.exchangeCodeForSession(code)
|
||||||
|
}
|
||||||
|
|
||||||
|
// URL to redirect to after sign in process completes
|
||||||
|
return NextResponse.redirect(requestUrl.origin)
|
||||||
|
}
|
BIN
app/favicon.ico
Normal file
After Width: | Height: | Size: 25 KiB |
42
app/globals.css
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
@tailwind base;
|
||||||
|
@tailwind components;
|
||||||
|
@tailwind utilities;
|
||||||
|
|
||||||
|
@layer base {
|
||||||
|
:root {
|
||||||
|
--background: 200 20% 98%;
|
||||||
|
--btn-background: 200 10% 91%;
|
||||||
|
--btn-background-hover: 200 10% 89%;
|
||||||
|
--foreground: 200 50% 3%;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
:root {
|
||||||
|
--background: 200 50% 3%;
|
||||||
|
--btn-background: 200 10% 9%;
|
||||||
|
--btn-background-hover: 200 10% 12%;
|
||||||
|
--foreground: 200 20% 96%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@layer base {
|
||||||
|
* {
|
||||||
|
@apply border-foreground/20;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.animate-in {
|
||||||
|
animation: animateIn 0.3s ease 0.15s both;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes animateIn {
|
||||||
|
from {
|
||||||
|
opacity: 0;
|
||||||
|
transform: translateY(10px);
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
opacity: 1;
|
||||||
|
transform: translateY(0);
|
||||||
|
}
|
||||||
|
}
|
22
app/layout.tsx
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
import './globals.css'
|
||||||
|
|
||||||
|
export const metadata = {
|
||||||
|
title: 'Create Next App',
|
||||||
|
description: 'Generated by create next app',
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function RootLayout({
|
||||||
|
children,
|
||||||
|
}: {
|
||||||
|
children: React.ReactNode
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<html lang="en">
|
||||||
|
<body>
|
||||||
|
<main className="min-h-screen bg-background flex flex-col items-center">
|
||||||
|
{children}
|
||||||
|
</main>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
)
|
||||||
|
}
|
126
app/login/page.tsx
Normal file
|
@ -0,0 +1,126 @@
|
||||||
|
'use client'
|
||||||
|
|
||||||
|
import { useState } from 'react'
|
||||||
|
import { useRouter } from 'next/navigation'
|
||||||
|
import { createClientComponentClient } from '@supabase/auth-helpers-nextjs'
|
||||||
|
import Link from 'next/link'
|
||||||
|
|
||||||
|
export default function Login() {
|
||||||
|
const [email, setEmail] = useState('')
|
||||||
|
const [password, setPassword] = useState('')
|
||||||
|
const [view, setView] = useState('sign-in')
|
||||||
|
const router = useRouter()
|
||||||
|
const supabase = createClientComponentClient()
|
||||||
|
|
||||||
|
const handleSignUp = async (e: React.FormEvent<HTMLFormElement>) => {
|
||||||
|
e.preventDefault()
|
||||||
|
await supabase.auth.signUp({
|
||||||
|
email,
|
||||||
|
password,
|
||||||
|
options: {
|
||||||
|
emailRedirectTo: `${location.origin}/auth/callback`,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
setView('check-email')
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleSignIn = async (e: React.FormEvent<HTMLFormElement>) => {
|
||||||
|
e.preventDefault()
|
||||||
|
await supabase.auth.signInWithPassword({
|
||||||
|
email,
|
||||||
|
password,
|
||||||
|
})
|
||||||
|
router.push('/')
|
||||||
|
router.refresh()
|
||||||
|
}
|
||||||
|
|
||||||
|
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"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="24"
|
||||||
|
height="24"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
fill="none"
|
||||||
|
stroke="currentColor"
|
||||||
|
strokeWidth="2"
|
||||||
|
strokeLinecap="round"
|
||||||
|
strokeLinejoin="round"
|
||||||
|
className="mr-2 h-4 w-4 transition-transform group-hover:-translate-x-1"
|
||||||
|
>
|
||||||
|
<polyline points="15 18 9 12 15 6" />
|
||||||
|
</svg>{' '}
|
||||||
|
Back
|
||||||
|
</Link>
|
||||||
|
{view === 'check-email' ? (
|
||||||
|
<p className="text-center text-foreground">
|
||||||
|
Check <span className="font-bold">{email}</span> to continue signing
|
||||||
|
up
|
||||||
|
</p>
|
||||||
|
) : (
|
||||||
|
<form
|
||||||
|
className="flex-1 flex flex-col w-full justify-center gap-2 text-foreground"
|
||||||
|
onSubmit={view === 'sign-in' ? handleSignIn : handleSignUp}
|
||||||
|
>
|
||||||
|
<label className="text-md" htmlFor="email">
|
||||||
|
Email
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
className="rounded-md px-4 py-2 bg-inherit border mb-6"
|
||||||
|
name="email"
|
||||||
|
onChange={(e) => setEmail(e.target.value)}
|
||||||
|
value={email}
|
||||||
|
placeholder="you@example.com"
|
||||||
|
/>
|
||||||
|
<label className="text-md" htmlFor="password">
|
||||||
|
Password
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
className="rounded-md px-4 py-2 bg-inherit border mb-6"
|
||||||
|
type="password"
|
||||||
|
name="password"
|
||||||
|
onChange={(e) => setPassword(e.target.value)}
|
||||||
|
value={password}
|
||||||
|
placeholder="••••••••"
|
||||||
|
/>
|
||||||
|
{view === 'sign-in' && (
|
||||||
|
<>
|
||||||
|
<button className="bg-green-700 rounded px-4 py-2 text-white mb-6">
|
||||||
|
Sign In
|
||||||
|
</button>
|
||||||
|
<p className="text-sm text-center">
|
||||||
|
Don't have an account?
|
||||||
|
<button
|
||||||
|
className="ml-1 underline"
|
||||||
|
onClick={() => setView('sign-up')}
|
||||||
|
>
|
||||||
|
Sign Up Now
|
||||||
|
</button>
|
||||||
|
</p>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
{view === 'sign-up' && (
|
||||||
|
<>
|
||||||
|
<button className="bg-green-700 rounded px-4 py-2 text-white mb-6">
|
||||||
|
Sign Up
|
||||||
|
</button>
|
||||||
|
<p className="text-sm text-center">
|
||||||
|
Already have an account?
|
||||||
|
<button
|
||||||
|
className="ml-1 underline"
|
||||||
|
onClick={() => setView('sign-in')}
|
||||||
|
>
|
||||||
|
Sign In Now
|
||||||
|
</button>
|
||||||
|
</p>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</form>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
191
app/page.tsx
Normal file
|
@ -0,0 +1,191 @@
|
||||||
|
import { createServerComponentClient } from '@supabase/auth-helpers-nextjs'
|
||||||
|
import { cookies } from 'next/headers'
|
||||||
|
import Link from 'next/link'
|
||||||
|
import LogoutButton from '../components/LogoutButton'
|
||||||
|
import SupabaseLogo from '../components/SupabaseLogo'
|
||||||
|
import NextJsLogo from '../components/NextJsLogo'
|
||||||
|
|
||||||
|
export const dynamic = 'force-dynamic'
|
||||||
|
|
||||||
|
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 })
|
||||||
|
|
||||||
|
const {
|
||||||
|
data: { user },
|
||||||
|
} = await supabase.auth.getUser()
|
||||||
|
|
||||||
|
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 />
|
||||||
|
<div>
|
||||||
|
{user ? (
|
||||||
|
<div className="flex items-center gap-4">
|
||||||
|
Hey, {user.email}!
|
||||||
|
<LogoutButton />
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<Link
|
||||||
|
href="/login"
|
||||||
|
className="py-2 px-4 rounded-md no-underline bg-btn-background hover:bg-btn-background-hover"
|
||||||
|
>
|
||||||
|
Login
|
||||||
|
</Link>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</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 gap-8 justify-center items-center">
|
||||||
|
<Link href="https://supabase.com/" target="_blank">
|
||||||
|
<SupabaseLogo />
|
||||||
|
</Link>
|
||||||
|
<span className="border-l rotate-45 h-6" />
|
||||||
|
<NextJsLogo />
|
||||||
|
</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 my-12">
|
||||||
|
The fastest way to start building apps with{' '}
|
||||||
|
<strong>Supabase</strong> and <strong>Next.js</strong>
|
||||||
|
</p>
|
||||||
|
<div className="bg-foreground py-3 px-6 rounded-lg font-mono text-sm text-background">
|
||||||
|
Get started by editing <strong>app/page.tsx</strong>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<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">
|
||||||
|
<h2 className="text-lg font-bold text-center">
|
||||||
|
Everything you need to get started
|
||||||
|
</h2>
|
||||||
|
<div className="grid grid-cols-1 lg:grid-cols-3 gap-4">
|
||||||
|
{resources.map(({ title, subtitle, url, icon }) => (
|
||||||
|
<a
|
||||||
|
key={title}
|
||||||
|
className="relative flex flex-col group rounded-lg border p-6 hover:border-foreground"
|
||||||
|
href={url}
|
||||||
|
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">
|
||||||
|
<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"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d={icon}
|
||||||
|
stroke="currentColor"
|
||||||
|
strokeWidth="2"
|
||||||
|
strokeLinecap="round"
|
||||||
|
strokeLinejoin="round"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="24"
|
||||||
|
height="24"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
fill="none"
|
||||||
|
stroke="currentColor"
|
||||||
|
strokeWidth="2"
|
||||||
|
strokeLinecap="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" />
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<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>
|
||||||
|
<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 className="flex items-center font-bold p-4 min-h-12 w-full">
|
||||||
|
{type}
|
||||||
|
</div>
|
||||||
|
<div className="col-span-2 border-l p-4 flex items-center">
|
||||||
|
<code className="text-sm whitespace-pre-wrap">{src}</code>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex justify-center text-center text-xs">
|
||||||
|
<p>
|
||||||
|
Powered by{' '}
|
||||||
|
<Link
|
||||||
|
href="https://supabase.com/"
|
||||||
|
target="_blank"
|
||||||
|
className="font-bold"
|
||||||
|
>
|
||||||
|
Supabase
|
||||||
|
</Link>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
25
components/LogoutButton.tsx
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
'use client'
|
||||||
|
|
||||||
|
import { createClientComponentClient } from '@supabase/auth-helpers-nextjs'
|
||||||
|
import { useRouter } from 'next/navigation'
|
||||||
|
|
||||||
|
export default function LogoutButton() {
|
||||||
|
const router = useRouter()
|
||||||
|
|
||||||
|
// Create a Supabase client configured to use cookies
|
||||||
|
const supabase = createClientComponentClient()
|
||||||
|
|
||||||
|
const signOut = async () => {
|
||||||
|
await supabase.auth.signOut()
|
||||||
|
router.refresh()
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<button
|
||||||
|
className="py-2 px-4 rounded-md no-underline bg-btn-background hover:bg-btn-background-hover"
|
||||||
|
onClick={signOut}
|
||||||
|
>
|
||||||
|
Logout
|
||||||
|
</button>
|
||||||
|
)
|
||||||
|
}
|
48
components/NextJsLogo.tsx
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
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>
|
||||||
|
)
|
||||||
|
}
|
104
components/SupabaseLogo.tsx
Normal file
|
@ -0,0 +1,104 @@
|
||||||
|
import React from 'react'
|
||||||
|
|
||||||
|
export default function SupabaseLogo() {
|
||||||
|
return (
|
||||||
|
<svg
|
||||||
|
aria-label="Supabase logo"
|
||||||
|
width="140"
|
||||||
|
height="30"
|
||||||
|
viewBox="0 0 115 23"
|
||||||
|
fill="none"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
>
|
||||||
|
<g clipPath="url(#clip0_4671_51136)">
|
||||||
|
<g clipPath="url(#clip1_4671_51136)">
|
||||||
|
<path
|
||||||
|
d="M13.4028 21.8652C12.8424 22.5629 11.7063 22.1806 11.6928 21.2898L11.4954 8.25948H20.3564C21.9614 8.25948 22.8565 10.0924 21.8585 11.3353L13.4028 21.8652Z"
|
||||||
|
fill="url(#paint0_linear_4671_51136)"
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
d="M13.4028 21.8652C12.8424 22.5629 11.7063 22.1806 11.6928 21.2898L11.4954 8.25948H20.3564C21.9614 8.25948 22.8565 10.0924 21.8585 11.3353L13.4028 21.8652Z"
|
||||||
|
fill="url(#paint1_linear_4671_51136)"
|
||||||
|
fillOpacity="0.2"
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
d="M9.79895 0.89838C10.3593 0.200591 11.4954 0.582929 11.5089 1.47383L11.5955 14.5041H2.84528C1.24026 14.5041 0.345103 12.6711 1.34316 11.4283L9.79895 0.89838Z"
|
||||||
|
fill="#3ECF8E"
|
||||||
|
/>
|
||||||
|
</g>
|
||||||
|
<path
|
||||||
|
d="M30.5894 13.3913C30.7068 14.4766 31.7052 16.3371 34.6026 16.3371C37.1279 16.3371 38.3418 14.7479 38.3418 13.1976C38.3418 11.8022 37.3824 10.6588 35.4836 10.2712L34.1131 9.98049C33.5846 9.88359 33.2323 9.5929 33.2323 9.12777C33.2323 8.58512 33.7804 8.17818 34.4656 8.17818C35.5618 8.17818 35.9729 8.89521 36.0513 9.45725L38.2243 8.97275C38.1069 7.94561 37.1867 6.22083 34.446 6.22083C32.3709 6.22083 30.844 7.63555 30.844 9.34094C30.844 10.6781 31.6856 11.7828 33.5454 12.1898L34.8179 12.4805C35.5618 12.6355 35.8555 12.9844 35.8555 13.4107C35.8555 13.9146 35.4444 14.3603 34.583 14.3603C33.4476 14.3603 32.8797 13.6626 32.8212 12.9068L30.5894 13.3913Z"
|
||||||
|
fill="currentColor"
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
d="M46.6623 16.0464H49.1486C49.1094 15.717 49.0506 15.0581 49.0506 14.3216V6.51154H46.4468V12.0542C46.4468 13.1588 45.7813 13.934 44.6263 13.934C43.4126 13.934 42.8643 13.0813 42.8643 12.0154V6.51154H40.2606V12.5387C40.2606 14.6123 41.5918 16.2984 43.9215 16.2984C44.9393 16.2984 46.0556 15.9108 46.5841 15.0193C46.5841 15.4069 46.6231 15.8526 46.6623 16.0464Z"
|
||||||
|
fill="currentColor"
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
d="M54.433 19.7286V15.1162C54.9027 15.7558 55.8817 16.279 57.213 16.279C59.9341 16.279 61.7545 14.1472 61.7545 11.2596C61.7545 8.43021 60.1298 6.29842 57.3108 6.29842C55.8623 6.29842 54.7855 6.93792 54.3548 7.67439V6.51159H51.8295V19.7286H54.433ZM59.19 11.279C59.19 12.9845 58.133 13.9728 56.8017 13.9728C55.4708 13.9728 54.394 12.9651 54.394 11.279C54.394 9.59299 55.4708 8.6046 56.8017 8.6046C58.133 8.6046 59.19 9.59299 59.19 11.279Z"
|
||||||
|
fill="currentColor"
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
d="M63.229 13.4495C63.229 14.9417 64.4818 16.3177 66.5375 16.3177C67.9662 16.3177 68.8865 15.6588 69.3758 14.9029C69.3758 15.2712 69.4149 15.7944 69.4737 16.0464H71.862C71.8033 15.7169 71.7449 15.0386 71.7449 14.5348V9.84482C71.7449 7.92622 70.6093 6.22083 67.5555 6.22083C64.9713 6.22083 63.5811 7.86807 63.4248 9.36033L65.7347 9.84482C65.8131 9.0115 66.4395 8.29445 67.5747 8.29445C68.6713 8.29445 69.1998 8.85646 69.1998 9.53475C69.1998 9.86421 69.0238 10.1355 68.4755 10.2131L66.1068 10.5619C64.5015 10.7945 63.229 11.744 63.229 13.4495ZM67.0854 14.3991C66.2438 14.3991 65.8325 13.8565 65.8325 13.2945C65.8325 12.558 66.361 12.1898 67.0268 12.0929L69.1998 11.7634V12.1898C69.1998 13.8759 68.1818 14.3991 67.0854 14.3991Z"
|
||||||
|
fill="currentColor"
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
d="M76.895 16.0465V14.8837C77.4038 15.6976 78.4217 16.279 79.7531 16.279C82.4941 16.279 84.2951 14.1278 84.2951 11.2403C84.2951 8.4108 82.6701 6.25965 79.851 6.25965C78.4217 6.25965 77.3648 6.8798 76.934 7.55806V2.01546H74.3696V16.0465H76.895ZM81.6911 11.2596C81.6911 13.0038 80.6341 13.9728 79.3028 13.9728C77.9912 13.9728 76.895 12.9845 76.895 11.2596C76.895 9.51543 77.9912 8.56584 79.3028 8.56584C80.6341 8.56584 81.6911 9.51543 81.6911 11.2596Z"
|
||||||
|
fill="currentColor"
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
d="M85.7692 13.4495C85.7692 14.9417 87.022 16.3177 89.0776 16.3177C90.5065 16.3177 91.4269 15.6588 91.916 14.9029C91.916 15.2712 91.9554 15.7944 92.014 16.0464H94.4023C94.3439 15.7169 94.2851 15.0386 94.2851 14.5348V9.84482C94.2851 7.92622 93.1495 6.22083 90.0955 6.22083C87.5115 6.22083 86.1216 7.86807 85.965 9.36033L88.2747 9.84482C88.3533 9.0115 88.9798 8.29445 90.1149 8.29445C91.2115 8.29445 91.74 8.85646 91.74 9.53475C91.74 9.86421 91.5638 10.1355 91.0156 10.2131L88.647 10.5619C87.0418 10.7945 85.7692 11.744 85.7692 13.4495ZM89.6258 14.3991C88.784 14.3991 88.3727 13.8565 88.3727 13.2945C88.3727 12.558 88.9012 12.1898 89.5671 12.0929L91.74 11.7634V12.1898C91.74 13.8759 90.722 14.3991 89.6258 14.3991Z"
|
||||||
|
fill="currentColor"
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
d="M96.087 13.3913C96.2042 14.4766 97.2028 16.3371 100.1 16.3371C102.626 16.3371 103.839 14.7479 103.839 13.1976C103.839 11.8022 102.88 10.6588 100.981 10.2712L99.6105 9.98049C99.082 9.88359 98.7299 9.5929 98.7299 9.12777C98.7299 8.58512 99.2778 8.17818 99.963 8.17818C101.06 8.17818 101.471 8.89521 101.549 9.45725L103.722 8.97275C103.604 7.94561 102.684 6.22083 99.9436 6.22083C97.8683 6.22083 96.3416 7.63555 96.3416 9.34094C96.3416 10.6781 97.183 11.7828 99.043 12.1898L100.316 12.4805C101.06 12.6355 101.353 12.9844 101.353 13.4107C101.353 13.9146 100.942 14.3603 100.081 14.3603C98.9451 14.3603 98.3776 13.6626 98.3188 12.9068L96.087 13.3913Z"
|
||||||
|
fill="currentColor"
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
d="M107.794 10.1937C107.852 9.32158 108.596 8.31381 109.947 8.31381C111.435 8.31381 112.062 9.24406 112.101 10.1937H107.794ZM112.355 12.6743C112.042 13.527 111.376 14.1278 110.163 14.1278C108.87 14.1278 107.794 13.2169 107.735 11.9573H114.626C114.626 11.9184 114.665 11.5309 114.665 11.1626C114.665 8.10064 112.884 6.22083 109.908 6.22083C107.441 6.22083 105.17 8.19753 105.17 11.2402C105.17 14.4572 107.5 16.3371 110.143 16.3371C112.512 16.3371 114.039 14.9611 114.528 13.3138L112.355 12.6743Z"
|
||||||
|
fill="currentColor"
|
||||||
|
/>
|
||||||
|
</g>
|
||||||
|
<defs>
|
||||||
|
<linearGradient
|
||||||
|
id="paint0_linear_4671_51136"
|
||||||
|
x1="11.4954"
|
||||||
|
y1="11.1486"
|
||||||
|
x2="19.3439"
|
||||||
|
y2="14.4777"
|
||||||
|
gradientUnits="userSpaceOnUse"
|
||||||
|
>
|
||||||
|
<stop stopColor="#249361" />
|
||||||
|
<stop offset="1" stopColor="#3ECF8E" />
|
||||||
|
</linearGradient>
|
||||||
|
<linearGradient
|
||||||
|
id="paint1_linear_4671_51136"
|
||||||
|
x1="8.00382"
|
||||||
|
y1="6.42177"
|
||||||
|
x2="11.5325"
|
||||||
|
y2="13.1398"
|
||||||
|
gradientUnits="userSpaceOnUse"
|
||||||
|
>
|
||||||
|
<stop />
|
||||||
|
<stop offset="1" stopOpacity="0" />
|
||||||
|
</linearGradient>
|
||||||
|
<clipPath id="clip0_4671_51136">
|
||||||
|
<rect
|
||||||
|
width="113.85"
|
||||||
|
height="21.8943"
|
||||||
|
fill="currentColor"
|
||||||
|
transform="translate(0.922119 0.456161)"
|
||||||
|
/>
|
||||||
|
</clipPath>
|
||||||
|
<clipPath id="clip1_4671_51136">
|
||||||
|
<rect
|
||||||
|
width="21.3592"
|
||||||
|
height="21.8943"
|
||||||
|
fill="currentColor"
|
||||||
|
transform="translate(0.919006 0.497101)"
|
||||||
|
/>
|
||||||
|
</clipPath>
|
||||||
|
</defs>
|
||||||
|
</svg>
|
||||||
|
)
|
||||||
|
}
|
17
eduproj.code-workspace
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
{
|
||||||
|
"folders": [
|
||||||
|
{
|
||||||
|
"name": "project-root",
|
||||||
|
"path": "./"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "supabase-functions",
|
||||||
|
"path": "supabase/functions"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"settings": {
|
||||||
|
"files.exclude": {
|
||||||
|
"supabase/functions/": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
17
middleware.ts
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
import { createMiddlewareClient } from '@supabase/auth-helpers-nextjs'
|
||||||
|
import { NextResponse } from 'next/server'
|
||||||
|
|
||||||
|
import type { NextRequest } from 'next/server'
|
||||||
|
|
||||||
|
export async function middleware(req: NextRequest) {
|
||||||
|
const res = NextResponse.next()
|
||||||
|
|
||||||
|
// Create a Supabase client configured to use cookies
|
||||||
|
const supabase = createMiddlewareClient({ req, res })
|
||||||
|
|
||||||
|
// Refresh session if expired - required for Server Components
|
||||||
|
// https://supabase.com/docs/guides/auth/auth-helpers/nextjs#managing-session-with-middleware
|
||||||
|
await supabase.auth.getSession()
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
8
next.config.js
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
/** @type {import('next').NextConfig} */
|
||||||
|
const nextConfig = {
|
||||||
|
experimental: {
|
||||||
|
serverActions: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = nextConfig
|
22309
package-lock.json
generated
Normal file
36
package.json
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
{
|
||||||
|
"private": true,
|
||||||
|
"scripts": {
|
||||||
|
"dev": "next dev",
|
||||||
|
"build": "next build",
|
||||||
|
"start": "next start",
|
||||||
|
"storybook": "storybook dev -p 6006",
|
||||||
|
"build-storybook": "storybook build"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@supabase/auth-helpers-nextjs": "latest",
|
||||||
|
"@supabase/supabase-js": "latest",
|
||||||
|
"autoprefixer": "10.4.14",
|
||||||
|
"next": "latest",
|
||||||
|
"postcss": "8.4.24",
|
||||||
|
"react": "18.2.0",
|
||||||
|
"react-dom": "18.2.0",
|
||||||
|
"tailwindcss": "3.3.2",
|
||||||
|
"typescript": "5.1.3"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@storybook/addon-essentials": "^7.2.0",
|
||||||
|
"@storybook/addon-interactions": "^7.2.0",
|
||||||
|
"@storybook/addon-links": "^7.2.0",
|
||||||
|
"@storybook/addon-onboarding": "^1.0.8",
|
||||||
|
"@storybook/blocks": "^7.2.0",
|
||||||
|
"@storybook/react": "^7.2.0",
|
||||||
|
"@storybook/react-vite": "^7.2.0",
|
||||||
|
"@storybook/testing-library": "^0.2.0",
|
||||||
|
"@types/node": "20.3.1",
|
||||||
|
"@types/react": "18.2.12",
|
||||||
|
"@types/react-dom": "18.2.5",
|
||||||
|
"encoding": "^0.1.13",
|
||||||
|
"storybook": "^7.2.0"
|
||||||
|
}
|
||||||
|
}
|
6
postcss.config.js
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
module.exports = {
|
||||||
|
plugins: {
|
||||||
|
tailwindcss: {},
|
||||||
|
autoprefixer: {},
|
||||||
|
},
|
||||||
|
}
|
50
stories/Button.stories.ts
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
import type { Meta, StoryObj } from '@storybook/react';
|
||||||
|
|
||||||
|
import { Button } from './Button';
|
||||||
|
|
||||||
|
// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
|
||||||
|
const meta: Meta<typeof Button> = {
|
||||||
|
title: 'Example/Button',
|
||||||
|
component: Button,
|
||||||
|
parameters: {
|
||||||
|
// Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/react/configure/story-layout
|
||||||
|
layout: 'centered',
|
||||||
|
},
|
||||||
|
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/react/writing-docs/autodocs
|
||||||
|
tags: ['autodocs'],
|
||||||
|
// More on argTypes: https://storybook.js.org/docs/react/api/argtypes
|
||||||
|
argTypes: {
|
||||||
|
backgroundColor: { control: 'color' },
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default meta;
|
||||||
|
type Story = StoryObj<typeof Button>;
|
||||||
|
|
||||||
|
// More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args
|
||||||
|
export const Primary: Story = {
|
||||||
|
args: {
|
||||||
|
primary: true,
|
||||||
|
label: 'Button',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Secondary: Story = {
|
||||||
|
args: {
|
||||||
|
label: 'Button',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Large: Story = {
|
||||||
|
args: {
|
||||||
|
size: 'large',
|
||||||
|
label: 'Button',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Small: Story = {
|
||||||
|
args: {
|
||||||
|
size: 'small',
|
||||||
|
label: 'Button',
|
||||||
|
},
|
||||||
|
};
|
48
stories/Button.tsx
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
import React from 'react';
|
||||||
|
import './button.css';
|
||||||
|
|
||||||
|
interface ButtonProps {
|
||||||
|
/**
|
||||||
|
* Is this the principal call to action on the page?
|
||||||
|
*/
|
||||||
|
primary?: boolean;
|
||||||
|
/**
|
||||||
|
* What background color to use
|
||||||
|
*/
|
||||||
|
backgroundColor?: string;
|
||||||
|
/**
|
||||||
|
* How large should the button be?
|
||||||
|
*/
|
||||||
|
size?: 'small' | 'medium' | 'large';
|
||||||
|
/**
|
||||||
|
* Button contents
|
||||||
|
*/
|
||||||
|
label: string;
|
||||||
|
/**
|
||||||
|
* Optional click handler
|
||||||
|
*/
|
||||||
|
onClick?: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Primary UI component for user interaction
|
||||||
|
*/
|
||||||
|
export const Button = ({
|
||||||
|
primary = false,
|
||||||
|
size = 'medium',
|
||||||
|
backgroundColor,
|
||||||
|
label,
|
||||||
|
...props
|
||||||
|
}: ButtonProps) => {
|
||||||
|
const mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary';
|
||||||
|
return (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className={['storybook-button', `storybook-button--${size}`, mode].join(' ')}
|
||||||
|
style={{ backgroundColor }}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
{label}
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
};
|
364
stories/Configure.mdx
Normal file
|
@ -0,0 +1,364 @@
|
||||||
|
import { Meta } from "@storybook/blocks";
|
||||||
|
|
||||||
|
import Github from "./assets/github.svg";
|
||||||
|
import Discord from "./assets/discord.svg";
|
||||||
|
import Youtube from "./assets/youtube.svg";
|
||||||
|
import Tutorials from "./assets/tutorials.svg";
|
||||||
|
import Styling from "./assets/styling.png";
|
||||||
|
import Context from "./assets/context.png";
|
||||||
|
import Assets from "./assets/assets.png";
|
||||||
|
import Docs from "./assets/docs.png";
|
||||||
|
import Share from "./assets/share.png";
|
||||||
|
import FigmaPlugin from "./assets/figma-plugin.png";
|
||||||
|
import Testing from "./assets/testing.png";
|
||||||
|
import Accessibility from "./assets/accessibility.png";
|
||||||
|
import Theming from "./assets/theming.png";
|
||||||
|
import AddonLibrary from "./assets/addon-library.png";
|
||||||
|
|
||||||
|
export const RightArrow = () => <svg
|
||||||
|
viewBox="0 0 14 14"
|
||||||
|
width="8px"
|
||||||
|
height="14px"
|
||||||
|
style={{
|
||||||
|
marginLeft: '4px',
|
||||||
|
display: 'inline-block',
|
||||||
|
shapeRendering: 'inherit',
|
||||||
|
verticalAlign: 'middle',
|
||||||
|
fill: 'currentColor',
|
||||||
|
'path fill': 'currentColor'
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<path d="m11.1 7.35-5.5 5.5a.5.5 0 0 1-.7-.7L10.04 7 4.9 1.85a.5.5 0 1 1 .7-.7l5.5 5.5c.2.2.2.5 0 .7Z" />
|
||||||
|
</svg>
|
||||||
|
|
||||||
|
<Meta title="Configure your project" />
|
||||||
|
|
||||||
|
<div className="sb-container">
|
||||||
|
<div className='sb-section-title'>
|
||||||
|
# Configure your project
|
||||||
|
|
||||||
|
Because Storybook works separately from your app, you'll need to configure it for your specific stack and setup. Below, explore guides for configuring Storybook with popular frameworks and tools. If you get stuck, learn how you can ask for help from our community.
|
||||||
|
</div>
|
||||||
|
<div className="sb-section">
|
||||||
|
<div className="sb-section-item">
|
||||||
|
<img
|
||||||
|
src={Styling}
|
||||||
|
alt="A wall of logos representing different styling technologies"
|
||||||
|
/>
|
||||||
|
<h4 className="sb-section-item-heading">Add styling and CSS</h4>
|
||||||
|
<p className="sb-section-item-paragraph">Like with web applications, there are many ways to include CSS within Storybook. Learn more about setting up styling within Storybook.</p>
|
||||||
|
<a
|
||||||
|
href="https://storybook.js.org/docs/react/configure/styling-and-css"
|
||||||
|
target="_blank"
|
||||||
|
>Learn more<RightArrow /></a>
|
||||||
|
</div>
|
||||||
|
<div className="sb-section-item">
|
||||||
|
<img
|
||||||
|
src={Context}
|
||||||
|
alt="An abstraction representing the composition of data for a component"
|
||||||
|
/>
|
||||||
|
<h4 className="sb-section-item-heading">Provide context and mocking</h4>
|
||||||
|
<p className="sb-section-item-paragraph">Often when a story doesn't render, it's because your component is expecting a specific environment or context (like a theme provider) to be available.</p>
|
||||||
|
<a
|
||||||
|
href="https://storybook.js.org/docs/react/writing-stories/decorators#context-for-mocking"
|
||||||
|
target="_blank"
|
||||||
|
>Learn more<RightArrow /></a>
|
||||||
|
</div>
|
||||||
|
<div className="sb-section-item">
|
||||||
|
<img src={Assets} alt="A representation of typography and image assets" />
|
||||||
|
<div>
|
||||||
|
<h4 className="sb-section-item-heading">Load assets and resources</h4>
|
||||||
|
<p className="sb-section-item-paragraph">To link static files (like fonts) to your projects and stories, use the
|
||||||
|
`staticDirs` configuration option to specify folders to load when
|
||||||
|
starting Storybook.</p>
|
||||||
|
<a
|
||||||
|
href="https://storybook.js.org/docs/react/configure/images-and-assets"
|
||||||
|
target="_blank"
|
||||||
|
>Learn more<RightArrow /></a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="sb-container">
|
||||||
|
<div className='sb-section-title'>
|
||||||
|
# Do more with Storybook
|
||||||
|
|
||||||
|
Now that you know the basics, let's explore other parts of Storybook that will improve your experience. This list is just to get you started. You can customise Storybook in many ways to fit your needs.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="sb-section">
|
||||||
|
<div className="sb-features-grid">
|
||||||
|
<div className="sb-grid-item">
|
||||||
|
<img src={Docs} alt="A screenshot showing the autodocs tag being set, pointing a docs page being generated" />
|
||||||
|
<h4 className="sb-section-item-heading">Autodocs</h4>
|
||||||
|
<p className="sb-section-item-paragraph">Auto-generate living,
|
||||||
|
interactive reference documentation from your components and stories.</p>
|
||||||
|
<a
|
||||||
|
href="https://storybook.js.org/docs/react/writing-docs/autodocs"
|
||||||
|
target="_blank"
|
||||||
|
>Learn more<RightArrow /></a>
|
||||||
|
</div>
|
||||||
|
<div className="sb-grid-item">
|
||||||
|
<img src={Share} alt="A browser window showing a Storybook being published to a chromatic.com URL" />
|
||||||
|
<h4 className="sb-section-item-heading">Publish to Chromatic</h4>
|
||||||
|
<p className="sb-section-item-paragraph">Publish your Storybook to review and collaborate with your entire team.</p>
|
||||||
|
<a
|
||||||
|
href="https://storybook.js.org/docs/react/sharing/publish-storybook#publish-storybook-with-chromatic"
|
||||||
|
target="_blank"
|
||||||
|
>Learn more<RightArrow /></a>
|
||||||
|
</div>
|
||||||
|
<div className="sb-grid-item">
|
||||||
|
<img src={FigmaPlugin} alt="Windows showing the Storybook plugin in Figma" />
|
||||||
|
<h4 className="sb-section-item-heading">Figma Plugin</h4>
|
||||||
|
<p className="sb-section-item-paragraph">Embed your stories into Figma to cross-reference the design and live
|
||||||
|
implementation in one place.</p>
|
||||||
|
<a
|
||||||
|
href="https://storybook.js.org/docs/react/sharing/design-integrations#embed-storybook-in-figma-with-the-plugin"
|
||||||
|
target="_blank"
|
||||||
|
>Learn more<RightArrow /></a>
|
||||||
|
</div>
|
||||||
|
<div className="sb-grid-item">
|
||||||
|
<img src={Testing} alt="Screenshot of tests passing and failing" />
|
||||||
|
<h4 className="sb-section-item-heading">Testing</h4>
|
||||||
|
<p className="sb-section-item-paragraph">Use stories to test a component in all its variations, no matter how
|
||||||
|
complex.</p>
|
||||||
|
<a
|
||||||
|
href="https://storybook.js.org/docs/react/writing-tests/introduction"
|
||||||
|
target="_blank"
|
||||||
|
>Learn more<RightArrow /></a>
|
||||||
|
</div>
|
||||||
|
<div className="sb-grid-item">
|
||||||
|
<img src={Accessibility} alt="Screenshot of accessibility tests passing and failing" />
|
||||||
|
<h4 className="sb-section-item-heading">Accessibility</h4>
|
||||||
|
<p className="sb-section-item-paragraph">Automatically test your components for a11y issues as you develop.</p>
|
||||||
|
<a
|
||||||
|
href="https://storybook.js.org/docs/react/writing-tests/accessibility-testing"
|
||||||
|
target="_blank"
|
||||||
|
>Learn more<RightArrow /></a>
|
||||||
|
</div>
|
||||||
|
<div className="sb-grid-item">
|
||||||
|
<img src={Theming} alt="Screenshot of Storybook in light and dark mode" />
|
||||||
|
<h4 className="sb-section-item-heading">Theming</h4>
|
||||||
|
<p className="sb-section-item-paragraph">Theme Storybook's UI to personalize it to your project.</p>
|
||||||
|
<a
|
||||||
|
href="https://storybook.js.org/docs/react/configure/theming"
|
||||||
|
target="_blank"
|
||||||
|
>Learn more<RightArrow /></a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className='sb-addon'>
|
||||||
|
<div className='sb-addon-text'>
|
||||||
|
<h4>Addons</h4>
|
||||||
|
<p className="sb-section-item-paragraph">Integrate your tools with Storybook to connect workflows.</p>
|
||||||
|
<a
|
||||||
|
href="https://storybook.js.org/integrations/"
|
||||||
|
target="_blank"
|
||||||
|
>Discover all addons<RightArrow /></a>
|
||||||
|
</div>
|
||||||
|
<div className='sb-addon-img'>
|
||||||
|
<img src={AddonLibrary} alt="Integrate your tools with Storybook to connect workflows." />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="sb-section sb-socials">
|
||||||
|
<div className="sb-section-item">
|
||||||
|
<img src={Github} alt="Github logo" className="sb-explore-image"/>
|
||||||
|
Join our contributors building the future of UI development.
|
||||||
|
|
||||||
|
<a
|
||||||
|
href="https://github.com/storybookjs/storybook"
|
||||||
|
target="_blank"
|
||||||
|
>Star on GitHub<RightArrow /></a>
|
||||||
|
</div>
|
||||||
|
<div className="sb-section-item">
|
||||||
|
<img src={Discord} alt="Discord logo" className="sb-explore-image"/>
|
||||||
|
<div>
|
||||||
|
Get support and chat with frontend developers.
|
||||||
|
|
||||||
|
<a
|
||||||
|
href="https://discord.gg/storybook"
|
||||||
|
target="_blank"
|
||||||
|
>Join Discord server<RightArrow /></a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="sb-section-item">
|
||||||
|
<img src={Youtube} alt="Youtube logo" className="sb-explore-image"/>
|
||||||
|
<div>
|
||||||
|
Watch tutorials, feature previews and interviews.
|
||||||
|
|
||||||
|
<a
|
||||||
|
href="https://www.youtube.com/@chromaticui"
|
||||||
|
target="_blank"
|
||||||
|
>Watch on YouTube<RightArrow /></a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="sb-section-item">
|
||||||
|
<img src={Tutorials} alt="A book" className="sb-explore-image"/>
|
||||||
|
<p>Follow guided walkthroughs on for key workflows.</p>
|
||||||
|
|
||||||
|
<a
|
||||||
|
href="https://storybook.js.org/tutorials/"
|
||||||
|
target="_blank"
|
||||||
|
>Discover tutorials<RightArrow /></a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
{`
|
||||||
|
.sb-container {
|
||||||
|
margin-bottom: 48px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sb-section {
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
gap: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
img {
|
||||||
|
object-fit: cover;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sb-section-title {
|
||||||
|
margin-bottom: 32px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sb-section a:not(h1 a, h2 a, h3 a) {
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sb-section-item, .sb-grid-item {
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sb-section-item-heading {
|
||||||
|
padding-top: 20px !important;
|
||||||
|
padding-bottom: 5px !important;
|
||||||
|
margin: 0 !important;
|
||||||
|
}
|
||||||
|
.sb-section-item-paragraph {
|
||||||
|
margin: 0;
|
||||||
|
padding-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sb-chevron {
|
||||||
|
margin-left: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sb-features-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(2, 1fr);
|
||||||
|
grid-gap: 32px 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sb-socials {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(4, 1fr);
|
||||||
|
}
|
||||||
|
|
||||||
|
.sb-socials p {
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sb-explore-image {
|
||||||
|
max-height: 32px;
|
||||||
|
align-self: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sb-addon {
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
position: relative;
|
||||||
|
background-color: #EEF3F8;
|
||||||
|
border-radius: 5px;
|
||||||
|
border: 1px solid rgba(0, 0, 0, 0.05);
|
||||||
|
background: #EEF3F8;
|
||||||
|
height: 180px;
|
||||||
|
margin-bottom: 48px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sb-addon-text {
|
||||||
|
padding-left: 48px;
|
||||||
|
max-width: 240px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sb-addon-text h4 {
|
||||||
|
padding-top: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sb-addon-img {
|
||||||
|
position: absolute;
|
||||||
|
left: 345px;
|
||||||
|
top: 0;
|
||||||
|
height: 100%;
|
||||||
|
width: 200%;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sb-addon-img img {
|
||||||
|
width: 650px;
|
||||||
|
transform: rotate(-15deg);
|
||||||
|
margin-left: 40px;
|
||||||
|
margin-top: -72px;
|
||||||
|
box-shadow: 0 0 1px rgba(255, 255, 255, 0);
|
||||||
|
backface-visibility: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (max-width: 800px) {
|
||||||
|
.sb-addon-img {
|
||||||
|
left: 300px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (max-width: 600px) {
|
||||||
|
.sb-section {
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sb-features-grid {
|
||||||
|
grid-template-columns: repeat(1, 1fr);
|
||||||
|
}
|
||||||
|
|
||||||
|
.sb-socials {
|
||||||
|
grid-template-columns: repeat(2, 1fr);
|
||||||
|
}
|
||||||
|
|
||||||
|
.sb-addon {
|
||||||
|
height: 280px;
|
||||||
|
align-items: flex-start;
|
||||||
|
padding-top: 32px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sb-addon-text {
|
||||||
|
padding-left: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sb-addon-img {
|
||||||
|
right: 0;
|
||||||
|
left: 0;
|
||||||
|
top: 130px;
|
||||||
|
bottom: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
height: auto;
|
||||||
|
width: 124%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sb-addon-img img {
|
||||||
|
width: 1200px;
|
||||||
|
transform: rotate(-12deg);
|
||||||
|
margin-left: 0;
|
||||||
|
margin-top: 48px;
|
||||||
|
margin-bottom: -40px;
|
||||||
|
margin-left: -24px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`}
|
||||||
|
</style>
|
27
stories/Header.stories.ts
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
import type { Meta, StoryObj } from '@storybook/react';
|
||||||
|
|
||||||
|
import { Header } from './Header';
|
||||||
|
|
||||||
|
const meta: Meta<typeof Header> = {
|
||||||
|
title: 'Example/Header',
|
||||||
|
component: Header,
|
||||||
|
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/react/writing-docs/autodocs
|
||||||
|
tags: ['autodocs'],
|
||||||
|
parameters: {
|
||||||
|
// More on Story layout: https://storybook.js.org/docs/react/configure/story-layout
|
||||||
|
layout: 'fullscreen',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default meta;
|
||||||
|
type Story = StoryObj<typeof Header>;
|
||||||
|
|
||||||
|
export const LoggedIn: Story = {
|
||||||
|
args: {
|
||||||
|
user: {
|
||||||
|
name: 'Jane Doe',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export const LoggedOut: Story = {};
|
56
stories/Header.tsx
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
import { Button } from './Button';
|
||||||
|
import './header.css';
|
||||||
|
|
||||||
|
type User = {
|
||||||
|
name: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
interface HeaderProps {
|
||||||
|
user?: User;
|
||||||
|
onLogin: () => void;
|
||||||
|
onLogout: () => void;
|
||||||
|
onCreateAccount: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const Header = ({ user, onLogin, onLogout, onCreateAccount }: HeaderProps) => (
|
||||||
|
<header>
|
||||||
|
<div className="storybook-header">
|
||||||
|
<div>
|
||||||
|
<svg width="32" height="32" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<g fill="none" fillRule="evenodd">
|
||||||
|
<path
|
||||||
|
d="M10 0h12a10 10 0 0110 10v12a10 10 0 01-10 10H10A10 10 0 010 22V10A10 10 0 0110 0z"
|
||||||
|
fill="#FFF"
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
d="M5.3 10.6l10.4 6v11.1l-10.4-6v-11zm11.4-6.2l9.7 5.5-9.7 5.6V4.4z"
|
||||||
|
fill="#555AB9"
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
d="M27.2 10.6v11.2l-10.5 6V16.5l10.5-6zM15.7 4.4v11L6 10l9.7-5.5z"
|
||||||
|
fill="#91BAF8"
|
||||||
|
/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
<h1>Acme</h1>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
{user ? (
|
||||||
|
<>
|
||||||
|
<span className="welcome">
|
||||||
|
Welcome, <b>{user.name}</b>!
|
||||||
|
</span>
|
||||||
|
<Button size="small" onClick={onLogout} label="Log out" />
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<Button size="small" onClick={onLogin} label="Log in" />
|
||||||
|
<Button primary size="small" onClick={onCreateAccount} label="Sign up" />
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
);
|
29
stories/Page.stories.ts
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
import type { Meta, StoryObj } from '@storybook/react';
|
||||||
|
import { within, userEvent } from '@storybook/testing-library';
|
||||||
|
|
||||||
|
import { Page } from './Page';
|
||||||
|
|
||||||
|
const meta: Meta<typeof Page> = {
|
||||||
|
title: 'Example/Page',
|
||||||
|
component: Page,
|
||||||
|
parameters: {
|
||||||
|
// More on Story layout: https://storybook.js.org/docs/react/configure/story-layout
|
||||||
|
layout: 'fullscreen',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default meta;
|
||||||
|
type Story = StoryObj<typeof Page>;
|
||||||
|
|
||||||
|
export const LoggedOut: Story = {};
|
||||||
|
|
||||||
|
// More on interaction testing: https://storybook.js.org/docs/react/writing-tests/interaction-testing
|
||||||
|
export const LoggedIn: Story = {
|
||||||
|
play: async ({ canvasElement }) => {
|
||||||
|
const canvas = within(canvasElement);
|
||||||
|
const loginButton = await canvas.getByRole('button', {
|
||||||
|
name: /Log in/i,
|
||||||
|
});
|
||||||
|
await userEvent.click(loginButton);
|
||||||
|
},
|
||||||
|
};
|
73
stories/Page.tsx
Normal file
|
@ -0,0 +1,73 @@
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
import { Header } from './Header';
|
||||||
|
import './page.css';
|
||||||
|
|
||||||
|
type User = {
|
||||||
|
name: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Page: React.FC = () => {
|
||||||
|
const [user, setUser] = React.useState<User>();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<article>
|
||||||
|
<Header
|
||||||
|
user={user}
|
||||||
|
onLogin={() => setUser({ name: 'Jane Doe' })}
|
||||||
|
onLogout={() => setUser(undefined)}
|
||||||
|
onCreateAccount={() => setUser({ name: 'Jane Doe' })}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<section className="storybook-page">
|
||||||
|
<h2>Pages in Storybook</h2>
|
||||||
|
<p>
|
||||||
|
We recommend building UIs with a{' '}
|
||||||
|
<a href="https://componentdriven.org" target="_blank" rel="noopener noreferrer">
|
||||||
|
<strong>component-driven</strong>
|
||||||
|
</a>{' '}
|
||||||
|
process starting with atomic components and ending with pages.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Render pages with mock data. This makes it easy to build and review page states without
|
||||||
|
needing to navigate to them in your app. Here are some handy patterns for managing page
|
||||||
|
data in Storybook:
|
||||||
|
</p>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
Use a higher-level connected component. Storybook helps you compose such data from the
|
||||||
|
"args" of child component stories
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
Assemble data in the page component from your services. You can mock these services out
|
||||||
|
using Storybook.
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<p>
|
||||||
|
Get a guided tutorial on component-driven development at{' '}
|
||||||
|
<a href="renderers/react/template/cli/ts/Page" target="_blank" rel="noopener noreferrer">
|
||||||
|
Storybook tutorials
|
||||||
|
</a>
|
||||||
|
. Read more in the{' '}
|
||||||
|
<a href="https://storybook.js.org/docs" target="_blank" rel="noopener noreferrer">
|
||||||
|
docs
|
||||||
|
</a>
|
||||||
|
.
|
||||||
|
</p>
|
||||||
|
<div className="tip-wrapper">
|
||||||
|
<span className="tip">Tip</span> Adjust the width of the canvas with the{' '}
|
||||||
|
<svg width="10" height="10" viewBox="0 0 12 12" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<g fill="none" fillRule="evenodd">
|
||||||
|
<path
|
||||||
|
d="M1.5 5.2h4.8c.3 0 .5.2.5.4v5.1c-.1.2-.3.3-.4.3H1.4a.5.5 0 01-.5-.4V5.7c0-.3.2-.5.5-.5zm0-2.1h6.9c.3 0 .5.2.5.4v7a.5.5 0 01-1 0V4H1.5a.5.5 0 010-1zm0-2.1h9c.3 0 .5.2.5.4v9.1a.5.5 0 01-1 0V2H1.5a.5.5 0 010-1zm4.3 5.2H2V10h3.8V6.2z"
|
||||||
|
id="a"
|
||||||
|
fill="#999"
|
||||||
|
/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
Viewports addon in the toolbar
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</article>
|
||||||
|
);
|
||||||
|
};
|
BIN
stories/assets/accessibility.png
Normal file
After Width: | Height: | Size: 41 KiB |
5
stories/assets/accessibility.svg
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<svg width="48" height="48" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<title>Accessibility</title>
|
||||||
|
<circle cx="24.334" cy="24" r="24" fill="#A849FF" fill-opacity="0.3"/>
|
||||||
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M27.8609 11.585C27.8609 9.59506 26.2497 7.99023 24.2519 7.99023C22.254 7.99023 20.6429 9.65925 20.6429 11.585C20.6429 13.575 22.254 15.1799 24.2519 15.1799C26.2497 15.1799 27.8609 13.575 27.8609 11.585ZM21.8922 22.6473C21.8467 23.9096 21.7901 25.4788 21.5897 26.2771C20.9853 29.0462 17.7348 36.3314 17.3325 37.2275C17.1891 37.4923 17.1077 37.7955 17.1077 38.1178C17.1077 39.1519 17.946 39.9902 18.9802 39.9902C19.6587 39.9902 20.253 39.6293 20.5814 39.0889L20.6429 38.9874L24.2841 31.22C24.2841 31.22 27.5529 37.9214 27.9238 38.6591C28.2948 39.3967 28.8709 39.9902 29.7168 39.9902C30.751 39.9902 31.5893 39.1519 31.5893 38.1178C31.5893 37.7951 31.3639 37.2265 31.3639 37.2265C30.9581 36.3258 27.698 29.0452 27.0938 26.2771C26.8975 25.4948 26.847 23.9722 26.8056 22.7236C26.7927 22.333 26.7806 21.9693 26.7653 21.6634C26.7008 21.214 27.0231 20.8289 27.4097 20.7005L35.3366 18.3253C36.3033 18.0685 36.8834 16.9773 36.6256 16.0144C36.3678 15.0515 35.2722 14.4737 34.3055 14.7305C34.3055 14.7305 26.8619 17.1057 24.2841 17.1057C21.7062 17.1057 14.456 14.7947 14.456 14.7947C13.4893 14.5379 12.3937 14.9873 12.0715 15.9502C11.7493 16.9131 12.3293 18.0044 13.3604 18.3253L21.2873 20.7005C21.674 20.8289 21.9318 21.214 21.9318 21.6634C21.9174 21.9493 21.9053 22.2857 21.8922 22.6473Z" fill="#A470D5"/>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 1.5 KiB |
BIN
stories/assets/addon-library.png
Normal file
After Width: | Height: | Size: 456 KiB |
BIN
stories/assets/assets.png
Normal file
After Width: | Height: | Size: 3.8 KiB |
BIN
stories/assets/context.png
Normal file
After Width: | Height: | Size: 6 KiB |
15
stories/assets/discord.svg
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<svg width="33" height="32" viewBox="0 0 33 32" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<g clip-path="url(#clip0_10031_177575)">
|
||||||
|
<mask id="mask0_10031_177575" style="mask-type:luminance" maskUnits="userSpaceOnUse" x="0" y="4" width="33" height="25">
|
||||||
|
<path d="M32.5034 4.00195H0.503906V28.7758H32.5034V4.00195Z" fill="white"/>
|
||||||
|
</mask>
|
||||||
|
<g mask="url(#mask0_10031_177575)">
|
||||||
|
<path d="M27.5928 6.20817C25.5533 5.27289 23.3662 4.58382 21.0794 4.18916C21.0378 4.18154 20.9962 4.20057 20.9747 4.23864C20.6935 4.73863 20.3819 5.3909 20.1637 5.90358C17.7042 5.53558 15.2573 5.53558 12.8481 5.90358C12.6299 5.37951 12.307 4.73863 12.0245 4.23864C12.003 4.20184 11.9614 4.18281 11.9198 4.18916C9.63431 4.58255 7.44721 5.27163 5.40641 6.20817C5.38874 6.21578 5.3736 6.22848 5.36355 6.24497C1.21508 12.439 0.078646 18.4809 0.636144 24.4478C0.638667 24.477 0.655064 24.5049 0.677768 24.5227C3.41481 26.5315 6.06609 27.7511 8.66815 28.5594C8.70979 28.5721 8.75392 28.5569 8.78042 28.5226C9.39594 27.6826 9.94461 26.7968 10.4151 25.8653C10.4428 25.8107 10.4163 25.746 10.3596 25.7244C9.48927 25.3945 8.66058 24.9922 7.86343 24.5354C7.80038 24.4986 7.79533 24.4084 7.85333 24.3653C8.02108 24.2397 8.18888 24.109 8.34906 23.977C8.37804 23.9529 8.41842 23.9478 8.45249 23.963C13.6894 26.3526 19.359 26.3526 24.5341 23.963C24.5682 23.9465 24.6086 23.9516 24.6388 23.9757C24.799 24.1077 24.9668 24.2397 25.1358 24.3653C25.1938 24.4084 25.19 24.4986 25.127 24.5354C24.3298 25.0011 23.5011 25.3945 22.6296 25.7232C22.5728 25.7447 22.5476 25.8107 22.5754 25.8653C23.0559 26.7955 23.6046 27.6812 24.2087 28.5213C24.234 28.5569 24.2794 28.5721 24.321 28.5594C26.9357 27.7511 29.5869 26.5315 32.324 24.5227C32.348 24.5049 32.3631 24.4783 32.3656 24.4491C33.0328 17.5506 31.2481 11.5584 27.6344 6.24623C27.6256 6.22848 27.6105 6.21578 27.5928 6.20817ZM11.1971 20.8146C9.62043 20.8146 8.32129 19.3679 8.32129 17.5913C8.32129 15.8146 9.59523 14.368 11.1971 14.368C12.8115 14.368 14.0981 15.8273 14.0729 17.5913C14.0729 19.3679 12.7989 20.8146 11.1971 20.8146ZM21.8299 20.8146C20.2533 20.8146 18.9541 19.3679 18.9541 17.5913C18.9541 15.8146 20.228 14.368 21.8299 14.368C23.4444 14.368 24.7309 15.8273 24.7057 17.5913C24.7057 19.3679 23.4444 20.8146 21.8299 20.8146Z" fill="#5865F2"/>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<defs>
|
||||||
|
<clipPath id="clip0_10031_177575">
|
||||||
|
<rect width="31.9995" height="32" fill="white" transform="translate(0.5)"/>
|
||||||
|
</clipPath>
|
||||||
|
</defs>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 2.4 KiB |
BIN
stories/assets/docs.png
Normal file
After Width: | Height: | Size: 27 KiB |
BIN
stories/assets/figma-plugin.png
Normal file
After Width: | Height: | Size: 43 KiB |
3
stories/assets/github.svg
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M16.0001 0C7.16466 0 0 7.17472 0 16.0256C0 23.1061 4.58452 29.1131 10.9419 31.2322C11.7415 31.3805 12.0351 30.8845 12.0351 30.4613C12.0351 30.0791 12.0202 28.8167 12.0133 27.4776C7.56209 28.447 6.62283 25.5868 6.62283 25.5868C5.89499 23.7345 4.8463 23.2419 4.8463 23.2419C3.39461 22.2473 4.95573 22.2678 4.95573 22.2678C6.56242 22.3808 7.40842 23.9192 7.40842 23.9192C8.83547 26.3691 11.1514 25.6609 12.0645 25.2514C12.2081 24.2156 12.6227 23.5087 13.0803 23.1085C9.52648 22.7032 5.7906 21.3291 5.7906 15.1886C5.7906 13.4389 6.41563 12.0094 7.43916 10.8871C7.27303 10.4834 6.72537 8.85349 7.59415 6.64609C7.59415 6.64609 8.93774 6.21539 11.9953 8.28877C13.2716 7.9337 14.6404 7.75563 16.0001 7.74953C17.3599 7.75563 18.7297 7.9337 20.0084 8.28877C23.0623 6.21539 24.404 6.64609 24.404 6.64609C25.2749 8.85349 24.727 10.4834 24.5608 10.8871C25.5868 12.0094 26.2075 13.4389 26.2075 15.1886C26.2075 21.3437 22.4645 22.699 18.9017 23.0957C19.4756 23.593 19.9869 24.5683 19.9869 26.0634C19.9869 28.2077 19.9684 29.9334 19.9684 30.4613C19.9684 30.8877 20.2564 31.3874 21.0674 31.2301C27.4213 29.1086 32 23.1037 32 16.0256C32 7.17472 24.8364 0 16.0001 0ZM5.99257 22.8288C5.95733 22.9084 5.83227 22.9322 5.71834 22.8776C5.60229 22.8253 5.53711 22.7168 5.57474 22.6369C5.60918 22.5549 5.7345 22.5321 5.85029 22.587C5.9666 22.6393 6.03284 22.7489 5.99257 22.8288ZM6.7796 23.5321C6.70329 23.603 6.55412 23.5701 6.45291 23.4581C6.34825 23.3464 6.32864 23.197 6.40601 23.125C6.4847 23.0542 6.62937 23.0874 6.73429 23.1991C6.83895 23.3121 6.85935 23.4605 6.7796 23.5321ZM7.31953 24.4321C7.2215 24.5003 7.0612 24.4363 6.96211 24.2938C6.86407 24.1513 6.86407 23.9804 6.96422 23.9119C7.06358 23.8435 7.2215 23.905 7.32191 24.0465C7.41968 24.1914 7.41968 24.3623 7.31953 24.4321ZM8.23267 25.4743C8.14497 25.5712 7.95818 25.5452 7.82146 25.413C7.68156 25.2838 7.64261 25.1004 7.73058 25.0035C7.81934 24.9064 8.00719 24.9337 8.14497 25.0648C8.28381 25.1938 8.3262 25.3785 8.23267 25.4743ZM9.41281 25.8262C9.37413 25.9517 9.19423 26.0088 9.013 25.9554C8.83203 25.9005 8.7136 25.7535 8.75016 25.6266C8.78778 25.5003 8.96848 25.4408 9.15104 25.4979C9.33174 25.5526 9.45044 25.6985 9.41281 25.8262ZM10.7559 25.9754C10.7604 26.1076 10.6067 26.2172 10.4165 26.2196C10.2252 26.2238 10.0704 26.1169 10.0683 25.9868C10.0683 25.8534 10.2185 25.7448 10.4098 25.7416C10.6001 25.7379 10.7559 25.8441 10.7559 25.9754ZM12.0753 25.9248C12.0981 26.0537 11.9658 26.1862 11.7769 26.2215C11.5912 26.2554 11.4192 26.1758 11.3957 26.0479C11.3726 25.9157 11.5072 25.7833 11.6927 25.7491C11.8819 25.7162 12.0512 25.7937 12.0753 25.9248Z" fill="#161614"/>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 2.7 KiB |
BIN
stories/assets/share.png
Normal file
After Width: | Height: | Size: 40 KiB |
BIN
stories/assets/styling.png
Normal file
After Width: | Height: | Size: 7.1 KiB |
BIN
stories/assets/testing.png
Normal file
After Width: | Height: | Size: 48 KiB |
BIN
stories/assets/theming.png
Normal file
After Width: | Height: | Size: 43 KiB |
12
stories/assets/tutorials.svg
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
<svg width="33" height="32" viewBox="0 0 33 32" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<g clip-path="url(#clip0_10031_177597)">
|
||||||
|
<path opacity="0.7" fill-rule="evenodd" clip-rule="evenodd" d="M17 7.87059C17 6.48214 17.9812 5.28722 19.3431 5.01709L29.5249 2.99755C31.3238 2.64076 33 4.01717 33 5.85105V22.1344C33 23.5229 32.0188 24.7178 30.6569 24.9879L20.4751 27.0074C18.6762 27.3642 17 25.9878 17 24.1539L17 7.87059Z" fill="#B7F0EF"/>
|
||||||
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M1 5.85245C1 4.01857 2.67623 2.64215 4.47507 2.99895L14.6569 5.01848C16.0188 5.28861 17 6.48354 17 7.87198V24.1553C17 25.9892 15.3238 27.3656 13.5249 27.0088L3.34311 24.9893C1.98119 24.7192 1 23.5242 1 22.1358V5.85245Z" fill="#87E6E5"/>
|
||||||
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M15.543 5.71289C15.543 5.71289 16.8157 5.96289 17.4002 6.57653C17.9847 7.19016 18.4521 9.03107 18.4521 9.03107C18.4521 9.03107 18.4521 25.1106 18.4521 26.9629C18.4521 28.8152 19.3775 31.4174 19.3775 31.4174L17.4002 28.8947L16.2575 31.4174C16.2575 31.4174 15.543 29.0765 15.543 27.122C15.543 25.1674 15.543 5.71289 15.543 5.71289Z" fill="#61C1FD"/>
|
||||||
|
</g>
|
||||||
|
<defs>
|
||||||
|
<clipPath id="clip0_10031_177597">
|
||||||
|
<rect width="32" height="32" fill="white" transform="translate(0.5)"/>
|
||||||
|
</clipPath>
|
||||||
|
</defs>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 1.2 KiB |
4
stories/assets/youtube.svg
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M31.3313 8.44657C30.9633 7.08998 29.8791 6.02172 28.5022 5.65916C26.0067 5.00026 16 5.00026 16 5.00026C16 5.00026 5.99333 5.00026 3.4978 5.65916C2.12102 6.02172 1.03665 7.08998 0.668678 8.44657C0 10.9053 0 16.0353 0 16.0353C0 16.0353 0 21.1652 0.668678 23.6242C1.03665 24.9806 2.12102 26.0489 3.4978 26.4116C5.99333 27.0703 16 27.0703 16 27.0703C16 27.0703 26.0067 27.0703 28.5022 26.4116C29.8791 26.0489 30.9633 24.9806 31.3313 23.6242C32 21.1652 32 16.0353 32 16.0353C32 16.0353 32 10.9053 31.3313 8.44657Z" fill="#ED1D24"/>
|
||||||
|
<path d="M12.7266 20.6934L21.0902 16.036L12.7266 11.3781V20.6934Z" fill="white"/>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 721 B |
30
stories/button.css
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
.storybook-button {
|
||||||
|
font-family: 'Nunito Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
|
||||||
|
font-weight: 700;
|
||||||
|
border: 0;
|
||||||
|
border-radius: 3em;
|
||||||
|
cursor: pointer;
|
||||||
|
display: inline-block;
|
||||||
|
line-height: 1;
|
||||||
|
}
|
||||||
|
.storybook-button--primary {
|
||||||
|
color: white;
|
||||||
|
background-color: #1ea7fd;
|
||||||
|
}
|
||||||
|
.storybook-button--secondary {
|
||||||
|
color: #333;
|
||||||
|
background-color: transparent;
|
||||||
|
box-shadow: rgba(0, 0, 0, 0.15) 0px 0px 0px 1px inset;
|
||||||
|
}
|
||||||
|
.storybook-button--small {
|
||||||
|
font-size: 12px;
|
||||||
|
padding: 10px 16px;
|
||||||
|
}
|
||||||
|
.storybook-button--medium {
|
||||||
|
font-size: 14px;
|
||||||
|
padding: 11px 20px;
|
||||||
|
}
|
||||||
|
.storybook-button--large {
|
||||||
|
font-size: 16px;
|
||||||
|
padding: 12px 24px;
|
||||||
|
}
|
32
stories/header.css
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
.storybook-header {
|
||||||
|
font-family: 'Nunito Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
|
||||||
|
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
|
||||||
|
padding: 15px 20px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
|
.storybook-header svg {
|
||||||
|
display: inline-block;
|
||||||
|
vertical-align: top;
|
||||||
|
}
|
||||||
|
|
||||||
|
.storybook-header h1 {
|
||||||
|
font-weight: 700;
|
||||||
|
font-size: 20px;
|
||||||
|
line-height: 1;
|
||||||
|
margin: 6px 0 6px 10px;
|
||||||
|
display: inline-block;
|
||||||
|
vertical-align: top;
|
||||||
|
}
|
||||||
|
|
||||||
|
.storybook-header button + button {
|
||||||
|
margin-left: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.storybook-header .welcome {
|
||||||
|
color: #333;
|
||||||
|
font-size: 14px;
|
||||||
|
margin-right: 10px;
|
||||||
|
}
|
69
stories/page.css
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
.storybook-page {
|
||||||
|
font-family: 'Nunito Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 24px;
|
||||||
|
padding: 48px 20px;
|
||||||
|
margin: 0 auto;
|
||||||
|
max-width: 600px;
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.storybook-page h2 {
|
||||||
|
font-weight: 700;
|
||||||
|
font-size: 32px;
|
||||||
|
line-height: 1;
|
||||||
|
margin: 0 0 4px;
|
||||||
|
display: inline-block;
|
||||||
|
vertical-align: top;
|
||||||
|
}
|
||||||
|
|
||||||
|
.storybook-page p {
|
||||||
|
margin: 1em 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.storybook-page a {
|
||||||
|
text-decoration: none;
|
||||||
|
color: #1ea7fd;
|
||||||
|
}
|
||||||
|
|
||||||
|
.storybook-page ul {
|
||||||
|
padding-left: 30px;
|
||||||
|
margin: 1em 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.storybook-page li {
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.storybook-page .tip {
|
||||||
|
display: inline-block;
|
||||||
|
border-radius: 1em;
|
||||||
|
font-size: 11px;
|
||||||
|
line-height: 12px;
|
||||||
|
font-weight: 700;
|
||||||
|
background: #e7fdd8;
|
||||||
|
color: #66bf3c;
|
||||||
|
padding: 4px 12px;
|
||||||
|
margin-right: 10px;
|
||||||
|
vertical-align: top;
|
||||||
|
}
|
||||||
|
|
||||||
|
.storybook-page .tip-wrapper {
|
||||||
|
font-size: 13px;
|
||||||
|
line-height: 20px;
|
||||||
|
margin-top: 40px;
|
||||||
|
margin-bottom: 40px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.storybook-page .tip-wrapper svg {
|
||||||
|
display: inline-block;
|
||||||
|
height: 12px;
|
||||||
|
width: 12px;
|
||||||
|
margin-right: 4px;
|
||||||
|
vertical-align: top;
|
||||||
|
margin-top: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.storybook-page .tip-wrapper svg path {
|
||||||
|
fill: #1ea7fd;
|
||||||
|
}
|
3
supabase/.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
# Supabase
|
||||||
|
.branches
|
||||||
|
.temp
|
108
supabase/config.toml
Normal file
|
@ -0,0 +1,108 @@
|
||||||
|
# A string used to distinguish different Supabase projects on the same host. Defaults to the
|
||||||
|
# working directory name when running `supabase init`.
|
||||||
|
project_id = "eduproj"
|
||||||
|
|
||||||
|
[api]
|
||||||
|
# Port to use for the API URL.
|
||||||
|
port = 54321
|
||||||
|
# Schemas to expose in your API. Tables, views and stored procedures in this schema will get API
|
||||||
|
# endpoints. public and storage are always included.
|
||||||
|
schemas = ["public", "storage", "graphql_public"]
|
||||||
|
# Extra schemas to add to the search_path of every request. public is always included.
|
||||||
|
extra_search_path = ["public", "extensions"]
|
||||||
|
# The maximum number of rows returns from a view, table, or stored procedure. Limits payload size
|
||||||
|
# for accidental or malicious requests.
|
||||||
|
max_rows = 1000
|
||||||
|
|
||||||
|
[db]
|
||||||
|
# Port to use for the local database URL.
|
||||||
|
port = 54322
|
||||||
|
# Port used by db diff command to initialise the shadow database.
|
||||||
|
shadow_port = 54320
|
||||||
|
# The database major version to use. This has to be the same as your remote database's. Run `SHOW
|
||||||
|
# server_version;` on the remote database to check.
|
||||||
|
major_version = 15
|
||||||
|
|
||||||
|
[studio]
|
||||||
|
enabled = true
|
||||||
|
# Port to use for Supabase Studio.
|
||||||
|
port = 54323
|
||||||
|
# External URL of the API server that frontend connects to.
|
||||||
|
api_url = "http://localhost"
|
||||||
|
|
||||||
|
# Email testing server. Emails sent with the local dev setup are not actually sent - rather, they
|
||||||
|
# are monitored, and you can view the emails that would have been sent from the web interface.
|
||||||
|
[inbucket]
|
||||||
|
enabled = true
|
||||||
|
# Port to use for the email testing server web interface.
|
||||||
|
port = 54324
|
||||||
|
# Uncomment to expose additional ports for testing user applications that send emails.
|
||||||
|
# smtp_port = 54325
|
||||||
|
# pop3_port = 54326
|
||||||
|
|
||||||
|
[storage]
|
||||||
|
# The maximum file size allowed (e.g. "5MB", "500KB").
|
||||||
|
file_size_limit = "50MiB"
|
||||||
|
|
||||||
|
[auth]
|
||||||
|
# The base URL of your website. Used as an allow-list for redirects and for constructing URLs used
|
||||||
|
# in emails.
|
||||||
|
site_url = "http://localhost:3000"
|
||||||
|
# A list of *exact* URLs that auth providers are permitted to redirect to post authentication.
|
||||||
|
additional_redirect_urls = ["https://localhost:3000"]
|
||||||
|
# How long tokens are valid for, in seconds. Defaults to 3600 (1 hour), maximum 604,800 (1 week).
|
||||||
|
jwt_expiry = 3600
|
||||||
|
# If disabled, the refresh token will never expire.
|
||||||
|
enable_refresh_token_rotation = true
|
||||||
|
# Allows refresh tokens to be reused after expiry, up to the specified interval in seconds.
|
||||||
|
# Requires enable_refresh_token_rotation = true.
|
||||||
|
refresh_token_reuse_interval = 10
|
||||||
|
# Allow/disallow new user signups to your project.
|
||||||
|
enable_signup = true
|
||||||
|
|
||||||
|
[auth.email]
|
||||||
|
# Allow/disallow new user signups via email to your project.
|
||||||
|
enable_signup = true
|
||||||
|
# If enabled, a user will be required to confirm any email change on both the old, and new email
|
||||||
|
# addresses. If disabled, only the new email is required to confirm.
|
||||||
|
double_confirm_changes = true
|
||||||
|
# If enabled, users need to confirm their email address before signing in.
|
||||||
|
enable_confirmations = false
|
||||||
|
|
||||||
|
[auth.sms]
|
||||||
|
# Allow/disallow new user signups via SMS to your project.
|
||||||
|
enable_signup = true
|
||||||
|
# If enabled, users need to confirm their phone number before signing in.
|
||||||
|
enable_confirmations = false
|
||||||
|
|
||||||
|
# Configure one of the supported SMS providers: `twilio`, `messagebird`, `textlocal`, `vonage`.
|
||||||
|
[auth.sms.twilio]
|
||||||
|
enabled = false
|
||||||
|
account_sid = ""
|
||||||
|
message_service_sid = ""
|
||||||
|
# DO NOT commit your Twilio auth token to git. Use environment variable substitution instead:
|
||||||
|
auth_token = "env(SUPABASE_AUTH_SMS_TWILIO_AUTH_TOKEN)"
|
||||||
|
|
||||||
|
# Use an external OAuth provider. The full list of providers are: `apple`, `azure`, `bitbucket`,
|
||||||
|
# `discord`, `facebook`, `github`, `gitlab`, `google`, `keycloak`, `linkedin`, `notion`, `twitch`,
|
||||||
|
# `twitter`, `slack`, `spotify`, `workos`, `zoom`.
|
||||||
|
[auth.external.apple]
|
||||||
|
enabled = false
|
||||||
|
client_id = ""
|
||||||
|
# DO NOT commit your OAuth provider secret to git. Use environment variable substitution instead:
|
||||||
|
secret = "env(SUPABASE_AUTH_EXTERNAL_APPLE_SECRET)"
|
||||||
|
# Overrides the default auth redirectUrl.
|
||||||
|
redirect_uri = ""
|
||||||
|
# Overrides the default auth provider URL. Used to support self-hosted gitlab, single-tenant Azure,
|
||||||
|
# or any other third-party OIDC providers.
|
||||||
|
url = ""
|
||||||
|
|
||||||
|
[analytics]
|
||||||
|
enabled = false
|
||||||
|
port = 54327
|
||||||
|
vector_port = 54328
|
||||||
|
# Setup BigQuery project to enable log viewer on local development stack.
|
||||||
|
# See: https://supabase.com/docs/guides/getting-started/local-development#enabling-local-logging
|
||||||
|
gcp_project_id = ""
|
||||||
|
gcp_project_number = ""
|
||||||
|
gcp_jwt_path = "supabase/gcloud.json"
|
3
supabase/functions/.vscode/extensions.json
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"recommendations": ["denoland.vscode-deno"]
|
||||||
|
}
|
5
supabase/functions/.vscode/settings.json
vendored
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"deno.enable": true,
|
||||||
|
"deno.lint": true,
|
||||||
|
"editor.defaultFormatter": "denoland.vscode-deno"
|
||||||
|
}
|
18
supabase/migrations/20230618024722_init.sql
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
create table if not exists todos (
|
||||||
|
id uuid default gen_random_uuid() primary key,
|
||||||
|
created_at timestamp with time zone default timezone('utc'::text, now()) not null,
|
||||||
|
title text,
|
||||||
|
is_complete boolean default false,
|
||||||
|
user_id uuid references auth.users default auth.uid()
|
||||||
|
);
|
||||||
|
|
||||||
|
-- Set up Row Level Security (RLS)
|
||||||
|
-- See https://supabase.com/docs/guides/auth/row-level-security for more details.
|
||||||
|
alter table todos
|
||||||
|
enable row level security;
|
||||||
|
|
||||||
|
create policy "Authenticated users can select todos" on todos
|
||||||
|
for select to authenticated using (true);
|
||||||
|
|
||||||
|
create policy "Authenticated users can insert their own todos" on todos
|
||||||
|
for insert to authenticated with check (auth.uid() = user_id);
|
0
supabase/seed.sql
Normal file
17
tailwind.config.js
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
/** @type {import('tailwindcss').Config} */
|
||||||
|
module.exports = {
|
||||||
|
content: ['./app/**/*.{js,ts,jsx,tsx,mdx}'],
|
||||||
|
theme: {
|
||||||
|
extend: {
|
||||||
|
colors: {
|
||||||
|
background: 'hsl(var(--background))',
|
||||||
|
foreground: 'hsl(var(--foreground))',
|
||||||
|
btn: {
|
||||||
|
background: 'hsl(var(--btn-background))',
|
||||||
|
'background-hover': 'hsl(var(--btn-background-hover))',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
plugins: [],
|
||||||
|
}
|
28
tsconfig.json
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "es5",
|
||||||
|
"lib": ["dom", "dom.iterable", "esnext"],
|
||||||
|
"allowJs": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"strict": true,
|
||||||
|
"forceConsistentCasingInFileNames": true,
|
||||||
|
"noEmit": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"module": "esnext",
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"resolveJsonModule": true,
|
||||||
|
"isolatedModules": true,
|
||||||
|
"jsx": "preserve",
|
||||||
|
"incremental": true,
|
||||||
|
"plugins": [
|
||||||
|
{
|
||||||
|
"name": "next"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"paths": {
|
||||||
|
"@/*": ["./*"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
|
||||||
|
"exclude": ["node_modules"]
|
||||||
|
}
|