-
-
Save nonlinear/6082918 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Sass::Script::Functions | |
# Appends "_2x" to the end of a filename before the extension | |
# e.g. foobar.jpg => foobar_2x.jpg | |
def retinize(string) | |
assert_type string, :String | |
Sass::Script::String.new string.value.gsub(/\.(\w+)$/, '_2x.\\1') | |
end | |
declare :retinize, :args => [:string] | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// DRY retina media queries | |
@mixin media-retina { | |
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) { | |
@content; | |
} | |
} | |
@mixin retina-bg-image($image, $size) { | |
background-image: src($image); | |
background-size: $size; | |
@include media-retina { | |
background-image: src(retinize($image)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment