Skip to content

Commit

Permalink
Merge pull request #51 from deepraj21/main
Browse files Browse the repository at this point in the history
updated landing page for optimization
  • Loading branch information
deepraj21 authored Oct 16, 2024
2 parents 1e30322 + 311ee06 commit cb84077
Show file tree
Hide file tree
Showing 16 changed files with 1,943 additions and 312 deletions.
256 changes: 256 additions & 0 deletions client/dist/assets/index-CLZc1W7c.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion client/dist/assets/index-CUzNbDSS.css

This file was deleted.

296 changes: 0 additions & 296 deletions client/dist/assets/index-DQXpIS55.js

This file was deleted.

1 change: 1 addition & 0 deletions client/dist/assets/index-ndDbH7-g.css

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions client/dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<link rel="icon" type="image" href="/logo.png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>DevHub</title>
<script type="module" crossorigin src="/assets/index-DQXpIS55.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-CUzNbDSS.css">
<script type="module" crossorigin src="/assets/index-CLZc1W7c.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-ndDbH7-g.css">
</head>
<body>
<div id="root"></div>
Expand Down
362 changes: 362 additions & 0 deletions client/package-lock.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
"@radix-ui/react-toast": "^1.2.1",
"@reduxjs/toolkit": "^2.2.7",
"@tabler/icons-react": "^3.11.0",
"@tsparticles/engine": "^3.5.0",
"@tsparticles/react": "^3.0.0",
"@tsparticles/slim": "^3.5.0",
"axios": "^1.7.4",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
Expand Down
11 changes: 7 additions & 4 deletions client/src/components/Auth/user-auth-form-login.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"use client"
"use client";

