Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

stylus-spritesmith-brunch

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stylus-spritesmith-brunch

Adds Stylus support to Brunch with automatic sprite sheet generation.

  • 0.1.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

stylus-spritesmith-brunch

Adds Stylus support to Brunch with automatic sprite sheet generation.

Usage

Install the plugin via npm with npm install --save stylus-spritemith-brunch.

Or, do manual install:

  • Add "stylus-spritesmith-brunch": "x.y.z" to package.json of your Brunch app.
  • If you want to use the master branch of the plugin, add "stylus-spritesmith-brunch": "git+ssh://git@github.com:jas/stylus-spritesmith-brunch.git".

Note: This plugin is a replacement for stylus-brunch.

Using Sprites

This plugin defines Stylus mixins, variables, and functions that make using sprites in your stylesheets almost effortless.

Just drop images into app/assets/images/sprites, and a sprite sheet will be compiled to public/images/spritesheets/default.png.

If you need to configure the input and output directories, reference the Plugin Options section.

Mixin

The sprite mixin is the easiest way to use a sprite image. To use the mixin, you must first import it into your stylesheets.

@import "sprites"

Then use it like so...

.logo {
  sprite('logo.png') // finds "icon-star.png" in default sprite sheet
}

If you have multiple sprite sheets, a second argument can be given to specify the sprite sheet to which the image belongs.

.icon-star {
  sprite('icon-star.png', 'icons') // finds "icon-star.png" in sprite sheet named "icons"
}

Variables and Functions

The following variables and functions are also available for use in your stylesheets.

VariableTypeDescription
sprite-sheetsListList of sprite sheets generated
default-sprite-sheetStringValue of config option plugins.sprites.defaultSheet
extend-sprite-sheetsBooleanValue of config option plugins.sprites.useExtendDirective
Sprite Sheet Functions

These functions return values about a given sprite-sheet.

FunctionDescription
sprite-sheet-pathString — absolute path to the sprite sheet image
sprite-sheet-widthUnit, px — width of an entire sprite sheet
sprite-sheet-heightUnit, px — height of an entire sprite sheet
Sprite Images

These functions return values about a given image. A second, optional sprite-sheet argument can be given to specify the sprite sheet to which the image belongs.

FunctionDescription
sprite-image-widthUnit, px — width of an individual sprite image
sprite-image-heightUnit, px — height of an individual sprite image
sprite-image-xUnit, px — x-position of a sprite
sprite-image-yUnit, px — y-position of a sprite

Plugin Options

Options for Stylus and Spritesmith can be set in the plugins object in your brunch-config. All values below are the defaults.

Stylus

plugins: {
  stylus: {
    // Compress CSS output.
    compress: false,

    // Emits debug info that can be used by the FireStylus Firebug plugin.
    firebug: false,

    // Emits comments in the generated CSS indicating the corresponding Stylus lines.
    lineNumbers: false,

    // Include regular CSS on @import.
    includeCss: false
  }
}

Sprites

plugins: {
  sprites: {
    // Use sprite features.
    enabled: true,

    // Directory in which to output sprite sheet images.
    outputDir: 'images/spritesheets',

    // File name of output sprite sheet images.
    outputFile: '{{name}}.png',

    // Include provided `sprite` mixin when compiling Stylus.
    includeMixins: true,

    // Sprite mixin will `@extend` a sprite sheet's styles, instead of
    // including them directly in the selector in which the mixin is used.
    useExtendDirective: false,

    // Name of the default sprite sheet to use when one is not passed to the
    // provided Stylus mixin or functions.
    defaultSheet: 'default',

    // Sprite sheets to generate. The regular expression matches images to
    // include in that particular sprite sheet.
    spriteSheets: {
      'default': /^app\/assets\/images\/sprites\/(.*)\.png$/
    },

    // Engine Spritemith uses to generate images ('phantomjs', 'canvas', 'gm')
    // See https://github.com/Ensighten/spritesmith for more information.
    engine: 'auto',

    // Image packing algoritm ('binary-tree', 'top-down', 'left-right', 'diagonal', 'alt-diagonal')
    algoritm: 'binary-tree',

    // Padding in pixels to add between sprite images
    padding: 0,

    // Options to pass through to engine for settings
    exportOpts: {
      // Format of output sprite sheets ('png', 'jpeg'); Canvas and gm engines only
      format: 'png',

      // Quality of output sprite sheets; gm engine only
      quality: 75,

      // Milliseconds to wait until terminating PhantomJS script; phantomjs engine only
      timeout: 10000
    },

    // Options to pass through to engine for export
    engineOpts: {},
  }
}

License

The MIT License (MIT)

Copyright (c) 2013 Jason Sandmeyer

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Keywords

FAQs

Package last updated on 11 Aug 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc