quotes-nextjs

My favourite quotes. (nextjs)
git clone http://git.hanabi.in/repos/quotes-nextjs.git
Log | Files | Refs | LICENSE

WordCloud.js (1035B)


      1 import Link from "next/link";
      2 
      3 import { getMinMax } from "../helperFns.js";
      4 
      5 function WordCloud({ arr, prefix }) {
      6   let [min, max] = getMinMax(arr);
      7   return (
      8     <main id="main" className="main">
      9       <div className="term-cloud-container">
     10         <ul className="term-cloud">
     11           {arr.map((_) => {
     12             const numerator = _.count - min;
     13             const denominator = max - min;
     14             const num = denominator ? numerator / denominator : 1;
     15             const weight = 100 * Math.round((2 * numerator) / denominator + 3);
     16             return (
     17               <li key={_.name}>
     18                 <Link href={`/${prefix}/${_.name}`}>
     19                   <a
     20                     style={{
     21                       fontSize: `${1 + num}em`,
     22                       fontWeight: `${weight}`,
     23                     }}
     24                   >
     25                     {_.name}
     26                   </a>
     27                 </Link>
     28               </li>
     29             );
     30           })}
     31         </ul>
     32       </div>
     33     </main>
     34   );
     35 }
     36 
     37 export default WordCloud;