import React, { useState } from 'react';
import axios from 'axios';
Expand Down Expand Up @@ -30,12 +30,15 @@ export function UserAuthForm({ className, onLoginSuccess, ...props }: UserAuthFo
try {
const response = await axios.post(`${backendUrl}/login`, { username, password }, { withCredentials: true });
if (response.status === 200) {

localStorage.setItem('devhub_username', username);

if (onLoginSuccess) {
onLoginSuccess(username); // Pass the username to the callback
onLoginSuccess(username);
}
navigate('/home');
}
} catch (err:any) {
} catch (err: any) {
if (err.response && err.response.data && err.response.data.message) {
toast.error(err.response.data.message, {
description: "Please check your details and try again.",
Expand Down Expand Up @@ -103,4 +106,4 @@ export function UserAuthForm({ className, onLoginSuccess, ...props }: UserAuthFo
</form>
</div>
);
}
}
159 changes: 159 additions & 0 deletions client/src/components/MobileSidebar/MobileSidebar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
import {
CircleUser,
Home,
LineChart,
Menu,
Fullscreen,
Shrink
} from "lucide-react"
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuLabel,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu"
import { Sheet, SheetContent, SheetTrigger } from "@/components/ui/sheet"
import { Button } from "@/components/ui/button"
import { ModeToggle } from "@/components/Theme/mode-toggle"
import { useNavigate } from "react-router-dom";
import { useState, useEffect } from "react"

const BACKEND_URL = import.meta.env.VITE_BACKEND_URL || "http://localhost:5000";

const MobileSidebar = () => {
const [userImage, setUserImage] = useState<string | null>(null);
const [isFullscreen, setIsFullscreen] = useState(() => {
// Parse the value from localStorage as a boolean
return localStorage.getItem('isFullscreen') === 'true';
});
const navigate = useNavigate();

const handleFullscreenToggle = () => {
if (!isFullscreen) {
document.documentElement.requestFullscreen();
} else {
document.exitFullscreen();
}
setIsFullscreen(!isFullscreen);
// Store the fullscreen state as a string ("true"/"false")
localStorage.setItem('isFullscreen', String(!isFullscreen));
};

useEffect(() => {
const handleFullscreenChange = () => {
const fullscreen = document.fullscreenElement !== null;
setIsFullscreen(fullscreen);
localStorage.setItem('isFullscreen', String(fullscreen));
};

document.addEventListener('fullscreenchange', handleFullscreenChange);
return () => {
document.removeEventListener('fullscreenchange', handleFullscreenChange);
};
}, []);

useEffect(() => {
const fetchUserData = async () => {
try {
const username = localStorage.getItem('username');
if (!username) {
throw new Error('Username not found in localStorage');
}

const response = await fetch(`${BACKEND_URL}/profile/${username}`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
});

if (!response.ok) {
throw new Error('Network response was not ok');
}

const responseData = await response.json();
setUserImage(responseData.user.image || null);
} catch (error) {
console.error('Error fetching user data', error);
}
};

fetchUserData();
}, []);

return (
<header className="flex h-14 items-center gap-4 border-b bg-muted/40 px-4 lg:h-[60px] lg:px-6">
<Sheet>
<SheetTrigger asChild>
<Button variant="outline" size="icon" className="shrink-0 md:hidden">
<Menu className="h-5 w-5" />
<span className="sr-only">Toggle navigation menu</span>
</Button>
</SheetTrigger>
<SheetContent side="left" className="flex flex-col">
<nav className="grid gap-2 text-lg font-medium">
<a href="#" className="flex items-center gap-2 text-lg font-semibold">
<span>Quantica</span>
</a>
<a
href="/home"
className="mx-[-0.65rem] flex items-center gap-4 rounded-xl px-3 py-2 text-muted-foreground hover:text-foreground"
>
<Home className="h-5 w-5" />
Home
</a>
<a
href="/plot"
className="mx-[-0.65rem] flex items-center gap-4 rounded-xl px-3 py-2 text-muted-foreground hover:text-foreground"
>
<LineChart className="h-5 w-5" />
f(x) Plotter
</a>
</nav>
</SheetContent>
</Sheet>
<div className="w-full flex-1"></div>
<DropdownMenu>
{isFullscreen ? (
<Shrink onClick={handleFullscreenToggle} />
) : (
<Fullscreen onClick={handleFullscreenToggle} />
)}
<ModeToggle />
<DropdownMenuTrigger asChild>
<Button variant="secondary" size="icon" className="rounded-full">
{userImage ? (
<img src={userImage} alt="User Profile" className="h-5 w-5 rounded-full" />
) : (
<CircleUser className="h-5 w-5" />
)}
<span className="sr-only">Toggle user menu</span>
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuLabel>My Account</DropdownMenuLabel>
<DropdownMenuSeparator />
<DropdownMenuItem
onClick={() => {
const username = localStorage.getItem('username');
if (username) {
navigate(`/profile/${username}`);
} else {
console.error('Username not found in localStorage');
}
}}
>
Profile
</DropdownMenuItem>
<DropdownMenuItem onClick={() => navigate('/settings')}>Settings</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem>Logout</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</header>
);
};

export default MobileSidebar;
39 changes: 39 additions & 0 deletions client/src/components/Sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import {
Home,
LineChart,
} from "lucide-react"

const Sidebar = () => {
return (
<div className="hidden border-r bg-muted/40 md:block">
<div className="flex h-full max-h-screen flex-col gap-2">
<div className="flex h-14 items-center border-b px-4 lg:h-[60px] lg:px-6">
<a href="/" className="flex items-center gap-2 font-semibold">
<span className="">Quantica</span>
</a>

</div>
<div className="flex-1">
<nav className="grid items-start px-2 text-sm font-medium lg:px-4">
<a
href="/home"
className="flex items-center gap-3 rounded-lg px-3 py-2 text-muted-foreground transition-all hover:text-primary"
>
<Home className="h-4 w-4" />
Home
</a>
<a
href="/plot"
className="flex items-center gap-3 rounded-lg px-3 py-2 text-muted-foreground transition-all hover:text-primary"
>
<LineChart className="h-4 w-4" />
f(x) Plotter
</a>
</nav>
</div>
</div>
</div>
)
}

export default Sidebar
Loading

0 comments on commit cb84077

Please sign in to comment.