flpolprojects commited on
Commit
397b649
·
verified ·
1 Parent(s): 26eeec0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +90 -110
app.py CHANGED
@@ -111,7 +111,7 @@ def catalog():
111
  background-color: #f5f5f5;
112
  color: #333;
113
  line-height: 1.6;
114
- padding: 20px;
115
  }
116
  .container {
117
  max-width: 1200px;
@@ -119,13 +119,13 @@ def catalog():
119
  }
120
  .search-container {
121
  text-align: center;
122
- margin-bottom: 40px;
123
  }
124
  #search-input {
125
- width: 80%;
126
  max-width: 500px;
127
- padding: 10px;
128
- font-size: 1em;
129
  border: 1px solid #ddd;
130
  border-radius: 5px;
131
  outline: none;
@@ -136,40 +136,34 @@ def catalog():
136
  }
137
  .products-grid {
138
  display: grid;
139
- grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
140
- gap: 20px;
141
- padding: 0 15px;
 
 
142
  }
143
  .product {
144
  background: #ffffff;
145
- border-radius: 12px;
146
- padding: 20px;
147
- transition: transform 0.3s ease, box-shadow 0.3s ease;
148
  display: flex;
149
  flex-direction: column;
150
- box-shadow: 0 2px 15px rgba(0, 0, 0, 0.1);
151
- }
152
- .product:hover {
153
- transform: translateY(-5px);
154
- box-shadow: 0 5px 25px rgba(0, 0, 0, 0.15);
155
  }
156
  .product-image {
157
- width: 200px;
158
- height: 200px;
159
  background-color: #fff;
160
  border-radius: 8px;
161
- margin: 0 auto 15px;
162
  overflow: hidden;
163
- position: relative;
164
  display: flex;
165
  justify-content: center;
166
  align-items: center;
167
  }
168
  .product-image img {
169
- max-width: 200px;
170
- max-height: 200px;
171
- width: auto;
172
- height: auto;
173
  object-fit: contain;
174
  transition: transform 0.3s ease;
175
  }
@@ -177,30 +171,36 @@ def catalog():
177
  transform: scale(1.05);
178
  }
179
  .product h2 {
180
- font-size: 1.2em;
181
- color: #2c3e50;
182
- margin-bottom: 10px;
183
  font-weight: 600;
184
  text-align: center;
 
 
 
185
  }
186
  .product-price {
187
- font-size: 1.3em;
188
- color: #e74c3c;
189
  font-weight: 700;
190
- margin: 10px 0;
191
  text-align: center;
192
  }
193
  .product-description {
194
- color: #7f8c8d;
195
- font-size: 0.9em;
196
  flex-grow: 1;
197
- margin-bottom: 15px;
198
  text-align: center;
 
 
 
199
  }
200
  .product-button {
201
  background-color: #3498db;
202
  color: white;
203
- padding: 10px 20px;
204
  border: none;
205
  border-radius: 5px;
206
  cursor: pointer;
@@ -209,7 +209,7 @@ def catalog():
209
  text-decoration: none;
210
  display: block;
211
  margin: 5px auto;
212
- font-weight: 500;
213
  }
214
  .product-button:hover {
215
  background-color: #2980b9;
@@ -222,15 +222,15 @@ def catalog():
222
  }
223
  #cart-button {
224
  position: fixed;
225
- bottom: 20px;
226
- right: 20px;
227
  background-color: #e74c3c;
228
  color: white;
229
  border: none;
230
  border-radius: 50%;
231
- width: 60px;
232
- height: 60px;
233
- font-size: 20px;
234
  cursor: pointer;
235
  display: none;
236
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
@@ -254,9 +254,9 @@ def catalog():
254
  position: relative;
255
  background-color: #fefefe;
256
  margin: 10% auto;
257
- padding: 20px;
258
  border: 1px solid #888;
259
- width: 80%;
260
  max-width: 600px;
261
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
262
  animation: animatetop 0.4s;
@@ -268,7 +268,7 @@ def catalog():
268
  .close {
269
  color: #aaa;
270
  float: right;
271
- font-size: 28px;
272
  font-weight: bold;
273
  cursor: pointer;
274
  }
@@ -283,16 +283,17 @@ def catalog():
283
  border-bottom: 1px solid #eee;
284
  }
285
  .cart-item img {
286
- width: 50px;
287
- height: 50px;
288
  object-fit: contain;
289
  background-color: #fff;
290
  margin-right: 10px;
291
  }
292
  .quantity-input {
293
- width: 60px;
294
  padding: 5px;
295
  margin: 10px 0;
 
296
  }
