commit fc9297759af4a5b3c8c7212aa4bb3e5becdc21d1
parent f30467d1260e894ccaee066880a3faa8230a8070
Author: minerva-jupiter <ryouturn@gmail.com>
Date: Wed, 7 Jan 2026 15:58:40 +0900
feat: Implement push notifications and dark mode UI redesign
Diffstat:
13 files changed, 459 insertions(+), 21 deletions(-)
diff --git a/app/api/notif/route.ts b/app/api/notif/route.ts
@@ -0,0 +1,52 @@
+import { NextResponse } from "next/server";
+import type { TapKind } from "@/lib/handleTap";
+
+export async function POST(request: Request) {
+ try {
+ const { tapKind, time, userId } = await request.json();
+ if (
+ !tapKind ||
+ !time ||
+ !userId ||
+ !process.env.ONESIGNAL_APIKEY ||
+ !process.env.NEXT_PUBLIC_ONESIGNAL_APP_ID
+ ) {
+ return NextResponse.json(
+ { message: "Missing required fields" },
+ { status: 400 },
+ );
+ }
+ const response = await fetch("https://api.onesignal.com/notifications", {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ Authorization: `Basic ${process.env.ONESIGNAL_APIKEY}`,
+ },
+ body: JSON.stringify({
+ app_id: process.env.NEXT_PUBLIC_ONESIGNAL_APP_ID,
+ include_external_user_ids: [userId],
+ contents: {
+ en: `You have a ${tapKind} scheduled for ${time}`,
+ },
+ send_after: time,
+ }),
+ });
+ console.log(await response.text());
+ if (response.ok) {
+ return NextResponse.json({
+ message: "Notification scheduled successfully",
+ });
+ } else {
+ return NextResponse.json(
+ { message: "Failed to schedule notification" },
+ { status: response.status },
+ );
+ }
+ } catch (error) {
+ console.log(error);
+ return NextResponse.json(
+ { message: "Failed to schedule notification" },
+ { status: 500 },
+ );
+ }
+}
diff --git a/app/favicon.ico b/app/favicon.ico
Binary files differ.
diff --git a/app/globals.css b/app/globals.css
@@ -0,0 +1,353 @@
+@import "tailwindcss";
+
+:root {
+ --background: #fbfbfb;
+ --foreground: #000000;
+ --card: #ffffff;
+ --card-foreground: #000000;
+ --primary: #000000;
+ --primary-foreground: #ffffff;
+ --secondary: #000000;
+ --secondary-foreground: #666666;
+ --tap: #000000;
+ --tap-foreground: #ffffff;
+ --muted: #cccccc;
+ --muted-foreground: #777777;
+ --nav-foreground: #555555;
+ --tap-bg-1: #ededed;
+ --tap-bg-2: #ddffcc;
+ --tap-bg-3: #caffbb;
+ --tap-bg-4: #b0ffaa;
+ --tap-bg-5: #a0ff99;
+ --tap-bg-6: #88ff88;
+ --tap-bg-7: #73ff80;
+ --tap-bg-8: #55ff70;
+ --tap-bg-9: #00ff5e;
+ --setting: #333333;
+ --setting-foreground: #000000;
+}
+
+.dark {
+ --background: #000000;
+ --foreground: #ffffff;
+ --card: #151515;
+ --card-foreground: #ffffff;
+ --primary: #fbfbfb;
+ --primary-foreground: #333333;
+ --secondary: #ffffff;
+ --secondary-foreground: #aaaaaa;
+ --tap: #ffffff;
+ --tap-foreground: #333333;
+ --muted: #555555;
+ --muted-foreground: #aaaaaa;
+ --nav-foreground: #aaaaaa;
+ --tap-bg-1: #151515;
+ --tap-bg-2: #153011;
+ --tap-bg-3: #153911;
+ --tap-bg-4: #154811;
+ --tap-bg-5: #155711;
+ --tap-bg-6: #156611;
+ --tap-bg-7: #158811;
+ --tap-bg-8: #15aa11;
+ --tap-bg-9: #15cc11;
+}
+
+html {
+ font-size: clamp(0.875rem, 0.5rem + 1vw, 1.125rem);
+}
+
+:root {
+ --svh: 100vh;
+ --bottom-nav-height: 56px;
+}
+@supports (height: 1svh) {
+ :root {
+ --svh: 100svh;
+ }
+}
+@media (min-width: 1000px) {
+ :root {
+ --bottom-nav-height: 0px;
+ }
+}
+
+html,
+body,
+#__next {
+ height: var(--svh);
+ min-height: var(--svh);
+ display: flex;
+ flex-direction: column;
+}
+
+header {
+ background-color: var(--background);
+ font-size: 1.35rem;
+ font-weight: 700;
+}
+
+body {
+ background-color: var(--background);
+ color: var(--foreground);
+ font-family: sans-serif;
+ font-weight: 700;
+ padding-bottom: calc(
+ var(--bottom-nav-height) + env(safe-area-inset-bottom)
+ );
+}
+
+.btn-setting {
+ flex: 1 1 0%;
+ padding-top: 8px;
+ padding-bottom: 8px;
+ text-align: center;
+ font-size: 1.2rem;
+ line-height: 1.25;
+ font-weight: 700;
+ color: var(--secondary-foreground);
+ background-color: transparent;
+ transition: all 0.2s ease-in-out;
+}
+.btn-setting:hover {
+ color: var(--secondary);
+}
+
+.btn-nav {
+ flex: 1 1 0%;
+ padding-top: 14px;
+ padding-bottom: 14px;
+ text-align: center;
+ font-size: 1.2rem;
+ line-height: 1.25;
+ font-weight: 700;
+ color: var(--nav-foreground);
+ background-color: var(--background);
+ transition: all 0.2s ease-in-out;
+}
+.btn-nav:hover {
+ color: var(--primary);
+}
+.btn-nav.active {
+ background-color: var(--primary);
+ color: var(--primary-foreground);
+}
+
+.dashboard-container {
+ container-type: inline-size;
+ display: flex;
+ flex-direction: column;
+ gap: 6cqw;
+ padding: 6cqw;
+}
+
+.timer-card {
+ background-color: var(--card);
+ color: var(--card-foreground);
+ border: 1px solid var(--muted);
+ border-radius: 2cqw;
+ padding: 4.5cqw;
+ backdrop-filter: blur(6px);
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+}
+.timer-card-title {
+ font-size: 4cqw;
+ font-weight: 700;
+ color: var(--secondary-foreground);
+ margin-bottom: 0.8cqw;
+}
+
+.countdown-text-l {
+ font-size: 14cqw;
+ font-weight: 700;
+ letter-spacing: 0.05em;
+ line-height: 1.1;
+ margin-top: 0.5cqw;
+ margin-bottom: 0.5cqw;
+}
+.countdown-text-s {
+ font-size: 8.5cqw;
+ font-weight: 700;
+ letter-spacing: 0.05em;
+ line-height: 1.1;
+}
+
+.slot-grid {
+ display: grid;
+ grid-template-columns: repeat(4, 1fr);
+ gap: 1cqw;
+ margin-bottom: 4.5cqw;
+ padding: 0 6cqw;
+}
+.slot-item {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ border-radius: 1.5cqw;
+ border-style: none;
+ min-height: 8cqw;
+ transition: all 0.2s;
+ line-height: 1.2;
+ font-weight: 700;
+}
+.slot-default {
+ background-color: var(--card);
+ color: var(--muted);
+}
+.slot-current {
+ background-color: var(--card);
+ color: var(--muted);
+ text-decoration: underline;
+ text-underline-offset: 4px;
+ text-decoration-thickness: 1.5px;
+}
+.slot-tapped {
+ color: var(--primary);
+}
+.slot-text-main {
+ font-size: 5cqw;
+}
+.slot-text-sub {
+ font-size: 2cqw;
+}
+
+.btn-timer {
+ width: 100%;
+ font-weight: 700;
+ padding: 3cqw 0;
+ margin: 0;
+ border-radius: 1.5cqw;
+ font-size: 4.5cqw;
+ transition: all 0.2s ease-in-out;
+ background-color: var(--primary);
+ color: var(--primary-foreground);
+ height: auto;
+}
+.btn-timer:disabled {
+ background-color: var(--muted);
+ color: var(--muted-foreground);
+ cursor: not-allowed;
+}
+
+.btn-timer-tap {
+ background-color: var(--tap);
+ color: var(--tap-foreground);
+ transition: all 0.2s ease-in-out;
+}
+.btn-timer-tap:hover {
+ filter: brightness(0.9);
+}
+
+.cal-info {
+ font-size: 1.35rem;
+ font-weight: 700;
+}
+.cal-week {
+ font-size: 1.1rem;
+ font-weight: 700;
+}
+.cal-days {
+ font-size: 40cqw;
+ font-weight: 700;
+}
+.cal-tap {
+ font-size: 50cqw;
+ font-weight: 700;
+}
+.cal-nav {
+ flex: 1 1 0%;
+ padding-top: 14px;
+ padding-bottom: 14px;
+ text-align: center;
+ font-size: 1.2rem;
+ line-height: 1.25;
+ font-weight: 700;
+ color: var(--secondary-foreground);
+ background-color: transparent;
+ transition: all 0.2s ease-in-out;
+}
+.cal-nav:hover {
+ color: var(--primary);
+}
+.cal-cell {
+ container-type: inline-size;
+}
+
+.bg-tap-1 {
+ background-color: var(--tap-bg-1);
+}
+.bg-tap-2 {
+ background-color: var(--tap-bg-2);
+}
+.bg-tap-3 {
+ background-color: var(--tap-bg-3);
+}
+.bg-tap-4 {
+ background-color: var(--tap-bg-4);
+}
+.bg-tap-5 {
+ background-color: var(--tap-bg-5);
+}
+.bg-tap-6 {
+ background-color: var(--tap-bg-6);
+}
+.bg-tap-7 {
+ background-color: var(--tap-bg-7);
+}
+.bg-tap-8 {
+ background-color: var(--tap-bg-8);
+}
+.bg-tap-9 {
+ background-color: var(--tap-bg-9);
+}
+
+.mobile-view {
+ display: block;
+ margin-top: 3rem;
+ padding: 0.5rem;
+}
+.desktop-view {
+ display: none;
+}
+.desktop-hidden {
+ display: flex;
+}
+
+@media (min-width: 1000px) {
+ html {
+ font-size: 0.875rem;
+ }
+ .mobile-view {
+ display: none;
+ }
+ .desktop-view {
+ display: grid;
+ grid-template-columns: repeat(2, minmax(0, 1fr));
+ gap: 1.5rem;
+ margin-top: 2rem;
+ padding: 1.5rem;
+ }
+ .desktop-hidden {
+ display: none;
+ }
+ .dashboard-container {
+ gap: 2cqw;
+ padding: 3cqw;
+ }
+
+ .timer-card-title {
+ font-size: 3cqw;
+ }
+ .countdown-text-l {
+ font-size: 11cqw;
+ }
+ .countdown-text-s {
+ font-size: 7.5cqw;
+ }
+ .btn-timer {
+ padding: 2cqw 0;
+ font-size: 3.5cqw;
+ }
+}
diff --git a/app/page.tsx b/app/page.tsx
@@ -1,33 +1,54 @@
"use client";
-import { signInWithPopup, signOut } from "firebase/auth";
+import { signInWithPopup, signOut, onAuthStateChanged } from "firebase/auth";
import { auth, authProvider } from "@/lib/firebase";
-import { useState } from "react";
-import { saveTapHistory } from "@/lib/handleTap";
+import { useEffect, useState } from "react";
+import { saveTapHistory, testNotification } from "@/lib/handleTap";
+import OneSignal from "react-onesignal";
export default function Home() {
const [isSignedIn, setIsSignedIn] = useState(false);
+ useEffect(() => {
+ const unsubscribe = onAuthStateChanged(auth, async (user) => {
+ if (user) {
+ setIsSignedIn(true);
+ const userId = user.uid;
+
+ try {
+ await OneSignal.init({
+ appId: process.env.NEXT_PUBLIC_ONESIGNAL_APP_ID!,
+ });
+
+ await OneSignal.login(userId);
+ console.log("OneSignal login successful");
+ } catch (error) {
+ console.error("OneSignal operation failed:", error);
+ }
+ } else {
+ setIsSignedIn(false);
+ console.log("User is signed out");
+ }
+ });
+
+ return () => unsubscribe();
+ }, []);
function Signin() {
const handleSignIn = async () => {
try {
await signInWithPopup(auth, authProvider);
+ console.log("Sign-in popup successful");
} catch (error) {
console.error("Error signing in:", error);
- return;
}
- setIsSignedIn(true);
- console.log("Signed in");
};
const handleSignOut = async () => {
try {
await signOut(auth);
+ console.log("Signed out");
} catch (error) {
console.error("Error signing out:", error);
- return;
}
- setIsSignedIn(false);
- console.log("Signed out");
};
if (isSignedIn == false) {
return <button onClick={handleSignIn}>Sign in with Google</button>;
@@ -43,6 +64,7 @@ export default function Home() {
{Signin()}
<button onClick={() => saveTapHistory("normal")}>Save Tap History</button>
+ <button onClick={() => testNotification()}>Schedule Notification</button>
</main>
);
}
diff --git a/bun.lock b/bun.lock
@@ -11,6 +11,7 @@
"next": "16.1.1",
"react": "19.2.3",
"react-dom": "19.2.3",
+ "react-onesignal": "^3.4.6",
},
"devDependencies": {
"@tailwindcss/postcss": "^4.1.18",
@@ -1013,6 +1014,8 @@
"react-is": ["react-is@16.13.1", "", {}, "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ=="],
+ "react-onesignal": ["react-onesignal@3.4.6", "", {}, "sha512-Jxr5GMdHssaZBVeWjhwn4ImqP5qcc8ekrSIVYrvetlf+7UNn9zUrXFFcAoWGi1BRru/4UcDEB+lOaBEPJVI1yw=="],
+
"readable-stream": ["readable-stream@3.6.2", "", { "dependencies": { "inherits": "^2.0.3", "string_decoder": "^1.1.1", "util-deprecate": "^1.0.1" } }, "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA=="],
"reflect.getprototypeof": ["reflect.getprototypeof@1.0.10", "", { "dependencies": { "call-bind": "^1.0.8", "define-properties": "^1.2.1", "es-abstract": "^1.23.9", "es-errors": "^1.3.0", "es-object-atoms": "^1.0.0", "get-intrinsic": "^1.2.7", "get-proto": "^1.0.1", "which-builtin-type": "^1.2.1" } }, "sha512-00o4I+DVrefhv+nX0ulyi3biSHCPDe+yLv5o/p6d/UVlirijB8E16FtfwSAi4g3tcqrQ4lRAqQSoFEZJehYEcw=="],
diff --git a/lib/handleTap.ts b/lib/handleTap.ts
@@ -1,7 +1,7 @@
import { arrayUnion, doc, setDoc } from "firebase/firestore";
import { auth, db } from "./firebase";
-type TapKind = "normal" | "ticket1" | "ticket2";
+export type TapKind = "normal" | "ticket1" | "ticket2";
export async function saveTapHistory(tapKind: TapKind) {
const user = auth.currentUser;
@@ -29,4 +29,19 @@ export async function saveTapHistory(tapKind: TapKind) {
}
}
+export async function testNotification() {
+ const response = await fetch("api/notif", {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({
+ tapKind: "normal",
+ time: new Date(Date.now() + 30 * 1000).toISOString(),
+ userId: auth.currentUser?.uid,
+ }),
+ });
+ console.log(await response.json());
+}
+
export async function handleTap() {}
diff --git a/package.json b/package.json
@@ -15,7 +15,8 @@
"firebase-admin": "^13.6.0",
"next": "16.1.1",
"react": "19.2.3",
- "react-dom": "19.2.3"
+ "react-dom": "19.2.3",
+ "react-onesignal": "^3.4.6"
},
"devDependencies": {
"@tailwindcss/postcss": "^4.1.18",
diff --git a/public/OneSignalSDKWorker.js b/public/OneSignalSDKWorker.js
@@ -0,0 +1 @@
+importScripts("https://cdn.onesignal.com/sdks/web/v16/OneSignalSDK.sw.js");+
\ No newline at end of file
diff --git a/public/file.svg b/public/file.svg
@@ -1 +0,0 @@
-<svg fill="none" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M14.5 13.5V5.41a1 1 0 0 0-.3-.7L9.8.29A1 1 0 0 0 9.08 0H1.5v13.5A2.5 2.5 0 0 0 4 16h8a2.5 2.5 0 0 0 2.5-2.5m-1.5 0v-7H8v-5H3v12a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1M9.5 5V2.12L12.38 5zM5.13 5h-.62v1.25h2.12V5zm-.62 3h7.12v1.25H4.5zm.62 3h-.62v1.25h7.12V11z" clip-rule="evenodd" fill="#666" fill-rule="evenodd"/></svg>-
\ No newline at end of file
diff --git a/public/globe.svg b/public/globe.svg
@@ -1 +0,0 @@
-<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><g clip-path="url(#a)"><path fill-rule="evenodd" clip-rule="evenodd" d="M10.27 14.1a6.5 6.5 0 0 0 3.67-3.45q-1.24.21-2.7.34-.31 1.83-.97 3.1M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16m.48-1.52a7 7 0 0 1-.96 0H7.5a4 4 0 0 1-.84-1.32q-.38-.89-.63-2.08a40 40 0 0 0 3.92 0q-.25 1.2-.63 2.08a4 4 0 0 1-.84 1.31zm2.94-4.76q1.66-.15 2.95-.43a7 7 0 0 0 0-2.58q-1.3-.27-2.95-.43a18 18 0 0 1 0 3.44m-1.27-3.54a17 17 0 0 1 0 3.64 39 39 0 0 1-4.3 0 17 17 0 0 1 0-3.64 39 39 0 0 1 4.3 0m1.1-1.17q1.45.13 2.69.34a6.5 6.5 0 0 0-3.67-3.44q.65 1.26.98 3.1M8.48 1.5l.01.02q.41.37.84 1.31.38.89.63 2.08a40 40 0 0 0-3.92 0q.25-1.2.63-2.08a4 4 0 0 1 .85-1.32 7 7 0 0 1 .96 0m-2.75.4a6.5 6.5 0 0 0-3.67 3.44 29 29 0 0 1 2.7-.34q.31-1.83.97-3.1M4.58 6.28q-1.66.16-2.95.43a7 7 0 0 0 0 2.58q1.3.27 2.95.43a18 18 0 0 1 0-3.44m.17 4.71q-1.45-.12-2.69-.34a6.5 6.5 0 0 0 3.67 3.44q-.65-1.27-.98-3.1" fill="#666"/></g><defs><clipPath id="a"><path fill="#fff" d="M0 0h16v16H0z"/></clipPath></defs></svg>-
\ No newline at end of file
diff --git a/public/next.svg b/public/next.svg
@@ -1 +0,0 @@
-<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 394 80"><path fill="#000" d="M262 0h68.5v12.7h-27.2v66.6h-13.6V12.7H262V0ZM149 0v12.7H94v20.4h44.3v12.6H94v21h55v12.6H80.5V0h68.7zm34.3 0h-17.8l63.8 79.4h17.9l-32-39.7 32-39.6h-17.9l-23 28.6-23-28.6zm18.3 56.7-9-11-27.1 33.7h17.8l18.3-22.7z"/><path fill="#000" d="M81 79.3 17 0H0v79.3h13.6V17l50.2 62.3H81Zm252.6-.4c-1 0-1.8-.4-2.5-1s-1.1-1.6-1.1-2.6.3-1.8 1-2.5 1.6-1 2.6-1 1.8.3 2.5 1a3.4 3.4 0 0 1 .6 4.3 3.7 3.7 0 0 1-3 1.8zm23.2-33.5h6v23.3c0 2.1-.4 4-1.3 5.5a9.1 9.1 0 0 1-3.8 3.5c-1.6.8-3.5 1.3-5.7 1.3-2 0-3.7-.4-5.3-1s-2.8-1.8-3.7-3.2c-.9-1.3-1.4-3-1.4-5h6c.1.8.3 1.6.7 2.2s1 1.2 1.6 1.5c.7.4 1.5.5 2.4.5 1 0 1.8-.2 2.4-.6a4 4 0 0 0 1.6-1.8c.3-.8.5-1.8.5-3V45.5zm30.9 9.1a4.4 4.4 0 0 0-2-3.3 7.5 7.5 0 0 0-4.3-1.1c-1.3 0-2.4.2-3.3.5-.9.4-1.6 1-2 1.6a3.5 3.5 0 0 0-.3 4c.3.5.7.9 1.3 1.2l1.8 1 2 .5 3.2.8c1.3.3 2.5.7 3.7 1.2a13 13 0 0 1 3.2 1.8 8.1 8.1 0 0 1 3 6.5c0 2-.5 3.7-1.5 5.1a10 10 0 0 1-4.4 3.5c-1.8.8-4.1 1.2-6.8 1.2-2.6 0-4.9-.4-6.8-1.2-2-.8-3.4-2-4.5-3.5a10 10 0 0 1-1.7-5.6h6a5 5 0 0 0 3.5 4.6c1 .4 2.2.6 3.4.6 1.3 0 2.5-.2 3.5-.6 1-.4 1.8-1 2.4-1.7a4 4 0 0 0 .8-2.4c0-.9-.2-1.6-.7-2.2a11 11 0 0 0-2.1-1.4l-3.2-1-3.8-1c-2.8-.7-5-1.7-6.6-3.2a7.2 7.2 0 0 1-2.4-5.7 8 8 0 0 1 1.7-5 10 10 0 0 1 4.3-3.5c2-.8 4-1.2 6.4-1.2 2.3 0 4.4.4 6.2 1.2 1.8.8 3.2 2 4.3 3.4 1 1.4 1.5 3 1.5 5h-5.8z"/></svg>-
\ No newline at end of file
diff --git a/public/vercel.svg b/public/vercel.svg
@@ -1 +0,0 @@
-<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1155 1000"><path d="m577.3 0 577.4 1000H0z" fill="#fff"/></svg>-
\ No newline at end of file
diff --git a/public/window.svg b/public/window.svg
@@ -1 +0,0 @@
-<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path fill-rule="evenodd" clip-rule="evenodd" d="M1.5 2.5h13v10a1 1 0 0 1-1 1h-11a1 1 0 0 1-1-1zM0 1h16v11.5a2.5 2.5 0 0 1-2.5 2.5h-11A2.5 2.5 0 0 1 0 12.5zm3.75 4.5a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5M7 4.75a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0m1.75.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5" fill="#666"/></svg>-
\ No newline at end of file