@ 碳/地平线旗
以 C碳 特性标记构建
开始
要安装 @carbon/feature-flags 在您的项目中,您需要运行
根据命令使用 无数字 :
npm install -S @carbon/feature-flags
如果你喜欢 雅伦,使用以下命令 相反:
yarn add @carbon/feature-flags
使用量
这个 @carbon/feature-flags 提供基于运行时的特性旗系统
可以用来启用或禁用来自Carbon或你自己的预览功能
代码.
要检查是否启用了特性旗, 您可以使用 enabled 函数在
Java 脚本 :
import { enabled } from '@carbon/feature-flags';
enabled('feature-flag-name');
在萨斯,你会使用 enabled 函数或混合:
@use '@carbon/feature-flags';
// Return true if the flag is enabled
@if feature-flags.enabled('feature-flag-name') {
//
}
@include enabled('feature-flag-name') {
// only include contents if the flag is enabled
}
管理专题旗帜
您可以更改是否启用了特性旗 。 在JavaScript中,您可以使用
enable, (中文(简体) ), disable,以及 merge 实现此目标的功能.
import { enable, disable, merge } from '@carbon/feature-flags';
// Enable `feature-flag-a`
enable('feature-flag-a');
// Disable `feature-flag-a`
disable('feature-flag-a');
// Set a variety of feature flags to a specific value
merge({
'feature-flag-a': true,
'feature-flag-b': false,
'feature-flag-c': true,
});
在 Sass 中,您可以在包含时配置功能旗是否被启用
模块或通过使用 enable, (中文(简体) ), disable,以及 merge。 。 。 .
@use '@carbon/feature-flags' with (
$feature-flags: (
'feature-flag-a': false,
'feature-flag-b': true,
)
);
// Enable `feature-flag-a`
@include feature-flags.enable('feature-flag-a');
// Disable `feature-flag-b`
@include feature-flags.disable('feature-flag-b');
// Set a variety of feature flags to a specific value
@include feature-flags.merge(
(
'feature-flag-a': true,
'feature-flag-b': true,
)
);
捐款
我们总是寻找贡献者 帮助我们修复错误, 建立新的特性, 或者帮助我们改进项目文件。 如果你有兴趣,肯定 看看我们 贡献指南!
许可证
凭 Apache 2.0 许可证。 。 。 .
IBM 遥测
本套件使用 IBM 遥测来收集去识别和匿名的度量衡 数据。 通过安装此包作为依赖, 您同意远程测量 藏书。 选择退出,看 选择退出IBM遥测数据收集。 。 。 . 有关所收集数据的更多信息,请参见: IBM 遥测文档。 。 。 .