Skywalker71 commited on
Commit
fb34bbe
·
verified ·
1 Parent(s): 7e3f3ea

сделай несколько страниц и современым

Browse files
Files changed (4) hide show
  1. components/navbar.js +4 -4
  2. components/product-filter.js +148 -0
  3. products.html +107 -0
  4. script.js +30 -2
components/navbar.js CHANGED
@@ -24,8 +24,8 @@ class CustomNavbar extends HTMLElement {
24
  <nav>
25
  <ul class="flex space-x-6">
26
  <li><a href="/" class="text-blue-500 font-medium">Home</a></li>
27
- <li><a href="/products" class="text-gray-600 hover:text-blue-500">Products</a></li>
28
- <li><a href="/about" class="text-gray-600 hover:text-blue-500">About</a></li>
29
  <li><a href="/contact" class="text-gray-600 hover:text-blue-500">Contact</a></li>
30
  </ul>
31
  </nav>
@@ -53,8 +53,8 @@ class CustomNavbar extends HTMLElement {
53
  <nav class="pb-4">
54
  <ul class="space-y-3">
55
  <li><a href="/" class="block py-2 text-blue-500 font-medium">Home</a></li>
56
- <li><a href="/products" class="block py-2 text-gray-600">Products</a></li>
57
- <li><a href="/about" class="block py-2 text-gray-600">About</a></li>
58
  <li><a href="/contact" class="block py-2 text-gray-600">Contact</a></li>
59
  </ul>
60
  </nav>
 
24
  <nav>
25
  <ul class="flex space-x-6">
26
  <li><a href="/" class="text-blue-500 font-medium">Home</a></li>
27
+ <li><a href="/products.html" class="text-gray-600 hover:text-blue-500">Products</a></li>
28
+ <li><a href="/about" class="text-gray-600 hover:text-blue-500">About</a></li>
29
  <li><a href="/contact" class="text-gray-600 hover:text-blue-500">Contact</a></li>
30
  </ul>
31
  </nav>
 
53
  <nav class="pb-4">
54
  <ul class="space-y-3">
55
  <li><a href="/" class="block py-2 text-blue-500 font-medium">Home</a></li>
56
+ <li><a href="/products.html" class="block py-2 text-gray-600">Products</a></li>
57
+ <li><a href="/about" class="block py-2 text-gray-600">About</a></li>
58
  <li><a href="/contact" class="block py-2 text-gray-600">Contact</a></li>
59
  </ul>
60
  </nav>
components/product-filter.js ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ class ProductFilter extends HTMLElement {
2
+ connectedCallback() {
3
+ this.attachShadow({ mode: 'open' });
4
+ this.shadowRoot.innerHTML = `
5
+ <style>
6
+ .filter-section {
7
+ transition: all 0.3s ease;
8
+ }
9
+ .filter-header:hover {
10
+ background-color: #f3f4f6;
11
+ }
12
+ input[type="range"] {
13
+ -webkit-appearance: none;
14
+ height: 4px;
15
+ background: #d1d5db;
16
+ border-radius: 2px;
17
+ }
18
+ input[type="range"]::-webkit-slider-thumb {
19
+ -webkit-appearance: none;
20
+ width: 16px;
21
+ height: 16px;
22
+ background: #3b82f6;
23
+ border-radius: 50%;
24
+ cursor: pointer;
25
+ }
26
+ </style>
27
+ <div class="bg-white p-6 rounded-lg shadow-sm space-y-6">
28
+ <div class="filter-section border-b pb-4">
29
+ <div class="filter-header flex justify-between items-center cursor-pointer">
30
+ <h3 class="font-bold">Categories</h3>
31
+ <i data-feather="chevron-down" class="w-5 h-5"></i>
32
+ </div>
33
+ <div class="filter-content mt-4 space-y-2">
34
+ <div class="flex items-center">
35
+ <input type="checkbox" id="category-desktops" class="mr-2">
36
+ <label for="category-desktops" class="text-gray-700">Desktops (42)</label>
37
+ </div>
38
+ <div class="flex items-center">
39
+ <input type="checkbox" id="category-laptops" class="mr-2">
40
+ <label for="category-laptops" class="text-gray-700">Laptops (36)</label>
41
+ </div>
42
+ <div class="flex items-center">
43
+ <input type="checkbox" id="category-components" class="mr-2">
44
+ <label for="category-components" class="text-gray-700">Components (58)</label>
45
+ </div>
46
+ <div class="flex items-center">
47
+ <input type="checkbox" id="category-accessories" class="mr-2">
48
+ <label for="category-accessories" class="text-gray-700">Accessories (27)</label>
49
+ </div>
50
+ </div>
51
+ </div>
52
+
53
+ <div class="filter-section border-b pb-4">
54
+ <div class="filter-header flex justify-between items-center cursor-pointer">
55
+ <h3 class="font-bold">Price Range</h3>
56
+ <i data-feather="chevron-down" class="w-5 h-5"></i>
57
+ </div>
58
+ <div class="filter-content mt-4">
59
+ <input type="range" min="0" max="5000" value="2500" class="w-full mb-4">
60
+ <div class="flex justify-between text-sm text-gray-600">
61
+ <span>$0</span>
62
+ <span>$2500</span>
63
+ <span>$5000</span>
64
+ </div>
65
+ </div>
66
+ </div>
67
+
68
+ <div class="filter-section border-b pb-4">
69
+ <div class="filter-header flex justify-between items-center cursor-pointer">
70
+ <h3 class="font-bold">Brand</h3>
71
+ <i data-feather="chevron-down" class="w-5 h-5"></i>
72
+ </div>
73
+ <div class="filter-content mt-4 space-y-2">
74
+ <div class="flex items-center">
75
+ <input type="checkbox" id="brand-quantum" class="mr-2">
76
+ <label for="brand-quantum" class="text-gray-700">Quantum (18)</label>
77
+ </div>
78
+ <div class="flex items-center">
79
+ <input type="checkbox" id="brand-nova" class="mr-2">
80
+ <label for="brand-nova" class="text-gray-700">Nova (12)</label>
81
+ </div>
82
+ <div class="flex items-center">
83
+ <input type="checkbox" id="brand-zenith" class="mr-2">
84
+ <label for="brand-zenith" class="text-gray-700">Zenith (9)</label>
85
+ </div>
86
+ <div class="flex items-center">
87
+ <input type="checkbox" id="brand-aero" class="mr-2">
88
+ <label for="brand-aero" class="text-gray-700">Aero (7)</label>
89
+ </div>
90
+ </div>
91
+ </div>
92
+
93
+ <div class="filter-section">
94
+ <div class="filter-header flex justify-between items-center cursor-pointer">
95
+ <h3 class="font-bold">Rating</h3>
96
+ <i data-feather="chevron-down" class="w-5 h-5"></i>
97
+ </div>
98
+ <div class="filter-content mt-4 space-y-2">
99
+ <div class="flex items-center">
100
+ <input type="checkbox" id="rating-5" class="mr-2">
101
+ <label for="rating-5" class="flex items-center text-gray-700">
102
+ <div class="flex text-yellow-400 mr-1">
103
+ <i data-feather="star" class="w-4 h-4 fill-current"></i>
104
+ <i data-feather="star" class="w-4 h-4 fill-current"></i>
105
+ <i data-feather="star" class="w-4 h-4 fill-current"></i>
106
+ <i data-feather="star" class="w-4 h-4 fill-current"></i>
107
+ <i data-feather="star" class="w-4 h-4 fill-current"></i>
108
+ </div>
109
+ & Up (53)
110
+ </label>
111
+ </div>
112
+ <div class="flex items-center">
113
+ <input type="checkbox" id="rating-4" class="mr-2">
114
+ <label for="rating-4" class="flex items-center text-gray-700">
115
+ <div class="flex text-yellow-400 mr-1">
116
+ <i data-feather="star" class="w-4 h-4 fill-current"></i>
117
+ <i data-feather="star" class="w-4 h-4 fill-current"></i>
118
+ <i data-feather="star" class="w-4 h-4 fill-current"></i>
119
+ <i data-feather="star" class="w-4 h-4 fill-current"></i>
120
+ </div>
121
+ & Up (37)
122
+ </label>
123
+ </div>
124
+ </div>
125
+ </div>
126
+
127
+ <button class="w-full bg-blue-500 text-white py-2 rounded-md hover:bg-blue-600 transition duration-300 mt-6">
128
+ Apply Filters
129
+ </button>
130
+ </div>
131
+ `;
132
+
133
+ // Initialize filter section toggle functionality
134
+ const filterHeaders = this.shadowRoot.querySelectorAll('.filter-header');
135
+ filterHeaders.forEach(header => {
136
+ header.addEventListener('click', () => {
137
+ const section = header.closest('.filter-section');
138
+ const content = section.querySelector('.filter-content');
139
+ const icon = header.querySelector('i');
140
+
141
+ content.classList.toggle('hidden');
142
+ feather.replace(icon, content.classList.contains('hidden') ? 'chevron-down' : 'chevron-up');
143
+ });
144
+ });
145
+ }
146
+ }
147
+
148
+ customElements.define('custom-product-filter', ProductFilter);
products.html ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Products | ByteBazaar</title>
7
+ <link rel="stylesheet" href="style.css">
8
+ <script src="https://cdn.tailwindcss.com"></script>
9
+ <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
10
+ <script src="components/navbar.js"></script>
11
+ <script src="components/footer.js"></script>
12
+ <script src="components/product-card.js"></script>
13
+ <script src="components/product-filter.js"></script>
14
+ </head>
15
+ <body class="bg-gray-50">
16
+ <custom-navbar></custom-navbar>
17
+
18
+ <main class="container mx-auto px-4 py-8">
19
+ <div class="flex flex-col md:flex-row gap-8">
20
+ <!-- Filters Sidebar -->
21
+ <aside class="md:w-1/4">
22
+ <custom-product-filter></custom-product-filter>
23
+ </aside>
24
+
25
+ <!-- Product Grid -->
26
+ <div class="md:w-3/4">
27
+ <div class="flex justify-between items-center mb-8">
28
+ <h1 class="text-3xl font-bold">All Products</h1>
29
+ <div class="flex items-center space-x-4">
30
+ <span class="text-gray-600">Sort by:</span>
31
+ <select class="bg-white border border-gray-300 rounded-md px-3 py-2">
32
+ <option>Featured</option>
33
+ <option>Price: Low to High</option>
34
+ <option>Price: High to Low</option>
35
+ <option>Top Rated</option>
36
+ <option>Newest</option>
37
+ </select>
38
+ </div>
39
+ </div>
40
+
41
+ <div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6">
42
+ <custom-product-card
43
+ image="http://static.photos/technology/640x360/5"
44
+ title="Neon Blade X"
45
+ price="1799"
46
+ category="Gaming Laptop"
47
+ rating="4.7"
48
+ ></custom-product-card>
49
+ <custom-product-card
50
+ image="http://static.photos/technology/640x360/6"
51
+ title="Core i9 Extreme"
52
+ price="499"
53
+ category="Processor"
54
+ rating="4.9"
55
+ ></custom-product-card>
56
+ <custom-product-card
57
+ image="http://static.photos/technology/640x360/7"
58
+ title="Aero 34\" Curved"
59
+ price="699"
60
+ category="Monitor"
61
+ rating="4.6"
62
+ ></custom-product-card>
63
+ <custom-product-card
64
+ image="http://static.photos/technology/640x360/8"
65
+ title="Thunder Mouse Pro"
66
+ price="129"
67
+ category="Accessories"
68
+ rating="4.5"
69
+ ></custom-product-card>
70
+ <custom-product-card
71
+ image="http://static.photos/technology/640x360/9"
72
+ title="Nova SSD 2TB"
73
+ price="249"
74
+ category="Storage"
75
+ rating="4.8"
76
+ ></custom-product-card>
77
+ <custom-product-card
78
+ image="http://static.photos/technology/640x360/10"
79
+ title="Quantum Keyboard"
80
+ price="199"
81
+ category="Accessories"
82
+ rating="4.4"
83
+ ></custom-product-card>
84
+ </div>
85
+
86
+ <!-- Pagination -->
87
+ <div class="flex justify-center mt-12">
88
+ <nav class="flex items-center space-x-2">
89
+ <a href="#" class="px-4 py-2 border rounded-md hover:bg-gray-100">Previous</a>
90
+ <a href="#" class="px-4 py-2 border rounded-md bg-blue-500 text-white">1</a>
91
+ <a href="#" class="px-4 py-2 border rounded-md hover:bg-gray-100">2</a>
92
+ <a href="#" class="px-4 py-2 border rounded-md hover:bg-gray-100">3</a>
93
+ <a href="#" class="px-4 py-2 border rounded-md hover:bg-gray-100">Next</a>
94
+ </nav>
95
+ </div>
96
+ </div>
97
+ </div>
98
+ </main>
99
+
100
+ <custom-footer></custom-footer>
101
+
102
+ <script>
103
+ feather.replace();
104
+ </script>
105
+ <script src="script.js"></script>
106
+ </body>
107
+ </html>
script.js CHANGED
@@ -1,9 +1,37 @@
 
1
  // Main JavaScript functionality
2
  document.addEventListener('DOMContentLoaded', () => {
3
  // Initialize any global functionality here
4
  console.log('ByteBazaar loaded!');
5
-
6
- // Example: Add to cart functionality
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  document.addEventListener('click', (e) => {
8
  if (e.target.classList.contains('add-to-cart')) {
9
  const product = e.target.closest('.product-card').dataset.product;
 
1
+
2
  // Main JavaScript functionality
3
  document.addEventListener('DOMContentLoaded', () => {
4
  // Initialize any global functionality here
5
  console.log('ByteBazaar loaded!');
6
+
7
+ // Initialize price range slider
8
+ const initRangeSliders = () => {
9
+ document.querySelectorAll('input[type="range"]').forEach(slider => {
10
+ slider.addEventListener('input', function() {
11
+ const valueDisplay = this.nextElementSibling?.querySelector('span:nth-child(2)');
12
+ if (valueDisplay) {
13
+ valueDisplay.textContent = `${this.value}`;
14
+ }
15
+ });
16
+ });
17
+ };
18
+
19
+ // Initialize filter sections
20
+ const initFilterSections = () => {
21
+ document.querySelectorAll('.filter-section').forEach(section => {
22
+ const header = section.querySelector('.filter-header');
23
+ if (header) {
24
+ header.addEventListener('click', () => {
25
+ const content = section.querySelector('.filter-content');
26
+ content.classList.toggle('hidden');
27
+ });
28
+ }
29
+ });
30
+ };
31
+
32
+ initRangeSliders();
33
+ initFilterSections();
34
+ // Example: Add to cart functionality
35
  document.addEventListener('click', (e) => {
36
  if (e.target.classList.contains('add-to-cart')) {
37
  const product = e.target.closest('.product-card').dataset.product;