UNPKG

grunt-spritesmith

Version:

Grunt task for converting a set of images into a spritesheet and corresponding CSS variables.

104 lines (90 loc) 2.58 kB
/* Stylus variables are information about icon's compiled state, stored under its original file name .icon-home { width: $icon_home_width; } The large array-like variables contain all information about a single icon $icon_home = x y offset_x offset_y width height total_width total_height image_path; At the bottom of this section, we provide information about the spritesheet itself $spritesheet = width height image $spritesheet_sprites; */ $fork_name = 'fork'; $fork_x = 0px; $fork_y = 0px; $fork_offset_x = 0px; $fork_offset_y = 0px; $fork_width = 32px; $fork_height = 32px; $fork_total_width = 64px; $fork_total_height = 64px; $fork_image = 'spritesheet.engine.png'; $fork = 0px 0px 0px 0px 32px 32px 64px 64px 'spritesheet.engine.png' 'fork'; $github_name = 'github'; $github_x = 32px; $github_y = 0px; $github_offset_x = -32px; $github_offset_y = 0px; $github_width = 32px; $github_height = 32px; $github_total_width = 64px; $github_total_height = 64px; $github_image = 'spritesheet.engine.png'; $github = 32px 0px -32px 0px 32px 32px 64px 64px 'spritesheet.engine.png' 'github'; $twitter_name = 'twitter'; $twitter_x = 0px; $twitter_y = 32px; $twitter_offset_x = 0px; $twitter_offset_y = -32px; $twitter_width = 32px; $twitter_height = 32px; $twitter_total_width = 64px; $twitter_total_height = 64px; $twitter_image = 'spritesheet.engine.png'; $twitter = 0px 32px 0px -32px 32px 32px 64px 64px 'spritesheet.engine.png' 'twitter'; $spritesheet_width = 64px; $spritesheet_height = 64px; $spritesheet_image = 'spritesheet.engine.png'; $spritesheet_sprites = $fork $github $twitter; $spritesheet = 64px 64px 'spritesheet.engine.png' $spritesheet_sprites; /* The provided mixins are intended to be used with the array-like variables .icon-home { spriteWidth($icon_home) } .icon-email { sprite($icon_email) } */ spriteWidth($sprite) { width: $sprite[4]; } spriteHeight($sprite) { height: $sprite[5]; } spritePosition($sprite) { background-position: $sprite[2] $sprite[3]; } spriteImage($sprite) { background-image: url($sprite[8]); } sprite($sprite) { spriteImage($sprite) spritePosition($sprite) spriteWidth($sprite) spriteHeight($sprite) } /* The `sprites` mixin generates identical output to the CSS template but can be overridden inside of Stylus This must be run when you have at least 2 sprites. If run with a single sprite, then there will be reference errors. sprites($spritesheet_sprites); */ sprites($sprites) { for $sprite in $sprites { $sprite_name = $sprite[9]; .{$sprite_name} { sprite($sprite); } } }