【发布时间】:2018-06-28 07:14:18
【问题描述】:
我有一个名为“_color.scss”的部分 sass,其中包含来自 materializecss 的这些代码。
$materialize-red: (
"base": #e51c23,
"lighten-5": #fdeaeb,
"lighten-4": #f8c1c3,
"lighten-3": #f3989b,
"lighten-2": #ee6e73,
"lighten-1": #ea454b,
"darken-1": #d0181e,
"darken-2": #b9151b,
"darken-3": #a21318,
"darken-4": #8b1014,
);
...
@each $color_name, $color in $colors {
@each $color_type, $color_value in $color {
@if $color_type == "base" {
.#{$color_name} {
background-color: $color_value !important;
}
.#{$color_name}-text {
color: $color_value !important;
}
}
@else if $color_name != "shades" {
.#{$color_name}.#{$color_type} {
background-color: $color_value !important;
}
.#{$color_name}-text.text-#{$color_type} {
color: $color_value !important;
}
}
}
}
// Shade classes
@each $color, $color_value in $shades {
.#{$color} {
background-color: $color_value !important;
}
.#{$color}-text {
color: $color_value !important;
}
}
// usage: color("name_of_color", "type_of_color")
// to avoid to repeating map-get($colors, ...)
@function color($color, $type) {
@if map-has-key($colors, $color) {
$curr_color: map-get($colors, $color);
@if map-has-key($curr_color, $type) {
@return map-get($curr_color, $type);
}
}
@warn "Unknown `#{name}` in $colors.";
@return null;
}
然后在我的所有其他 .scss 文件中,我将其导入。
@import "../../bower_components/materialize/sass/components/color";
鉴于他们网站的声明,“下划线让 Sass 知道该文件只是部分文件,不应将其生成为 CSS 文件。”,这应该从实际的 css 中排除吗?但我目前的环境是将部分内容包含在我的 css 中
和我的咕噜声有关吗?
【问题讨论】:
-
您能发布您的 gruntfile 以便我们也能看到吗?
标签: css sass gruntjs materialize