Kgshop commited on
Commit
e177e65
·
verified ·
1 Parent(s): 80ff87d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -48
app.py CHANGED
@@ -18,7 +18,7 @@ HF_TOKEN_WRITE = os.getenv("HF_TOKEN")
18
  HF_TOKEN_READ = os.getenv("HF_TOKEN_READ")
19
 
20
  # Ссылка на логотип
21
- LOGO_URL = "https://huggingface.co/spaces/Udeda/tkani/resolve/main/Picsart_25-03-20_11-33-51-169.jpg" # Замените на вашу ссылку
22
 
23
  # Настройка логирования
24
  logging.basicConfig(level=logging.DEBUG)
@@ -332,7 +332,7 @@ def catalog():
332
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
333
  z-index: 1000;
334
  }
335
- .modal {
336
  display: none;
337
  position: fixed;
338
  z-index: 1001;
@@ -481,13 +481,13 @@ def catalog():
481
  <div class="products-grid" id="products-grid">
482
  {% for product in products %}
483
  <div class="product" onclick="openModal({{ loop.index0 }})"
484
- data-name="{{ product['name']|lower }}"
485
  data-description="{{ product['description']|lower }}"
486
  data-category="{{ product.get('category', 'Без категории') }}">
487
  {% if product.get('photos') and product['photos']|length > 0 %}
488
  <div class="product-image">
489
- <img src="https://huggingface.co/datasets/{{ repo_id }}/resolve/main/photos/{{ product['photos'][0] }}"
490
- alt="{{ product['name'] }}"
491
  loading="lazy">
492
  </div>
493
  {% endif %}
@@ -777,50 +777,40 @@ def product_detail(index):
777
  .image-grid img:hover {
778
  transform: scale(1.1);
779
  }
780
- .fullscreen-image-modal {
781
  display: none;
782
  position: fixed;
783
  top: 0;
784
  left: 0;
785
  width: 100%;
786
  height: 100%;
787
- background-color: rgba(0, 0, 0, 0.9);
788
  z-index: 1003;
789
  justify-content: center;
790
  align-items: center;
791
- opacity: 0;
792
- transition: opacity 0.3s ease;
793
- }
794
- .fullscreen-image-modal.show {
795
- opacity: 1;
796
  }
797
- .fullscreen-image-container {
 
 
798
  position: relative;
799
- max-width: 100%;
800
- max-height: 100%;
801
  }
802
- .fullscreen-image {
803
- max-width: 100%;
804
- max-height: 100vh;
805
  display: block;
 
 
806
  margin: auto;
807
- object-fit: contain;
808
- animation: zoomIn 0.3s ease;
809
- }
810
- @keyframes zoomIn {
811
- from { transform: scale(0.8); opacity: 0; }
812
- to { transform: scale(1); opacity: 1; }
813
  }
814
- .fullscreen-close {
815
  position: absolute;
816
- top: 20px;
817
- right: 20px;
818
- font-size: 2.5rem;
819
  color: white;
820
  cursor: pointer;
821
- transition: color 0.3s ease;
822
  }
823
- .fullscreen-close:hover {
824
  color: #ddd;
825
  }
826
  .product-info p {
@@ -837,17 +827,17 @@ def product_detail(index):
837
  {% for photo in product['photos'] %}
838
  <img src="https://huggingface.co/datasets/{{ repo_id }}/resolve/main/photos/{{ photo }}"
839
  alt="{{ product['name'] }}"
840
- onclick="openFullscreenImage('https://huggingface.co/datasets/{{ repo_id }}/resolve/main/photos/{{ photo }}')">
841
  {% endfor %}
842
  {% else %}
843
  <p>Нет фотографий</p>
844
  {% endif %}
845
  </div>
846
 
847
- <div id="fullscreenImageModal" class="fullscreen-image-modal">
848
- <div class="fullscreen-image-container">
849
- <span class="fullscreen-close" onclick="closeFullscreenImage()">×</span>
850
- <img id="fullscreenImage" class="fullscreen-image" src="" alt="Полноэкранное изображение">
851
  </div>
852
  </div>
853
 
@@ -861,31 +851,26 @@ def product_detail(index):
861
  </div>
862
 
863
  <script>
864
- function openFullscreenImage(src) {
865
- const modal = document.getElementById('fullscreenImageModal');
866
- document.getElementById('fullscreenImage').src = src;
867
  modal.style.display = 'flex';
868
- setTimeout(() => modal.classList.add('show'), 10); // Небольшая задержка для анимации
869
  }
870
 
871
- function closeFullscreenImage() {
872
- const modal = document.getElementById('fullscreenImageModal');
873
- modal.classList.remove('show');
874
- setTimeout(() => {
875
- modal.style.display = 'none';
876
- }, 300); // Соответствует времени анимации
877
  }
878
 
879
  window.onclick = function(event) {
880
- const modal = document.getElementById('fullscreenImageModal');
881
  if (event.target === modal) {
882
- closeFullscreenImage();
883
  }
884
  }
885
 
886
  document.addEventListener('keydown', function(event) {
887
  if (event.key === 'Escape') {
888
- closeFullscreenImage();
889
  }
890
  });
891
  </script>
 
18
  HF_TOKEN_READ = os.getenv("HF_TOKEN_READ")
19
 
20
  # Ссылка на логотип
21
+ LOGO_URL = "https://huggingface.co/spaces/Udeda/tkani/resolve/main/IMG_20250319_193200_052.jpg" # Замените на вашу ссылку
22
 
23
  # Настройка логирования
24
  logging.basicConfig(level=logging.DEBUG)
 
332
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
333
  z-index: 1000;
334
  }
335
+ .modal {
336
  display: none;
337
  position: fixed;
338
  z-index: 1001;
 
481
  <div class="products-grid" id="products-grid">
482
  {% for product in products %}
483
  <div class="product" onclick="openModal({{ loop.index0 }})"
484
+ data-name="{{ product['name']|lower }}"
485
  data-description="{{ product['description']|lower }}"
486
  data-category="{{ product.get('category', 'Без категории') }}">
487
  {% if product.get('photos') and product['photos']|length > 0 %}
488
  <div class="product-image">
489
+ <img src="https://huggingface.co/datasets/{{ repo_id }}/resolve/main/photos/{{ product['photos'][0] }}"
490
+ alt="{{ product['name'] }}"
491
  loading="lazy">
492
  </div>
493
  {% endif %}
 
777
  .image-grid img:hover {
778
  transform: scale(1.1);
779
  }
780
+ .photo-modal {
781
  display: none;
782
  position: fixed;
783
  top: 0;
784
  left: 0;
785
  width: 100%;
786
  height: 100%;
787
+ background-color: rgba(0, 0, 0, 0.7);
788
  z-index: 1003;
789
  justify-content: center;
790
  align-items: center;
 
 
 
 
 
791
  }
792
+ .photo-modal-content {
793
+ max-width: 90%;
794
+ max-height: 90%;
795
  position: relative;
 
 
796
  }
797
+ .photo-modal-content img {
 
 
798
  display: block;
799
+ max-width: 100%;
800
+ max-height: 100%;
801
  margin: auto;
802
+ border-radius: 10px;
 
 
 
 
 
803
  }
804
+ .photo-close {
805
  position: absolute;
806
+ top: 15px;
807
+ right: 15px;
808
+ font-size: 2rem;
809
  color: white;
810
  cursor: pointer;
811
+ z-index: 1004;
812
  }
813
+ .photo-close:hover {
814
  color: #ddd;
815
  }
816
  .product-info p {
 
827
  {% for photo in product['photos'] %}
828
  <img src="https://huggingface.co/datasets/{{ repo_id }}/resolve/main/photos/{{ photo }}"
829
  alt="{{ product['name'] }}"
830
+ onclick="openPhotoModal('https://huggingface.co/datasets/{{ repo_id }}/resolve/main/photos/{{ photo }}')">
831
  {% endfor %}
832
  {% else %}
833
  <p>Нет фотографий</p>
834
  {% endif %}
835
  </div>
836
 
837
+ <div id="photoModal" class="photo-modal">
838
+ <div class="photo-modal-content">
839
+ <span class="photo-close" onclick="closePhotoModal()">×</span>
840
+ <img id="photoImage" src="" alt="Фото товара">
841
  </div>
842
  </div>
843
 
 
851
  </div>
852
 
853
  <script>
854
+ function openPhotoModal(src) {
855
+ const modal = document.getElementById('photoModal');
856
+ document.getElementById('photoImage').src = src;
857
  modal.style.display = 'flex';
 
858
  }
859
 
860
+ function closePhotoModal() {
861
+ document.getElementById('photoModal').style.display = 'none';
 
 
 
 
862
  }
863
 
864
  window.onclick = function(event) {
865
+ const modal = document.getElementById('photoModal');
866
  if (event.target === modal) {
867
+ closePhotoModal();
868
  }
869
  }
870
 
871
  document.addEventListener('keydown', function(event) {
872
  if (event.key === 'Escape') {
873
+ closePhotoModal();
874
  }
875
  });
876
  </script>