Skip to content

Commit

Permalink
Merge pull request #21 from davidemarcoli/feature/pwa
Browse files Browse the repository at this point in the history
Feature/pwa
  • Loading branch information
davidemarcoli authored Oct 27, 2023
2 parents 9e37d87 + c6f141a commit 12f1d2a
Show file tree
Hide file tree
Showing 21 changed files with 240 additions and 63 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# Auto Generated PWA files
**/public/sw.js
**/public/workbox-*.js
**/public/worker-*.js
**/public/sw.js.map
**/public/workbox-*.js.map
**/public/worker-*.js.map

# dependencies
/node_modules
/.pnp
Expand Down
Binary file removed app/favicon2.ico
Binary file not shown.
76 changes: 39 additions & 37 deletions app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,51 +1,53 @@
import "./globals.css";
import { Analytics } from "@vercel/analytics/react";
import {Analytics} from "@vercel/analytics/react";
import Nav from "@/components/layout/nav";
import React from "react";
import { ThemeProvider } from "@/components/theme-provider";
import { inter, sfPro } from "@/app/fonts";
import { cx } from "class-variance-authority";
import { Toaster } from "@/components/ui/toaster";
import {ThemeProvider} from "@/components/theme-provider";
import {inter, sfPro} from "@/app/fonts";
import {cx} from "class-variance-authority";
import {Toaster} from "@/components/ui/toaster";
import {CommandMenu} from "@/components/command-menu";
import {Changelog} from "@/components/changelog";

export const metadata = {
title: "NextQuiz",
description:
"NextQuiz is a quiz app built with Next.js, Prisma, and Tailwind CSS.",
twitter: {
card: "summary_large_image",
title: "NextQuiz",
description:
"NextQuiz is a quiz app built with Next.js, Prisma, and Tailwind CSS.",
creator: "@davide_marcoli",
},
metadataBase: new URL("https://next-quiz.davidemarcoli.dev"),
themeColor: "#000000",
"NextQuiz is a quiz app built with Next.js, Prisma, and Tailwind CSS.",
twitter: {
card: "summary_large_image",
title: "NextQuiz",
description:
"NextQuiz is a quiz app built with Next.js, Prisma, and Tailwind CSS.",
creator: "@davide_marcoli",
},
manifest: '/manifest.webmanifest',
keywords: ['NextQuiz', 'Quiz', 'Davide Marcoli'],
metadataBase: new URL("https://next-quiz.davidemarcoli.dev"),
themeColor: "#000000",
};

export default async function RootLayout({
children,
}: {
children: React.ReactNode;
children,
}: {
children: React.ReactNode;
}) {
return (
<>
<html lang="en">
<body className={cx(sfPro.variable, inter.variable)}>
<ThemeProvider attribute="class" defaultTheme="system" enableSystem>
{/*<Suspense fallback="...">*/}
{/* @ts-expect-error Server Component */}
<Nav />
{/*</Suspense>*/}
<main className={"mx-4 mt-16"}>{children}</main>
<Toaster />
<Analytics />
<CommandMenu />
<Changelog />
</ThemeProvider>
</body>
</html>
</>
);
return (
<>
<html lang="en">
<body className={cx(sfPro.variable, inter.variable)}>
<ThemeProvider attribute="class" defaultTheme="system" enableSystem>
{/*<Suspense fallback="...">*/}
{/* @ts-expect-error Server Component */}
<Nav/>
{/*</Suspense>*/}
<main className={"mx-4 mt-16"}>{children}</main>
<Toaster/>
<Analytics/>
<CommandMenu/>
<Changelog/>
</ThemeProvider>
</body>
</html>
</>
);
}
11 changes: 1 addition & 10 deletions app/quiz/list/page.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
import {Quiz, User} from "@prisma/client";
import Balancer from "react-wrap-balancer";
import ReactMarkdown from "react-markdown";
import Link from "next/link";
import prisma from "@/lib/prisma";
import {
Card,
CardContent,
CardDescription,
CardFooter,
CardHeader,
CardTitle,
} from "@/components/ui/card";
import {Card, CardFooter, CardHeader, CardTitle,} from "@/components/ui/card";

