ntl69 commited on
Commit
cf3eccd
·
verified ·
1 Parent(s): b8425db

also add show recommedation in search bar

Browse files
Files changed (2) hide show
  1. articles.html +72 -3
  2. index.html +72 -3
articles.html CHANGED
@@ -54,18 +54,87 @@
54
  </div>
55
  </div>
56
  </nav>
57
- <!-- Search Bar -->
58
  <div class="container mx-auto px-4 py-8">
59
  <div class="max-w-4xl mx-auto relative">
60
- <input type="text" placeholder="Search for articles..."
61
  class="w-full bg-gray-800 text-white px-6 py-4 rounded-full focus:outline-none focus:ring-2 focus:ring-gray-600 border border-gray-700">
62
  <button class="absolute right-3 top-3 bg-black hover:bg-gray-800 text-white px-6 py-2 rounded-full transition">
63
  <i data-feather="search" class="inline-block"></i> Search
64
  </button>
 
 
 
 
 
 
 
 
 
65
  </div>
66
  </div>
67
 
68
- <main class="container mx-auto px-4 pb-12">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
  <h1 class="text-4xl font-bold mb-8" style="font-family: 'Shrikhand', cursive;">All Articles</h1>
70
 
71
  <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8">
 
54
  </div>
55
  </div>
56
  </nav>
57
+ <!-- Search Bar with Recommendations -->
58
  <div class="container mx-auto px-4 py-8">
59
  <div class="max-w-4xl mx-auto relative">
60
+ <input type="text" id="searchInput" placeholder="Search for articles..."
61
  class="w-full bg-gray-800 text-white px-6 py-4 rounded-full focus:outline-none focus:ring-2 focus:ring-gray-600 border border-gray-700">
62
  <button class="absolute right-3 top-3 bg-black hover:bg-gray-800 text-white px-6 py-2 rounded-full transition">
63
  <i data-feather="search" class="inline-block"></i> Search
64
  </button>
65
+ <div id="searchSuggestions" class="hidden absolute left-0 right-0 mt-1 bg-gray-800 rounded-lg shadow-lg z-50 max-h-60 overflow-y-auto">
66
+ <div class="p-2 text-gray-400">Popular searches:</div>
67
+ <div class="divide-y divide-gray-700">
68
+ <a href="#" class="block px-4 py-2 hover:bg-gray-700 text-white">Politics</a>
69
+ <a href="#" class="block px-4 py-2 hover:bg-gray-700 text-white">Technology</a>
70
+ <a href="#" class="block px-4 py-2 hover:bg-gray-700 text-white">Health</a>
71
+ <a href="#" class="block px-4 py-2 hover:bg-gray-700 text-white">Business</a>
72
+ </div>
73
+ </div>
74
  </div>
75
  </div>
76
 
77
+ <script>
78
+ const searchInput = document.getElementById('searchInput');
79
+ const searchSuggestions = document.getElementById('searchSuggestions');
80
+
81
+ searchInput.addEventListener('focus', () => {
82
+ searchSuggestions.classList.remove('hidden');
83
+ });
84
+
85
+ searchInput.addEventListener('blur', () => {
86
+ setTimeout(() => {
87
+ searchSuggestions.classList.add('hidden');
88
+ }, 200);
89
+ });
90
+
91
+ // Sample search suggestions - in a real app you would fetch these from an API
92
+ const popularSearches = [
93
+ "Politics",
94
+ "Technology",
95
+ "Health",
96
+ "Business",
97
+ "World News",
98
+ "Conspiracy Theories",
99
+ "Latest Updates"
100
+ ];
101
+
102
+ searchInput.addEventListener('input', (e) => {
103
+ const value = e.target.value.toLowerCase();
104
+ if (value.length > 0) {
105
+ const filtered = popularSearches.filter(item =>
106
+ item.toLowerCase().includes(value)
107
+ );
108
+
109
+ // Update suggestions dropdown
110
+ if (filtered.length > 0) {
111
+ searchSuggestions.innerHTML = `
112
+ <div class="p-2 text-gray-400">Suggestions:</div>
113
+ <div class="divide-y divide-gray-700">
114
+ ${filtered.map(item => `
115
+ <a href="/search?q=${encodeURIComponent(item)}" class="block px-4 py-2 hover:bg-gray-700 text-white">${item}</a>
116
+ `).join('')}
117
+ </div>
118
+ `;
119
+ } else {
120
+ searchSuggestions.innerHTML = `
121
+ <div class="p-4 text-gray-400 text-center">No suggestions found</div>
122
+ `;
123
+ }
124
+ searchSuggestions.classList.remove('hidden');
125
+ } else {
126
+ searchSuggestions.innerHTML = `
127
+ <div class="p-2 text-gray-400">Popular searches:</div>
128
+ <div class="divide-y divide-gray-700">
129
+ ${popularSearches.map(item => `
130
+ <a href="/search?q=${encodeURIComponent(item)}" class="block px-4 py-2 hover:bg-gray-700 text-white">${item}</a>
131
+ `).join('')}
132
+ </div>
133
+ `;
134
+ }
135
+ });
136
+ </script>
137
+ <main class="container mx-auto px-4 pb-12">
138
  <h1 class="text-4xl font-bold mb-8" style="font-family: 'Shrikhand', cursive;">All Articles</h1>
