iurbinah commited on
Commit
318cd17
·
1 Parent(s): e8c5946

feat: add mobile sidebar close button

Browse files
Files changed (4) hide show
  1. .gitignore +0 -1
  2. index.html +11 -2
  3. main.js +6 -0
  4. style.css +42 -0
.gitignore CHANGED
@@ -10,4 +10,3 @@ stop_server.sh
10
  remount_exec.sh
11
  GEMINI.md
12
  .gitignore
13
- .geminiignore
 
10
  remount_exec.sh
11
  GEMINI.md
12
  .gitignore
 
index.html CHANGED
@@ -40,8 +40,17 @@
40
 
41
  <!-- Header -->
42
  <header class="p-4 mb-4 flex-shrink-0">
43
- <h1 class="text-2xl font-bold text-white">Ignacio Urbina</h1>
44
- <p class="text-sm text-gray-400">Statistical Tools Portfolio</p>
 
 
 
 
 
 
 
 
 
45
  </header>
46
 
47
  <!-- Navigation -->
 
40
 
41
  <!-- Header -->
42
  <header class="p-4 mb-4 flex-shrink-0">
43
+ <div class="flex justify-between items-start">
44
+ <div>
45
+ <h1 class="text-2xl font-bold text-white">Ignacio Urbina</h1>
46
+ <p class="text-sm text-gray-400">Statistical Tools Portfolio</p>
47
+ </div>
48
+ <button id="sidebar-close-button" class="md:hidden p-1 text-gray-400 hover:text-white">
49
+ <svg class="w-6 h-6" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor">
50
+ <path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12" />
51
+ </svg>
52
+ </button>
53
+ </div>
54
  </header>
55
 
56
  <!-- Navigation -->
main.js CHANGED
@@ -6,6 +6,7 @@ document.addEventListener('DOMContentLoaded', () => {
6
  const sidebarHandle = document.getElementById('sidebar-handle');
7
  const mainContent = document.getElementById('main-content');
8
  const loadingSpinner = document.getElementById('loading-spinner');
 
9
 
10
  let spinnerTimeout;
11
  const loadedUrls = new Set();
@@ -51,6 +52,11 @@ document.addEventListener('DOMContentLoaded', () => {
51
  sidebar.classList.add('is-open');
52
  });
53
 
 
 
 
 
 
54
  // Handle clicks on the navigation links
55
  navList.addEventListener('click', (e) => {
56
  const link = e.target.closest('.nav-link');
 
6
  const sidebarHandle = document.getElementById('sidebar-handle');
7
  const mainContent = document.getElementById('main-content');
8
  const loadingSpinner = document.getElementById('loading-spinner');
9
+ const sidebarCloseButton = document.getElementById('sidebar-close-button');
10
 
11
  let spinnerTimeout;
12
  const loadedUrls = new Set();
 
52
  sidebar.classList.add('is-open');
53
  });
54
 
55
+ // Close the sidebar when clicking the close button
56
+ sidebarCloseButton.addEventListener('click', () => {
57
+ sidebar.classList.remove('is-open');
58
+ });
59
+
60
  // Handle clicks on the navigation links
61
  navList.addEventListener('click', (e) => {
62
  const link = e.target.closest('.nav-link');
style.css CHANGED
@@ -79,3 +79,45 @@ body:not(.touch-device) #sidebar:hover #sidebar-handle {
79
  0% { transform: rotate(0deg); }
80
  100% { transform: rotate(360deg); }
81
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  0% { transform: rotate(0deg); }
80
  100% { transform: rotate(360deg); }
81
  }
82
+
83
+
84
+ /* --- Responsive Adjustments --- */
85
+ @media (max-width: 768px) {
86
+ #sidebar {
87
+ /* On smaller screens, the sidebar is completely hidden off-screen */
88
+ transform: translateX(-100%);
89
+ }
90
+ #sidebar:hover {
91
+ /* Disable hover effect on mobile */
92
+ transform: translateX(-100%);
93
+ }
94
+ #sidebar.is-open {
95
+ /* When opened by JS, it slides fully into view */
96
+ transform: translateX(0);
97
+ }
98
+ #main-content {
99
+ /* Main content takes up the full width */
100
+ margin-left: 0;
101
+ }
102
+ #sidebar-handle {
103
+ /* Make the handle slightly larger and more visible for touch */
104
+ width: 32px;
105
+ right: -32px; /* Position it outside the hidden sidebar */
106
+ background-color: rgba(31, 41, 55, 0.7); /* gray-800 with more opacity */
107
+ }
108
+ #sidebar-open-icon {
109
+ /* Make the icon slightly larger */
110
+ width: 20px;
111
+ height: 20px;
112
+ }
113
+ #sidebar-close-button {
114
+ display: block; /* Show the close button on mobile */
115
+ }
116
+ }
117
+
118
+ /* Hide close button on desktop */
119
+ @media (min-width: 769px) {
120
+ #sidebar-close-button {
121
+ display: none;
122
+ }
123
+ }