297
  .clear-cart {
298
  background-color: #e74c3c;
@@ -309,80 +310,36 @@ def catalog():
309
  .order-button:hover {
310
  background-color: #20B956;
311
  }
312
- @media (max-width: 768px) {
313
- body {
314
- padding: 10px;
315
- }
316
  .products-grid {
317
- gap: 15px;
318
- padding: 0 10px;
 
 
319
  }
320
  .product {
321
  padding: 15px;
322
  }
323
  .product-image {
324
- width: 150px;
325
- height: 150px;
326
- }
327
- .product-image img {
328
- max-width: 150px;
329
- max-height: 150px;
330
  }
331
  .product h2 {
332
- font-size: 1em;
333
  }
334
  .product-price {
335
- font-size: 1.1em;
336
  }
337
  .product-description {
338
- font-size: 0.85em;
339
  }
340
  .product-button {
341
- padding: 8px 15px;
342
  font-size: 0.9em;
 
343
  }
344
  #cart-button {
345
  width: 50px;
346
  height: 50px;
347
  font-size: 18px;
348
- bottom: 15px;
349
- right: 15px;
350
- }
351
- }
352
- @media (max-width: 480px) {
353
- .products-grid {
354
- gap: 10px;
355
- padding: 0 5px;
356
- }
357
- .product {
358
- padding: 10px;
359
- }
360
- .product-image {
361
- width: 120px;
362
- height: 120px;
363
- }
364
- .product-image img {
365
- max-width: 120px;
366
- max-height: 120px;
367
- }
368
- .search-container {
369
- margin-bottom: 20px;
370
- }
371
- #search-input {
372
- width: 90%;
373
- }
374
- .product h2 {
375
- font-size: 0.9em;
376
- }
377
- .product-price {
378
- font-size: 1em;
379
- }
380
- .product-description {
381
- font-size: 0.8em;
382
- }
383
- .product-button {
384
- padding: 6px 12px;
385
- font-size: 0.85em;
386
  }
387
  }
388
  </style>
@@ -404,7 +361,7 @@ def catalog():
404
  {% endif %}
405
  <h2>{{ product['name'] }}</h2>
406
  <div class="product-price">{{ product['price'] }}</div>
407
- <p class="product-description">{{ product['description'][:100] }}{% if product['description']|length > 100 %}...{% endif %}</p>
408
  <button class="product-button" onclick="openModal({{ loop.index0 }})">Подробнее</button>
409
  <button class="product-button add-to-cart" onclick="openQuantityModal({{ loop.index0 }})">В корзину</button>
410
  </div>
@@ -436,7 +393,7 @@ def catalog():
436
  <span class="close" onclick="closeModal('cartModal')">×</span>
437
  <h2>Корзина</h2>
438
  <div id="cartContent"></div>
439
- <div style="margin-top: 20px; text-align: right;">
440
  <strong>Итого: <span id="cartTotal">0</span></strong>
441
  <button class="product-button clear-cart" onclick="clearCart()">Очистить корзину</button>
442
  <button class="product-button order-button" onclick="orderViaWhatsApp()">Заказать</button>
@@ -478,7 +435,7 @@ def catalog():
478
  function initializeSwiper() {
479
  new Swiper('.swiper-container', {
480
  slidesPerView: 1,
481
- spaceBetween: 30,
482
  loop: true,
483
  grabCursor: true,
484
  pagination: {
@@ -489,6 +446,9 @@ def catalog():
489
  nextEl: '.swiper-button-next',
490
  prevEl: '.swiper-button-prev',
491
  },
 
 
 
492
  });
493
  }
494
 
@@ -663,9 +623,11 @@ def product_detail(index):
663
  {% if product.get('photos') %}
664
  {% for photo in product['photos'] %}
665
  <div class="swiper-slide" style="background-color: #fff; display: flex; justify-content: center; align-items: center;">
666
- <img src="https://huggingface.co/datasets/{{ repo_id }}/resolve/main/photos/{{ photo }}"
667
- alt="{{ product['name'] }}"
668
- style="max-width: 200px; max-height: 200px; width: auto; height: auto; object-fit: contain;">
 
 
669
  </div>
670
  {% endfor %}
671
  {% else %}
@@ -829,7 +791,7 @@ def admin():
829
  }
830
  form {
831
  background-color: #fff;
832
- padding: 20px;
833
  border: 1px solid #ddd;
834
  border-radius: 5px;
835
  max-width: 100%;
@@ -849,8 +811,8 @@ def admin():
849
  box-sizing: border-box;
850
  }
