Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
eraykeskinmac committed Oct 21, 2024
1 parent f469f8c commit 54309eb
Show file tree
Hide file tree
Showing 28 changed files with 2,187 additions and 247 deletions.
8 changes: 8 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

NEXT_PUBLIC_SUPABASE_URL=https://csfaqeefgtohburtvgpn.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImNzZmFxZWVmZ3RvaGJ1cnR2Z3BuIiwicm9sZSI6ImFub24iLCJpYXQiOjE3Mjg5OTg4ODYsImV4cCI6MjA0NDU3NDg4Nn0.mlKCP-Gsjch8GJr0ua2zfN8_JKlLZqiXpqT7TLyAbTw
NEXT_PUBLIC_ENABLE_SUPABASE=true

NEXT_PUBLIC_ENABLE_POSTHOG=true
NEXT_PUBLIC_POSTHOG_KEY=phc_SpfNUuNO79fyikMCwJKB4K9lRrDMyXrQT7XZBZYb5qx
NEXT_PUBLIC_POSTHOG_HOST=https://us.i.posthog.com
Empty file modified .gitignore
100644 → 100755
Empty file.
Empty file modified README.md
100644 → 100755
Empty file.
Empty file modified app/favicon.ico
100644 → 100755
Empty file.
Empty file modified app/fonts/GeistMonoVF.woff
100644 → 100755
Empty file.
Empty file modified app/fonts/GeistVF.woff
100644 → 100755
Empty file.
79 changes: 65 additions & 14 deletions app/globals.css
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,7 @@
@tailwind components;
@tailwind utilities;

:root {
--background: #ffffff;
--foreground: #171717;
}

@media (prefers-color-scheme: dark) {
:root {
--background: #0a0a0a;
--foreground: #ededed;
}
}

body {
color: var(--foreground);
background: var(--background);
font-family: Arial, Helvetica, sans-serif;
}

Expand All @@ -25,3 +11,68 @@ body {
text-wrap: balance;
}
}

@layer base {
:root {
--background: 0 0% 100%;
--foreground: 0 0% 3.9%;
--card: 0 0% 100%;
--card-foreground: 0 0% 3.9%;
--popover: 0 0% 100%;
--popover-foreground: 0 0% 3.9%;
--primary: 0 0% 9%;
--primary-foreground: 0 0% 98%;
--secondary: 0 0% 96.1%;
--secondary-foreground: 0 0% 9%;
--muted: 0 0% 96.1%;
--muted-foreground: 0 0% 45.1%;
--accent: 0 0% 96.1%;
--accent-foreground: 0 0% 9%;
--destructive: 0 84.2% 60.2%;
--destructive-foreground: 0 0% 98%;
--border: 0 0% 89.8%;
--input: 0 0% 89.8%;
--ring: 0 0% 3.9%;
--chart-1: 12 76% 61%;
--chart-2: 173 58% 39%;
--chart-3: 197 37% 24%;
--chart-4: 43 74% 66%;
--chart-5: 27 87% 67%;
--radius: 0.5rem;
}
.dark {
--background: 0 0% 3.9%;
--foreground: 0 0% 98%;
--card: 0 0% 3.9%;
--card-foreground: 0 0% 98%;
--popover: 0 0% 3.9%;
--popover-foreground: 0 0% 98%;
--primary: 0 0% 98%;
--primary-foreground: 0 0% 9%;
--secondary: 0 0% 14.9%;
--secondary-foreground: 0 0% 98%;
--muted: 0 0% 14.9%;
--muted-foreground: 0 0% 63.9%;
--accent: 0 0% 14.9%;
--accent-foreground: 0 0% 98%;
--destructive: 0 62.8% 30.6%;
--destructive-foreground: 0 0% 98%;
--border: 0 0% 14.9%;
--input: 0 0% 14.9%;
--ring: 0 0% 83.1%;
--chart-1: 220 70% 50%;
--chart-2: 160 60% 45%;
--chart-3: 30 80% 55%;
--chart-4: 280 65% 60%;
--chart-5: 340 75% 55%;
}
}

@layer base {
* {
@apply border-border;
}
body {
@apply bg-background text-foreground;
}
}
20 changes: 15 additions & 5 deletions app/layout.tsx
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Metadata } from "next";
import localFont from "next/font/local";
import "./globals.css";
import { PostHogProvider, ThemeProvider } from "./providers";