139
 
140
  <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8">
index.html CHANGED
@@ -56,18 +56,87 @@ NoCap Nation
56
  </div>
57
  </div>
58
  </nav>
59
- <!-- Search Bar -->
60
  <div class="container mx-auto px-4 py-8">
61
  <div class="max-w-4xl mx-auto relative">
62
- <input type="text" placeholder="Search for articles..."
63
  class="w-full bg-gray-800 text-white px-6 py-4 rounded-full focus:outline-none focus:ring-2 focus:ring-gray-600 border border-gray-700">
64
  <button class="absolute right-3 top-3 bg-black hover:bg-gray-800 text-white px-6 py-2 rounded-full transition">
65
  <i data-feather="search" class="inline-block"></i> Search
66
  </button>
 
 
 
 
 
 
 
 
 
67
  </div>
68
  </div>
69
 
70
- <!-- Hero Section -->
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
  <header class="relative bg-gradient-to-r from-gray-800 to-gray-900 py-16">
72
  <div class="absolute inset-0 bg-black opacity-60"></div>
73
  <div class="container mx-auto px-4 relative z-10 pt-4">
 
56
  </div>
57
  </div>
58
  </nav>
59
+ <!-- Search Bar with Recommendations -->
60
  <div class="container mx-auto px-4 py-8">
61
  <div class="max-w-4xl mx-auto relative">
62
+ <input type="text" id="searchInput" placeholder="Search for articles..."
63
  class="w-full bg-gray-800 text-white px-6 py-4 rounded-full focus:outline-none focus:ring-2 focus:ring-gray-600 border border-gray-700">
64
  <button class="absolute right-3 top-3 bg-black hover:bg-gray-800 text-white px-6 py-2 rounded-full transition">
65
  <i data-feather="search" class="inline-block"></i> Search
66
  </button>
67
+ <div id="searchSuggestions" class="hidden absolute left-0 right-0 mt-1 bg-gray-800 rounded-lg shadow-lg z-50 max-h-60 overflow-y-auto">
68
+ <div class="p-2 text-gray-400">Popular searches:</div>
69
+ <div class="divide-y divide-gray-700">
70
+ <a href="#" class="block px-4 py-2 hover:bg-gray-700 text-white">Politics</a>
71
+ <a href="#" class="block px-4 py-2 hover:bg-gray-700 text-white">Technology</a>
72
+ <a href="#" class="block px-4 py-2 hover:bg-gray-700 text-white">Health</a>
73
+ <a href="#" class="block px-4 py-2 hover:bg-gray-700 text-white">Business</a>
74
+ </div>
75
+ </div>
76
  </div>
77
  </div>
78
 
79
+ <script>
80
+ const searchInput = document.getElementById('searchInput');
81
+ const searchSuggestions = document.getElementById('searchSuggestions');
82
+
83
+ searchInput.addEventListener('focus', () => {
84
+ searchSuggestions.classList.remove('hidden');
85
+ });
86
+
87
+ searchInput.addEventListener('blur', () => {
88
+ setTimeout(() => {
89
+ searchSuggestions.classList.add('hidden');
90
+ }, 200);
91
+ });
92
+
93
+ // Sample search suggestions - in a real app you would fetch these from an API
94
+ const popularSearches = [
95
+ "Politics",
96
+ "Technology",
97
+ "Health",
98
+ "Business",
99
+ "World News",
100
+ "Conspiracy Theories",
101
+ "Latest Updates"
102
+ ];
103
+
104
+ searchInput.addEventListener('input', (e) => {
105
+ const value = e.target.value.toLowerCase();
106
+ if (value.length > 0) {
107
+ const filtered = popularSearches.filter(item =>
108
+ item.toLowerCase().includes(value)
109
+ );
110
+
111
+ // Update suggestions dropdown
112
+ if (filtered.length > 0) {
113
+ searchSuggestions.innerHTML = `
114
+ <div class="p-2 text-gray-400">Suggestions:</div>
115
+ <div class="divide-y divide-gray-700">
116
+ ${filtered.map(item => `
117
+ <a href="/search?q=${encodeURIComponent(item)}" class="block px-4 py-2 hover:bg-gray-700 text-white">${item}</a>
118
+ `).join('')}
119
+ </div>
120
+ `;
121
+ } else {
122
+ searchSuggestions.innerHTML = `
123
+ <div class="p-4 text-gray-400 text-center">No suggestions found</div>
124
+ `;
125
+ }
126
+ searchSuggestions.classList.remove('hidden');
127
+ } else {
128
+ searchSuggestions.innerHTML = `
129
+ <div class="p-2 text-gray-400">Popular searches:</div>
130
+ <div class="divide-y divide-gray-700">
131
+ ${popularSearches.map(item => `
132
+ <a href="/search?q=${encodeURIComponent(item)}" class="block px-4 py-2 hover:bg-gray-700 text-white">${item}</a>
133
+ `).join('')}
134
+ </div>
135
+ `;
136
+ }
137
+ });
138
+ </script>
139
+ <!-- Hero Section -->
140
  <header class="relative bg-gradient-to-r from-gray-800 to-gray-900 py-16">
141
  <div class="absolute inset-0 bg-black opacity-60"></div>
142
  <div class="container mx-auto px-4 relative z-10 pt-4">