sass / scss创建主题的最佳方法是什么?

时间:2017-01-10 18:18:22

标签: css sass

我正在使用sass功能制作一个多主题网站。我所拥有的是一个主题部分循环遍历地图列表,其中包含不同主题的所有功能,如下所示:

$themes: (
    theme1: (
        color: #000
    ),
    theme2: (
        color: #fff
    )
);

@each $theme, $map in $themes {
    .#{$theme} {
        .text{
            color: map-get($map, color);
        }
    }
}

我会将需要改变的元素添加到每个循环中,以便它们全部生成如下:

.theme1 .text{ color: #000; }
.theme2 .text{ color: #fff; }

我想知道是否有办法利用mixin / function功能,我可以自定义主题:

.text{
    font-size: 12px;
    @include get-theme-component(color); // or
    color: get-theme-component(color);
}

它应该生成css,如:

.theme1 .text{ color: #000; }
.theme2 .text{ color: #fff; }

我是sass的新手,不确定这是否可行:D

0 个答案:

没有答案