• Stars
    star
    233
  • Rank 172,230 (Top 4 %)
  • Language
    CSS
  • License
    MIT License
  • Created over 12 years ago
  • Updated about 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A mixin for creating retina sprites with hover & active states

Retina Sprites for Compass

Notice - Depricated

I'm no longer actively using sprites in my projects so i'm not going to be maintaining this any longer. Pivital Tracker has a nice fork that is faster and more current. I would recommend using this going forward!

pivotaltracker/Retina-Sprites-for-Compass








While building Tagit's website, I came across the need to use compass sprites with hover states on normal and retina devices. Not being able to find anything that would suite my needs, I forked a gist from this Gist and added hover & active parameters. Big thanks to thulstrup and rstacruz!

I created a drop in utility mixin to allow compass to automatically create sprites for normal and retina devices, and also providing hover and active states.

Features

  • Generate Normal & Retina Sprites
  • Optional Hover & Active States
  • Optional Sprite Spacing/Padding

I've provided a demo folder with working sample buttons.

Instructions

Drop _retina-sprites.scss into your preferred location and link @include it into your main CSS file. I prefer to drop it into a utilities folder with other commonly used helpers.

@import "utilities/retina-sprites";

Create two folders in your images folder. For my example I've created "sprites" for 1x sprites and "sprites-retina" for 2x sprites. In my example I've also created a subfolder called buttons to sprite these as a group. Drop your photo's in these folders, they should have the same file name. Also make sure the retina images are divisible by 4. If they are not, it can lead to clipping and shifting.

In your SCSS file, declare where your sprites are located. In this example I have my buttons in a separate scss file, and I place the following in the top of this file.

$sprites: sprite-map("sprites/buttons/*.png");            // import 1x sprites
$sprites2x: sprite-map("sprites-retina/buttons/*.png");   // import 2x sprites

If you would like to add padding to your sprites, use the spacing parameter and double the value for the retina version:

$sprites: sprite-map("sprites/buttons/*.png", $spacing: 10px);            // import 1x sprites, 10px padding
$sprites2x: sprite-map("sprites-retina/buttons/*.png", $spacing: 20px);   // import 2x sprites, 20px padding

Almost ready to rock and roll!! Create a class for your sprite, and use an include to generate it.

.myHoverActiveButton {
	@include retina-sprite(signIn, $hover: true, $active: true);    // imports signIn.png, signIn_hover.png, and signIn_active.png
}

.myHoverButton {
   @include retina-sprite(signIn, $hover: true);                    // imports signIn.png and signIn_hover.png
}

.myBoringButton {
   @include retina-sprite(signIn);                                  // imports signIn.png
}

More Repositories

1

RedScript

An Elixir Flavored Language for the Browser
JavaScript
418
star
2

react-ive-meteor

Demo app of React and Meteor using a social feed
JavaScript
243
star
3

meteor-react-boilerplate

A starter project for React & Meteor
JavaScript
168
star
4

meteor-flux-leaderboard

Flux Example with React & Meteor
JavaScript
131
star
5

parse-form

A micro library & Meteor package used to parse and manipulate forms
JavaScript
71
star
6

meteor-redux-example

Redux for Blaze
JavaScript
69
star
7

meteor-generate

Meteor Generate - A Rails Inspired File Generator for Meteor
JavaScript
65
star
8

meteor_elixir

An experiment to eliminate bottlenecks in Meteor
JavaScript
45
star
9

Meteor-RethinkDB-GraphQL

A Meteor and RethinkDB Example Using GraphQL
JavaScript
44
star
10

react-meteor-tests

React Unit Tests in Meteor
JavaScript
39
star
11

meteor-phonegap-oauth

Fixes how Meteor handles OAuth popups on PhoneGap/fullscreen
JavaScript
33
star
12

phoenix-rethinkdb-example

Example App with RethinkDB
JavaScript
22
star
13

Meteor-Cordova-Status

Reactive Cordova Status & Meteor Disconnect/Reconnect Handling
JavaScript
18
star
14

awesome-stack

Elixir
17
star
15

life-changing-programming-lessons

A collection of things I wish I knew 20 years ago
16
star
16

simple-redux-react

A wrapper to get Redux, React, react-router-redux, redux-devtools going in a few lines
JavaScript
16
star
17

meteor-flux-helpers

Meteor package with general flux helpers
JavaScript
15
star
18

backbone-fill-collection

Fill collections with mock data with every fetch.
JavaScript
11
star
19

validate-form

Meteor form validation micro library
JavaScript
11
star
20

reason-simple-form-example

Create React App Example
OCaml
10
star
21

meteor-react-accounts

A set of compossible components to sign in / login / signin / reset password / dropdown
JavaScript
9
star
22

pipes-js

Pipe operators in JS like Elm / Elixir / F#
8
star
23

elixir-stdlib-js

JavaScript
7
star
24

alfred-meteor-atmosphere

Search for Atmosphere Packages with Alfred
7
star
25

alfred-hex-search

Search for Erlang & Elixir packages on Hex with Alfred
6
star
26

restful-js

An opinionated REST framework for Node & Meteor
JavaScript
6
star
27

ocamlish

An OCaml inspired standard library for TypeScript
TypeScript
6
star
28

meteor-graphql-boilerplate

A quick start for using Apollo, Redux, and Meteor
5
star
29

dotfiles

CSS
3
star
30

react-native-navigation-android-example

JavaScript
1
star
31

reason-simple-form

A simple form solution for ReasonML
OCaml
1
star
32

elixir-graphql-issue-54

repro for https://github.com/joshprice/graphql-elixir/issues/54
JavaScript
1
star
33

generator-mgen

Backend for the Meteor Generate CLI
JavaScript
1
star