<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">

<div class="input-container">
  <input id="searchInput" type="search" placeholder="Filter by Username">
  <button id="reloadBtn"><i class="fa fa-refresh"></i></button>
</div>
<p id="loadingText">Loading...</p>
<table id="table" hidden>
  <thead>
    <tr>
      <th>Username</th>
      <th>Balance</th>
      <th>Updated</th>
    </tr>
  </thead>
  <tbody>
  </tbody>
</table>
$dark-bg: #1a1a1a;
$light-bg: #fff;

html, body {
  color-scheme: dark light;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  margin-inline: 0;
  background-color: $light-bg;
  @media (prefers-color-scheme: dark) { background-color: $dark-bg; }
}
* { box-sizing: border-box; }
body {
  padding-top: 40px;
}
#loadingText {
  text-align: center;
  font-size: 18px;
}

#reloadBtn {
  position: absolute;
  z-index: 1;
  top: 4px;
  right: 4px;
  background: #eff8;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  box-shadow: 0 0 2px 1px #8885;
  border: none;
  font-size: 16px;
  width: 36px;
  height: 36px;
  border-radius: 20px;
  padding: 8px;
  cursor: pointer;
  transition: opacity 0.2s;
  &:hover { opacity: 0.8 }
  &:active { opacity: 0.5 }
  @media (min-width: 560px) {
    top: 15px;
    right: 15px;
  }
  i.fa { transition: transform 0.5s }
}

.input-container {
  position: fixed;
  top: 0;
  left: 0;
  padding: 16px 0 19px;
  background-color: inherit;
  width: 100%;
}
input[type="search"] {
  display: block;
  width: 90%;
  max-width: 440px;
  margin: auto;
  padding: 6px 10px;
  font-size: 16px;
}

table {
  border-collapse: separate;
  border-spacing: 0;
  margin: 20px auto 64px;
  border: 1px solid gray;
  border-top: 0px;
  font-size: 18px;
  @media (max-width: 390px) { font-size: 16px }
  width: 90%;
  max-width: 440px;
  thead tr {
    position: sticky;
    top: 69px;
    background-color: $light-bg;
    @media (prefers-color-scheme: dark) { background-color: $dark-bg }
    th { border-top: 1px solid gray }
  }
  th, td {
    padding: 4px 8px;
    border: 0.5px solid gray;
    text-align: center;
    &:nth-child(2) { width: 100px }
    &:nth-child(3) { width: 110px }
  }
  tbody tr {
    --border-color: transparent;
    // box-shadow: 4px 0 0 0 var(--border-color) inset;
    td:first-child { border-left: 4px solid var(--border-color); }
    &:nth-child(1) td { --border-color: gold; }
    &:nth-child(2) td { --border-color: silver; }
    &:nth-child(3) td { --border-color: #bf4c00; }
    &:nth-child(n+4) td { --border-color: #12a3ecaa; }
    &:nth-child(n+11) td { border-left: 0.5px solid gray; }
  }
}
View Compiled
function showData () {
  document.querySelector('tbody').innerHTML = ''
  fetch('https://hs-tools-api.deta.dev/hopbytes/balances')
    .then(x => x.json())
    .then(result => {
      result.forEach(({ username, balance, lastUpdated }) => {
        const row = document.createElement('tr')
        lastUpdated = new Date(lastUpdated).toLocaleDateString();
        [username, balance, lastUpdated].forEach(data => {
          const td = document.createElement('td')
          td.innerText = data.toString()
          row.appendChild(td)
        })
        document.querySelector('tbody').appendChild(row)
      })
      table.hidden = false
      loadingText.hidden = true
      filterEntries()
    })
    .catch(e => loadingText.innerText = 'Error Loading')
}
showData()

function filterEntries () {
  const value = searchInput.value.toLowerCase()
  document.querySelectorAll('tbody tr').forEach(row => {
    const name = row.children[0]
    const show = name.innerText.toLowerCase().includes(value)
    row.hidden = !show
  })
}
searchInput.addEventListener('input', filterEntries)
searchInput.addEventListener('search', filterEntries)

let rotate = 0
function reloadData () {
  table.hidden = true
  loadingText.innerText = 'Loading...'
  loadingText.hidden = false
  showData()
  rotate += 360
  reloadBtn.querySelector('i.fa').style.transform = `rotate(${rotate}deg)`
}
reloadBtn.addEventListener('click', reloadData)
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.