Skip to content

Commit

Permalink
auth page changes + icons with potential fix for google oauth
Browse files Browse the repository at this point in the history
  • Loading branch information
vuvincent committed Sep 22, 2023
1 parent faeb462 commit fea3fdf
Show file tree
Hide file tree
Showing 14 changed files with 124 additions and 63 deletions.
1 change: 1 addition & 0 deletions apps/api-v2/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const config = parseEnv(process.env, {
REDIS_URL: z.string().min(1),
AXIOM_TOKEN: z.string().min(1).optional(),
AXIOM_DATASET: z.string().min(1).optional(),
THIS_URL: z.string().min(1),
});

export default config;
4 changes: 3 additions & 1 deletion apps/api-v2/src/db.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { PrismaClient } from "@prisma/client";
import { createClient } from "redis";
import config from "./config";
import { logger } from "./logging";

export const prisma = new PrismaClient();

// TODO: use ioredis instead
export const redis = createClient({
url: config.REDIS_URL,
});

redis.on("error", (err) => {
console.error(err);
logger.error(err);
});
2 changes: 1 addition & 1 deletion apps/api-v2/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const createApp = () => {
{
clientID: config.GOOGLE_CLIENT_ID,
clientSecret: config.GOOGLE_CLIENT_SECRET,
callbackURL: "/auth/google/callback",
callbackURL: `${config.THIS_URL}/auth/google/callback`,
},
(_accessToken, _refreshToken, profile, cb) => {
// generate a JWT that encodes the user's OAuth profile
Expand Down
3 changes: 2 additions & 1 deletion apps/desktop-v2/.env.example
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
NEXT_PUBLIC_API_BASE_URL=""
NEXT_PUBLIC_API_BASE_URL= # the API's base URL; prod should be https://api.trysupernova.one
ENV= # the platform to build for. Either "desktop" or "web"; optional
18 changes: 15 additions & 3 deletions apps/desktop-v2/app/auth/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import Link from "next/link";
import { useRouter } from "next/navigation";
import { useEffect } from "react";
import { homeRoute } from "../meta";
import { GlobeIcon } from "@radix-ui/react-icons";
import { SupernovaGlobeLogoImage } from "@/components/icons";

const AuthPage = () => {
const router = useRouter();
Expand All @@ -20,10 +22,20 @@ const AuthPage = () => {
}, []);

return (
<main className="flex flex-col items-center justify-center max-h-screen">
<div className="flex flex-col">
<main className="flex flex-col items-center justify-center h-screen max-h-screen bg-dark-teal-gradient">
<div className="flex flex-col items-center gap-2">
<SupernovaGlobeLogoImage
priority
className="animate-slideInFromTopFast"
/>
<div className="h-1" />
<h1 className="text-xl text-white">Sign in</h1>
<div className="h-1" />
<Link href={supernovaAPI.getGoogleOAuthUrl()}>
<Button>Login with Google</Button>
{/* TODO: replace with Google logo */}
<Button bgVariant="white" className="gap-1">
<GlobeIcon /> Sign in with Google
</Button>
</Link>
</div>
</main>
Expand Down
5 changes: 4 additions & 1 deletion apps/desktop-v2/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ function RootLayout({ children }: RootLayoutProps) {
<html lang="en">
<body className={manrope.className}>
{/* drag region because titlebar is overlay */}
<div data-tauri-drag-region="self" className="h-5" />
<div
data-tauri-drag-region="self"
className="h-5 bg-transparent z-10 absolute top-0"
/>
<ToastClientWrapper>{children}</ToastClientWrapper>
</body>
</html>
Expand Down
9 changes: 2 additions & 7 deletions apps/desktop-v2/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { CreateTaskPlaceholder } from "@/components/create-task-placeholder";
import { useAtom } from "jotai";
import { chosenTaskIndexGlobal } from "@/store/ui";
import useOutsideClick from "@/hooks/useOutsideClick";
import { SupernovaGlobeLogoImage } from "@/components/icons";

function Home() {
// get today's date in this format: Tue, 26th Aug
Expand Down Expand Up @@ -368,13 +369,7 @@ function Home() {
/>
)}
<div>
<Image
src="/supernova-globe.svg"
width={30}
height={30}
alt="Supernova's icon"
priority
/>
<SupernovaGlobeLogoImage width={30} height={30} priority />
</div>
<div className="flex items-center gap-[10px]">
<h4 className="text-[20px] font-semibold">Today</h4>
Expand Down
11 changes: 9 additions & 2 deletions apps/desktop-v2/components/button.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
import { ButtonHTMLAttributes } from "react";
import { twMerge } from "tailwind-merge";

export const Button = (props: ButtonHTMLAttributes<HTMLButtonElement>) => {
type Props = ButtonHTMLAttributes<HTMLButtonElement> & {
bgVariant?: "black" | "white";
};

export const Button = ({ bgVariant = "black", ...props }: Props) => {
return (
<button
{...props}
className={twMerge(
"px-[7px] py-[5px] bg-slate-900 hover:bg-slate-700 transition-colors rounded-[5px] justify-center items-center inline-flex text-white text-sm font-medium leading-[14px]",
"px-[7px] py-[5px] transition-colors rounded-[5px] justify-center items-center inline-flex text-sm font-medium leading-[14px]",
props.disabled && "opacity-50 cursor-not-allowed",
bgVariant === "white"
? "bg-white text-black hover:bg-slate-300"
: "bg-slate-900 hover:bg-slate-700 text-white",
props.className
)}
>
Expand Down
9 changes: 2 additions & 7 deletions apps/desktop-v2/components/command-center.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { SupernovaCommand } from "../types/command";
import { ISupernovaTask } from "../types/supernova-task";
import { twMerge } from "tailwind-merge";
import { ibmPlexMono } from "./fonts";
import { SupernovaGlobeLogoImage } from "./icons";

export const SupernovaCommandCenter = ({
commands,
Expand Down Expand Up @@ -57,13 +58,7 @@ export const SupernovaCommandCenter = ({
</div>
)}
<div className="flex items-center gap-2">
<Image
src={"/supernova-globe.svg"}
width={20}
height={20}
alt="Supernova's logo"
priority
/>
<SupernovaGlobeLogoImage width={20} height={20} priority />
<Command.Input
placeholder="Find a command..."
className="outline-none"
Expand Down
29 changes: 27 additions & 2 deletions apps/desktop-v2/components/icons.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,32 @@
import Image from "next/image";

type ImageProps = React.ImgHTMLAttributes<HTMLImageElement> & {
width?: number;
height?: number;
priority?: boolean;
placeholder?: "blur" | "empty";
};

export const arrowRightPath = "icons/arrow-right.svg";

export const ArrowRightIcon = () => (
<Image src={arrowRightPath} width={20} height={20} alt="Arrow Right" />
export const ArrowRightIcon = (props: ImageProps) => (
<Image
src={arrowRightPath}
width={20}
height={20}
alt="Arrow Right"
{...props}
/>
);

export const supernovaGlobePath = "/supernova-globe.svg";

export const SupernovaGlobeLogoImage = (props: ImageProps) => (
<Image
src={supernovaGlobePath}
width={40}
height={40}
alt="Supernova's logo--a gradient globe with cyan/bright teal colors on the left, and pinkish color on the right"
{...props}
/>
);
8 changes: 2 additions & 6 deletions apps/desktop-v2/components/task-builder-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { Kbd } from "./kbd";
import { Button } from "./button";
import { twMerge } from "tailwind-merge";
import { ibmPlexMono } from "./fonts";
import { SupernovaGlobeLogoImage } from "./icons";

type CustomElement = { type: "paragraph" | string; children: CustomText[] };
type CustomText = { text: string };
Expand Down Expand Up @@ -183,12 +184,7 @@ export const TaskBuilderDialog = (props: {
>
<div className="w-full h-full px-3 py-2.5 bg-white rounded-[10px] shadow border border-gray-300 justify-start items-start gap-2.5 flex">
<div className="w-[25px] h-[25px] relative">
<Image
src="/supernova-globe.svg"
width={25}
height={25}
alt="Supernova's icon"
/>
<SupernovaGlobeLogoImage width={25} height={25} />
</div>
<div className="grow shrink basis-0 overflow-x-clip flex flex-col gap-1">
<p
Expand Down
61 changes: 30 additions & 31 deletions apps/desktop-v2/hooks/useSupernovaToast.tsx
Original file line number Diff line number Diff line change
@@ -1,39 +1,38 @@
import { manrope } from "@/components/fonts";
import { ReactNode } from "react";
import { ReactNode, useCallback } from "react";
import { ExternalToast, toast } from "sonner";
import { twMerge } from "tailwind-merge";

const useSupernovaToast = () => {
const makeToast = (
message: ReactNode,
type?: "success" | "error",
data?: ExternalToast
) => {
if (type === "success") {
// toast.custom((t) => (
// <div className="flex flex-col p-2 shadow bg-white w-full rounded-md border border-gray-300">
// <p className={twMerge("font-medium inline-flex items-center gap-2", manrope.className)}>
// {data?.icon}
// {message}</p>
// </div>
// ));
toast.success(
<p
className={twMerge(
"font-medium inline-flex items-center gap-2",
manrope.className
)}
>
{data?.icon} {message}
</p>,
data
);
} else if (type === "error") {
toast.error(message, data);
} else {
toast(message, data);
}
};
const makeToast = useCallback(
(message: ReactNode, type?: "success" | "error", data?: ExternalToast) => {
if (type === "success") {
// toast.custom((t) => (
// <div className="flex flex-col p-2 shadow bg-white w-full rounded-md border border-gray-300">
// <p className={twMerge("font-medium inline-flex items-center gap-2", manrope.className)}>
// {data?.icon}
// {message}</p>
// </div>
// ));
toast.success(
<p
className={twMerge(
"font-medium inline-flex items-center gap-2",
manrope.className
)}
>
{data?.icon} {message}
</p>,
data
);
} else if (type === "error") {
toast.error(message, data);
} else {
toast(message, data);
}
},
[]
);

return { makeToast };
};
Expand Down
24 changes: 24 additions & 0 deletions apps/desktop-v2/tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,30 @@ const config: Config = {
"gradient-radial": "radial-gradient(var(--tw-gradient-stops))",
"gradient-conic":
"conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))",
"dark-teal-gradient":
"linear-gradient(180deg, #000 17.19%, #0A3631 100%)",
},
keyframes: {
slideInFromTop: {
from: {
opacity: "0",
transform: "translateY(-20%)",
},
to: {
opacity: "1",
transform: "translateY(0)",
},
},
slideInFromBottom: {
from: {
opacity: "0",
transform: "translateY(10%)",
},
to: {
opacity: "1",
transform: "translateY(0)",
},
},
overlayShow: {
from: { opacity: "0" },
to: { opacity: "0.3" },
Expand All @@ -29,6 +51,8 @@ const config: Config = {
animation: {
overlayShow: "overlayShow 150ms cubic-bezier(0.16, 1, 0.3, 1)",
contentShow: "contentShow 150ms cubic-bezier(0.16, 1, 0.3, 1)",
slideInFromBottomSlow: "slideInFromBottom 1.5s ease-in",
slideInFromTopFast: "slideInFromTop 0.4s ease-in",
},
},
},
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"lint": "turbo run lint",
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
"prepare": "husky install",
"dockerize:api": "docker build -f apps/api-v2/Dockerfile -t supernova-api-v2:latest ."
"dockerize:api": "docker build -f apps/api-v2/Dockerfile -t supernova-api-v2:latest .",
"prisma-studio": "cd apps/api-v2 && npx prisma studio"
},
"devDependencies": {
"@turbo/gen": "^1.9.7",
Expand Down

1 comment on commit fea3fdf

@vercel
Copy link

@vercel vercel bot commented on fea3fdf Sep 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.