Sha256: 23c3623a84c891d509161689997c2e2fa7d782d3468c33483a7c24a5c8ae1814

Contents?: true

Size: 1.72 KB

Versions: 3

Compression:

Stored size: 1.72 KB

Contents

// apropos-bg-variants automatically generates rules for applying image
// variants as CSS backgrounds.
//
// Arguments:
//   $path: path to base image
//   $generate-height: true to have height properties generated for all
//     non-hidpi variants.
// ===========================================================================
=apropos-bg-variants($path, $generate-height: false)
  +apropos-bg-image-with-height($path, $generate-height)
  @each $_variant in image-variants($path)
    $_type: nth-polyfill($_variant, 1)
    $_path: nth-polyfill($_variant, -1)
    $_class: nth-polyfill($_variant, 2)
    $_query: nth-polyfill($_variant, -2)
    @if $_type == "class+media"
      @media #{$_query}
        #{nest($_class, "&")}
          +apropos-bg-image-with-height($_path, $generate-height, $_query)
    @else if $_type == media
      @media #{$_query}
        +apropos-bg-image-with-height($_path, $generate-height, $_query)
    @else if $_type == class
      #{nest($_class, "&")}
        background-image: image-url($_path)

// apropos-bg-image-with-height generates a background-image property and
// optionally generates a height property calculated from the image, if the
// query argument is not hidpi.
//
// Arguments:
//   $path: path to base image
//   $generate-height: true to have height properties generated
//   $query: media query that this image will be used with (height will not be
//     generated if the query is hidpi)
// ===========================================================================
=apropos-bg-image-with-height($path, $generate-height, $query: "")
  background-image: image-url($path)
  @if $generate-height and not (str-index($query, "dpi") > 0 or str-index($query, "pixel-ratio") > 0)
    height: image-height($path)

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
apropos-0.1.2 stylesheets/apropos/_core.sass
apropos-0.1.1 stylesheets/apropos/_core.sass
apropos-0.1.0 stylesheets/apropos/_core.sass