Unverified Commit 02ebd324 authored by Anurag Hazra's avatar Anurag Hazra Committed by GitHub
Browse files

refactor: jsdoc in utils & minor changes (#1377)

* refactor: jsdoc in utils & minor changes

* chore: jsdoc Card class

* chore: jsdoc for getStyles
parent d0ab2ff0
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -34,8 +34,6 @@ module.exports = async (req, res) => {
    border_radius,
    border_color,
  } = req.query;
  let stats;

  res.setHeader("Content-Type", "image/svg+xml");

  if (blacklist.includes(username)) {
@@ -47,7 +45,7 @@ module.exports = async (req, res) => {
  }

  try {
    stats = await fetchStats(
    const stats = await fetchStats(
      username,
      parseBoolean(count_private),
      parseBoolean(include_all_commits),
+1 −3
Original line number Diff line number Diff line
@@ -27,8 +27,6 @@ module.exports = async (req, res) => {
    border_color,
  } = req.query;

  let repoData;

  res.setHeader("Content-Type", "image/svg+xml");

  if (blacklist.includes(username)) {
@@ -40,7 +38,7 @@ module.exports = async (req, res) => {
  }

  try {
    repoData = await fetchRepo(username, repo);
    const repoData = await fetchRepo(username, repo);

    let cacheSeconds = clampValue(
      parseInt(cache_seconds || CONSTANTS.TWO_HOURS, 10),
+1 −3
Original line number Diff line number Diff line
@@ -31,8 +31,6 @@ module.exports = async (req, res) => {
    border_radius,
    border_color,
  } = req.query;
  let topLangs;

  res.setHeader("Content-Type", "image/svg+xml");

  if (blacklist.includes(username)) {
@@ -44,7 +42,7 @@ module.exports = async (req, res) => {
  }

  try {
    topLangs = await fetchTopLanguages(
    const topLangs = await fetchTopLanguages(
      username,
      parseArray(exclude_repo),
      parseArray(hide),
+14 −21
Original line number Diff line number Diff line
@@ -110,8 +110,7 @@ const renderRepoCard = (repo, options = {}) => {
  });

  // returns theme based colors with proper overrides and defaults
  const { titleColor, textColor, iconColor, bgColor, borderColor } =
    getCardColors({
  const colors = getCardColors({
    title_color,
    icon_color,
    text_color,
@@ -145,22 +144,16 @@ const renderRepoCard = (repo, options = {}) => {
    width: 400,
    height,
    border_radius,
    colors: {
      titleColor,
      textColor,
      iconColor,
      bgColor,
      borderColor,
    },
    colors,
  });

  card.disableAnimations();
  card.setHideBorder(hide_border);
  card.setHideTitle(false);
  card.setCSS(`
    .description { font: 400 13px 'Segoe UI', Ubuntu, Sans-Serif; fill: ${textColor} }
    .gray { font: 400 12px 'Segoe UI', Ubuntu, Sans-Serif; fill: ${textColor} }
    .icon { fill: ${iconColor} }
    .description { font: 400 13px 'Segoe UI', Ubuntu, Sans-Serif; fill: ${colors.textColor} }
    .gray { font: 400 12px 'Segoe UI', Ubuntu, Sans-Serif; fill: ${colors.textColor} }
    .icon { fill: ${colors.iconColor} }
    .badge { font: 600 11px 'Segoe UI', Ubuntu, Sans-Serif; }
    .badge rect { opacity: 0.2 }
  `);
@@ -168,9 +161,9 @@ const renderRepoCard = (repo, options = {}) => {
  return card.render(`
    ${
      isTemplate
        ? getBadgeSVG(i18n.t("repocard.template"), textColor)
        ? getBadgeSVG(i18n.t("repocard.template"), colors.textColor)
        : isArchived
        ? getBadgeSVG(i18n.t("repocard.archived"), textColor)
        ? getBadgeSVG(i18n.t("repocard.archived"), colors.textColor)
        : ""
    }

+25 −0
Original line number Diff line number Diff line
@@ -2,6 +2,16 @@ const { getAnimations } = require("../getStyles");
const { flexLayout, encodeHTML } = require("../common/utils");

class Card {
  /**
   * @param {object} args
   * @param {number?=} args.width
   * @param {number?=} args.height
   * @param {number?=} args.border_radius
   * @param {string?=} args.customTitle
   * @param {string?=} args.defaultTitle
   * @param {string?=} args.titlePrefixIcon
   * @param {ReturnType<import('../common/utils').getCardColors>?=} args.colors
   */
  constructor({
    width = 100,
    height = 100,
@@ -38,14 +48,23 @@ class Card {
    this.animations = false;
  }

  /**
   * @param {string} value
   */
  setCSS(value) {
    this.css = value;
  }

  /**
   * @param {boolean} value
   */
  setHideBorder(value) {
    this.hideBorder = value;
  }

  /**
   * @param {boolean} value
   */
  setHideTitle(value) {
    this.hideTitle = value;
    if (value) {
@@ -53,6 +72,9 @@ class Card {
    }
  }

  /**
   * @param {string} text
   */
  setTitle(text) {
    this.title = text;
  }
@@ -114,6 +136,9 @@ class Card {
      : "";
  }

  /**
   * @param {string} body
   */
  render(body) {
    return `
      <svg
Loading