JSFiddle - React, Tailwind, and code Playground

by dledle2

HTML

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Hacker News - Articles with 100+ Comments</title>
  <style>
    body { font-family: Arial, sans-serif; margin: 20px; }
    h1 { color: #333; }
    ul { list-style-type: none; padding: 0; }
    li { margin-bottom: 15px; padding: 10px; border: 1px solid #ddd; border-radius: 5px; }
    a { text-decoration: none; color: #0077cc; margin-right: 5px; }
    a:hover { text-decoration: underline; }
    .meta { font-size: 0.9em; color: #555; margin-top: 5px; }
    #loading { font-style: italic; color: #666; }
    #controls { margin-bottom: 10px; }
    #pagination { margin: 15px 0; }
    #pagination button { margin-right: 5px; padding: 5px 10px; }
    .comments-link { font-size: 0.9em; color: #0077cc; margin-right: 10px; }
    .site-link { font-size: 0.9em; color: #0077cc; }
    .user-link, .time-link { font-size: 0.9em; color: #0077cc; margin: 0 3px; }
  </style>
</head>
<body>
  <h1>Hacker News Articles with 100+ Comments</h1>
  <div id="controls">
    <label><input type="checkbox" id="sortComments" checked> Sort by comments</label>
  </div>
  <p id="loading">Loading stories...</p>
  <div id="pagination" style="display:none;">
    <button id="prevBtn">Previous</button>
    <span id="pageInfo"></span>
    <button id="nextBtn">Next</button>
  </div>
  <ul id="stories"></ul>

  <script>
    const storiesList = document.getElementById('stories');
    const loadingEl = document.getElementById('loading');
    const paginationEl = document.getElementById('pagination');
    const prevBtn = document.getElementById('prevBtn');
    const nextBtn = document.getElementById('nextBtn');
    const pageInfo = document.getElementById('pageInfo');
    const sortCheckbox = document.getElementById('sortComments');

    let filtered = [];
    const pageSize = 10;
    let currentPage = 1;

    function...