that's how my next.config.js look like
// 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);
I'm not able to return Colour in hsl form, can anyone please help me how to resolve this issue?
In CSS, a color can be specified using hue, saturation, and lightness (HSL) in the form: hsl (hue, saturation, lightness) Hue is a degree on the color wheel from 0 to 360. 0 is red, 120 is green, and 240 is blue. Saturation is a percentage value, 0% means a shade of gray, and 100% is the full color.
hsl ( hue, saturation, lightness) Hue is a degree on the color wheel from 0 to 360. 0 is red, 120 is green, and 240 is blue. Saturation is a percentage value, 0% means a shade of gray, and 100% is the full color. Lightness is also a percentage, 0% is black, 50% is neither light or dark, 100% is white. Experiment by mixing the HSL values below:
The hsl () function define colors using the Hue-saturation-lightness model (HSL). HSL stands for hue, saturation, and lightness - and represents a cylindrical-coordinate representation of colors. The numbers in the table specify the first browser version that fully supports the function.
Sass’s special parsing rules for slash-separated values make it difficult to pass variables for $blue or $alpha when using the rgb ($red $green $blue / $alpha) signature. Consider using rgb ($red, $green, $blue, $alpha) instead.
according to https://github.com/sass/sass/issues/2988 you cannot do this with the javascript api. dart-sass has it in the dart api, but not in the javascript api (yet).
your best bet is to convert from hsl to rgb and return Colour, as you are doing now.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With