How to use the file-icons-js.getClass function in file-icons-js

To help you get started, we’ve selected a few file-icons-js 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 lvarayut / github-file-icons / src / injections / octotree.js View on Github external
$items.each((index, item) => {
      const $item = $(item);
      const name = $item.parent().contents().get(1).data;
      const hasIcon = $item.find('.gfi').length > 0;

      if (!hasIcon) {
        let className;
          if (isColor) {
            className = fileIcons.getClassWithColor(name) || DEFAULT_ICON;
          } else {
            className = fileIcons.getClass(name) || DEFAULT_ICON;
          }
          const $icon = $(`<span class="gfi ${className}"></span>`);
          $item.append($icon);

          // Bind on click for downloading the file
          $icon.on('click', () =&gt; {
            $item.click();
          });
      }
    });
  });
github eclipse-theia / theia / packages / filesystem / src / browser / icons / file-icons.ts View on Github external
getFileIconForURI(uri: URI): string {
        const iconClass = fileIcons.getClass(uri.path.toString()) || 'fa fa-file';
        return iconClass + " file-icon";
    }
github xxhomey19 / github-file-icon / src / js / content.js View on Github external
for (let i = 0; i &lt; filenameDomsLength; i += 1) {
    const filename =
      isGitHub &amp;&amp; isMobile
        ? getGitHubMobileFilename(filenameDoms[i])
        : filenameDoms[i].innerText.trim();

    const iconDom = isGitHub
      ? iconDoms[i].querySelector('.octicon')
      : iconDoms[i];

    const isDirectory =
      iconDom.classList.contains('octicon-file-directory') ||
      iconDom.classList.contains('fa-folder');

    const className = colorsDisabled
      ? fileIcons.getClass(filename)
      : fileIcons.getClassWithColor(filename);

    const darkClassName = darkMode ? 'dark' : '';

    if (className &amp;&amp; !isDirectory) {
      const icon = document.createElement('span');

      if (isGitHub) {
        icon.className = `icon octicon ${className} ${darkClassName}`;
        icon.style.opacity = 1;
      } else {
        icon.className = `${className} ${darkClassName}`;
        icon.style.marginRight = host === 'bitbucket' ? '10px' : '3px';
      }

      iconDom.parentNode.replaceChild(icon, iconDom);
github lvarayut / github-file-icons / src / injections / github.js View on Github external
$items.each((index, item) => {
      const $item = $(item);
      const isFile = $item.find('.octicon-file').length > 0
      const isSvg = $item.find('.octicon-file-text').length > 0;
      const name = $item.find('.js-navigation-open').text();
      const $icon = $item.find('.icon');

      if (isFile || isSvg) {
          let className;
          if (isColor) {
            className = fileIcons.getClassWithColor(name) || DEFAULT_ICON;
          } else {
            className = fileIcons.getClass(name) || DEFAULT_ICON;
          }
          $icon.addClass(`gfi ${className}`);

          if (isSvg) {
            $item.find('svg').remove()
          }
      }
    });
  });

file-icons-js

File specific icons for the browser from Atom File-icons, https://github.com/file-icons/atom

MIT
Latest version published 4 years ago

Package Health Score

48 / 100
Full package analysis