gpt4 book ai didi

javascript - 如何使用 hsl 而不是 rgb 进行 scss 全局声明 javascript api

转载 作者:行者123 更新时间:2023-12-03 14:41:21 27 4
gpt4 key购买 nike

这就是我的 next.config.js 的样子

// next.config.js

const env = require('./site.config').env;
const Colour = require('sass').types.Color;
const {r, g, b} = require('./site.config').customProperties;

const withBundleAnalyzer = require('@next/bundle-analyzer')({enabled: !!process.env.ANALYZE});

const config = {
env: {
...env,
},
sassOptions: {
functions: {
'primaryOpacityColour()': function(){
return new Colour(r, g,b)
// here I want to return Colour in hsl form
},
},
},
};

module.exports = withBundleAnalyzer(config);
我无法以 hsl 形式返回颜色,谁能帮我解决这个问题?

最佳答案

根据 https://github.com/sass/sass/issues/2988你不能用 javascript api 做到这一点。 dart-sass 在 dart api 中有它,但在 javascript api 中没有(还没有)。
您最好的选择是从 hsl 转换为 rgb 并返回 Colour,就像您现在所做的那样。

关于javascript - 如何使用 hsl 而不是 rgb 进行 scss 全局声明 javascript api,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65592793/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com