Add a static login footer that prompts login, disable input box without auth

This commit is contained in:
sabaimran 2024-12-12 14:57:52 -08:00
parent a7d0ed8670
commit ad3f8a33d1
4 changed files with 49 additions and 8 deletions

View file

@ -629,7 +629,7 @@ export const ChatInputArea = forwardRef<HTMLTextAreaElement, ChatInputProps>((pr
<Button <Button
variant={"ghost"} variant={"ghost"}
className="!bg-none p-0 m-2 h-auto text-3xl rounded-full text-gray-300 hover:text-gray-500" className="!bg-none p-0 m-2 h-auto text-3xl rounded-full text-gray-300 hover:text-gray-500"
disabled={props.sendDisabled} disabled={props.sendDisabled || !props.isLoggedIn}
onClick={handleFileButtonClick} onClick={handleFileButtonClick}
> >
<Paperclip className="w-8 h-8" /> <Paperclip className="w-8 h-8" />
@ -669,7 +669,7 @@ export const ChatInputArea = forwardRef<HTMLTextAreaElement, ChatInputProps>((pr
onClick={() => { onClick={() => {
setRecording(!recording); setRecording(!recording);
}} }}
disabled={props.sendDisabled} disabled={props.sendDisabled || !props.isLoggedIn}
> >
<Stop weight="fill" className="w-6 h-6" /> <Stop weight="fill" className="w-6 h-6" />
</Button> </Button>
@ -699,6 +699,7 @@ export const ChatInputArea = forwardRef<HTMLTextAreaElement, ChatInputProps>((pr
<Button <Button
variant="default" variant="default"
className={`${!message || recording || "hidden"} ${props.agentColor ? convertToBGClass(props.agentColor) : "bg-orange-300 hover:bg-orange-500"} rounded-full p-1 m-2 h-auto text-3xl transition transform md:hover:-translate-y-1`} className={`${!message || recording || "hidden"} ${props.agentColor ? convertToBGClass(props.agentColor) : "bg-orange-300 hover:bg-orange-500"} rounded-full p-1 m-2 h-auto text-3xl transition transform md:hover:-translate-y-1`}
disabled={props.sendDisabled || !props.isLoggedIn}
onClick={() => { onClick={() => {
setMessage("Listening..."); setMessage("Listening...");
setRecording(!recording); setRecording(!recording);
@ -718,6 +719,7 @@ export const ChatInputArea = forwardRef<HTMLTextAreaElement, ChatInputProps>((pr
)} )}
<Button <Button
className={`${(!message || recording) && "hidden"} ${props.agentColor ? convertToBGClass(props.agentColor) : "bg-orange-300 hover:bg-orange-500"} rounded-full p-1 m-2 h-auto text-3xl transition transform md:hover:-translate-y-1`} className={`${(!message || recording) && "hidden"} ${props.agentColor ? convertToBGClass(props.agentColor) : "bg-orange-300 hover:bg-orange-500"} rounded-full p-1 m-2 h-auto text-3xl transition transform md:hover:-translate-y-1`}
disabled={props.sendDisabled || !props.isLoggedIn}
onClick={onSendMessage} onClick={onSendMessage}
> >
<ArrowUp className="w-6 h-6" weight="bold" /> <ArrowUp className="w-6 h-6" weight="bold" />

View file

@ -0,0 +1,31 @@
"use client";
import { Button } from "@/components/ui/button";
import { Card, CardDescription, CardHeader } from "@/components/ui/card";
import { KhojLogo } from "../logo/khojLogo";
export interface LoginPopupProps {
isMobileWidth?: boolean;
setShowLoginPrompt: (show: boolean) => void;
}
export default function LoginPopup(props: LoginPopupProps) {
return (
<Card className="absolute inset-x-0 bottom-2 md:bottom-8 left-1/2 transform -translate-x-1/2 p-6 flex flex-col md:flex-row items-center justify-between bg-gradient-to-b from-slate-50 dark:from-slate-900 to-bg-secondary z-30 shadow-lg gap-8 w-full md:w-fit">
{!props.isMobileWidth && <KhojLogo className="w-12 h-auto" />}
<div className="flex flex-col items-start justify-center">
<CardHeader className="p-0 text-xl">Welcome to Khoj!</CardHeader>
<CardDescription>
Get started with Khoj's AI-powered research assistant now.
</CardDescription>
</div>
<Button
variant={"default"}
className="bg-gradient-to-br from-orange-200 to-orange-500"
onClick={() => props.setShowLoginPrompt(true)}
>
Get started for free
</Button>
</Card>
);
}

View file

@ -320,7 +320,7 @@ function MainSignInContext({
]; ];
return ( return (
<div className="flex flex-col gap-4 p-4"> <div className="flex flex-col gap-4 p-4 md:p-0">
{!isMobileWidth && ( {!isMobileWidth && (
<Carousel <Carousel
plugins={[plugin.current]} plugins={[plugin.current]}
@ -331,13 +331,13 @@ function MainSignInContext({
<CarouselContent> <CarouselContent>
{tips.map((tip, index) => ( {tips.map((tip, index) => (
<CarouselItem key={index}> <CarouselItem key={index}>
<div className="p-1"> <div className="p-0">
<Card> <Card>
<CardContent className="flex items-center justify-center rounded-b-none rounded-t-lg p-0"> <CardContent className="flex items-center justify-center rounded-b-none rounded-t-lg p-0">
<img <img
src={tip.src} src={tip.src}
alt={tip.alt} alt={tip.alt}
className="w-full h-auto" className="w-full h-auto rounded-b-none rounded-t-lg"
/> />
</CardContent> </CardContent>
</Card> </Card>
@ -351,7 +351,7 @@ function MainSignInContext({
)} )}
<div className="flex flex-col gap-4 text-center p-4"> <div className="flex flex-col gap-4 text-center p-4">
<div className="text-center font-bold text-lg"> <div className="text-center font-bold text-lg">
Sign In for free to start using Khoj: Your AI-powered second brain Sign in to unlock your second brain
</div> </div>
</div> </div>
<div className="flex flex-col gap-4 py-4 text-center align-middle items-center"> <div className="flex flex-col gap-4 py-4 text-center align-middle items-center">
@ -404,7 +404,7 @@ function MainSignInContext({
</Button> </Button>
<Button <Button
variant="secondary" variant="outline"
className="w-[300px] p-6 flex gap-2 items-center justify-center" className="w-[300px] p-6 flex gap-2 items-center justify-center"
onClick={() => { onClick={() => {
setUseEmailSignIn(true); setUseEmailSignIn(true);
@ -416,7 +416,8 @@ function MainSignInContext({
</div> </div>
<div className="text-center text-muted-foreground text-xs"> <div className="text-center text-muted-foreground text-xs">
By logging in, you agree to our{" "} By logging in, you agree to our{" "}
<Link href="https://khoj.dev/terms-of-service">Terms of Service.</Link> <Link href="https://khoj.dev/terms-of-service">Terms of Service</Link>. See{" "}
<Link href="https://khoj.dev/privacy-policy">Privacy Policy</Link>.
</div> </div>
</div> </div>
); );

View file

@ -34,6 +34,7 @@ import { useRouter, useSearchParams } from "next/navigation";
import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area"; import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area";
import { AgentCard } from "@/app/components/agentCard/agentCard"; import { AgentCard } from "@/app/components/agentCard/agentCard";
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"; import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
import LoginPopup from "./components/loginPrompt/loginPopup";
interface ChatBodyDataProps { interface ChatBodyDataProps {
chatOptionsData: ChatOptions | null; chatOptionsData: ChatOptions | null;
@ -221,6 +222,12 @@ function ChatBodyData(props: ChatBodyDataProps) {
loginRedirectMessage={"Login to your second brain"} loginRedirectMessage={"Login to your second brain"}
/> />
)} )}
{!props.isLoggedIn && (
<LoginPopup
isMobileWidth={props.isMobileWidth}
setShowLoginPrompt={setShowLoginPrompt}
/>
)}
<div className={`w-full text-center justify-end content-end`}> <div className={`w-full text-center justify-end content-end`}>
<div className="items-center"> <div className="items-center">
<h1 className="text-2xl md:text-3xl text-center w-fit pb-6 px-4 mx-auto"> <h1 className="text-2xl md:text-3xl text-center w-fit pb-6 px-4 mx-auto">