How to use github-colors - 8 common examples

To help you get started, we’ve selected a few github-colors examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github IonicaBizau / node-gh-polyglot / build / client.js View on Github external
;

const TEMPLATE = "(function (root) {\n"
               + "  var GitHubColors = __GITHUB_COLORS__;\n"
               + "  __GITHUB_POLYGLOT__\n"
               + "})(window);";

// Configurations
GitHubColors.init();

var ghPolyglot = Fs.readFileSync(__dirname + "/../lib/index.js", "utf-8")
  , lines = ghPolyglot.split("\n")
  , replace = {
        __GITHUB_POLYGLOT__: lines.slice(lines.indexOf("/**")).join("\n")
      , __GITHUB_COLORS__: "{ get: " + GitHubColors.get.toString() + ",\n"
                         + "colors: " + JSON.stringify(GitHubColors.colors) + "}"
    }
  , client = TEMPLATE
  ;

Object.keys(replace).forEach(function (c) {
    client = client.replace(new RegExp(c), replace[c]);
});

client = client.replace("module.exports = ", "root.GitHubPolyglot = ");
client = client.replace("this.init();", "");

Fs.writeFileSync(__dirname + "/../dist/gh-polyglot.js", client);
Fs.writeFileSync(__dirname + "/../dist/gh-polyglot.min.js", UglifyJS.minify(client, { fromString: true }).code);
github IonicaBizau / node-gh-polyglot / build / client.js View on Github external
// This file generates the client script
// Dependencies
var Fs = require("fs")
  , GitHubColors = require("github-colors")
  , UglifyJS = require("uglify-js")
  ;

const TEMPLATE = "(function (root) {\n"
               + "  var GitHubColors = __GITHUB_COLORS__;\n"
               + "  __GITHUB_POLYGLOT__\n"
               + "})(window);";

// Configurations
GitHubColors.init();

var ghPolyglot = Fs.readFileSync(__dirname + "/../lib/index.js", "utf-8")
  , lines = ghPolyglot.split("\n")
  , replace = {
        __GITHUB_POLYGLOT__: lines.slice(lines.indexOf("/**")).join("\n")
      , __GITHUB_COLORS__: "{ get: " + GitHubColors.get.toString() + ",\n"
                         + "colors: " + JSON.stringify(GitHubColors.colors) + "}"
    }
  , client = TEMPLATE
  ;

Object.keys(replace).forEach(function (c) {
    client = client.replace(new RegExp(c), replace[c]);
});

client = client.replace("module.exports = ", "root.GitHubPolyglot = ");
github kamranahmedse / githunt / src / components / filters / language-filter / index.js View on Github external
return availableLanguages.map((language, counter) => {
      const isSelectedIndex = counter === this.state.selectedIndex;

      // This will be used in making sure of the element visibility
      const refProp = isSelectedIndex ? { ref: 'activeItem' } : {};
      const languageColor = GithubColors.get(language.title) || {
        color: language.title === 'All Languages' ? 'transparent' : '#e8e8e8'
      };

      return (
        <a className={ classNames('select-menu-item', { 'active-item': isSelectedIndex }) }
           { ...refProp }
           onMouseDown={ () => this.selectLanguage(counter) }
           key={ counter }>
          <span className='repo-language-color' style={{
            backgroundColor: languageColor.color
          }}></span>
          <span className="select-menu-item-text">{ language.title }</span>
        </a>
      );
    });
  }
github ghuser-io / ghuser.io / db / fetch.js View on Github external
spinner = ora(`Fetching ${ghUrl}...`).start();

      if (!db.repos[repo].fetching ||
          db.repos[repo].fetched_at &&
          new Date(db.repos[repo].fetched_at) > new Date(db.repos[repo].pushed_at)) {
        spinner.succeed(`${repo} hasn't changed`);
        return;
      }

      const ghDataJson = await fetchJson(authify(ghUrl));
      spinner.succeed(`Fetched ${ghUrl}`);

      for (let language in ghDataJson) {
        ghDataJson[language] = {
          bytes: ghDataJson[language],
          color: githubColors.get(language, true).color
        };
      }

      db.repos[repo].languages = ghDataJson;
      db.write();
    }
github ghuser-io / ghuser.io / db / fetchRepos.js View on Github external
const ghUrl = `https://api.github.com/repos/${repo}/languages`;
      spinner = ora(`Fetching ${ghUrl}...`).start();

      if (!repos[repo].fetching_since || repos[repo].fetched_at &&
          new Date(repos[repo].fetched_at) > new Date(repos[repo].pushed_at)) {
        spinner.succeed(`${repo} hasn't changed`);
        return;
      }

      const ghDataJson = await github.fetchGHJson(ghUrl, spinner);
      spinner.succeed(`Fetched ${ghUrl}`);

      for (let language in ghDataJson) {
        ghDataJson[language] = {
          bytes: ghDataJson[language],
          color: githubColors.get(language, true).color
        };
      }

      repos[repo].languages = ghDataJson;
      repos[repo].write();
    }
github kamranahmedse / githunt / src / components / repository-grid / grid-item / index.js View on Github external
render() {
    const languageColor = GithubColors.get(this.props.repository.language);

    return (
      <div className="col-xl-4 col-lg-4 col-md-6 col-sm-12 col-12 grid-item-container">
        <div className="grid-item-body">
          <div className="author-header clearfix">
            <a href={ this.props.repository.owner.html_url } rel="noopener noreferrer" target="_blank">
              <div className="author-img">
                <img src={ this.props.repository.owner.avatar_url }
                     onError={ (e) => {
                       e.target.src = '/img/logo.svg';
                     } }
                     alt={ this.props.repository.owner.login }/>
              </div>
              <div className="author-details">
                <h5>{ this.props.repository.owner.login }</h5>
                <p className="small text-muted">View Profile</p>
github kamranahmedse / githunt / src / components / repository-list / list-item / index.js View on Github external
render() {
    const languageColor = GithubColors.get(this.props.repository.language);

    return (
      <div className="col-12 list-item-container">
        <div className="list-item-body">
          <div className="repo-header">
            <h3>
              <a href={ this.props.repository.html_url } rel="noopener noreferrer" target="_blank">
                <span className="text-normal">{ this.props.repository.owner.login } / </span>
                { this.props.repository.name }
              </a>
            </h3>
            <p className="repo-meta text-muted small">Built by &middot; <a href={ this.props.repository.owner.html_url } rel="noopener noreferrer" target="_blank">{ this.props.repository.owner.login }</a> &middot; { moment(this.props.repository.created_at).format('MMMM D YYYY') }</p>
          </div>
          <div className="repo-body">
            <p>{ this.props.repository.description || 'No description given.' }</p>
          </div>
github IonicaBizau / node-gh-polyglot / lib / index.js View on Github external
arrData = Object.keys(languages).map(function (cLang) {
            return {
                label: cLang
              , value: languages[cLang]
              , color: GitHubColors.get(cLang, true).color
            };
        });

github-colors

GitHub colors and file extensions mapping

MIT
Latest version published 1 year ago

Package Health Score

49 / 100
Full package analysis