Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how can I return Colour in "hsl" form #2988

Closed
PavanTank4631 opened this issue Jan 6, 2021 · 7 comments
Closed

how can I return Colour in "hsl" form #2988

PavanTank4631 opened this issue Jan 6, 2021 · 7 comments

Comments

@PavanTank4631
Copy link

PavanTank4631 commented Jan 6, 2021

// 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)
      },
    },
  },
};

module.exports = withBundleAnalyzer(config);
@stof
Copy link
Contributor

stof commented Jan 6, 2021

I don't understand what your question is

@PavanTank4631
Copy link
Author

I want to return hsl(r, g%, b%) value from the primaryOpacityColour() function, but When I tried it, It's not working

@stof
Copy link
Contributor

stof commented Jan 6, 2021

hmm, it looks like the node API does not have the equivalent of SassColor.hsl() in the dart API for values.

@PavanTank4631
Copy link
Author

Is there any other way to archive something like this?

@stof
Copy link
Contributor

stof commented Jan 6, 2021

I don't think there is a way to achieve this until some improvement is done in the JS API. Currently this JS API for types is implemented to copy the API of node-sass (to make it a drop-in replacement) rather than to expose all the features of the underlying dart API.

@Awjin
Copy link
Contributor

Awjin commented Jan 6, 2021

@stof is right—there's currently no way to do this. We are working on designing a new API to resolve these issues (see #2510).

@Awjin Awjin closed this as completed Jan 6, 2021
@jayenashar
Copy link

is it possible to use a string somehow? like return new sass.types.String(`hsl(${h}, ${s}%, ${l}%)`);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants