Spaces:
Running
Running
کامل تر باید باشد باید در وییندوز نو بار داشته باشد و ساید باشد
Browse files- components/mobile-navbar.js +55 -0
- index.html +3 -3
- script.js +19 -0
- style.css +8 -0
components/mobile-navbar.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
class MobileNavbar extends HTMLElement {
|
| 2 |
+
connectedCallback() {
|
| 3 |
+
this.attachShadow({ mode: 'open' });
|
| 4 |
+
this.shadowRoot.innerHTML = `
|
| 5 |
+
<style>
|
| 6 |
+
:host {
|
| 7 |
+
display: block;
|
| 8 |
+
height: 60px;
|
| 9 |
+
}
|
| 10 |
+
.mobile-nav {
|
| 11 |
+
display: flex;
|
| 12 |
+
justify-content: space-around;
|
| 13 |
+
align-items: center;
|
| 14 |
+
height: 100%;
|
| 15 |
+
}
|
| 16 |
+
.nav-item {
|
| 17 |
+
display: flex;
|
| 18 |
+
flex-direction: column;
|
| 19 |
+
align-items: center;
|
| 20 |
+
justify-content: center;
|
| 21 |
+
color: #6b7280;
|
| 22 |
+
text-decoration: none;
|
| 23 |
+
font-size: 0.75rem;
|
| 24 |
+
padding: 0.5rem;
|
| 25 |
+
flex: 1;
|
| 26 |
+
}
|
| 27 |
+
.nav-item.active {
|
| 28 |
+
color: #6366f1;
|
| 29 |
+
}
|
| 30 |
+
.nav-item i {
|
| 31 |
+
margin-bottom: 0.25rem;
|
| 32 |
+
}
|
| 33 |
+
</style>
|
| 34 |
+
<nav class="mobile-nav">
|
| 35 |
+
<a href="/" class="nav-item active">
|
| 36 |
+
<i data-feather="home"></i>
|
| 37 |
+
<span>Dashboard</span>
|
| 38 |
+
</a>
|
| 39 |
+
<a href="#" class="nav-item">
|
| 40 |
+
<i data-feather="users"></i>
|
| 41 |
+
<span>Clients</span>
|
| 42 |
+
</a>
|
| 43 |
+
<a href="#" class="nav-item">
|
| 44 |
+
<i data-feather="activity"></i>
|
| 45 |
+
<span>Analytics</span>
|
| 46 |
+
</a>
|
| 47 |
+
<a href="#" class="nav-item">
|
| 48 |
+
<i data-feather="settings"></i>
|
| 49 |
+
<span>Settings</span>
|
| 50 |
+
</a>
|
| 51 |
+
</nav>
|
| 52 |
+
`;
|
| 53 |
+
}
|
| 54 |
+
}
|
| 55 |
+
customElements.define('mobile-navbar', MobileNavbar);
|
index.html
CHANGED
|
@@ -31,9 +31,9 @@
|
|
| 31 |
<body class="bg-gray-50 dark:bg-gray-900 text-gray-800 dark:text-gray-100 overflow-x-hidden">
|
| 32 |
<custom-navbar></custom-navbar>
|
| 33 |
<div class="flex">
|
| 34 |
-
<custom-sidebar></custom-sidebar>
|
| 35 |
-
|
| 36 |
-
|
| 37 |
<!-- Stats Cards -->
|
| 38 |
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4 mb-8">
|
| 39 |
<div class="bg-white dark:bg-gray-800 p-4 rounded-lg shadow">
|
|
|
|
| 31 |
<body class="bg-gray-50 dark:bg-gray-900 text-gray-800 dark:text-gray-100 overflow-x-hidden">
|
| 32 |
<custom-navbar></custom-navbar>
|
| 33 |
<div class="flex">
|
| 34 |
+
<custom-sidebar class="hidden lg:block"></custom-sidebar>
|
| 35 |
+
<mobile-navbar class="lg:hidden fixed bottom-0 left-0 right-0 bg-white dark:bg-gray-800 shadow-lg z-50"></mobile-navbar>
|
| 36 |
+
<main class="flex-1 p-6 ml-0 lg:ml-64 transition-all duration-300">
|
| 37 |
<!-- Stats Cards -->
|
| 38 |
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4 mb-8">
|
| 39 |
<div class="bg-white dark:bg-gray-800 p-4 rounded-lg shadow">
|
script.js
CHANGED
|
@@ -1,6 +1,25 @@
|
|
|
|
|
| 1 |
document.addEventListener('DOMContentLoaded', function() {
|
| 2 |
// Initialize chart
|
| 3 |
initChart();
|
| 4 |
|
| 5 |
// Setup event listeners
|
| 6 |
setupEventListeners();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
document.addEventListener('DOMContentLoaded', function() {
|
| 3 |
// Initialize chart
|
| 4 |
initChart();
|
| 5 |
|
| 6 |
// Setup event listeners
|
| 7 |
setupEventListeners();
|
| 8 |
+
|
| 9 |
+
// Mobile menu toggle
|
| 10 |
+
document.addEventListener('click', function(e) {
|
| 11 |
+
if (e.target.closest('.menu-button')) {
|
| 12 |
+
const sidebar = document.querySelector('custom-sidebar');
|
| 13 |
+
sidebar.shadowRoot.querySelector('aside').classList.toggle('open');
|
| 14 |
+
}
|
| 15 |
+
});
|
| 16 |
+
|
| 17 |
+
// Close sidebar when clicking outside on mobile
|
| 18 |
+
document.addEventListener('click', function(e) {
|
| 19 |
+
const sidebar = document.querySelector('custom-sidebar');
|
| 20 |
+
if (window.innerWidth < 1024 && sidebar &&
|
| 21 |
+
!e.target.closest('custom-sidebar') &&
|
| 22 |
+
!e.target.closest('.menu-button')) {
|
| 23 |
+
sidebar.shadowRoot.querySelector('aside').classList.remove('open');
|
| 24 |
+
}
|
| 25 |
+
});
|
style.css
CHANGED
|
@@ -1,4 +1,12 @@
|
|
| 1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
/* Stats Cards */
|
| 3 |
.stats-card {
|
| 4 |
height: auto;
|
|
|
|
| 1 |
|
| 2 |
+
/* Responsive Navigation */
|
| 3 |
+
@media (max-width: 1023px) {
|
| 4 |
+
main {
|
| 5 |
+
margin-left: 0;
|
| 6 |
+
padding-bottom: 5rem; /* Space for mobile navbar */
|
| 7 |
+
}
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
/* Stats Cards */
|
| 11 |
.stats-card {
|
| 12 |
height: auto;
|