]> xenbits.xensource.com Git - www-xenproject-org.git/commitdiff
carousel
authorArnaud Guéras <arnaudgs@gmail.com>
Sun, 24 Nov 2024 12:36:37 +0000 (13:36 +0100)
committerArnaud Guéras <arnaudgs@gmail.com>
Sun, 24 Nov 2024 12:36:37 +0000 (13:36 +0100)
Signed-off-by: Arnaud Guéras <arnaudgs@gmail.com>
content/_index.md
content/test.md
themes/xen-project/assets/css/components/carousel.scss
themes/xen-project/assets/css/components/news-container.scss [deleted file]
themes/xen-project/assets/css/main.scss
themes/xen-project/assets/js/carousel.js
themes/xen-project/layouts/partials/latest-news.html

index 5dbcfd5ebbcd03628763e13e6d438845b52eb345..cf63e83174809d2a146f6380ec3dd84b26cf5b9c 100644 (file)
@@ -71,7 +71,7 @@ The Xen Project focuses on revolutionizing virtualization by providing a versati
 
 
 {{<section container="full">}}
-{{<carousel class="mg-t-lg carousel-container-width">}}
+{{<carousel class="mg-t-lg">}}
 {{<getpages "projects" "hidden">}}
 {{</carousel>}}
 
index b4ff9d7c5b7f3aeeb984a11afb6d9a786cfcb9e3..6e2400848b7987920588cd3512fce089e270af9e 100644 (file)
@@ -4,7 +4,12 @@ draft: true
 hidden: true
 ---
 {{<section container="full">}}
-{{<carousel class="mg-t-lg carousel-container-width">}}
+{{<carousel class="mg-t-lg ">}}
 {{<getpages "projects" "hidden">}}
 {{</carousel>}}
+{{</section>}}
+
+
+{{<section container="full">}}
+{{<latest-news>}}
 {{</section>}}
\ No newline at end of file
index fbe61e448e168cd685951d43098088b04eb807b7..e67523e3cefa6cbfce3b47508ee35b3a68f48ca8 100644 (file)
   }
 
   .carousel-content-inner {
-    --opacity: 0.2;
+    --opacity: 0.1;
     --mask-image: linear-gradient(
       to right,
       transparent,
-      rgba(0, 0, 0, var(--opacity)) calc(var(--mask-size) - 5%),
+      rgba(0, 0, 0, var(--opacity)) calc(var(--mask-size) - 2%),
       black calc(var(--mask-size) + 5%),
       black calc(100% - var(--mask-size) - 5%),
-      rgba(0, 0, 0, var(--opacity)) calc(100% - var(--mask-size) + 5%),
+      rgba(0, 0, 0, var(--opacity)) calc(100% - var(--mask-size) + 2%),
       transparent
     );
     mask-image: var(--mask-image);
diff --git a/themes/xen-project/assets/css/components/news-container.scss b/themes/xen-project/assets/css/components/news-container.scss
deleted file mode 100644 (file)
index de4d5fa..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-.news-container {
-  --cols: 1;
-  --gap: 24px;
-  display: flex;
-  flex-direction: row;
-  flex-wrap: wrap;
-  justify-content: space-between;
-  align-items: stretch;
-  gap: var(--gap);
-
-  --col-width: calc((100% / var(--cols)) - var(--gap));
-  > * {
-    flex: 1 1 var(--col-width);
-  }
-
-  @include tablet {
-    --cols: 2;
-  }
-
-  @include desktop {
-    --cols: 3;
-  }
-}
index 244feb8dd04c927e5a199e1ba61d3a3eb8540f37..19aca87fe2f89f80459e63f5eea8831f9da3c772 100644 (file)
@@ -31,7 +31,6 @@
 @import "./components/box-members.scss";
 @import "./components/carousel.scss";
 @import "./components/news-card.scss";
-@import "./components/news-container.scss";
 @import "./components/images-in-circle.scss";
 @import "./components/latest-news.scss";
 @import "./content-markdown.scss";
index ddef7772f49ea7e0eeb6368967beb41a80824bbf..08f8553a05ab7a7d5a7ecaf5dfbf3f661a1ffcf1 100644 (file)
@@ -4,11 +4,11 @@
   const itemsContainerSelector = ".carousel";
   const itemSelector = ".carousel-item";
 
-  const { debounce } = window.XenSiteUtils;
+  const { debounce, waitForElements } = window.XenSiteUtils;
 
   const carousel = async (element) => {
     const itemsContainer = element.querySelector(itemsContainerSelector);
-    const items = element.querySelectorAll(itemSelector);
+    const items = await waitForElements(element, itemSelector);
 
     const firstItem = items[0].cloneNode(true);
     firstItem.innerHTML = "";
         behavior: "smooth",
       });
     });
-  };
-
-  [...document.querySelectorAll(selector)].forEach((elm) => {
-    carousel(elm);
-  });
 
-  function updateCarouselTabIndexes() {
-    const items = document.querySelectorAll(".carousel-item");
+    function updateCarouselTabIndexes() {
+      const items = element.querySelectorAll(".carousel-item");
 
-    items.forEach((item) => {
-      const rect = item.getBoundingClientRect();
-      const isVisible = rect.left >= 0 && rect.right <= window.innerWidth;
+      items.forEach((item) => {
+        const rect = item.getBoundingClientRect();
+        const isVisible = rect.left >= 0 && rect.right <= window.innerWidth;
 
-      item.classList.toggle("carousel-item--hidden", !isVisible);
-      const links = item.querySelectorAll("a");
+        item.classList.toggle("carousel-item--hidden", !isVisible);
+        const links = item.querySelectorAll("a");
 
-      links.forEach((link) => {
-        if (link.getAttribute("aria-hidden") !== "true") {
-          if (isVisible) {
-            link.removeAttribute("tabindex");
-          } else {
-            link.setAttribute("tabindex", "-1");
+        links.forEach((link) => {
+          if (link.getAttribute("aria-hidden") !== "true") {
+            if (isVisible) {
+              link.removeAttribute("tabindex");
+            } else {
+              link.setAttribute("tabindex", "-1");
+            }
           }
-        }
+        });
       });
-    });
-  }
+    }
 
-  document.querySelector(".carousel").addEventListener("scroll", updateCarouselTabIndexes);
-  updateCarouselTabIndexes();
+    element.querySelector(".carousel").addEventListener("scroll", updateCarouselTabIndexes);
+    updateCarouselTabIndexes();
+  };
+
+  [...document.querySelectorAll(selector)].forEach((elm) => {
+    carousel(elm);
+  });
 })();
index 3a54f0a678f61dbda20497019e71f80267de3dd7..3fdda30dfb142587c6c93de41344c14f9925ea1a 100644 (file)
@@ -33,7 +33,9 @@
 
   <div class="carousel-container carousel-container-width">
     <div class="carousel-content">
-      <div class="carousel latest-news_container news-container"></div>
+      <div class="carousel-content-inner">
+        <div class="carousel latest-news_container"></div>
+      </div>
       <div class="carousel-buttons">
         <button class="carousel-button prev">
           <i class="fas fa-arrow-left"></i>