All Projects â†’ DavidWells â†’ icon-pipeline

DavidWells / icon-pipeline

Licence: other
🚚 SVG icon pipeline - Optimize icons & build SVG sprites

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects
CSS
56736 projects
Pug
443 projects

Projects that are alternatives of or similar to icon-pipeline

streamlinehq-npm
The deprecated Streamline NPM package, which will be deleted on 1st November 2022.
Stars: ✭ 26 (-39.53%)
Mutual labels:  icons
microns
The universal icon set for user interfaces.
Stars: ✭ 58 (+34.88%)
Mutual labels:  icons
whey
A simple Python wheel builder for simple projects.
Stars: ✭ 17 (-60.47%)
Mutual labels:  build
create-chakra-icons
Transform SVGs to React Chakra UI <Icon /> ✨
Stars: ✭ 80 (+86.05%)
Mutual labels:  icons
rofi-fontawesome
fontawesome icon list for rofi dmenu
Stars: ✭ 58 (+34.88%)
Mutual labels:  icons
awsicons
Open source SVG icon library with over 500+ icons
Stars: ✭ 60 (+39.53%)
Mutual labels:  icons
ionic4-angular8-crud-mobileapps-example
Ionic 4 Angular 8 Tutorial: Learn to Build CRUD Mobile Apps
Stars: ✭ 20 (-53.49%)
Mutual labels:  build
SketchSVG
Have icons in a Sketch file but don't want to manually extract and compress them as SVGs? Let our SketchSVG tool do it!
Stars: ✭ 23 (-46.51%)
Mutual labels:  icons
vsc-material-theme-icons
Material Theme Icons, the most epic icons theme for Visual Studio Code and Material Theme.
Stars: ✭ 90 (+109.3%)
Mutual labels:  icons
xcodedevtools
Xcode Development Scripts
Stars: ✭ 44 (+2.33%)
Mutual labels:  build
icons
Archived since there are many great open source icon sites already which we list on our resources page, also see the same topic for fonts https://github.com/opensourcedesign/fonts/issues/21
Stars: ✭ 52 (+20.93%)
Mutual labels:  icons
Prismatic-Night
A dark themed startpage and dark themes for Firefox and Linux inspired by Material design and Adapta.
Stars: ✭ 287 (+567.44%)
Mutual labels:  icons
Lineage-Icons
LineageOS Icon Pack
Stars: ✭ 37 (-13.95%)
Mutual labels:  icons
php-feather
🕊 PHP Library for https://feathericons.com/
Stars: ✭ 42 (-2.33%)
Mutual labels:  icons
vs-material-icons-generator
This plugin will help you to set material design icons to your Xamarin projects In Visual Studio.
Stars: ✭ 50 (+16.28%)
Mutual labels:  icons
get-cmake
Install and Cache latest CMake and ninja executables for your workflows on your GitHub
Stars: ✭ 52 (+20.93%)
Mutual labels:  build
build verify
A Dart package to verify that the build is up-to-date with respect to a git repository
Stars: ✭ 28 (-34.88%)
Mutual labels:  build
k8s-knative-gitlab-harbor
Build container images with Knative + Gitlab + Harbor inside Kops cluster running on AWS
Stars: ✭ 23 (-46.51%)
Mutual labels:  build
svelte-simple-icons
📦 This package provides the Simple Icons packaged as a set of Svelte components.
Stars: ✭ 27 (-37.21%)
Mutual labels:  icons
visioStencils
My 2,700 visio 🎨 shapes, stencils, symbols, and icons collection to visually represent IT infrastructure
Stars: ✭ 43 (+0%)
Mutual labels:  icons

Icon Pipeline

The no nonsense icon pipeline

Optimizes svg icons and creates SVG sprites for <use> tags.

Automatically optimize SVGs and build icon sprite for use in HTML or in JS.

Install

npm install icon-pipeline

Usage

Include icon-pipeline as a dev dependency and call it during your build process.

Here is an example:

const path = require('path')
const iconPipeline = require('icon-pipeline')

const iconSrcFolder = path.join(__dirname, 'src', 'icons')
const iconOutputFolder = path.join(__dirname, 'build', 'icons')

/* Generate optimized SVGs and icon sprite */
iconPipeline({
  // Location of non optimized svg icons
  srcDir: iconSrcFolder,
  // Output directory for optimized svg icons & svg sprite
  outputDir: iconOutputFolder,
  // Includes the sprite.js && sprite.svg in original icon directory
  includeSpriteInSrc: true,
  // Turn off additional svg classes added for advanced styling
  /* disableClasses: true, */
  // Namespace of icon IDs. Will prefix icon names. Example 'foo.svg' will become 'company-foo'
  /* namespace: 'company' */
}).then((iconData) => {
  console.log('iconData', iconData)
})

console.log(iconData)

See make-icons.js file for a working example of this.

Input

So for example, the src directory (srcDir) of unoptimized SVG icons looks like:

src/icons/
├── profile.svg
├── github.svg
└── facebook.svg

Output

The output directory (outputDir) of icons will result in:

build/icons/
├── sprite.svg     <-- SVG sprite for usage in HTML
├── sprite.js      <-- SVG sprite for usage in javascript
├── icon-list.js   <-- manifest of all available icons
├── profile.svg    <-- optimized svg
├── github.svg     <-- optimized svg
└── facebook.svg   <-- optimized svg

How to reference sprite icons

There are a couple different ways you can reference your newly created icon sprite.

Vanilla HTML

Include your sprite.svg into your DOM.

<!doctype html>
<html>
  <head></head>
  <body>
    <div>Your app</div>
    <!-- Include the sprite -->
    <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="position:absolute; width: 0; height: 0">
      <symbol viewBox="0 0 24 24" id="facebook">
        <path d="M18.768 7.465Hl.417-4z..."></path>
      </symbol>
      <symbol viewBox="0 0 24 24" id="github">
        <path d="M12 0C5.374 0 0 5.373..."></path>
      </symbol>
    </svg>
  </body>
</html>

Javascript

Or include the sprite.js into your JS app and inject into the DOM.

import sprite from './icons/sprite'
import addSVGtoDOM from './components/Icon/addSVGtoDOM'
addSVGtoDOM(null, sprite)

See the example for how to use with React components.

use tag

After your sprite is in the DOM, you can reference icons with the use tag and the ID of the icon. #facebook here is the name of the icon file.

<svg>
  <use xlink:href="#facebook"></use>
</svg>

Recommended SVG resources

SVG tools

Alt packages

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].