5

私は Sass から Stylus に移行しており、多くの mixin があり、mixin 内で@content.

例えば...

@mixin respond-min($width) {
    // If we're outputting for a fixed media query set...
    @if $fix-mqs {
        // ...and if we should apply these rules...
        @if $fix-mqs >= $width {
            // ...output the content the user gave us.
            @content;
        }
    }
    @else {
        // Otherwise, output it using a regular media query
        @media all and (min-width: $width) {
            @content;
        }
    }
}

@include respond-min($mq-group2) {
    & {
        border: 1px solid green;
    }
}

上記のコードをスタイラスに変換したいのですが、スタイラスにはその機能がないように見えるため、これまでの主な問題はコードブロックをミックスインに渡す方法でした。

代替ソリューションはありますか?

どんな助けでも感謝します。

4

2 に答える 2

6

これは Stylus の最新リリース — 0.41.0 で可能になりました。上記のコードは Stylus で次のように記述できます。

respond-min($width)
  // If we're outputting for a fixed media query set...
  if $fix-mqs is defined
    // ...and if we should apply these rules...
    if $fix-mqs >= $width
      // ...output the content the user gave us.
      {block}
  else
    // Otherwise, output it using a regular media query
    media = 'all and (min-width: %s)' % $width
    @media media
      {block}

+respond-min($mq-group2)
  border: 1px solid green
于 2013-12-01T10:25:55.190 に答える