Search code examples
sasscompass-sasssusy-compass

I am just getting started with susy grid and am trying to figure out responsive part


Susy is new to me so bare with. I am trying to setup breakpoints for my page

This is the demo code on the site documentation

// at-breakpoint(<$media-layout> [, <$font-size>]) { <@content> }
@include at-breakpoint(30em 12) {
  .page { @include container; }
}

What I dont understand is what the 30em and 12 represent, I want to setup a media query for when the page is so wide, ideally mobile phone size to start and. How would I go about doing this with sussy?

UPDATE

I dont quite understand the syntax even after reading the documentation, I have tried writing, but i get a sass error. How would I write at 30em use a 12col grid?

@mixin at-breakpoint($media-layout: 30em 12, $base-font-size){
    #mastHead{background: red;}
}

Solution

  • Your answer is in the source: https://github.com/ericam/susy/blob/master/sass/susy/_media.scss#L23

    // Nest a block of code inside a new media-query and layout context.
    //
    // $media-layout  : a list of values [$min $layout $max $ie] including...
    //                : - one unitless number (columns in a layout)
    //                : - two optional lengths (min and max-width media-query breakpoints).
    //                : - one optional boolean or string to trigger fallback support for IE.
    // $font-size     : [optional] The base font-size of your layout, if you are using ems.
    //                : - defaults to $base-font-size
    @mixin at-breakpoint(
      $media-layout,
      $font-size: $base-font-size
    ) {
        // stuff
    }
    

    It is also in the documentation: http://susy.oddbird.net/guides/reference/#ref-media-layouts

    // $media-layout: <min-width> <layout> <max-width> <ie-fallback>;
    // - You must supply either <min-width> or <layout>.
    $media-layout: 12;          // Use 12-col layout at matching min-width.
    $media-layout: 30em;        // At min 30em, use closest fitting layout.
    $media-layout: 30em 12;     // At min 30em, use 12-col layout.
    $media-layout: 12 60em;     // Use 12 cols up to max 60em.
    $media-layout: 30em 60em;   // Between min 30em & max 60em, use closest layout.
    $media-layout: 30em 12 60em;// Use 12 cols between min 30em & max 60em.
    $media-layout: 60em 12 30em;// Same. Larger length will always be max-width.
    $media-layout : 12 lt-ie9;  // Output is included under `.lt-ie9` class,
                                // for use with IE conditional comments
                                // on the <html> tag.