【发布时间】:2019-09-20 12:56:28
【问题描述】:
我已设置 Bootstrap 4 主题变量如下:
// custom-theme.scss
$primary: green;
$secondary: purple;
然后自定义变量,如:
// custom-variables.scss
@import "~bootstrap/scss/functions";
@import "~bootstrap/scss/variables";
$idi-primary-12: theme-color-level(primary, -12);
然后全部导入如下:
//main.scss,
@import "./bootstrap-theme";
@import "./custom-variables";
@import '~bootstrap/scss/bootstrap';
这会更新引导程序类,如 btn-primary 和 text-secondary AS EXPECTED (nice);
但是基于我的 $primary 的 自定义变量 ($idi-primary-12) 不起作用。我使用的是official documentation 中给出的theme-color-level SASS 函数。
当我在我的组件中使用它时,
// myComponent.scss
@import "../custom-variables";
.myUserInfo {
background-color: $idi-primary-12;
color: color-yiq($idi-primary-12);
}
我得到 BLUE 阴影(这是 bootstrap/scss/variables.scss 中的默认值)。 Github source 而不是我的覆盖(绿色 - 如上所述)
问题:如何使用主题颜色级别函数,使用我的 $primary(绿色)变量来生成绿色的较浅版本? (而不是默认的蓝色)。
附加信息: official documentation for SASS functions
-
theme-color-level使用theme-color -
theme-color按键从对象$theme-colors中提取(我使用的是primary) -
$theme-colorsprimary 键设置为$primary(Github for $theme-colors) -
$primary设置为 蓝色 (Github for $primary) - 这应该被我来自 custom-theme.scss 的
$primary = green;覆盖。这就是 btn-primary 工作的原因。 (显示为绿色)。但为什么不使用相同的覆盖变量来创建我的$idi-primary-12变量?
【问题讨论】:
标签: sass bootstrap-4