const geistSans = localFont({
src: "./fonts/GeistVF.woff",
Expand All @@ -25,11 +26,20 @@ export default function RootLayout({
}>) {
return (
<html lang="en">
<body
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
>
{children}
</body>
<PostHogProvider>
<body
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
>
<ThemeProvider
attribute="class"
defaultTheme="dark"
enableSystem
disableTransitionOnChange
>
{children}
</ThemeProvider>
</body>
</PostHogProvider>
</html>
);
}
125 changes: 32 additions & 93 deletions app/page.tsx
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,101 +1,40 @@
"use client";

import { AuthDialog } from "@/components/auth-dialog";
import { Navbar } from "@/components/navbar";
import { AuthViewType, useAuth } from "@/lib/auth";
import { supabase } from "@/lib/supabase";
import Image from "next/image";
import { useState } from "react";

export default function Home() {
const [isAuthDialogOpen, setAuthDialog] = useState(false);
const [authView, setAuthView] = useState<AuthViewType>("sign_in");
const { session } = useAuth(setAuthDialog, setAuthView);

function logout() {
supabase ? supabase.auth.signOut() : console.warn("supabase not loaded");
}

return (
<div className="grid grid-rows-[20px_1fr_20px] items-center justify-items-center min-h-screen p-8 pb-20 gap-16 sm:p-20 font-[family-name:var(--font-geist-sans)]">
<main className="flex flex-col gap-8 row-start-2 items-center sm:items-start">
<Image
className="dark:invert"
src="https://nextjs.org/icons/next.svg"
alt="Next.js logo"
width={180}
height={38}
priority
<main className="flex min-h-screen max-h-screen">
{supabase && (
<AuthDialog
open={isAuthDialogOpen}
setOpen={setAuthDialog}
view={authView}
supabase={supabase}
/>
<ol className="list-inside list-decimal text-sm text-center sm:text-left font-[family-name:var(--font-geist-mono)]">
<li className="mb-2">
Get started by editing{" "}
<code className="bg-black/[.05] dark:bg-white/[.06] px-1 py-0.5 rounded font-semibold">
app/page.tsx
</code>
.
</li>
<li>Save and see your changes instantly.</li>
</ol>

<div className="flex gap-4 items-center flex-col sm:flex-row">
<a
className="rounded-full border border-solid border-transparent transition-colors flex items-center justify-center bg-foreground text-background gap-2 hover:bg-[#383838] dark:hover:bg-[#ccc] text-sm sm:text-base h-10 sm:h-12 px-4 sm:px-5"
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
<Image
className="dark:invert"
src="https://nextjs.org/icons/vercel.svg"
alt="Vercel logomark"
width={20}
height={20}
/>
Deploy now
</a>
<a
className="rounded-full border border-solid border-black/[.08] dark:border-white/[.145] transition-colors flex items-center justify-center hover:bg-[#f2f2f2] dark:hover:bg-[#1a1a1a] hover:border-transparent text-sm sm:text-base h-10 sm:h-12 px-4 sm:px-5 sm:min-w-44"
href="https://nextjs.org/docs?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
Read our docs
</a>
</div>
</main>
<footer className="row-start-3 flex gap-6 flex-wrap items-center justify-center">
<a
className="flex items-center gap-2 hover:underline hover:underline-offset-4"
href="https://nextjs.org/learn?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
<Image
aria-hidden
src="https://nextjs.org/icons/file.svg"
alt="File icon"
width={16}
height={16}
/>
Learn
</a>
<a
className="flex items-center gap-2 hover:underline hover:underline-offset-4"
href="https://vercel.com/templates?framework=next.js&utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
<Image
aria-hidden
src="https://nextjs.org/icons/window.svg"
alt="Window icon"
width={16}
height={16}
)}
<div className="grid w-full md:grid-cols-2">
<div>
<Navbar
session={session}
showLogin={() => setAuthDialog(true)}
signOut={logout}
/>
Examples
</a>
<a
className="flex items-center gap-2 hover:underline hover:underline-offset-4"
href="https://nextjs.org?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
<Image
aria-hidden
src="https://nextjs.org/icons/globe.svg"
alt="Globe icon"
width={16}
height={16}
/>
Go to nextjs.org →
</a>
</footer>
</div>
</div>
</div>
</main>
);
}
29 changes: 29 additions & 0 deletions app/providers.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
'use client'

import posthog from 'posthog-js'
import React, { ReactNode } from 'react'
import {PostHogProvider as PostHogProviderJS} from 'posthog-js/react'
import { ThemeProvider as NextThemesProvider } from 'next-themes'
import { ThemeProviderProps } from 'next-themes/dist/types'

if (typeof window !== 'undefined' && process.env.NEXT_PUBLIC_ENABLE_POSTHOG) {
posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY ?? '', {
api_host: process.env.NEXT_PUBLIC_POSTHOG_HOST,
person_profiles: 'identified_only',
session_recording: {
recordCrossOriginIframes: true,
}
})
}

export function PostHogProvider({children}: {children: ReactNode}) {
return process.env.NEXT_PUBLIC_ENABLE_POSTHOG ? (
<PostHogProviderJS client={posthog}>{children}</PostHogProviderJS>
) : (
children
)
}

export function ThemeProvider({children, ...props}: ThemeProviderProps) {
return <NextThemesProvider {...props}>{children}</NextThemesProvider>
}
20 changes: 20 additions & 0 deletions components.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"$schema": "https://ui.shadcn.com/schema.json",
"style": "default",
"rsc": true,
"tsx": true,
"tailwind": {
"config": "tailwind.config.ts",
"css": "app/globals.css",
"baseColor": "neutral",
"cssVariables": true,
"prefix": ""
},
"aliases": {
"components": "@/components",
"utils": "@/lib/utils",
"ui": "@/components/ui",
"lib": "@/lib",
"hooks": "@/hooks"
}
}
28 changes: 28 additions & 0 deletions components/auth-dialog.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { AuthViewType } from "@/lib/auth";
import { SupabaseClient } from "@supabase/supabase-js";
import { Dialog, DialogContent, DialogTitle } from "./ui/dialog";
import { VisuallyHidden } from "@radix-ui/react-visually-hidden";
import AuthForm from "./auth-form";

export function AuthDialog({
open,
setOpen,
supabase,
view,
}: {
open: boolean;
setOpen: (open: boolean) => void;
supabase: SupabaseClient;
view: AuthViewType;
}) {
return (
<Dialog open={open} onOpenChange={setOpen}>
<DialogContent>
<VisuallyHidden>
<DialogTitle>Sig in to Tiny Chat</DialogTitle>
</VisuallyHidden>
<AuthForm supabase={supabase} view={view} />
</DialogContent>
</Dialog>
);
}
Loading

0 comments on commit 54309eb

Please sign in to comment.