async function getQuizzes(): Promise<(Quiz & {user: User})[]> {
return await prisma.quiz.findMany({
Expand Down
Binary file modified bun.lockb
Binary file not shown.
10 changes: 2 additions & 8 deletions components/changelog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ const {version} = require("/package.json");

export function Changelog() {

console.log(version)

const [showDialog, setShowDialog] = React.useState(false)

React.useEffect(() => {
Expand All @@ -27,16 +25,12 @@ export function Changelog() {
<DialogContent>
<DialogHeader>
<DialogTitle>Changelog</DialogTitle>
<h1 className="text-2xl">October 07, 2023 - Release 1.0.0</h1>
<h1 className="text-2xl">October 26, 2023 - Release {version}</h1>
<hr/>

<h3 className="text-xl">Summary</h3>
<ul>
<li><strong>[New]</strong> Changelog</li>
<li><strong>[New]</strong> Command Menu on desktop which can be opened with <code>Ctrl/Cmd +
K</code> 🎉
</li>
<li><strong>[Upgraded]</strong> to Next.js 13.5 and TypeScript 5.2.2</li>
<li><strong>[New]</strong> Add PWA</li>

{/*<li><strong>[New]</strong> Added new feature</li>*/}
{/*<li><strong>[Fix]</strong> Fixed some bugs</li>*/}
Expand Down
8 changes: 7 additions & 1 deletion next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,10 @@ const nextConfig = {
},
};

module.exports = nextConfig;
const withPWA = require("@ducanh2912/next-pwa").default({
dest: "public",
register: true,
skipWaiting: true,
});

module.exports = withPWA(nextConfig);
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "next-quiz",
"version": "1.0.0",
"version": "1.0.1",
"private": true,
"scripts": {
"dev": "prisma generate && next dev",
Expand All @@ -11,6 +11,7 @@
"lint": "next lint"
},
"dependencies": {
"@ducanh2912/next-pwa": "^9.7.2",
"@hookform/resolvers": "^3.3.1",
"@next-auth/prisma-adapter": "^1.0.7",
"@prisma/client": "^5.4.1",
Expand All @@ -32,12 +33,12 @@
"clsx": "^2.0.0",
"cmdk": "^0.2.0",
"eslint": "^8.51.0",
"eslint-config-next": "^13.5.4",
"eslint-config-next": "^13.5.6",
"focus-trap-react": "^10.2.2",
"framer-motion": "^10.16.4",
"lucide-react": "^0.284.0",
"ms": "^2.1.3",
"next": "13.5.4",
"next": "^13.5.6",
"next-auth": "^4.23.2",
"next-themes": "^0.2.1",
"react": "^18.2.0",
Expand Down
107 changes: 107 additions & 0 deletions prisma/schema.planetscale.prisma
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
generator client {
provider = "prisma-client-js"
}

datasource db {
provider = "mysql"
url = env("DATABASE_URL")
relationMode = "prisma"
}

model Account {
id String @id @default(cuid())
userId String
type String
provider String
providerAccountId String
refresh_token String? @db.Text
refresh_token_expires_in Int?
access_token String? @db.Text
expires_at Int?
token_type String?
scope String?
id_token String? @db.Text
session_state String?
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@unique([provider, providerAccountId])
@@index([userId])
}

model Session {
id String @id @default(cuid())
sessionToken String @unique
userId String
expires DateTime
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@index([userId])
}

model User {
id String @id @default(cuid())
name String?
email String? @unique
emailVerified DateTime?
image String?
accounts Account[]
sessions Session[]
quizzes Quiz[]
Skill Skill[]
LearnedWord LearnedWord[]
}

model VerificationToken {
identifier String
token String @unique
expires DateTime
@@unique([identifier, token])
}

model QuizWord {
id String @id @default(cuid())
term String
definition String
quiz Quiz @relation(fields: [quizId], references: [id], onDelete: Cascade)
quizId String
Skill Skill[]
LearnedWord LearnedWord[]
@@index([quizId])
}

model Quiz {
id String @id @default(cuid())
name String
words QuizWord[]
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
userId String
@@index([userId])
}

model Skill {
id String @id @default(cuid())
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
userId String
quizWord QuizWord @relation(fields: [quizWordId], references: [id], onDelete: Cascade)
quizWordId String
proficiency Int
@@index([userId])
@@index([quizWordId])
}

model LearnedWord {
id String @id @default(cuid())
learned Boolean
userId String
quizWordId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
quizWord QuizWord @relation(fields: [quizWordId], references: [id], onDelete: Cascade)
@@index([userId, quizWordId])
@@index([quizWordId])
}
6 changes: 2 additions & 4 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ generator client {
}

datasource db {
provider = "postgresql"
url = env("POSTGRES_PRISMA_URL") // uses connection pooling
directUrl = env("POSTGRES_URL_NON_POOLING") // uses a direct connection
shadowDatabaseUrl = env("POSTGRES_URL_NON_POOLING") // used for migrations
provider = "postgresql"
url = env("DATABASE_URL")
}

model Account {
Expand Down
Binary file added public/icons/icon-192x192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/icons/icon-256x256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/icons/icon-384x384.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/icons/icon-512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/screenshot-narrow-cards.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/screenshot-narrow-quiz-list.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/screenshot-narrow-quiz.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/screenshot-wide-cards.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/screenshot-wide-quiz-list.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/screenshot-wide-quiz.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
70 changes: 70 additions & 0 deletions public/manifest.webmanifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"theme_color": "#020817",
"background_color": "#020817",
"display": "standalone",
"scope": "/",
"start_url": "/",
"name": "Next Quiz",
"short_name": "Next Quiz",
"description": "NextQuiz is a quiz app built with Next.js, Prisma, and Tailwind CSS.",
"icons": [
{
"src": "/icons/icon-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "/icons/icon-256x256.png",
"sizes": "256x256",
"type": "image/png"
},
{
"src": "/icons/icon-384x384.png",
"sizes": "384x384",
"type": "image/png"
},
{
"src": "/icons/icon-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
],
"screenshots": [
{
"src": "/images/screenshot-narrow-quiz-list.png",
"type": "image/png",
"sizes": "388x813",
"form_factor": "narrow"
},
{
"src": "/images/screenshot-narrow-quiz.png",
"type": "image/png",
"sizes": "388x813",
"form_factor": "narrow"
},
{
"src": "/images/screenshot-narrow-cards.png",
"type": "image/png",
"sizes": "388x813",
"form_factor": "narrow"
},
{
"src": "/images/screenshot-wide-quiz-list.png",
"type": "image/jpg",
"sizes": "1918x993",
"form_factor": "wide"
},
{
"src": "/images/screenshot-wide-quiz.png",
"type": "image/jpg",
"sizes": "1918x993",
"form_factor": "wide"
},
{
"src": "/images/screenshot-wide-cards.png",
"type": "image/jpg",
"sizes": "1918x993",
"form_factor": "wide"
}
]
}

0 comments on commit 12f1d2a

Please sign in to comment.