hexo/node_modules/nib/lib/nib/image.styl

26 lines
956 B
Stylus

/*
* Define background-image as `path` with optional width and height, adding an
* @2x variant.
*
* affected by github.com/LearnBoost/stylus/issues/1050 and
* github.com/LearnBoost/stylus/issues/1038 ... refactor when those are closed
*/
image(path, w = auto, h = auto, min_pixel_ratio = 1.5)
background-image: url(path)
s = 'all and (-webkit-min-device-pixel-ratio:' + min_pixel_ratio + '),'
s = s + '(min--moz-device-pixel-ratio:' + min_pixel_ratio + '),'
s = s + '(-o-min-device-pixel-ratio:' + min_pixel_ratio + '/1),'
s = s + '(min-device-pixel-ratio:' + min_pixel_ratio + '),'
s = s + '(min-resolution:' + unit(min_pixel_ratio*92, dpi) + '),'
s = s + '(min-resolution:' + unit(min_pixel_ratio, dppx) + ')'
@media s
ext = extname(path)
path = pathjoin(dirname(path), basename(path, ext) + '@2x' + ext)
background-image: url(path)
if w in (cover contain) and h == auto
h = null
background-size: w h