Skip to content

Commit f9cbbc9

Browse files
PengyuChen01pengyuautofix-ci[bot]
authored
feat(frontend): landing page ui optimization (#149)
Co-authored-by: pengyu <pengyuchen01@gmail.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent af3af8e commit f9cbbc9

File tree

6 files changed

+70
-17
lines changed

6 files changed

+70
-17
lines changed

frontend/src/app/(main)/page.tsx

+19-7
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,15 @@ import { useAuthContext } from '@/providers/AuthProvider';
88
import { ProjectsSection } from '@/components/root/projects-section';
99
import { PromptForm, PromptFormRef } from '@/components/root/prompt-form';
1010
import { ProjectContext } from '@/components/chat/code-engine/project-context';
11-
11+
import { SignInModal } from '@/components/sign-in-modal';
12+
import { SignUpModal } from '@/components/sign-up-modal';
13+
import { useRouter } from 'next/navigation';
1214
export default function HomePage() {
15+
// States for AuthChoiceModal
1316
const [showAuthChoice, setShowAuthChoice] = useState(false);
17+
const router = useRouter();
18+
const [showSignIn, setShowSignIn] = useState(false);
19+
const [showSignUp, setShowSignUp] = useState(false);
1420

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

22-
// Get form data from the prompt form
2328
const { message, isPublic, model } = promptFormRef.current.getPromptData();
24-
2529
if (!message.trim()) return;
2630

2731
try {
@@ -37,12 +41,11 @@ export default function HomePage() {
3741
}
3842
} catch (error) {
3943
console.error('Error creating project:', error);
40-
// Error handling is done via toast in ProjectContext
4144
}
4245
};
4346

4447
return (
45-
<div className="pt-32 pb-24 px-6 ">
48+
<div className="pt-32 pb-24 px-6">
4649
<motion.div
4750
className="flex flex-col items-center"
4851
initial={{ opacity: 0, y: 20 }}
@@ -85,19 +88,28 @@ export default function HomePage() {
8588
</div>
8689
</motion.div>
8790

88-
{/* Modals */}
91+
{/* Choice Modal */}
8992
<AuthChoiceModal
9093
isOpen={showAuthChoice}
9194
onClose={() => setShowAuthChoice(false)}
9295
onSignUpClick={() => {
9396
setShowAuthChoice(false);
97+
setTimeout(() => {
98+
setShowSignUp(true);
99+
}, 100);
94100
}}
95101
onSignInClick={() => {
96102
setShowAuthChoice(false);
103+
setTimeout(() => {
104+
setShowSignIn(true);
105+
}, 100);
97106
}}
98107
/>
99108

100-
{/* Add this to your global CSS for the subtle pulse animation */}
109+
{/* SignInModal & SignUpModal */}
110+
<SignInModal isOpen={showSignIn} onClose={() => setShowSignIn(false)} />
111+
<SignUpModal isOpen={showSignUp} onClose={() => setShowSignUp(false)} />
112+
101113
<style jsx global>{`
102114
.animate-pulse-subtle {
103115
animation: pulse-subtle 2s infinite;

frontend/src/components/auth-choice-modal.tsx

+19-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
'use client';
2+
23
import { Dialog, DialogContent, DialogTitle } from '@/components/ui/dialog';
34
import { BackgroundGradient } from '@/components/ui/background-gradient';
45
import { Button } from '@/components/ui/button';
@@ -24,6 +25,7 @@ export function AuthChoiceModal({
2425
<VisuallyHidden>
2526
<DialogTitle>Choose Authentication Method</DialogTitle>
2627
</VisuallyHidden>
28+
2729
<BackgroundGradient className="rounded-[22px] p-4 bg-white dark:bg-zinc-900">
2830
<div className="w-full p-6 space-y-6">
2931
<h2 className="text-2xl font-semibold text-center dark:text-white">
@@ -33,16 +35,31 @@ export function AuthChoiceModal({
3335
Choose how you want to continue
3436
</p>
3537
<div className="space-y-4">
38+
{/* Sign In button */}
3639
<Button
3740
className="w-full py-6 text-lg bg-primary hover:bg-primary/90"
38-
onClick={onSignInClick}
41+
onClick={() => {
42+
// 1) Close current modal
43+
onClose();
44+
// 2) After a brief delay, call onSignInClick
45+
setTimeout(() => {
46+
onSignInClick();
47+
}, 100);
48+
}}
3949
>
4050
Sign in
4151
</Button>
52+
53+
{/* Sign Up button */}
4254
<Button
4355
variant="outline"
4456
className="w-full py-6 text-lg"
45-
onClick={onSignUpClick}
57+
onClick={() => {
58+
onClose();
59+
setTimeout(() => {
60+
onSignUpClick();
61+
}, 100);
62+
}}
4663
>
4764
Create an account
4865
</Button>

frontend/src/components/root/nav.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -174,15 +174,15 @@ const FloatingNavbar = forwardRef<NavbarRef, FloatingNavbarProps>(
174174
alert('Coming Soon');
175175
} else if (label === 'Codefox Journey') {
176176
e.preventDefault();
177-
window.open('https://github.com/Sma1lboy/codefox', '_blank');
177+
alert('Coming Soon');
178178
} else {
179179
handleTabChange(index);
180180
}
181181
};
182182

183183
return (
184184
<>
185-
<div className={`fixed top-5 left-0 right-0 z-50 ${className}`}>
185+
<div className={` top-5 left-0 right-0 z-50 ${className}`}>
186186
<motion.div
187187
className={`w-full flex justify-around items-center px-6 py-4 ${containerClassName}`}
188188
initial="hidden"

frontend/src/components/root/prompt-form.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ export const PromptForm = forwardRef<PromptFormRef, PromptFormProps>(
211211
>
212212
<SelectTrigger
213213
className={cn(
214-
'w-[117px] h-6 border-0 focus:ring-0 hover:bg-gray-100 dark:hover:bg-gray-600 pl-1',
214+
'h-6 border-0 focus:ring-0 hover:bg-gray-100 dark:hover:bg-gray-600 pl-1 min-w-max',
215215
(isLoading || isRegenerating) &&
216216
'opacity-50 cursor-not-allowed'
217217
)}

frontend/src/components/sidebar.tsx

+26-4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import UserSettings from './user-settings';
88
import { SideBarItem } from './sidebar-item';
99
import { Chat } from '@/graphql/type';
1010
import { EventEnum } from '../const/EventEnum';
11+
import { useRouter } from 'next/navigation';
1112

1213
import {
1314
SidebarContent,
@@ -49,6 +50,7 @@ export function ChatSideBar({
4950
onRefetch,
5051
}: SidebarProps) {
5152
// Use a local state only for the currently selected chat.
53+
const router = useRouter();
5254
const [currentChatid, setCurrentChatid] = useState('');
5355
const { setCurProject, pollChatProject } = useContext(ProjectContext);
5456
// Handler for starting a new chat.
@@ -84,8 +86,27 @@ export function ChatSideBar({
8486
className="lg:flex items-center justify-center cursor-pointer p-2 ml-3.5 mt-2"
8587
onClick={() => setIsCollapsed(!isCollapsed)}
8688
/>
87-
88-
<div className="flex items-center justify-start w-[85%] h-14 text-sm xl:text-lg font-normal pl-4 gap-2">
89+
<Button
90+
onClick={() => router.push('/')}
91+
variant="ghost"
92+
className="
93+
w-full
94+
h-14
95+
flex
96+
items-center
97+
justify-start
98+
px-4
99+
gap-2
100+
text-sm
101+
xl:text-lg
102+
font-normal
103+
rounded-md
104+
hover:bg-yellow-50
105+
transition-all
106+
duration-200
107+
ease-in-out
108+
"
109+
>
89110
<Image
90111
src="/codefox.svg"
91112
alt="CodeFox Logo"
@@ -98,9 +119,10 @@ export function ChatSideBar({
98119
CodeFox
99120
</span>
100121
)}
101-
</div>
122+
</Button>
123+
102124
{/* Divider Line */}
103-
<div className="border-t border-dotted border-gray-300 my-2 w-[85%] mx-auto"></div>
125+
<div className="border-t border-dotted border-gray-300 my-2 w-full mx-auto" />
104126

105127
<Button
106128
onClick={() => setIsModalOpen(true)}

frontend/src/components/sign-in-modal.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ export function SignInModal({ isOpen, onClose }: SignInModalProps) {
4343
if (data?.login) {
4444
// Store tokens where desired (session storage for access, local for refresh)
4545
login(data.login.accessToken, data.login.refreshToken);
46-
toast.success('Login successful!');
46+
toast.success('Login successful!', {
47+
position: 'bottom-right',
48+
});
4749
setErrorMessage(null);
4850
onClose(); // Close the modal
4951

0 commit comments

Comments
 (0)