UNPKG

grunt-spritesmith

Version:

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

104 lines (90 loc) 2.9 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; */ $sprite_fork_name = 'sprite_fork'; $sprite_fork_x = 0px; $sprite_fork_y = 0px; $sprite_fork_offset_x = 0px; $sprite_fork_offset_y = 0px; $sprite_fork_width = 32px; $sprite_fork_height = 32px; $sprite_fork_total_width = 64px; $sprite_fork_total_height = 64px; $sprite_fork_image = 'spritesheet.cssVarMap.png'; $sprite_fork = 0px 0px 0px 0px 32px 32px 64px 64px 'spritesheet.cssVarMap.png' 'sprite_fork'; $sprite_github_name = 'sprite_github'; $sprite_github_x = 32px; $sprite_github_y = 0px; $sprite_github_offset_x = -32px; $sprite_github_offset_y = 0px; $sprite_github_width = 32px; $sprite_github_height = 32px; $sprite_github_total_width = 64px; $sprite_github_total_height = 64px; $sprite_github_image = 'spritesheet.cssVarMap.png'; $sprite_github = 32px 0px -32px 0px 32px 32px 64px 64px 'spritesheet.cssVarMap.png' 'sprite_github'; $sprite_twitter_name = 'sprite_twitter'; $sprite_twitter_x = 0px; $sprite_twitter_y = 32px; $sprite_twitter_offset_x = 0px; $sprite_twitter_offset_y = -32px; $sprite_twitter_width = 32px; $sprite_twitter_height = 32px; $sprite_twitter_total_width = 64px; $sprite_twitter_total_height = 64px; $sprite_twitter_image = 'spritesheet.cssVarMap.png'; $sprite_twitter = 0px 32px 0px -32px 32px 32px 64px 64px 'spritesheet.cssVarMap.png' 'sprite_twitter'; $spritesheet_width = 64px; $spritesheet_height = 64px; $spritesheet_image = 'spritesheet.cssVarMap.png'; $spritesheet_sprites = $sprite_fork $sprite_github $sprite_twitter; $spritesheet = 64px 64px 'spritesheet.cssVarMap.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); } } }