-
Notifications
You must be signed in to change notification settings - Fork 669
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Innei <i@innei.in>
- Loading branch information
Showing
11 changed files
with
117 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ out | |
*.log* | ||
.env | ||
.eslintcache | ||
.env.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import type { PropsWithChildren } from "react" | ||
|
||
export const NoopChildren = ({ children }: PropsWithChildren) => children |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
import { signIn } from "@hono/auth-js/react" | ||
|
||
export const LOGIN_CALLBACK_URL = `${import.meta.env.VITE_WEB_URL}/redirect?app=follow` | ||
export const loginHandler = (provider: string) => { | ||
export type LoginRuntime = "browser" | "app" | ||
export const loginHandler = (provider: string, runtime: LoginRuntime = "app") => { | ||
if (window.electron) { | ||
window.open( | ||
`${import.meta.env.VITE_WEB_URL}/login?provider=${provider}`, | ||
) | ||
} else { | ||
signIn(provider, { | ||
callbackUrl: LOGIN_CALLBACK_URL, | ||
callbackUrl: runtime === "app" ? LOGIN_CALLBACK_URL : import.meta.env.VITE_WEB_URL, | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { FollowIcon } from "@renderer/components/icons/follow" | ||
import { Button } from "@renderer/components/ui/button" | ||
import { useCurrentModal } from "@renderer/components/ui/modal" | ||
import { modalMontionConfig } from "@renderer/components/ui/modal/stacked/constants" | ||
import type { LoginRuntime } from "@renderer/lib/auth" | ||
import { loginHandler } from "@renderer/lib/auth" | ||
import { APP_NAME } from "@renderer/lib/constants" | ||
import { stopPropagation } from "@renderer/lib/dom" | ||
import { m } from "framer-motion" | ||
|
||
interface LoginModalContentProps { | ||
runtime?: LoginRuntime | ||
} | ||
export const LoginModalContent = (props: LoginModalContentProps) => { | ||
const modal = useCurrentModal() | ||
return ( | ||
<div className="center flex h-full" onClick={modal.dismiss}> | ||
<m.div | ||
className="shadow-modal rounded-lg border border-border bg-theme-background p-4 px-8 pb-8" | ||
onClick={stopPropagation} | ||
{...modalMontionConfig} | ||
> | ||
<div className="mb-8 mt-4 text-center align-middle font-sans text-2xl font-bold leading-relaxed"> | ||
<span className="text-xl">Sign in to </span> | ||
<span className="center flex translate-y-px gap-2 font-theme text-theme-accent"> | ||
<FollowIcon className="size-4" /> | ||
{APP_NAME} | ||
</span> | ||
</div> | ||
<div className="flex flex-col gap-4"> | ||
<Button | ||
className="h-[48px] w-[320px] rounded-[8px] !bg-black font-sans text-base text-white hover:!bg-black/80" | ||
size="lg" | ||
onClick={() => { | ||
loginHandler("github", props.runtime) | ||
}} | ||
> | ||
<i className="i-mgc-github-cute-fi mr-2 text-xl" /> | ||
{" "} | ||
Continue with | ||
GitHub | ||
</Button> | ||
<Button | ||
className="h-[48px] w-[320px] rounded-[8px] bg-blue-500 font-sans text-base text-white hover:bg-blue-500/90" | ||
size="xl" | ||
onClick={() => { | ||
loginHandler("google", props.runtime) | ||
}} | ||
> | ||
<i className="i-mgc-google-cute-fi mr-2 text-xl" /> | ||
{" "} | ||
Continue with | ||
</Button> | ||
</div> | ||
</m.div> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/// <reference types="vite/client" /> | ||
|
||
interface ImportMetaEnv { | ||
|
||
VITE_WEB_URL: string | ||
VITE_API_URL: string | ||
VITE_IMGPROXY_URL: string | ||
} | ||
|
||
interface ImportMeta { | ||
readonly env: ImportMetaEnv | ||
} |