851
  button {
852
- margin-top: 15px;
853
- padding: 10px 15px;
854
  background-color: #28a745;
855
  color: white;
856
  border: none;
@@ -866,7 +828,7 @@ def admin():
866
  .product-item {
867
  background-color: #fff;
868
  border: 1px solid #ddd;
869
- padding: 15px;
870
  margin-bottom: 10px;
871
  border-radius: 5px;
872
  }
@@ -877,6 +839,24 @@ def admin():
877
  border-radius: 5px;
878
  background-color: #f9f9f9;
879
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
880
  </style>
881
  </head>
882
  <body>
 
111
  background-color: #f5f5f5;
112
  color: #333;
113
  line-height: 1.6;
114
+ padding: 10px;
115
  }
116
  .container {
117
  max-width: 1200px;
 
119
  }
120
  .search-container {
121
  text-align: center;
122
+ margin-bottom: 20px;
123
  }
124
  #search-input {
125
+ width: 90%;
126
  max-width: 500px;
127
+ padding: 8px;
128
+ font-size: 0.9em;
129
  border: 1px solid #ddd;
130
  border-radius: 5px;
131
  outline: none;
 
136
  }
137
  .products-grid {
138
  display: grid;
139
+ grid-template-columns: repeat(2, 1fr);
140
+ gap: 10px;
141
+ padding: 0 5px;
142
+ overflow-y: auto;
143
+ max-height: calc(100vh - 120px);
144
  }
145
  .product {
146
  background: #ffffff;
147
+ border-radius: 10px;
148
+ padding: 10px;
149
+ box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
150
  display: flex;
151
  flex-direction: column;
152
+ min-width: 0;
 
 
 
 
153
  }
154
  .product-image {
155
+ width: 100%;
156
+ aspect-ratio: 1;
157
  background-color: #fff;
158
  border-radius: 8px;
 
159
  overflow: hidden;
 
160
  display: flex;
161
  justify-content: center;
162
  align-items: center;
163
  }
164
  .product-image img {
165
+ max-width: 100%;
166
+ max-height: 100%;
 
 
167
  object-fit: contain;
168
  transition: transform 0.3s ease;
169
  }
 
171
  transform: scale(1.05);
172
  }
173
  .product h2 {
174
+ font-size: 1em;
175
+ color: #333;
176
+ margin: 10px 0 5px;
177
  font-weight: 600;
178
  text-align: center;
179
+ overflow: hidden;
180
+ text-overflow: ellipsis;
181
+ white-space: nowrap;
182
  }
183
  .product-price {
184
+ font-size: 1.1em;
185
+ color: #ff0000;
186
  font-weight: 700;
187
+ margin: 5px 0;
188
  text-align: center;
189
  }
190
  .product-description {
191
+ color: #666;
192
+ font-size: 0.8em;
193
  flex-grow: 1;
194
+ margin-bottom: 10px;
195
  text-align: center;
196
+ overflow: hidden;
197
+ text-overflow: ellipsis;
198
+ white-space: nowrap;
199
  }
200
  .product-button {
201
  background-color: #3498db;
202
  color: white;
203
+ padding: 6px 12px;
204
  border: none;
205
  border-radius: 5px;
206
  cursor: pointer;
 
209
  text-decoration: none;
210
  display: block;
211
  margin: 5px auto;
212
+ font-size: 0.8em;
213
  }
214
  .product-button:hover {
215
  background-color: #2980b9;
 
222
  }
223
  #cart-button {
224
  position: fixed;
225
+ bottom: 15px;
226
+ right: 15px;
227
  background-color: #e74c3c;
228
  color: white;
229
  border: none;
230
  border-radius: 50%;
231
+ width: 40px;
232
+ height: 40px;
233
+ font-size: 16px;
234
  cursor: pointer;
235
  display: none;
236
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
 
254
  position: relative;
255
  background-color: #fefefe;
256
  margin: 10% auto;
257
+ padding: 15px;
258
  border: 1px solid #888;
259
+ width: 90%;
260
  max-width: 600px;
261
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
262
  animation: animatetop 0.4s;
 
268
  .close {
269
  color: #aaa;
270
  float: right;
271
+ font-size: 24px;
272
  font-weight: bold;
273
  cursor: pointer;
274
  }
 
283
  border-bottom: 1px solid #eee;
284
  }
285
  .cart-item img {
286
+ width: 40px;
287
+ height: 40px;
288
  object-fit: contain;
289
  background-color: #fff;
290
  margin-right: 10px;
291
  }
292
  .quantity-input {
293
+ width: 50px;
294
  padding: 5px;
295
  margin: 10px 0;
296
+ font-size: 0.9em;
297
  }
298
  .clear-cart {
299
  background-color: #e74c3c;
 
310
  .order-button:hover {
311
  background-color: #20B956;
312
  }
313
+ @media (min-width: 768px) {
 
 
 
314
  .products-grid {
315
+ grid-template-columns: repeat(2, 1fr);
316
+ gap: 20px;
317
+ padding: 0 15px;
318
+ max-height: none;
319
  }
320
  .product {
321
  padding: 15px;
322
  }
323
  .product-image {
324
+ aspect-ratio: 1;
 
 
 
 
 
325
  }
326
  .product h2 {
327
+ font-size: 1.2em;
328
  }
329
  .product-price {
330
+ font-size: 1.3em;
331
  }
332
  .product-description {
333
+ font-size: 0.9em;
334
  }
335
  .product-button {
 
336
  font-size: 0.9em;
337
+ padding: 8px 15px;
338
  }
339
  #cart-button {
340
  width: 50px;
341
  height: 50px;
342
  font-size: 18px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
343
  }
344
  }
345
  </style>
 
361
  {% endif %}
362
  <h2>{{ product['name'] }}</h2>
363
  <div class="product-price">{{ product['price'] }}</div>
364
+ <p class="product-description">{{ product['description'][:50] }}{% if product['description']|length > 50 %}...{% endif %}</p>
365
  <button class="product-button" onclick="openModal({{ loop.index0 }})">Подробнее</button>
366
  <button class="product-button add-to-cart" onclick="openQuantityModal({{ loop.index0 }})">В корзину</button>
367
  </div>
 
393
  <span class="close" onclick="closeModal('cartModal')">×</span>
394
  <h2>Корзина</h2>
395
  <div id="cartContent"></div>
396
+ <div style="margin-top: 15px; text-align: right;">
397
  <strong>Итого: <span id="cartTotal">0</span></strong>
398
  <button class="product-button clear-cart" onclick="clearCart()">Очистить корзину</button>
399
  <button class="product-button order-button" onclick="orderViaWhatsApp()">Заказать</button>
 
435
  function initializeSwiper() {
436
  new Swiper('.swiper-container', {
437
  slidesPerView: 1,
438
+ spaceBetween: 20,
439
  loop: true,
440
  grabCursor: true,
441
  pagination: {
 
446
  nextEl: '.swiper-button-next',
447
  prevEl: '.swiper-button-prev',
448
  },
449
+ zoom: {
450
+ maxRatio: 3,
451
+ },
452
  });
453
  }
454
 
 
623
  {% if product.get('photos') %}
624
  {% for photo in product['photos'] %}
625
  <div class="swiper-slide" style="background-color: #fff; display: flex; justify-content: center; align-items: center;">
626
+ <div class="swiper-zoom-container">
627
+ <img src="https://huggingface.co/datasets/{{ repo_id }}/resolve/main/photos/{{ photo }}"
628
+ alt="{{ product['name'] }}"
629
+ style="max-width: 200px; max-height: 200px; width: auto; height: auto; object-fit: contain;">
630
+ </div>
631
  </div>
632
  {% endfor %}
633
  {% else %}
 
791
  }
792
  form {
793
  background-color: #fff;
794
+ padding: 15px;
795
  border: 1px solid #ddd;
796
  border-radius: 5px;
797
  max-width: 100%;
 
811
  box-sizing: border-box;
812
  }
813
  button {
814
+ margin-top: 10px;
815
+ padding: 8px 12px;
816
  background-color: #28a745;
817
  color: white;
818
  border: none;
 
828
  .product-item {
829
  background-color: #fff;
830
  border: 1px solid #ddd;
831
+ padding: 10px;
832
  margin-bottom: 10px;
833
  border-radius: 5px;
834
  }
 
839
  border-radius: 5px;
840
  background-color: #f9f9f9;
841
  }
842
+ @media (max-width: 768px) {
843
+ body {
844
+ margin: 10px;
845
+ }
846
+ form {
847
+ padding: 10px;
848
+ }
849
+ input, textarea {
850
+ font-size: 0.9em;
851
+ }
852
+ button {
853
+ padding: 6px 10px;
854
+ font-size: 0.9em;
855
+ }
856
+ .product-item {
857
+ padding: 8px;
858
+ }
859
+ }
860
  </style>
861
  </head>
862
  <body>