簡體   English   中英

帶有SASS mixins的色彩主題

[英]Color themes with SASS mixins

我正在嘗試在以下mixin的幫助下使用SASS創建兩個顏色主題:

@mixin theme($name, $bgColor, $textColor) {
  .#{$name}{
    blockquote {
       @include borderLeft($textColor, $basicUnit/2);
    }
    strong {
        @include doubleFrame($bgColor, $textColor, 1px);
    }
    .highlighted {
        @include highlight($textColor);
    }
    .bb-custom-side.left .content-title {
        color: $textColor;
    }
    .content > h2 {
        border-top:$basicUnit/2 solid $bgColor;
    }
    .content { 
        background: $bgColor;
        color: $textColor;
    }
  }
}

然后打電話

@include theme("odd", $blue, $white);
@include theme("even", $green, $black);

我的_layout.scss中

但是我一直收到此錯誤,無法弄清楚我的mixin出了什么問題:

Syntax error: Invalid CSS after "...ily : "#{$name}": expected string, was "_#{$nameWeight}"";"
        on line 31 of /Users/Works/html/assets/scss/_typography.scss
        from line 11 of /Users/Works/html/assets/scss/main.scss
Use --trace for backtrace.

一個新手問題...

謝謝

這似乎是您在theme mixin中使用的一個mixin的問題(我懷疑它帶有highlight因為這似乎是唯一處理字體家族的問題(在錯誤跟蹤中提到)。

刪除對其他mixin的調用,這是:

@mixin theme($name, $bgColor, $textColor) {
  .#{$name}{
    .content { 
        background: $bgColor;
        color: $textColor;
    }
  }
}

@include theme("odd", 'blue', 'white');

產生這個:

.odd .content {
  background: "blue";
  color: "white";
}

這似乎是您想要的。

Codepen

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM