2017-06-07 3 views
0

コレクションをサンプミックスインに渡すには?SASS - コレクションを引数としてmixinに渡す

=media($type1, $size1: null) 
    @if ($type1) and ($size1) 
    @media ($type1: $size1) 
     @content 
    @elseif ($type1) and not ($size1) 
    $collection: $type1 
    @media (nth($collection, 1): nth($collection, 2)) <-- ERROR 
     @content 
    @else 
    @error "Upsss...." 

ユースケース

$m: "36em" 
$minw: "min-width 
$tablet: ("type1": $minw, "size1": $m) 

+media($tablet) <-- ERROR 
    p 
    font-size: 2em 

答えて

0

ソート。 #{map-get($ collection、$ key-name)}関数を使用しなければならなかった

=media($type1, $size1: null) 
    @if ($type1) and ($size1) 
    @media ($type1: $size1) 
     @content 
    @elseif ($type1) and not ($size1) 
    $collection: $type1 
    @media (#{map-get($collection, "type1")}: #{map-get($collection, "size1")}) 
     @content 
    @else 
    @error "Upsss...." 
関連する問題