Skip to content

Commit

Permalink
feat(frontend): landing page ui optimization (#149)
Browse files Browse the repository at this point in the history
Co-authored-by: pengyu <pengyuchen01@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Mar 5, 2025
1 parent af3af8e commit f9cbbc9
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 17 deletions.
26 changes: 19 additions & 7 deletions frontend/src/app/(main)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,15 @@ import { useAuthContext } from '@/providers/AuthProvider';
import { ProjectsSection } from '@/components/root/projects-section';
import { PromptForm, PromptFormRef } from '@/components/root/prompt-form';
import { ProjectContext } from '@/components/chat/code-engine/project-context';

import { SignInModal } from '@/components/sign-in-modal';
import { SignUpModal } from '@/components/sign-up-modal';
import { useRouter } from 'next/navigation';
export default function HomePage() {
// States for AuthChoiceModal
const [showAuthChoice, setShowAuthChoice] = useState(false);
const router = useRouter();
const [showSignIn, setShowSignIn] = useState(false);
const [showSignUp, setShowSignUp] = useState(false);

const promptFormRef = useRef<PromptFormRef>(null);
const { isAuthorized } = useAuthContext();
Expand All @@ -19,9 +25,7 @@ export default function HomePage() {
const handleSubmit = async () => {
if (!promptFormRef.current) return;

// Get form data from the prompt form
const { message, isPublic, model } = promptFormRef.current.getPromptData();

if (!message.trim()) return;

try {
Expand All @@ -37,12 +41,11 @@ export default function HomePage() {
}
} catch (error) {
console.error('Error creating project:', error);
// Error handling is done via toast in ProjectContext
}
};

return (
<div className="pt-32 pb-24 px-6 ">
<div className="pt-32 pb-24 px-6">
<motion.div
className="flex flex-col items-center"
initial={{ opacity: 0, y: 20 }}
Expand Down Expand Up @@ -85,19 +88,28 @@ export default function HomePage() {
</div>
</motion.div>

{/* Modals */}
{/* Choice Modal */}
<AuthChoiceModal
isOpen={showAuthChoice}
onClose={() => setShowAuthChoice(false)}
onSignUpClick={() => {
setShowAuthChoice(false);
setTimeout(() => {
setShowSignUp(true);
}, 100);
}}
onSignInClick={() => {
setShowAuthChoice(false);
setTimeout(() => {
setShowSignIn(true);
}, 100);
}}
/>

{/* Add this to your global CSS for the subtle pulse animation */}
{/* SignInModal & SignUpModal */}
<SignInModal isOpen={showSignIn} onClose={() => setShowSignIn(false)} />
<SignUpModal isOpen={showSignUp} onClose={() => setShowSignUp(false)} />

<style jsx global>{`
.animate-pulse-subtle {
animation: pulse-subtle 2s infinite;
Expand Down
21 changes: 19 additions & 2 deletions frontend/src/components/auth-choice-modal.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use client';

import { Dialog, DialogContent, DialogTitle } from '@/components/ui/dialog';
import { BackgroundGradient } from '@/components/ui/background-gradient';
import { Button } from '@/components/ui/button';
Expand All @@ -24,6 +25,7 @@ export function AuthChoiceModal({
<VisuallyHidden>
<DialogTitle>Choose Authentication Method</DialogTitle>
</VisuallyHidden>

<BackgroundGradient className="rounded-[22px] p-4 bg-white dark:bg-zinc-900">
<div className="w-full p-6 space-y-6">
<h2 className="text-2xl font-semibold text-center dark:text-white">
Expand All @@ -33,16 +35,31 @@ export function AuthChoiceModal({
Choose how you want to continue
</p>
<div className="space-y-4">
{/* Sign In button */}
<Button
className="w-full py-6 text-lg bg-primary hover:bg-primary/90"
onClick={onSignInClick}
onClick={() => {
// 1) Close current modal
onClose();
// 2) After a brief delay, call onSignInClick
setTimeout(() => {
onSignInClick();
}, 100);
}}
>
Sign in
</Button>

{/* Sign Up button */}
<Button
variant="outline"
className="w-full py-6 text-lg"
onClick={onSignUpClick}
onClick={() => {
onClose();
setTimeout(() => {
onSignUpClick();
}, 100);
}}
>
Create an account
</Button>
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/root/nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,15 +174,15 @@ const FloatingNavbar = forwardRef<NavbarRef, FloatingNavbarProps>(
alert('Coming Soon');
} else if (label === 'Codefox Journey') {
e.preventDefault();
window.open('https://github.com/Sma1lboy/codefox', '_blank');
alert('Coming Soon');
} else {
handleTabChange(index);
}
};

return (
<>
<div className={`fixed top-5 left-0 right-0 z-50 ${className}`}>
<div className={` top-5 left-0 right-0 z-50 ${className}`}>
<motion.div
className={`w-full flex justify-around items-center px-6 py-4 ${containerClassName}`}
initial="hidden"
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/root/prompt-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ export const PromptForm = forwardRef<PromptFormRef, PromptFormProps>(
>
<SelectTrigger
className={cn(
'w-[117px] h-6 border-0 focus:ring-0 hover:bg-gray-100 dark:hover:bg-gray-600 pl-1',
'h-6 border-0 focus:ring-0 hover:bg-gray-100 dark:hover:bg-gray-600 pl-1 min-w-max',
(isLoading || isRegenerating) &&
'opacity-50 cursor-not-allowed'
)}
Expand Down
30 changes: 26 additions & 4 deletions frontend/src/components/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import UserSettings from './user-settings';
import { SideBarItem } from './sidebar-item';
import { Chat } from '@/graphql/type';
import { EventEnum } from '../const/EventEnum';
import { useRouter } from 'next/navigation';

import {
SidebarContent,
Expand Down Expand Up @@ -49,6 +50,7 @@ export function ChatSideBar({
onRefetch,
}: SidebarProps) {
// Use a local state only for the currently selected chat.
const router = useRouter();
const [currentChatid, setCurrentChatid] = useState('');
const { setCurProject, pollChatProject } = useContext(ProjectContext);
// Handler for starting a new chat.
Expand Down Expand Up @@ -84,8 +86,27 @@ export function ChatSideBar({
className="lg:flex items-center justify-center cursor-pointer p-2 ml-3.5 mt-2"
onClick={() => setIsCollapsed(!isCollapsed)}
/>

<div className="flex items-center justify-start w-[85%] h-14 text-sm xl:text-lg font-normal pl-4 gap-2">
<Button
onClick={() => router.push('/')}
variant="ghost"
className="
w-full
h-14
flex
items-center
justify-start
px-4
gap-2
text-sm
xl:text-lg
font-normal
rounded-md
hover:bg-yellow-50
transition-all
duration-200
ease-in-out
"
>
<Image
src="/codefox.svg"
alt="CodeFox Logo"
Expand All @@ -98,9 +119,10 @@ export function ChatSideBar({
CodeFox
</span>
)}
</div>
</Button>

{/* Divider Line */}
<div className="border-t border-dotted border-gray-300 my-2 w-[85%] mx-auto"></div>
<div className="border-t border-dotted border-gray-300 my-2 w-full mx-auto" />

<Button
onClick={() => setIsModalOpen(true)}
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/components/sign-in-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ export function SignInModal({ isOpen, onClose }: SignInModalProps) {
if (data?.login) {
// Store tokens where desired (session storage for access, local for refresh)
login(data.login.accessToken, data.login.refreshToken);
toast.success('Login successful!');
toast.success('Login successful!', {
position: 'bottom-right',
});
setErrorMessage(null);
onClose(); // Close the modal

Expand Down

0 comments on commit f9cbbc9

Please sign in to comment.