From aaefd5054d674f19ca57cf1a3f724a588690e0dc Mon Sep 17 00:00:00 2001 From: anuraghazra Date: Fri, 10 Jul 2020 12:41:06 +0530 Subject: [PATCH] fix: fixed overflowing layout --- api/pin.js | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/api/pin.js b/api/pin.js index 8a58668b..6cfade4d 100644 --- a/api/pin.js +++ b/api/pin.js @@ -1,6 +1,12 @@ const axios = require("axios"); require("dotenv").config(); +function kFormatter(num) { + return Math.abs(num) > 999 + ? Math.sign(num) * (Math.abs(num) / 1000).toFixed(1) + "k" + : Math.sign(num) * Math.abs(num); +} + async function fetchRepo(username, reponame) { const res = await axios({ url: "https://api.github.com/graphql", @@ -64,6 +70,7 @@ const renderRepoCard = (repo) => { const { name, description, primaryLanguage, stargazers, forkCount } = repo; const height = 120; + const shiftText = primaryLanguage.name.length > 15 ? 0 : 30; return ` `; };