Giter Club home page Giter Club logo

sassyicons's Introduction

⚠️ Archived project

SassyIcons

Flexible system to manipulate icons, SVG, PNG, sprites.

NOTICE: This project is unmaintained and won't receive new features.
Spritesheets automation helpers should better be handled by PostCSS plugins.

Works on top of compass sprite API.
It was designed to easily switch between SVG and PNG while working with icons as background-images.
So you have more granular control over which icons to use as SVG or PNG.
SVG first with PNG sprite fallback, or PNG first with hidpi sprite support.

Also managing several "thematic" sprites a breeze.

Best workflow used in conjunction with grunt-svg2png.

Online Documentation (generated with SassDoc).

API

sprite-map-create($name [, $spacing])
icon($map, $sprite [, $offset, $format])
icon-single($map, $sprite [, $format])
icon-generated($map, $sprite [, $pos, $centered, $format])

Usage

Requirements

  • Sass ~> 3.3.0
  • Compass ~> 1.0.0.rc.1

Installation

Git

git clone [email protected]:pascalduez/SassyIcons.git

npm

npm install sassyicons --save

Bower

bower install SassyIcons --save

Compass extension

Since SassyIcons is dependant on Compass, this is the recommended installation and usage.

  1. Add gem 'SassyIcons', '~>0.1.0' to your Gemfile
  2. bundle install --path . (manage your gems in project dir, not globally)
  3. Add require 'SassyIcons' to your config.rb
  4. Import it in your stylesheets with @import 'SassyIcons'

Configuration

// Default settings.
$icons-defaults: (

  // Space around sprites in generated spritemap.
  // Useful with `$offset` parameter.
  // This setting is global for all spritemaps.
  // Can be set per spritemap with the `$spacing` parameter.
  spacing: 0,

  // Main icons directory. `sprite-map-create()`, base for sub dirs.
  dir: "icons",

  // Name of the png sub-folders.
  dir-png: "png",

  // Name of the hidpi png sub-folders.
  dir-hidpi: "png_2x",

  // Scale of the hidpi pngs.
  hidpi-scale: 2,

  // Minimum resolution ratio used in the hidpi media query.
  hidpi-ratio: 1.3,

  // Whether to embed icons as data URI in the `icon-single()` mixin.
  single-embed: true,

  // Default file format unless overridden by parameter, svg | png.
  format: "svg",

  // Whether to support legacy browsers, svg fallback.
  legacy: true

);

Override default values in a new $icons-settings map.

Usage

Example usage with Compass

// Import SassyIcons.
@import 'SassyIcons';

// Instantiate a new sprite-map from folder `icons/social`.
@include sprite-map-create(social, $spacing: 10px);

.icon--twitter {
  @include icon(social, "twitter");
}

.icon--twitter {
  @include icon-generated(social, "twitter", $format: "png");
}
bundle exec compass watch

Roadmap

  • More documentation
  • icon-generated() and generated() Don't force absolute positioning.
  • Rewrite generated() mixin
  • icon-generated() configurable calc() fallback
  • Helper mixin to work with background-size
  • Support for SVG sprites ?
  • Support for SVG stacks ?
  • Try to further improve output CSS
  • More control over print position in the stylesheet ?
  • Abstract and move away from Compass sprites ?
  • Move away from Modernizr classes ? Or make it an option.
  • Clarify or remove the @content thing to pass additional rules to .svg.

Future

This library used to address a specific need, at a specific moment. Although one of its main feature is to bring granular control on how many icons you want to inline, keep in mind that too many inlined SVG's, especially base64 encoded might be a concern for performances.

There are a bunch of different techniques to integrate SVG icons, that you should check out and evaluate before deciding on any.

Some (non exaustive) resources:

Development

You need

How to

  1. Fork this repository
  2. Run npm install
  3. Make your changes + write tests
  4. grunt test

Authors

Pascal Duez

Licence

SassyIcons is available under the MIT license.

sassyicons's People

Contributors

pascalduez avatar

