Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
stylus-spritesmith-brunch
Advanced tools
Adds Stylus support to Brunch with automatic sprite sheet generation.
Adds Stylus support to Brunch with automatic sprite sheet generation.
Install the plugin via npm with npm install --save stylus-spritemith-brunch
.
Or, do manual install:
"stylus-spritesmith-brunch": "x.y.z"
to package.json
of your Brunch app.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
.
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.
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"
}
The following variables and functions are also available for use in your stylesheets.
Variable | Type | Description |
---|---|---|
sprite-sheets | List | List of sprite sheets generated |
default-sprite-sheet | String | Value of config option plugins.sprites.defaultSheet |
extend-sprite-sheets | Boolean | Value of config option plugins.sprites.useExtendDirective |
These functions return values about a given sprite-sheet
.
Function | Description |
---|---|
sprite-sheet-path | String — absolute path to the sprite sheet image |
sprite-sheet-width | Unit, px — width of an entire sprite sheet |
sprite-sheet-height | Unit, px — height of an entire sprite sheet |
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.
Function | Description |
---|---|
sprite-image-width | Unit, px — width of an individual sprite image |
sprite-image-height | Unit, px — height of an individual sprite image |
sprite-image-x | Unit, px — x-position of a sprite |
sprite-image-y | Unit, px — y-position of a sprite |
Options for Stylus and Spritesmith can be set in the plugins
object in your brunch-config
. All values below are the defaults.
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
}
}
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: {},
}
}
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.
FAQs
Adds Stylus support to Brunch with automatic sprite sheet generation.
We found that stylus-spritesmith-brunch demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.