
Security News
PEP 810 Proposes Explicit Lazy Imports for Python 3.15
An opt-in lazy import keyword aims to speed up Python startups, especially CLIs, without the ecosystem-wide risks that sank PEP 690.
@calibur/dark-mode
Advanced tools
h5页面深色模式的less/scss颜色转换
npm install @calibur/dark-mode
// webapck中全局引用深色模式转换 mixins
{
loader: 'style-resources-loader',
options: {
// dark-mixins.scss or dark-mixins.less
patterns: [require.resolve('@calibur/dark-mode/dark-mixins.less')],
}
}
// 局部引用深色模式转换 mixins
@import '~@calibur/dark-mode/dark-mixins.less';
如果为深色模式,在html
节点上添加class="night-mode"
.
例如:
document.querySelector('html').classList.add('night-mode');
以less为例
@key
是css属性,例如background
background-color
color
border-color
等,@value
是具体的颜色色值,支持hex/rgb/rgba/hsl/hsla。.dark-img();
.dark-elem(@property, @value);
.dark-bg(@property, @value);
.dark-gray-bg(@property, @value);
.dark-cus(@property, @lightCSS, @darkCSS);
具体用法请继续往下看!
请按照以下四种元素类型使用对应转换函数
.dark-img();
图片不需要处理
.dark-elem(@property, @value);
将
.text {
font-size: 13px;
color: #333;
border: 2px solid #333;
}
// 按钮背景色
.button {
width: 80px;
height: 30px;
color: #333;
background: #fff;
}
更换为
.text {
font-size: 13px;
border: 2px solid;
.dark-elem(color, #333);
.dark-elem(border-color, #333);
}
.button {
width: 80px;
height: 30px;
.dark-elem(color, #333);
.dark-elem(background, #fff);
}
.dark-bg(@property, @value);
提示:按钮/图标/描边的背景色,用 .dark-elem()
将
.box {
background: #fff;
width: 100px;
}
更换为
.box {
.dark-bg(background, #fff);
width: 100px;
}
.dark-gray-bg(@property, @value);
background
为浅灰色且亮度>=95%的背景色 #f3f3f3
#f2f2f2
#f7f7f7
#fafafa
#fcfcfc
将
.app {
width: 100%;
height: 100%;
background: #f7f7f7;
}
改成
.app {
width: 100%;
height: 100%;
.dark-gray-bg(background, #f7f7f7);
}
.dark-cus(@property, @lightCSS, @darkCSS);
对于较复杂的属性,建议自行转换为对应的深色属性,填入第三个参数中,
@darkValue
将
.app {
width: 100%;
height: 100%;
box-shadow: 10px 5px 5px #F4F4F4;
background: linear-gradient(0.25turn, #3f87a6, #ebf8e1, #f69d3c);
}
改成
.app {
width: 100%;
height: 100%;
.dark-cus(box-shadow, 10px 5px 5px #F4F4F4, 10px 5px 5px #1E1E1E);
.dark-cus(background, linear-gradient(0.25turn, #3f87a6, #ebf8e1, #f69d3c), linear-gradient(0.25turn, #467C94, #2A3025, #E19441));
}
FAQs
h5页面深色模式的less/scss颜色转换
We found that @calibur/dark-mode demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
An opt-in lazy import keyword aims to speed up Python startups, especially CLIs, without the ecosystem-wide risks that sank PEP 690.
Security News
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.