academy/resources/views/layouts/studentportalnav.blade.php

382 lines
12 KiB
PHP

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>Responsive Student Portal</title>
<!-- Font Awesome Icons -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
<style>
/* Global Root Variables */
:root {
--primary: #000000;
--background: #f5f6fb;
--sidebar-width: 260px;
--text-color: #333333;
--sidebar-bg: #5E244E;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
body {
background-color: var(--background);
color: var(--text-color);
display: flex;
min-height: 100vh;
overflow-x: hidden;
}
/* ---------- Sidebar Style ---------- */
.sidebar {
width: var(--sidebar-width);
height: 100vh;
background: var(--sidebar-bg);
color: #fff;
position: fixed;
top: 0;
left: 0;
padding: 24px 0;
transition: all 0.3s ease;
z-index: 1030;
display: flex;
flex-direction: column;
}
.sidebar .brand {
padding: 0 24px 24px;
font-weight: 700;
font-size: 1.2rem;
border-bottom: 1px solid rgba(255,255,255,.12);
margin-bottom: 12px;
display: flex;
align-items: center;
}
/* User Profile Section inside Sidebar */
.sidebar-user-profile {
padding: 15px 24px;
border-bottom: 1px solid rgba(255,255,255,.12);
margin-bottom: 15px;
}
.sidebar-user-profile .dropdown-toggle {
display: flex;
align-items: center;
gap: 10px;
color: #fff;
text-decoration: none;
font-size: 0.95rem;
}
.sidebar .nav {
display: flex;
flex-direction: column;
flex-grow: 1;
overflow-y: auto;
}
.sidebar .nav-link {
color: rgba(255,255,255,.75);
padding: 14px 24px;
font-size: .95rem;
display: flex;
align-items: center;
gap: 12px;
transition: .2s;
border-left: 3px solid transparent;
text-decoration: none;
}
.sidebar .nav-link i {
width: 20px;
text-align: center;
}
.sidebar .nav-link:hover {
background: rgba(255,255,255,.06);
color: #fff;
}
.sidebar .nav-link.active {
background: rgba(255,255,255,.1);
color: #fff;
border-left: 3px solid #fff;
font-weight: 600;
}
.sidebar .logout-link {
color: rgba(255,255,255,.6);
margin-top: auto;
}
.sidebar .logout-link:hover {
color: #fff;
background: rgba(220,53,69,.25);
}
/* ---------- Main Content Layout ---------- */
.main {
margin-left: var(--sidebar-width);
width: calc(100% - var(--sidebar-width));
min-height: 100vh;
padding: 40px;
background: var(--background);
transition: all 0.3s ease;
}
/* Mobile Header Toggle Bar */
.mobile-header {
display: none;
background: #fff;
padding: 15px 20px;
box-shadow: 0 2px 5px rgba(0,0,0,0.05);
align-items: center;
justify-content: space-between;
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 1020;
}
.sidebar-toggle {
background: none;
border: none;
font-size: 1.5rem;
cursor: pointer;
color: var(--sidebar-bg);
display: flex;
align-items: center;
justify-content: center;
}
.mobile-brand {
font-weight: 700;
font-size: 1.1rem;
color: #333;
}
/* Overlay Background when sidebar open on Mobile */
.sidebar-overlay {
display: none;
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0,0,0,0.4);
z-index: 1025;
opacity: 0;
transition: opacity 0.3s ease;
}
.sidebar-overlay.show {
display: block;
opacity: 1;
}
/* ---------- Responsive Media Queries (Mobile & Tablets) ---------- */
@media (max-width: 991px) {
.sidebar {
left: calc(-1 * var(--sidebar-width));
}
.sidebar.show {
left: 0;
}
.main {
margin-left: 0;
padding: 90px 20px 20px 20px;
width: 100%;
}
.mobile-header {
display: flex;
}
}
</style>
</head>
<body>
<!-- Mobile Top Navigation Bar -->
<header class="mobile-header">
<button class="sidebar-toggle" id="toggleBtn" aria-label="Toggle Sidebar">
<i class="fa-solid fa-bars"></i>
</button>
<div class="mobile-brand">Student Portal</div>
<!-- Mobile View User Profile Header Dropdown -->
<div class="mobile-user-profile">
@if(Auth::check())
<div class="dropdown">
<a class="text-dark no-toggle-icon" href="#" role="button" id="userMenuMobile" data-bs-toggle="dropdown" aria-expanded="false">
<i class="fa-solid fa-circle-user" style="font-size: 35px; color: var(--sidebar-bg);"></i>
<strong>{{ Auth::user()->first_name }}</strong>
</a>
<ul class="dropdown-menu dropdown-menu-end shadow" aria-labelledby="userMenuMobile">
<li class="px-3 py-2 ">
<!-- <small class="text-muted">Signed in as</small><br> -->
<!-- <strong>{{ Auth::user()->first_name }}</strong> -->
</li>
<li><a class="dropdown-item mt-1" href="/StudentProfile"><i class="fa-solid fa-user me-2"></i> Profile</a></li>
<li><hr class="dropdown-divider"></li>
<li>
<button type="button" onclick="submitLogout()" class="dropdown-item text-danger w-100 text-start border-0 bg-transparent">
<i class="fa-solid fa-right-from-bracket me-2"></i> Logout
</button>
</li>
</ul>
</div>
@else
<a href="/signin" class="btn btn-sm btn-outline-dark"><i class="fa-solid fa-right-to-bracket"></i></a>
@endif
</div>
</header>
<!-- Overlay dim background element -->
<div class="sidebar-overlay" id="sidebarOverlay"></div>
<!-- Sidebar Navigation -->
<aside class="sidebar" id="sidebar">
<div class="brand">
<i class="fa-solid fa-graduation-cap"></i>&nbsp;&nbsp;Student Portal
</div>
<!-- Sidebar Active User Profile Details (Desktop View) -->
<nav class="nav">
<a href="/Dashboard" class="nav-link ">
<i class="fa-solid fa-gauge"></i>Dashboard
</a>
<a href="/mycourse" class="nav-link">
<i class="fa-solid fa-book"></i>My Courses
</a>
<a href="/timetable" class="nav-link">
<i class="fa-solid fa-calendar-days"></i>Class Timetable
</a>
<!-- <a href="/Assignments" class="nav-link">
<i class="fa-solid fa-file-lines"></i>Assignments
</a> -->
<a href="/results" class="nav-link">
<i class="fa-solid fa-square-poll-vertical"></i>Exam Results
</a>
<a href="/Studentguidelines" class="nav-link">
<i class="fa-solid fa-book-open"></i>Student Guidelines
</a>
<a href="/Feedback&Complain" class="nav-link">
<i class="fa-solid fa-comments"></i>Feedback & Complain
</a>
<a href="/StudentProfile" class="nav-link">
<i class="fa-solid fa-user"></i>Student Profile
</a>
</nav>
<div class="sidebar-user-profile">
@if(Auth::check())
@php
$displayName = Auth::user()->first_name . ' ' . Auth::user()->last_name;
@endphp
<div class="dropdown">
<a class="dropdown-toggle" href="#" role="button" id="userMenuDesktop" data-bs-toggle="dropdown" aria-expanded="false">
<i class="fa-solid fa-circle-user" style="font-size: 24px;"></i>
<span class="user-profile-name text-truncate" style="max-width: 160px;">{{ $displayName }}</span>
</a>
<ul class="dropdown-menu dropdown-menu-start shadow w-100" aria-labelledby="userMenuDesktop">
<li>
<a class="dropdown-item" href="/StudentProfile">
<i class="fa-solid fa-user me-2"></i> Profile
</a>
</li>
<li><hr class="dropdown-divider"></li>
<li>
<a href="#" onclick="submitLogout(); return false;" class="nav-link logout-link mt-auto" style="color:black;">
<i class="fa-solid fa-right-from-bracket"></i>Logout
</a>
</li>
</ul>
</div>
@else
<div class="d-flex gap-2 px-2">
<a href="/signin" class="btn btn-outline-light btn-sm w-50">Sign In</a>
<a href="/signup" class="btn btn-warning btn-sm w-50">Register</a>
</div>
@endif
</div>
</aside>
<!-- Main Content Area -->
<main class="main">
@yield('content')
</main>
<!-- Sidebar Toggle JavaScript -->
<script>
const toggleBtn = document.getElementById('toggleBtn');
const sidebar = document.getElementById('sidebar');
const overlay = document.getElementById('sidebarOverlay');
// Function to toggle sidebar view
toggleBtn.addEventListener('click', () => {
sidebar.classList.toggle('show');
overlay.classList.toggle('show');
});
// Close sidebar if user clicks outside of it
overlay.addEventListener('click', () => {
sidebar.classList.remove('show');
overlay.classList.remove('show');
});
</script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
<script>
function submitLogout() {
const tokenEl = document.querySelector('meta[name="csrf-token"]');
fetch('/studentlogout', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'X-CSRF-TOKEN': tokenEl ? tokenEl.getAttribute('content') : ''
}
})
.then(res => {
if (!res.ok) {
return res.text().then(text => { throw new Error(text) });
}
return res.json();
})
.then(data => {
if (data.success) {
alert('Logged out successfully!');
window.location.href = '/students';
} else {
alert('Logout failed. Please try again.');
}
})
.catch(err => {
console.error('Error:', err);
alert('Server side error occurred during logout.');
});
}
}
</script>
</body>
</html>