<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>FootBall Video Highlight</title>
    <link rel="stylesheet" href="style.css" />
    <!-- font awesome -->
    <script src="./js/all.min.js"></script>
  </head>
  <body>
    <!--  -->
    <div class="section-center">
      <header class="title">
        <h1>
          <span>F</span><i class="fas fa-spinner fa-pulse"></i>tBall <br />
          Highlight Videos
        </h1>
        <p>Don't miss out on the thrills, watch it!</p>
      </header>
      <div class="btn-container">
        <div class="filter-btns">
          <!-- single-btn -->
          <button class="btn" type="button" data-id="England">England</button>
          <!-- single-btn -->
          <button class="btn" type="button" data-id="Spain">Spain</button>
          <!-- single-btn -->
          <button class="btn" type="button" data-id="Italy">Italy</button>
          <!-- single-btn -->
          <button class="btn" type="button" data-id="Germany">Germany</button>
          <!-- single-btn -->
          <button class="btn" type="button" data-id="France">France</button>
          <!-- single-btn -->
          <button class="btn" type="button" data-id="Champions League">
            UCL
          </button>
          <!-- single-btn -->
          <button class="btn" type="button" data-id="Europa League">
            Europa League
          </button>
          <!-- single-btn -->
          <button class="btn" type="button" data-id="Brasil">Brasil</button>
          <!-- single-btn -->
          <button class="btn" type="button" data-id="portugal">portugal</button>
          <!-- single-btn -->
          <button class="btn" type="button" data-id="Mexico">Mexico</button>
          <!-- single-btn -->
          <button class="btn" type="button" data-id="Poland">Poland</button>
          <!-- single-btn -->
          <button class="btn" type="button" data-id="Greece">Greece</button>
          <!-- single-btn -->
          <button class="btn" type="button" data-id="Armenia">Armenia</button>
          <!-- single-btn -->
          <button class="btn" type="button" data-id="Azerbaijan">
            Azerbaijan
          </button>
          <!-- single-btn -->
          <button class="btn" type="button" data-id="Slovenia">Slovenia</button>
          <!-- single-btn -->
          <button class="btn" type="button" data-id="Japan">Japan</button>
          <button class="btn" type="button" data-id="Netherlands">
            Netherlands
          </button>
        </div>
      </div>
      <!-- video content section -->
      <div class="highlight">
        <div class="content">
          <!--  -->
        </div>
      </div>
    </div>
    <!-- script -->
    <script src="script.js"></script>
  </body>
</html>
*,
*::after,
*::before {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
html {
  box-sizing: inherit;
}
body {
  background-color: #000;
  font-family: sans-serif;
  line-height: 1.5;
}
.title {
  color: #fff;
  position: relative;
  letter-spacing: 1px;
}
.title h1 {
  font-size: 35px;
}
.title p {
  position: relative;
  padding-bottom: 10px;
}
/* .title p::after {
  content: url(./image/bg-dots.svg);
  display: block;
  position: absolute;
  top: 30px;
  left: 0;
  width: 100%;
} */
.section-center {
  width: 90%;
  max-width: 800px;
  margin: 3em auto;
  /* outline: 1px solid red; */
  text-align: center;
}
.btn-container {
  margin: 3em 0;
}
.filter-btns {
  text-align: center;
}
button {
  display: inline-block;
  padding: 0.8em 1.2em;
  background: none;
  border: 0;
  color: #fff;
  font-size: 15px;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin: 0.5em 0.2em;
  border: 1px solid#fff;
  border-radius: 2px;
  cursor: pointer;
  box-shadow: 0 1px 9px rgba(255, 255, 255, 0.5);
  transition: transform 0.2s ease-in-out;
}
button:active {
  transform: scale(0.95);
}
.card {
  color: #fff;
  margin-bottom: 2em;
  background-color: #121212;
  width: 100%;
  line-height: normal;
  padding: 2em 0;
  letter-spacing: 0.9px;
  border-radius: 8px;
  box-shadow: 0 7px 10px rgba(255, 255, 255, 0.15);
  position: relative;
}
.card h1 {
  font-size: 25px;
  margin-bottom: 0.5em;
}
.card h2 {
  font-size: 20px;
  margin-bottom: 0.7em;
}
.details p {
  font-size: 18px;
}
.info {
  width: 90%;
  margin: 0 auto;
  text-align: left;
}
.details p {
  margin-bottom: 0.7em;
}
.league-name {
  color: #ededee;
}

@media screen and (min-width: 550px) {
  .details {
    display: flex;
    justify-content: space-between;
  }
}
const url = 'https://www.scorebat.com/video-api/v1/'
const content = document.querySelector('.content')
const filterBtns = document.querySelectorAll('.btn')

const fetchData = async () => {
  try {
    const response = await fetch(url)
    const data = await response.json();
    
    // This will hold the results. Remember filter doesn't
    // modify the original array.
    let data_results = [];
    
    if (response.status === 200) {
      filterBtns.forEach((btn) => {
        btn.addEventListener('click', (e) => {
          // Make sure to uppercase since that is what is in names
          let id = e.target.dataset.id.toUpperCase()
          data_results = data.filter((league) => {
            let res = league.competition
            
            // We want to compare the name
            if (res.name.includes(id)) {
              return res
            }
          })
          
          // For each click, feed the new results to output
          output = filterResults(data_results);
          content.innerHTML = output;
        })
      })
    }
  } catch (error) {
    console.log(error)
  }
}

fetchData()

{
  /* <h3>${result.videos[0].embed}</h3> */
}

// Take results, map them to our cards and return them.
function filterResults(data_results) {
  let output = data_results.map((result) => {
        return `<article class="card">
        <div class="info">
        <h1 class="league-name"> ${result.competition.name}</h1>
        <h2><i class="fas fa-spinner fa-pulse"></i> Match: ${result.title}</h2>
        <div class="details">
        <p>Date: ${result.date.substring(0, 10)}</p>
        <p>Kickoff: ${result.date.substring(11, 16)}GMT</p>
        </div>
        </div>
        <div class="video">
        </div>
        </article>
        `
      });
  output = output.join(' ')
  return output;
}
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.