我開始將網站從Singularity 1.1.2升級到1.4.0,並立即在相同樣式表中使用多個網格時遇到了問題。我在這個網站上有五個不同的網格。以前我能夠設置變量對每個網格和排水溝,像這樣的......在Singularitygs v1.4中定義多個網格
$copy-grids: 2;
$copy-grids: add-grid(4 at $breakpoint-xs-min, $copy-grids);
$copy-grids: add-grid(6 at $breakpoint-l-min, $copy-grids);
$copy-gutters: $gutter-width;
$front-grids: 1;
$front-grids: add-grid(2 at $breakpoint-2up-min, $front-grids);
$front-grids: add-grid(3 at $breakpoint-3up-min, $front-grids);
$front-grids: add-grid(4 at $breakpoint-4up-min, $front-grids);
$front-gutters: breakpoint-to-base-em($front-gutter-width);
...
然後我就能夠用奇異的layout()
函數來傳遞這些變量來定製混入,這樣的...
// Mixins for the main content body copy.
@mixin copy-layout {
@include layout($copy-grids, $copy-gutters) {
// All the things!
@content;
}
}
@mixin copy-grid-span($span, $location) {
@include copy-layout {
@include grid-span($span, $location);
}
}
// Mixins for the front page.
@mixin front-layout {
@include layout($front-grids, $front-gutters) {
$gutter-styles: 'split' 'fixed';
// All the things!
@content;
}
}
@mixin front-grid-span($span, $location) {
@include front-layout {
@include grid-span($span, $location);
}
}
...
這讓我用我的自定義mixin來代替標準的grid-span()
mixins來輕鬆實現我定義的任何網格。例如:
#block-bean-front-page-message {
margin-bottom: $front-gutters;
@include breakpoint-1up() {
width: 100%;
padding: 0 $front-gutters/2;
}
@include breakpoint-2up-to-4up() {
@include front-grid-span(1, 2);
}
@include breakpoint-4up(true) {
@include front-grid-span(3, 2);
}
}
問題是,在Singularity v1.4中,網格和排水溝設置不再保存到普通的sass變量。相反,它們將保存爲全局$Singularity-Settings
映射中的鍵控值。用於這些值的密鑰在add-grid()
,add-gutter()
和add-gutter-style()
mixins中進行了硬編碼,其中沒有一個接受自定義變量名稱。這似乎有效地阻止我定義多個網格。因此,雖然mixin仍然存在,但我不再有變量可以傳遞給它,用於我的網格和陰影設置,從而打破了我的自定義佈局包裝混合。
我已經發布了這個作爲issue on Github,我知道一個更永久的修復可能在工作中。但與此同時,我希望有一種解決方法可以使用當前版本的Singularity完成多個網格。