Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -141,14 +141,21 @@ def catalog():
|
|
| 141 |
.product-image {
|
| 142 |
width: 200px;
|
| 143 |
height: 200px;
|
| 144 |
-
|
| 145 |
border-radius: 8px;
|
| 146 |
margin: 0 auto 15px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 147 |
}
|
| 148 |
.product-image img {
|
| 149 |
-
width: 200px;
|
| 150 |
-
height: 200px;
|
| 151 |
-
|
|
|
|
|
|
|
| 152 |
transition: transform 0.3s ease;
|
| 153 |
}
|
| 154 |
.product-image img:hover {
|
|
@@ -159,18 +166,21 @@ def catalog():
|
|
| 159 |
color: #2c3e50;
|
| 160 |
margin-bottom: 10px;
|
| 161 |
font-weight: 600;
|
|
|
|
| 162 |
}
|
| 163 |
.product-price {
|
| 164 |
font-size: 1.3em;
|
| 165 |
color: #e74c3c;
|
| 166 |
font-weight: 700;
|
| 167 |
margin: 10px 0;
|
|
|
|
| 168 |
}
|
| 169 |
.product-description {
|
| 170 |
color: #7f8c8d;
|
| 171 |
font-size: 0.9em;
|
| 172 |
flex-grow: 1;
|
| 173 |
margin-bottom: 15px;
|
|
|
|
| 174 |
}
|
| 175 |
.product-button {
|
| 176 |
background-color: #3498db;
|
|
@@ -182,7 +192,8 @@ def catalog():
|
|
| 182 |
transition: background-color 0.3s ease;
|
| 183 |
text-align: center;
|
| 184 |
text-decoration: none;
|
| 185 |
-
display:
|
|
|
|
| 186 |
font-weight: 500;
|
| 187 |
}
|
| 188 |
.product-button:hover {
|
|
@@ -190,7 +201,6 @@ def catalog():
|
|
| 190 |
}
|
| 191 |
.add-to-cart {
|
| 192 |
background-color: #27ae60;
|
| 193 |
-
margin-top: 10px;
|
| 194 |
}
|
| 195 |
.add-to-cart:hover {
|
| 196 |
background-color: #219653;
|
|
@@ -260,7 +270,8 @@ def catalog():
|
|
| 260 |
.cart-item img {
|
| 261 |
width: 50px;
|
| 262 |
height: 50px;
|
| 263 |
-
object-fit:
|
|
|
|
| 264 |
margin-right: 10px;
|
| 265 |
}
|
| 266 |
.quantity-input {
|
|
@@ -277,17 +288,67 @@ def catalog():
|
|
| 277 |
background-color: #c0392b;
|
| 278 |
}
|
| 279 |
@media (max-width: 768px) {
|
|
|
|
|
|
|
|
|
|
| 280 |
.products-grid {
|
| 281 |
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
|
| 282 |
-
gap:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 283 |
}
|
| 284 |
.product-image {
|
| 285 |
width: 150px;
|
| 286 |
height: 150px;
|
| 287 |
}
|
| 288 |
.product-image img {
|
| 289 |
-
width: 150px;
|
| 290 |
-
height: 150px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 291 |
}
|
| 292 |
}
|
| 293 |
</style>
|
|
@@ -394,7 +455,7 @@ def catalog():
|
|
| 394 |
function openQuantityModal(index) {
|
| 395 |
selectedProductIndex = index;
|
| 396 |
document.getElementById('quantityModal').style.display = 'block';
|
| 397 |
-
document.getElementById('quantityInput').value = 1;
|
| 398 |
}
|
| 399 |
|
| 400 |
function confirmAddToCart() {
|
|
@@ -404,7 +465,7 @@ def catalog():
|
|
| 404 |
}
|
| 405 |
|
| 406 |
const quantityInput = document.getElementById('quantityInput').value;
|
| 407 |
-
const quantity = parseInt(quantityInput) || 0;
|
| 408 |
|
| 409 |
if (quantity <= 0) {
|
| 410 |
alert("Пожалуйста, укажите количество больше 0");
|
|
@@ -482,7 +543,6 @@ def catalog():
|
|
| 482 |
}
|
| 483 |
}
|
| 484 |
|
| 485 |
-
// Инициализация при загрузке страницы
|
| 486 |
updateCartButton();
|
| 487 |
</script>
|
| 488 |
</body>
|
|
@@ -504,10 +564,10 @@ def product_detail(index):
|
|
| 504 |
<div class="swiper-wrapper">
|
| 505 |
{% if product.get('photos') %}
|
| 506 |
{% for photo in product['photos'] %}
|
| 507 |
-
<div class="swiper-slide">
|
| 508 |
<img src="https://huggingface.co/datasets/{{ repo_id }}/resolve/main/photos/{{ photo }}"
|
| 509 |
alt="{{ product['name'] }}"
|
| 510 |
-
style="width: 200px; height: 200px; object-fit:
|
| 511 |
</div>
|
| 512 |
{% endfor %}
|
| 513 |
{% else %}
|
|
@@ -720,9 +780,11 @@ def admin():
|
|
| 720 |
<p><strong>Цена:</strong> {{ product['price'] }} руб.</p>
|
| 721 |
<p><strong>Описание:</strong> {{ product['description'] }}</p>
|
| 722 |
{% if product.get('photos') and product['photos']|length > 0 %}
|
| 723 |
-
<
|
| 724 |
-
|
| 725 |
-
|
|
|
|
|
|
|
| 726 |
{% endif %}
|
| 727 |
<details>
|
| 728 |
<summary>Редактировать</summary>
|
|
|
|
| 141 |
.product-image {
|
| 142 |
width: 200px;
|
| 143 |
height: 200px;
|
| 144 |
+
background-color: #fff;
|
| 145 |
border-radius: 8px;
|
| 146 |
margin: 0 auto 15px;
|
| 147 |
+
overflow: hidden;
|
| 148 |
+
position: relative;
|
| 149 |
+
display: flex;
|
| 150 |
+
justify-content: center;
|
| 151 |
+
align-items: center;
|
| 152 |
}
|
| 153 |
.product-image img {
|
| 154 |
+
max-width: 200px;
|
| 155 |
+
max-height: 200px;
|
| 156 |
+
width: auto;
|
| 157 |
+
height: auto;
|
| 158 |
+
object-fit: contain;
|
| 159 |
transition: transform 0.3s ease;
|
| 160 |
}
|
| 161 |
.product-image img:hover {
|
|
|
|
| 166 |
color: #2c3e50;
|
| 167 |
margin-bottom: 10px;
|
| 168 |
font-weight: 600;
|
| 169 |
+
text-align: center;
|
| 170 |
}
|
| 171 |
.product-price {
|
| 172 |
font-size: 1.3em;
|
| 173 |
color: #e74c3c;
|
| 174 |
font-weight: 700;
|
| 175 |
margin: 10px 0;
|
| 176 |
+
text-align: center;
|
| 177 |
}
|
| 178 |
.product-description {
|
| 179 |
color: #7f8c8d;
|
| 180 |
font-size: 0.9em;
|
| 181 |
flex-grow: 1;
|
| 182 |
margin-bottom: 15px;
|
| 183 |
+
text-align: center;
|
| 184 |
}
|
| 185 |
.product-button {
|
| 186 |
background-color: #3498db;
|
|
|
|
| 192 |
transition: background-color 0.3s ease;
|
| 193 |
text-align: center;
|
| 194 |
text-decoration: none;
|
| 195 |
+
display: block;
|
| 196 |
+
margin: 5px auto;
|
| 197 |
font-weight: 500;
|
| 198 |
}
|
| 199 |
.product-button:hover {
|
|
|
|
| 201 |
}
|
| 202 |
.add-to-cart {
|
| 203 |
background-color: #27ae60;
|
|
|
|
| 204 |
}
|
| 205 |
.add-to-cart:hover {
|
| 206 |
background-color: #219653;
|
|
|
|
| 270 |
.cart-item img {
|
| 271 |
width: 50px;
|
| 272 |
height: 50px;
|
| 273 |
+
object-fit: contain;
|
| 274 |
+
background-color: #fff;
|
| 275 |
margin-right: 10px;
|
| 276 |
}
|
| 277 |
.quantity-input {
|
|
|
|
| 288 |
background-color: #c0392b;
|
| 289 |
}
|
| 290 |
@media (max-width: 768px) {
|
| 291 |
+
body {
|
| 292 |
+
padding: 10px;
|
| 293 |
+
}
|
| 294 |
.products-grid {
|
| 295 |
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
|
| 296 |
+
gap: 15px;
|
| 297 |
+
padding: 0 10px;
|
| 298 |
+
}
|
| 299 |
+
.product {
|
| 300 |
+
padding: 15px;
|
| 301 |
}
|
| 302 |
.product-image {
|
| 303 |
width: 150px;
|
| 304 |
height: 150px;
|
| 305 |
}
|
| 306 |
.product-image img {
|
| 307 |
+
max-width: 150px;
|
| 308 |
+
max-height: 150px;
|
| 309 |
+
}
|
| 310 |
+
.product h2 {
|
| 311 |
+
font-size: 1em;
|
| 312 |
+
}
|
| 313 |
+
.product-price {
|
| 314 |
+
font-size: 1.1em;
|
| 315 |
+
}
|
| 316 |
+
.product-description {
|
| 317 |
+
font-size: 0.85em;
|
| 318 |
+
}
|
| 319 |
+
.product-button {
|
| 320 |
+
padding: 8px 15px;
|
| 321 |
+
font-size: 0.9em;
|
| 322 |
+
}
|
| 323 |
+
#cart-button {
|
| 324 |
+
width: 50px;
|
| 325 |
+
height: 50px;
|
| 326 |
+
font-size: 18px;
|
| 327 |
+
bottom: 15px;
|
| 328 |
+
right: 15px;
|
| 329 |
+
}
|
| 330 |
+
}
|
| 331 |
+
@media (max-width: 480px) {
|
| 332 |
+
.products-grid {
|
| 333 |
+
grid-template-columns: 1fr;
|
| 334 |
+
gap: 10px;
|
| 335 |
+
}
|
| 336 |
+
.product {
|
| 337 |
+
padding: 10px;
|
| 338 |
+
margin: 0 auto;
|
| 339 |
+
max-width: 300px;
|
| 340 |
+
}
|
| 341 |
+
.product-image {
|
| 342 |
+
width: 120px;
|
| 343 |
+
height: 120px;
|
| 344 |
+
}
|
| 345 |
+
.product-image img {
|
| 346 |
+
max-width: 120px;
|
| 347 |
+
max-height: 120px;
|
| 348 |
+
}
|
| 349 |
+
h1 {
|
| 350 |
+
font-size: 1.8em;
|
| 351 |
+
margin-bottom: 20px;
|
| 352 |
}
|
| 353 |
}
|
| 354 |
</style>
|
|
|
|
| 455 |
function openQuantityModal(index) {
|
| 456 |
selectedProductIndex = index;
|
| 457 |
document.getElementById('quantityModal').style.display = 'block';
|
| 458 |
+
document.getElementById('quantityInput').value = 1;
|
| 459 |
}
|
| 460 |
|
| 461 |
function confirmAddToCart() {
|
|
|
|
| 465 |
}
|
| 466 |
|
| 467 |
const quantityInput = document.getElementById('quantityInput').value;
|
| 468 |
+
const quantity = parseInt(quantityInput) || 0;
|
| 469 |
|
| 470 |
if (quantity <= 0) {
|
| 471 |
alert("Пожалуйста, укажите количество больше 0");
|
|
|
|
| 543 |
}
|
| 544 |
}
|
| 545 |
|
|
|
|
| 546 |
updateCartButton();
|
| 547 |
</script>
|
| 548 |
</body>
|
|
|
|
| 564 |
<div class="swiper-wrapper">
|
| 565 |
{% if product.get('photos') %}
|
| 566 |
{% for photo in product['photos'] %}
|
| 567 |
+
<div class="swiper-slide" style="background-color: #fff; display: flex; justify-content: center; align-items: center;">
|
| 568 |
<img src="https://huggingface.co/datasets/{{ repo_id }}/resolve/main/photos/{{ photo }}"
|
| 569 |
alt="{{ product['name'] }}"
|
| 570 |
+
style="max-width: 200px; max-height: 200px; width: auto; height: auto; object-fit: contain;">
|
| 571 |
</div>
|
| 572 |
{% endfor %}
|
| 573 |
{% else %}
|
|
|
|
| 780 |
<p><strong>Цена:</strong> {{ product['price'] }} руб.</p>
|
| 781 |
<p><strong>Описание:</strong> {{ product['description'] }}</p>
|
| 782 |
{% if product.get('photos') and product['photos']|length > 0 %}
|
| 783 |
+
<div style="background-color: #fff; width: 100px; height: 100px; display: flex; justify-content: center; align-items: center;">
|
| 784 |
+
<img src="https://huggingface.co/datasets/{{ repo_id }}/resolve/main/photos/{{ product['photos'][0] }}"
|
| 785 |
+
alt="{{ product['name'] }}"
|
| 786 |
+
style="max-width: 100px; max-height: 100px; width: auto; height: auto; object-fit: contain;">
|
| 787 |
+
</div>
|
| 788 |
{% endif %}
|
| 789 |
<details>
|
| 790 |
<summary>Редактировать</summary>
|