oddbird / susy

Pre-grid responsive layout toolkit for Sass, now deprecated
http://oddbird.net/susy/
BSD 3-Clause "New" or "Revised" License
3.87k stars 348 forks source link

@if index($span, 'last') does not work #683

Open jvandenrym opened 5 years ago

jvandenrym commented 5 years ago

I have created a gist with susy 3 and a span mixin. https://gist.github.com/jvandenrym/64070b3cc0920ba7752bd2b495ca3ab1

The checking of the last item does not do anything. Not sure I can even use this expression. @if index($span, 'last') {

mirisuzanne commented 5 years ago

Yeah, if index($span, 'last') relies on the user explicitly adding last to the span argument. A more robust approach would probably look like this (tested and updated):

  $span: map-get($context, 'span');
  $location: map-get($context, 'location') or 1;
  $end: $span + $location - 1; 
  $is-last: ($end == length(map-get($context, 'columns')));

You shouldn't need the to-list helper. susy-compile() should already normalize everything