Stargazers

 avatar Mart dn avatar Matt Danskine avatar Andy Primawan avatar Tarmo avatar  avatar Daniël Smink avatar timelyportfolio avatar RR avatar Evgeniy Kuznetsov avatar Goio Telletxea avatar Benny Böhm avatar straybro avatar Airat Zhanshuakov avatar Adrian Green avatar Aaron Greenlee avatar Patrik Riske avatar Michael Puckett avatar Marko Srdoč avatar Richard Scoop avatar Dan Okkels Brendstrup avatar Jarrett Drouillard avatar Justin Hough avatar Mohamed Farid Naga avatar Marty Helmick avatar Nikolay Nenov avatar Red avatar  avatar Martijn Eerens avatar Dil Ahdan avatar Benjamin Gaier avatar Arek Bartnik avatar Phil Rose avatar Zeke Gabrielse avatar Annette Völckner avatar Tom Bamford avatar Andrei Zvonkov avatar Andy Poschen avatar David Tintner avatar  avatar Chris Yates avatar sebastian avatar Chris avatar Benoit Deziel avatar Braunson Yager avatar Rıfat Caner Anıltürk avatar Nikita Bayev avatar Vadim Sikora avatar Darren Wood avatar Ding Yi avatar Filipe Oliveira avatar Francesco Kirchhoff avatar Sean Gravener avatar  avatar Chris Rolfs avatar Linus Lundahl avatar  avatar Cole Townsend avatar HongKheng Yap avatar Ken Verhaegen avatar Daryn St. Pierre avatar Sacha Greif avatar Petr Hlavicka avatar  avatar valters grišāns avatar Bubuku I Code avatar  avatar M Haidar Hanif avatar  avatar Arthur avatar Joe Lipper avatar Michael Sacca avatar Biko Tushinde avatar  avatar Maher Saif avatar  avatar Kris Haamer avatar Michael D Johnson avatar Hendrik Gebhardt avatar   Victor avatar PJ avatar iilei • jochen preusche avatar roks0n avatar Josh Dean avatar Arnstein Henriksen avatar Dan Leatherman avatar Marcello Alvarado avatar Erick Patrick avatar Vitaly Sorokin avatar Antti Niemenpää avatar Jan Deppisch avatar Clément Noterdaem avatar Aleksandr avatar ishihara takashi avatar Martin Alker avatar Philippe Barbosa avatar Patrick Fulton avatar Lucas avatar 神仙 avatar Rogier Barendregt avatar

Watchers

 avatar Arnstein Henriksen avatar James Cloos avatar  avatar Riccardo Petracchini avatar Rana Banerjee avatar  avatar

sassyicons's Issues

Unable to load source sprites

Hello,

I'm sure I'm making some silly mistake but I've searched and struggled for far to long so I thought an issue may exist.

I am able to create Compass sprites normally.

@import "compass/utilities/sprites";
@import "icons/sprites/png/*.png";
@include all-png-sprites;

However, I can't seem to get SassyIcons to find the source files and continue to receive the following exception:

error web-src/wc/sass/wc.scss (/Users/aarongreenlee/.../ruby/2.0.0/gems/compass-1.1.0.alpha.3/lib/compass/sprite_importer.rb:89:in `files': undefined method `any?' for nil:NilClass)

My icons config:

@import 'SassyIcons';

$icons-defaults: (
  spacing: 0,
  // Main icons directory. `sprite-map-create()`, base for sub dirs.
  dir: "icons/sprites/",

  // Name of the png sub-folders.
  dir-png: "png",

  // Name of the hidpi png sub-folders.
  dir-hidpi: "png_2x",

  // Scale of the hidpi pngs.
  hidpi-scale: 2,

  // Minimum resolution ratio used in the hidpi media query.
  hidpi-ratio: 1.3,

  // Whether to embed icons as data URI in the `icon-single()` mixin.
  single-embed: true,

  // Default file format unless overridden by parameter, svg | png.
  format: "svg",

  // Whether to support legacy browsers, svg fallback.
  legacy: true
);

@include sprite-map-create(sprites, $spacing: 10px);

I've tried many different path attempts and can't seem to find the correct path.

offset for svg icon?

Would it have an impact on functionality to add the offset (background-position) to svg icons as well?

If I have an icon as background image of a link i want the clickable area to be bigger than the icon. And I do so by making the Element bigger and adding an offset to the background image. The Png Fallback is positioned correctly, but the svg doesn't get positioned at all.

if I add position: unquote($offset-x + px $offset-y + px); to the _icon.scss file in the background property of the svg image it works like I would expect it. But I just started using your system and maybe I misunderstood something

@if $format == 'svg' {

    $svg-file: _join((conf(dir), $map, '#{$sprite}.svg'), '/');

    background: {
      image: inline-image($svg-file);
      repeat: no-repeat;
      position: unquote($offset-x + px  $offset-y + px);
    }

    .svg & {
      @content;
    }

    @if $legacy-support {
      .no-svg &,
      .no-js & {

        @extend %sprite-map-#{$map}-image-map;

        background-position: _sprite-position($map-1x, $sprite, $offset-x, $offset-y);
      }
    }

  }

error _config.scss: Invalid CSS after " spacing": expected ")", was ": 0,")

Hi, I'm trying to troubleshoot where I messed up that's causing me to get this error:
error app/_scss/style.scss (Line 14 of node_modules/sassyicons/stylesheets/config/_config.scss: Invalid CSS after " spacing": expected ")", was ": 0,")

I'm using sassyicon with a yeoman generated jekyll based site. I'm using Compass 1.0.0.rc.1 and Sass 3.4.0.rc.3. I'm using grunt for task running.

It's entirely possible I installed SassyIcons wrong. I initially tried to install it with Bower but kept getting "ENOTFOUND Package SassyIcons not found" in response. After that I installed it with npm and also installed the compass extension. I also installed grunt-svg2png

I can see the reference to it in my package.json file:
"dependencies": {
"sassyicons": "0.0.10"
},

The import in my scss file is: @import "../../node_modules/sassyicons/stylesheets/SassyIcons";

Any help would be appreciated.

Thanks,
Andrew

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.