<div class="np-homepage-ongoing np-max-width">
  <div class="np-homepage-ongoing-text">
    <div class="np-homepage-headline">
      Ongoing Training
    </div>
    <div class="ongoing-carousel-controls np-hidden-mobile">
      <div class="prev-arrow carousel-control"><i class="far fa-chevron-left"></i></div>
      <div class="next-arrow carousel-control"><i class="far fa-chevron-right"></i></div>
    </div>
  </div>
  {% if items.size > 0 %}
    {% assign ongoing_courses_count = 0 %}
    <div class="ongoing-courses-wrapper">
      <div class="ongoing-courses-slider">
        {% for course in items %}
          {% if course.properties.is_article_course  == false %}
            {% if course.progress > 0 and course.progress < 100 %}
              {% assign ongoing_courses_count = ongoing_courses_count | plus: 1 %}
              <div class="ongoing-course-slide">
                {% include "cards_course_ongoing" with course %}
              </div>
            {% endif %}
          {% endif %}
        {% endfor %}
      </div>
    </div>

    {% if ongoing_courses_count > 0 %}
      <div class="ongoing-see-more-wrapper">
        <a href="/app/dashboard">See more</a>
      </div>
    {% else %}
      <script>console.log("{{ongoing_courses_count}}")</script>
      <div class="np-homepage-featured-empty">
        <div class="np-zero-state-text">
          Yikes! You don't have any ongoing training at this moment.
        </div>
        <img
          class="np-zero-state-courses"
          alt="Yikes! You don't have any ongoing training at this moment."
        />
        <div class="zero-state-cta" style="margin-top:32px;">
          <a href="/app/catalog" class="np-button">Explore Catalog</a>
        </div>
      </div>
    {% endif %}
  {% else %}
    <div class="np-homepage-featured-empty">
      <div class="np-zero-state-text">
        Yikes! You don't have any ongoing training at this moment.
      </div>
      <img
        class="np-zero-state-courses"
        alt="Yikes! You don't have any ongoing training at this moment."
      />
      <div class="zero-state-cta" style="margin-top:32px;">
        <a href="/app/catalog" class="np-button">Explore Catalog</a>
      </div>
    </div>
  {% endif %}
</div>


<script>

window.addEventListener("DOMContentLoaded", (event) => {

  var ongoingSlider = tns({
    container: '.ongoing-courses-slider',
    items: 1,
    slideBy: 'page',
    autoplay: false,
    gutter: 8,
    controls:false,
    navPosition:"bottom",
    loop: false,
    mouseDrag: true,
    speed: 500,
    controlsContainer: document.querySelector('.ongoing-carousel-controls'),
    responsive: {
      600: {
        items: 2,
      },
      768: {
        items:3,
        gutter: 16,
        controls:true
      }
    }
  });
});

 
</script>


<style>

  .ongoing-courses-wrapper {
    margin: 0 -8px;
  }

  .np-homepage-ongoing {
    padding: 0 16px;
    margin-bottom:56px;
  }

  .np-homepage-ongoing-text {
    padding: 0 0 32px;
    text-align:left;
    display:flex;
  }

  .np-homepage-ongoing-text .np-homepage-headline {
    font-weight: 400;
    font-size: 24px;
    line-height: 32px;
    color:#333;
    align-self: flex-start;
  }

  .ongoing-carousel-controls {
    align-self:flex-end;
    display:flex;
  }

  .ongoing-carousel-controls .carousel-control {
    margin: 0 8px;
    background-color: #ebe8f3;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #3c228a;
    cursor: pointer;
    transition:opacity 0.2s;
  }

  .ongoing-carousel-controls .carousel-control[aria-disabled='true'] {
    opacity: 0.3;
    cursor:default;
  }

  .ongoing-carousel-controls .carousel-control.next-arrow {
    margin-right:0;
  }

  .ongoing-courses-slider {
    display:flex;
  }

  .ongoing-course-slide {
    margin-bottom: 12px;
  }

  .ongoing-course-slide .np-card {
    margin:0 auto;
    padding: 0;
    height:100%;
  }

  .ongoing-course-slide .np-card-container {
    height: 100%;
    margin: 0 8px;
  }

  .ongoing-see-more-wrapper {
    display:flex;
    justify-content:flex-end;
    margin-top:8px;
  }

  .ongoing-see-more-wrapper a {
    color:#3C228A;
  }

  @media (min-width:768px){
    .np-homepage-ongoing-text {
      flex-direction:row;
      justify-content:space-between;
    }

    .np-homepage-ongoing-text .np-homepage-headline {
      font-size: 32px;
      line-height: 40px;
    }

    .ongoing-see-more-wrapper {
      margin-top:12px;
    }
  }
</style>